upgrade 3.13 targets to 3.13.2, refresh patches
[openwrt/openwrt.git] / target / linux / omap / patches-3.12 / 906-wlcore-sdio-get-clocks-from-device-tree.patch
1 Read the clock nodes from the device tree and use them to set the
2 frequency for the refclock and the tcxo clock.
3
4 Also, call sdio_set_drvdata() earlier, so the glue is already set in
5 the driver data when we call wlcore_get_pdata_from_of() and we don't
6 need to pass it as a parameter.
7
8 Signed-off-by: Luciano Coelho <coelho@ti.com>
9 Reviewed-by: Felipe Balbi <balbi@ti.com>
10
11 ---
12 drivers/net/wireless/ti/wlcore/sdio.c | 36 +++++++++++++++++++++++++++++++++--
13 1 file changed, 34 insertions(+), 2 deletions(-)
14
15 --- a/drivers/net/wireless/ti/wlcore/sdio.c
16 +++ b/drivers/net/wireless/ti/wlcore/sdio.c
17 @@ -53,6 +53,7 @@ static bool dump = false;
18 struct wl12xx_sdio_glue {
19 struct device *dev;
20 struct platform_device *core;
21 + struct clk *refclock, *tcxoclock;
22 };
23
24 static const struct sdio_device_id wl1271_devices[] = {
25 @@ -224,6 +225,7 @@ static struct wl12xx_platform_data *wlco
26 struct wl12xx_platform_data *pdata;
27 struct device_node *np = dev->of_node;
28 struct device_node *clock_node;
29 + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(dev_to_sdio_func(dev));
30
31 if (!np) {
32 np = of_find_matching_node(NULL, dev->driver->of_match_table);
33 @@ -250,6 +252,26 @@ static struct wl12xx_platform_data *wlco
34 for_each_matching_node(clock_node, wlcore_sdio_of_clk_match_table)
35 of_fixed_clk_setup(clock_node);
36
37 + /* TODO: make sure we have this when needed (ie. for WL6 and WL7) */
38 + glue->refclock = of_clk_get_by_name(np, "refclock");
39 + if (IS_ERR(glue->refclock)) {
40 + dev_err(dev, "couldn't find refclock on the device tree\n");
41 + glue->refclock = NULL;
42 + } else {
43 + clk_prepare_enable(glue->refclock);
44 + pdata->ref_clock_freq = clk_get_rate(glue->refclock);
45 + }
46 +
47 + /* TODO: make sure we have this when needed (ie. for WL7) */
48 + glue->tcxoclock = of_clk_get_by_name(np, "tcxoclock");
49 + if (IS_ERR(glue->tcxoclock)) {
50 + dev_err(dev, "couldn't find tcxoclock on the device tree\n");
51 + glue->tcxoclock = NULL;
52 + } else {
53 + clk_prepare_enable(glue->tcxoclock);
54 + pdata->ref_clock_freq = clk_get_rate(glue->tcxoclock);
55 + }
56 +
57 goto out;
58
59 out_free:
60 @@ -294,6 +316,8 @@ static int wl1271_probe(struct sdio_func
61 /* Use block mode for transferring over one block size of data */
62 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
63
64 + sdio_set_drvdata(func, glue);
65 +
66 /* The pdata allocated here is freed when the device is freed,
67 * so we don't need an additional out label to free it in case
68 * of error further on.
69 @@ -319,8 +343,6 @@ static int wl1271_probe(struct sdio_func
70 if (mmcflags & MMC_PM_KEEP_POWER)
71 pdev_data->pwr_in_suspend = true;
72
73 - sdio_set_drvdata(func, glue);
74 -
75 /* Tell PM core that we don't need the card to be powered now */
76 pm_runtime_put_noidle(&func->dev);
77
78 @@ -387,6 +409,16 @@ static void wl1271_remove(struct sdio_fu
79 {
80 struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func);
81
82 + if (glue->refclock) {
83 + clk_disable_unprepare(glue->refclock);
84 + clk_put(glue->refclock);
85 + }
86 +
87 + if (glue->tcxoclock) {
88 + clk_disable_unprepare(glue->tcxoclock);
89 + clk_put(glue->tcxoclock);
90 + }
91 +
92 /* Undo decrement done above in wl1271_probe */
93 pm_runtime_get_noresume(&func->dev);
94