1 Read the clock nodes from the device tree and use them to set the
2 frequency for the refclock and the tcxo clock.
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.
8 Signed-off-by: Luciano Coelho <coelho@ti.com>
9 Reviewed-by: Felipe Balbi <balbi@ti.com>
11 --- a/drivers/net/wireless/ti/wlcore/sdio.c
12 +++ b/drivers/net/wireless/ti/wlcore/sdio.c
13 @@ -53,6 +53,7 @@ static bool dump = false;
14 struct wl12xx_sdio_glue {
16 struct platform_device *core;
17 + struct clk *refclock, *tcxoclock;
20 static const struct sdio_device_id wl1271_devices[] = {
21 @@ -224,6 +225,7 @@ static struct wl12xx_platform_data *wlco
22 struct wl12xx_platform_data *pdata;
23 struct device_node *np = dev->of_node;
24 struct device_node *clock_node;
25 + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(dev_to_sdio_func(dev));
28 np = of_find_matching_node(NULL, dev->driver->of_match_table);
29 @@ -250,6 +252,26 @@ static struct wl12xx_platform_data *wlco
30 for_each_matching_node(clock_node, wlcore_sdio_of_clk_match_table)
31 of_fixed_clk_setup(clock_node);
33 + /* TODO: make sure we have this when needed (ie. for WL6 and WL7) */
34 + glue->refclock = of_clk_get_by_name(np, "refclock");
35 + if (IS_ERR(glue->refclock)) {
36 + dev_err(dev, "couldn't find refclock on the device tree\n");
37 + glue->refclock = NULL;
39 + clk_prepare_enable(glue->refclock);
40 + pdata->ref_clock_freq = clk_get_rate(glue->refclock);
43 + /* TODO: make sure we have this when needed (ie. for WL7) */
44 + glue->tcxoclock = of_clk_get_by_name(np, "tcxoclock");
45 + if (IS_ERR(glue->tcxoclock)) {
46 + dev_err(dev, "couldn't find tcxoclock on the device tree\n");
47 + glue->tcxoclock = NULL;
49 + clk_prepare_enable(glue->tcxoclock);
50 + pdata->ref_clock_freq = clk_get_rate(glue->tcxoclock);
56 @@ -294,6 +316,8 @@ static int wl1271_probe(struct sdio_func
57 /* Use block mode for transferring over one block size of data */
58 func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE;
60 + sdio_set_drvdata(func, glue);
62 /* The pdata allocated here is freed when the device is freed,
63 * so we don't need an additional out label to free it in case
64 * of error further on.
65 @@ -319,8 +343,6 @@ static int wl1271_probe(struct sdio_func
66 if (mmcflags & MMC_PM_KEEP_POWER)
67 pdev_data->pwr_in_suspend = true;
69 - sdio_set_drvdata(func, glue);
71 /* Tell PM core that we don't need the card to be powered now */
72 pm_runtime_put_noidle(&func->dev);
74 @@ -387,6 +409,16 @@ static void wl1271_remove(struct sdio_fu
76 struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func);
78 + if (glue->refclock) {
79 + clk_disable_unprepare(glue->refclock);
80 + clk_put(glue->refclock);
83 + if (glue->tcxoclock) {
84 + clk_disable_unprepare(glue->tcxoclock);
85 + clk_put(glue->tcxoclock);
88 /* Undo decrement done above in wl1271_probe */
89 pm_runtime_get_noresume(&func->dev);