1 Instead of defining an enumeration with the FW specific values for the
2 different clock rates, use the actual frequency instead. Also add a
3 boolean to specify whether the clock is XTAL or not.
5 Change all board files to reflect this.
7 Additionally, this reverts commit 26f45c (ARM: OMAP2+: Legacy support
8 for wl12xx when booted with devicetree), since this is not be needed
9 anymore, now that DT support for WiLink is implemented.
11 Cc: Tony Lindgren <tony@atomide.com>
12 Cc: Sekhar Nori <nsekhar@ti.com>
13 Signed-off-by: Luciano Coelho <coelho@ti.com>
14 Reviewed-by: Felipe Balbi <balbi@ti.com>
17 arch/arm/mach-davinci/board-da850-evm.c | 3 +-
18 arch/arm/mach-omap2/board-omap3evm.c | 3 +-
19 arch/arm/mach-omap2/board-zoom-peripherals.c | 3 +-
20 arch/arm/mach-omap2/devices.c | 39 -------------------
21 drivers/net/wireless/ti/wl12xx/main.c | 58 +++++++++++++++++++++++++++-
22 drivers/net/wireless/ti/wl12xx/wl12xx.h | 28 ++++++++++++++
23 include/linux/wl12xx.h | 27 ++-----------
24 7 files changed, 93 insertions(+), 68 deletions(-)
26 --- a/arch/arm/mach-davinci/board-da850-evm.c
27 +++ b/arch/arm/mach-davinci/board-da850-evm.c
28 @@ -1370,7 +1370,8 @@ static const short da850_wl12xx_pins[] _
30 static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
32 - .board_ref_clock = WL12XX_REFCLOCK_38,
33 + .ref_clock_freq = 38400000,
34 + .ref_clock_xtal = false,
37 static __init int da850_wl12xx_init(void)
38 --- a/arch/arm/mach-omap2/board-omap3evm.c
39 +++ b/arch/arm/mach-omap2/board-omap3evm.c
40 @@ -473,7 +473,8 @@ static struct platform_device omap3evm_w
43 struct wl12xx_platform_data omap3evm_wlan_data __initdata = {
44 - .board_ref_clock = WL12XX_REFCLOCK_38, /* 38.4 MHz */
45 + .ref_clock_freq = 38400000,
46 + .ref_clock_xtal = false,
50 --- a/arch/arm/mach-omap2/board-zoom-peripherals.c
51 +++ b/arch/arm/mach-omap2/board-zoom-peripherals.c
52 @@ -244,7 +244,8 @@ static struct platform_device *zoom_devi
55 static struct wl12xx_platform_data omap_zoom_wlan_data __initdata = {
56 - .board_ref_clock = WL12XX_REFCLOCK_26, /* 26 MHz */
57 + .ref_clock_freq = 26000000,
58 + .ref_clock_xtal = false,
61 static struct omap2_hsmmc_info mmc[] = {
62 --- a/arch/arm/mach-omap2/devices.c
63 +++ b/arch/arm/mach-omap2/devices.c
65 * the Free Software Foundation; either version 2 of the License, or
66 * (at your option) any later version.
68 -#include <linux/gpio.h>
69 #include <linux/kernel.h>
70 #include <linux/init.h>
71 #include <linux/platform_device.h>
74 #include <linux/pinctrl/machine.h>
75 #include <linux/platform_data/omap4-keypad.h>
76 -#include <linux/wl12xx.h>
77 #include <linux/platform_data/mailbox-omap.h>
79 #include <asm/mach-types.h>
80 @@ -475,40 +473,6 @@ static void omap_init_vout(void)
81 static inline void omap_init_vout(void) {}
84 -#if IS_ENABLED(CONFIG_WL12XX)
86 -static struct wl12xx_platform_data wl12xx __initdata;
88 -void __init omap_init_wl12xx_of(void)
92 - if (!of_have_populated_dt())
95 - if (of_machine_is_compatible("ti,omap4-sdp")) {
96 - wl12xx.board_ref_clock = WL12XX_REFCLOCK_26;
97 - wl12xx.board_tcxo_clock = WL12XX_TCXOCLOCK_26;
98 - wl12xx.irq = gpio_to_irq(53);
99 - } else if (of_machine_is_compatible("ti,omap4-panda")) {
100 - wl12xx.board_ref_clock = WL12XX_REFCLOCK_38;
101 - wl12xx.irq = gpio_to_irq(53);
106 - ret = wl12xx_set_platform_data(&wl12xx);
108 - pr_err("error setting wl12xx data: %d\n", ret);
113 -static inline void omap_init_wl12xx_of(void)
118 /*-------------------------------------------------------------------------*/
120 static int __init omap2_init_devices(void)
121 @@ -531,9 +495,6 @@ static int __init omap2_init_devices(voi
126 - /* These can be removed when bindings are done */
127 - omap_init_wl12xx_of();
131 --- a/drivers/net/wireless/ti/wl12xx/main.c
132 +++ b/drivers/net/wireless/ti/wl12xx/main.c
133 @@ -1701,6 +1701,43 @@ static struct ieee80211_sta_ht_cap wl12x
137 +static const struct wl12xx_clock wl12xx_refclock_table[] = {
138 + { 19200000, false, WL12XX_REFCLOCK_19 },
139 + { 26000000, false, WL12XX_REFCLOCK_26 },
140 + { 26000000, true, WL12XX_REFCLOCK_26_XTAL },
141 + { 38400000, false, WL12XX_REFCLOCK_38 },
142 + { 38400000, true, WL12XX_REFCLOCK_38_XTAL },
143 + { 52000000, false, WL12XX_REFCLOCK_52 },
147 +static const struct wl12xx_clock wl12xx_tcxoclock_table[] = {
148 + { 16368000, true, WL12XX_TCXOCLOCK_16_368 },
149 + { 16800000, true, WL12XX_TCXOCLOCK_16_8 },
150 + { 19200000, true, WL12XX_TCXOCLOCK_19_2 },
151 + { 26000000, true, WL12XX_TCXOCLOCK_26 },
152 + { 32736000, true, WL12XX_TCXOCLOCK_32_736 },
153 + { 33600000, true, WL12XX_TCXOCLOCK_33_6 },
154 + { 38400000, true, WL12XX_TCXOCLOCK_38_4 },
155 + { 52000000, true, WL12XX_TCXOCLOCK_52 },
159 +static int wl12xx_get_clock_idx(const struct wl12xx_clock *table,
160 + u32 freq, bool xtal)
164 + while(table[i].freq != 0) {
165 + if ((table[i].freq == freq) &&
166 + (table[i].xtal == xtal))
167 + return table[i].hw_idx;
174 static int wl12xx_setup(struct wl1271 *wl)
176 struct wl12xx_priv *priv = wl->priv;
177 @@ -1722,7 +1759,16 @@ static int wl12xx_setup(struct wl1271 *w
178 wl12xx_conf_init(wl);
181 - priv->ref_clock = pdata->board_ref_clock;
182 + priv->ref_clock = wl12xx_get_clock_idx(wl12xx_refclock_table,
183 + pdata->ref_clock_freq,
184 + pdata->ref_clock_xtal);
185 + if (priv->ref_clock < 0) {
186 + wl1271_error("Invalid ref_clock frequency (%d Hz, %s)",
187 + pdata->ref_clock_freq,
188 + pdata->ref_clock_xtal ? "XTAL" : "not XTAL");
190 + return priv->ref_clock;
193 if (!strcmp(fref_param, "19.2"))
194 priv->ref_clock = WL12XX_REFCLOCK_19;
195 @@ -1741,7 +1787,15 @@ static int wl12xx_setup(struct wl1271 *w
199 - priv->tcxo_clock = pdata->board_tcxo_clock;
200 + priv->tcxo_clock = wl12xx_get_clock_idx(wl12xx_tcxoclock_table,
201 + pdata->tcxo_clock_freq,
203 + if (priv->tcxo_clock < 0) {
204 + wl1271_error("Invalid tcxo_clock frequency (%d Hz)",
205 + pdata->tcxo_clock_freq);
207 + return priv->tcxo_clock;
210 if (!strcmp(tcxo_param, "19.2"))
211 priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2;
212 --- a/drivers/net/wireless/ti/wl12xx/wl12xx.h
213 +++ b/drivers/net/wireless/ti/wl12xx/wl12xx.h
214 @@ -79,4 +79,32 @@ struct wl12xx_priv {
215 struct wl127x_rx_mem_pool_addr *rx_mem_addr;
218 +/* Reference clock values */
220 + WL12XX_REFCLOCK_19 = 0, /* 19.2 MHz */
221 + WL12XX_REFCLOCK_26 = 1, /* 26 MHz */
222 + WL12XX_REFCLOCK_38 = 2, /* 38.4 MHz */
223 + WL12XX_REFCLOCK_52 = 3, /* 52 MHz */
224 + WL12XX_REFCLOCK_38_XTAL = 4, /* 38.4 MHz, XTAL */
225 + WL12XX_REFCLOCK_26_XTAL = 5, /* 26 MHz, XTAL */
228 +/* TCXO clock values */
230 + WL12XX_TCXOCLOCK_19_2 = 0, /* 19.2MHz */
231 + WL12XX_TCXOCLOCK_26 = 1, /* 26 MHz */
232 + WL12XX_TCXOCLOCK_38_4 = 2, /* 38.4MHz */
233 + WL12XX_TCXOCLOCK_52 = 3, /* 52 MHz */
234 + WL12XX_TCXOCLOCK_16_368 = 4, /* 16.368 MHz */
235 + WL12XX_TCXOCLOCK_32_736 = 5, /* 32.736 MHz */
236 + WL12XX_TCXOCLOCK_16_8 = 6, /* 16.8 MHz */
237 + WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
240 +struct wl12xx_clock {
246 #endif /* __WL12XX_PRIV_H__ */
247 --- a/include/linux/wl12xx.h
248 +++ b/include/linux/wl12xx.h
251 #include <linux/err.h>
253 -/* Reference clock values */
255 - WL12XX_REFCLOCK_19 = 0, /* 19.2 MHz */
256 - WL12XX_REFCLOCK_26 = 1, /* 26 MHz */
257 - WL12XX_REFCLOCK_38 = 2, /* 38.4 MHz */
258 - WL12XX_REFCLOCK_52 = 3, /* 52 MHz */
259 - WL12XX_REFCLOCK_38_XTAL = 4, /* 38.4 MHz, XTAL */
260 - WL12XX_REFCLOCK_26_XTAL = 5, /* 26 MHz, XTAL */
263 -/* TCXO clock values */
265 - WL12XX_TCXOCLOCK_19_2 = 0, /* 19.2MHz */
266 - WL12XX_TCXOCLOCK_26 = 1, /* 26 MHz */
267 - WL12XX_TCXOCLOCK_38_4 = 2, /* 38.4MHz */
268 - WL12XX_TCXOCLOCK_52 = 3, /* 52 MHz */
269 - WL12XX_TCXOCLOCK_16_368 = 4, /* 16.368 MHz */
270 - WL12XX_TCXOCLOCK_32_736 = 5, /* 32.736 MHz */
271 - WL12XX_TCXOCLOCK_16_8 = 6, /* 16.8 MHz */
272 - WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
275 struct wl1251_platform_data {
276 void (*set_power)(bool enable);
277 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
278 @@ -57,8 +35,9 @@ struct wl1251_platform_data {
280 struct wl12xx_platform_data {
282 - int board_ref_clock;
283 - int board_tcxo_clock;
284 + int ref_clock_freq; /* in Hertz */
285 + bool ref_clock_xtal; /* specify whether the clock is XTAL or not */
286 + int tcxo_clock_freq; /* in Hertz, tcxo is always XTAL */
289 #ifdef CONFIG_WILINK_PLATFORM_DATA