ath9k: improve ANI debugfs file
[openwrt.git] / package / kernel / mac80211 / patches / 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 --- a/drivers/net/wireless/ti/wl12xx/main.c
11 +++ b/drivers/net/wireless/ti/wl12xx/main.c
12 @@ -930,6 +930,11 @@ static int wl128x_boot_clk(struct wl1271
13         u16 sys_clk_cfg;
14         int ret;
15  
16 +       if ((priv->ref_clock < 0) || (priv->tcxo_clock < 0)) {
17 +               wl1271_error("Missing fref and/or tcxo clock settings\n");
18 +               return -EINVAL;
19 +       }
20 +
21         /* For XTAL-only modes, FREF will be used after switching from TCXO */
22         if (priv->ref_clock == WL12XX_REFCLOCK_26_XTAL ||
23             priv->ref_clock == WL12XX_REFCLOCK_38_XTAL) {
24 @@ -979,6 +984,11 @@ static int wl127x_boot_clk(struct wl1271
25         u32 clk;
26         int ret;
27  
28 +       if (priv->ref_clock < 0) {
29 +               wl1271_error("Missing fref clock settings\n");
30 +               return -EINVAL;
31 +       }
32 +
33         if (WL127X_PG_GET_MAJOR(wl->hw_pg_ver) < 3)
34                 wl->quirks |= WLCORE_QUIRK_END_OF_TRANSACTION;
35  
36 @@ -1768,7 +1778,7 @@ static int wl12xx_setup(struct wl1271 *w
37         wlcore_set_ht_cap(wl, IEEE80211_BAND_5GHZ, &wl12xx_ht_cap);
38         wl12xx_conf_init(wl);
39  
40 -       if (!fref_param) {
41 +       if (!fref_param && (pdata->ref_clock_freq > 0)) {
42                 priv->ref_clock = wl12xx_get_clock_idx(wl12xx_refclock_table,
43                                                        pdata->ref_clock_freq,
44                                                        pdata->ref_clock_xtal);
45 @@ -1779,6 +1789,8 @@ static int wl12xx_setup(struct wl1271 *w
46  
47                         return priv->ref_clock;
48                 }
49 +       } else if (!fref_param) {
50 +               priv->ref_clock = -EINVAL;
51         } else {
52                 if (!strcmp(fref_param, "19.2"))
53                         priv->ref_clock = WL12XX_REFCLOCK_19;
54 @@ -1796,7 +1808,7 @@ static int wl12xx_setup(struct wl1271 *w
55                         wl1271_error("Invalid fref parameter %s", fref_param);
56         }
57  
58 -       if (!tcxo_param) {
59 +       if (!fref_param && (pdata->tcxo_clock_freq > 0)) {
60                 priv->tcxo_clock = wl12xx_get_clock_idx(wl12xx_tcxoclock_table,
61                                                         pdata->tcxo_clock_freq,
62                                                         true);
63 @@ -1806,7 +1818,9 @@ static int wl12xx_setup(struct wl1271 *w
64  
65                         return priv->tcxo_clock;
66                 }
67 -       } else {
68 +       } else if (!fref_param) {
69 +               priv->tcxo_clock = -EINVAL;
70 +       }else {
71                 if (!strcmp(tcxo_param, "19.2"))
72                         priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2;
73                 else if (!strcmp(tcxo_param, "26"))
74 --- a/drivers/net/wireless/ti/wlcore/sdio.c
75 +++ b/drivers/net/wireless/ti/wlcore/sdio.c
76 @@ -252,20 +252,16 @@ static struct wl12xx_platform_data *wlco
77         for_each_matching_node(clock_node, wlcore_sdio_of_clk_match_table)
78                 of_fixed_clk_setup(clock_node);
79  
80 -       /* TODO: make sure we have this when needed (ie. for WL6 and WL7) */
81         glue->refclock = of_clk_get_by_name(np, "refclock");
82         if (IS_ERR(glue->refclock)) {
83 -               dev_err(dev, "couldn't find refclock on the device tree\n");
84                 glue->refclock = NULL;
85         } else {
86                 clk_prepare_enable(glue->refclock);
87                 pdata->ref_clock_freq = clk_get_rate(glue->refclock);
88         }
89  
90 -       /* TODO: make sure we have this when needed (ie. for WL7) */
91         glue->tcxoclock = of_clk_get_by_name(np, "tcxoclock");
92         if (IS_ERR(glue->tcxoclock)) {
93 -               dev_err(dev, "couldn't find tcxoclock on the device tree\n");
94                 glue->tcxoclock = NULL;
95         } else {
96                 clk_prepare_enable(glue->tcxoclock);