8929c7897534630d0d708d77cbf1fd38416ecc4a
[15.05/openwrt.git] / target / linux / omap / patches-3.13 / 907-wlcore-wl12xx-check-if-we-got-correct-clock-data-from-DT.patch
1 The fref and the tcxo clocks settings are optional in some platforms.
2 WiLink8 doesn't need either, so we don't check the values.  WiLink 6
3 only needs the fref clock, so we check that it is valid or return with
4 an error.  WiLink7 needs both clocks, if either is not available we
5 return with an error.
6
7 Signed-off-by: Luciano Coelho <coelho@ti.com>
8 Reviewed-by: Felipe Balbi <balbi@ti.com>
9
10 ---
11 drivers/net/wireless/ti/wl12xx/main.c | 20 +++++++++++++++++---
12  drivers/net/wireless/ti/wlcore/sdio.c |  4 ----
13  2 files changed, 17 insertions(+), 7 deletions(-)
14
15 --- a/drivers/net/wireless/ti/wl12xx/main.c
16 +++ b/drivers/net/wireless/ti/wl12xx/main.c
17 @@ -930,6 +930,11 @@ static int wl128x_boot_clk(struct wl1271
18         u16 sys_clk_cfg;
19         int ret;
20  
21 +       if ((priv->ref_clock < 0) || (priv->tcxo_clock < 0)) {
22 +               wl1271_error("Missing fref and/or tcxo clock settings\n");
23 +               return -EINVAL;
24 +       }
25 +
26         /* For XTAL-only modes, FREF will be used after switching from TCXO */
27         if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL ||
28             priv->ref_clock == WL12XX_REFCLOCK_38_XTAL) {
29 @@ -979,6 +984,11 @@ static int wl127x_boot_clk(struct wl1271
30         u32 clk;
31         int ret;
32  
33 +       if (priv->ref_clock < 0) {
34 +               wl1271_error("Missing fref clock settings\n");
35 +               return -EINVAL;
36 +       }
37 +
38         if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3)
39                 wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION;
40  
41 @@ -1768,7 +1778,7 @@ static int wl12xx_setup(struct wl1271 *w
42         wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, &wl12xx_ht_cap);
43         wl12xx_conf_init(wl);
44  
45 -       if (!fref_param) {
46 +       if (!fref_param && (pdata->ref_clock_freq > 0)) {
47                 priv->ref_clock = wl12xx_get_clock_idx(wl12xx_refclock_table,
48                                                        pdata->ref_clock_freq,
49                                                        pdata->ref_clock_xtal);
50 @@ -1779,6 +1789,8 @@ static int wl12xx_setup(struct wl1271 *w
51  
52                         return priv->ref_clock;
53                 }
54 +       } else if (!fref_param) {
55 +               priv->ref_clock = -EINVAL;
56         } else {
57                 if (!strcmp(fref_param, "19.2"))
58                         priv->ref_clock = WL12XX_REFCLOCK_19;
59 @@ -1796,7 +1808,7 @@ static int wl12xx_setup(struct wl1271 *w
60                         wl1271_error("Invalid fref parameter %s", fref_param);
61         }
62  
63 -       if (!tcxo_param) {
64 +       if (!fref_param && (pdata->tcxo_clock_freq > 0)) {
65                 priv->tcxo_clock = wl12xx_get_clock_idx(wl12xx_tcxoclock_table,
66                                                         pdata->tcxo_clock_freq,
67                                                         true);
68 @@ -1806,7 +1818,9 @@ static int wl12xx_setup(struct wl1271 *w
69  
70                         return priv->tcxo_clock;
71                 }
72 -       } else {
73 +       } else if (!fref_param) {
74 +               priv->tcxo_clock = -EINVAL;
75 +       }else {
76                 if (!strcmp(tcxo_param, "19.2"))
77                         priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2;
78                 else if (!strcmp(tcxo_param, "26"))
79 --- a/drivers/net/wireless/ti/wlcore/sdio.c
80 +++ b/drivers/net/wireless/ti/wlcore/sdio.c
81 @@ -252,20 +252,16 @@ static struct wl12xx_platform_data *wlco
82         for_each_matching_node(clock_node, wlcore_sdio_of_clk_match_table)
83                 of_fixed_clk_setup(clock_node);
84  
85 -       /* TODO: make sure we have this when needed (ie. for WL6 and WL7) */
86         glue->refclock = of_clk_get_by_name(np, "refclock");
87         if (IS_ERR(glue->refclock)) {
88 -               dev_err(dev, "couldn't find refclock on the device tree\n");
89                 glue->refclock = NULL;
90         } else {
91                 clk_prepare_enable(glue->refclock);
92                 pdata->ref_clock_freq = clk_get_rate(glue->refclock);
93         }
94  
95 -       /* TODO: make sure we have this when needed (ie. for WL7) */
96         glue->tcxoclock = of_clk_get_by_name(np, "tcxoclock");
97         if (IS_ERR(glue->tcxoclock)) {
98 -               dev_err(dev, "couldn't find tcxoclock on the device tree\n");
99                 glue->tcxoclock = NULL;
100         } else {
101                 clk_prepare_enable(glue->tcxoclock);