aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuciano Coelho <luca@coelho.fi>2015-03-18 12:38:26 -0400
committerTony Lindgren <tony@atomide.com>2015-03-24 12:47:57 -0400
commit44486b48b066330e0ed0a66478cc49f5975ec6c1 (patch)
tree9961c30c1a665a3dbba3e738072b8077c284f141
parent6f921fab5844941f7605b7f1a265f5fc7fe969a7 (diff)
wl12xx: use frequency instead of enumerations for pdata clocks
Instead of defining an enumeration with the FW specific values for the different clock rates, use the actual frequency instead. Also add a boolean to specify whether the clock is XTAL or not. Change all board files to reflect this. Signed-off-by: Luciano Coelho <luca@coelho.fi> [Eliad - small fixes, update board file changes] Signed-off-by: Eliad Peller <eliad@wizery.com> Tested-by: Nikita Kiryanov <nikita@compulab.co.il> Acked-by: Kalle Valo <kvalo@codeaurora.org> Acked-by: Sekhar Nori <nsekhar@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-davinci/board-da850-evm.c3
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c29
-rw-r--r--drivers/net/wireless/ti/wl12xx/main.c60
-rw-r--r--drivers/net/wireless/ti/wl12xx/wl12xx.h28
-rw-r--r--include/linux/wl12xx.h27
5 files changed, 103 insertions, 44 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
index 916589ca8d44..853b941b710e 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -1386,7 +1386,8 @@ static const short da850_wl12xx_pins[] __initconst = {
1386static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = { 1386static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = {
1387 .irq = -1, 1387 .irq = -1,
1388 .irq_trigger = IRQ_TYPE_EDGE_RISING, 1388 .irq_trigger = IRQ_TYPE_EDGE_RISING,
1389 .board_ref_clock = WL12XX_REFCLOCK_38, 1389 .ref_clock_freq = 38400000,
1390 .ref_clock_xtal = false,
1390}; 1391};
1391 1392
1392static __init int da850_wl12xx_init(void) 1393static __init int da850_wl12xx_init(void)
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index e86fb0d55c59..cebdf8d0dc08 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -39,14 +39,14 @@ static struct twl4030_gpio_platform_data twl_gpio_auxdata;
39 39
40static struct wl12xx_platform_data wl12xx __initdata; 40static struct wl12xx_platform_data wl12xx __initdata;
41 41
42static void __init __used legacy_init_wl12xx(unsigned ref_clock, 42static void __init __used legacy_init_wl12xx(u32 ref_clock_freq,
43 unsigned tcxo_clock, 43 u32 tcxo_clock_freq,
44 int gpio) 44 int gpio)
45{ 45{
46 int res; 46 int res;
47 47
48 wl12xx.board_ref_clock = ref_clock; 48 wl12xx.ref_clock_freq = ref_clock_freq;
49 wl12xx.board_tcxo_clock = tcxo_clock; 49 wl12xx.tcxo_clock_freq = tcxo_clock_freq;
50 wl12xx.irq = gpio_to_irq(gpio); 50 wl12xx.irq = gpio_to_irq(gpio);
51 wl12xx.irq_trigger = IRQ_TYPE_LEVEL_HIGH; 51 wl12xx.irq_trigger = IRQ_TYPE_LEVEL_HIGH;
52 52
@@ -57,8 +57,8 @@ static void __init __used legacy_init_wl12xx(unsigned ref_clock,
57 } 57 }
58} 58}
59#else 59#else
60static inline void legacy_init_wl12xx(unsigned ref_clock, 60static inline void legacy_init_wl12xx(u32 ref_clock_freq,
61 unsigned tcxo_clock, 61 u32 tcxo_clock_freq,
62 int gpio) 62 int gpio)
63{ 63{
64} 64}
@@ -130,7 +130,7 @@ static void __init omap3_sbc_t3730_twl_init(void)
130static void __init omap3_sbc_t3730_legacy_init(void) 130static void __init omap3_sbc_t3730_legacy_init(void)
131{ 131{
132 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub"); 132 omap3_sbc_t3x_usb_hub_init(167, "sb-t35 usb hub");
133 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 136); 133 legacy_init_wl12xx(38400000, 0, 136);
134} 134}
135 135
136static void __init omap3_sbc_t3530_legacy_init(void) 136static void __init omap3_sbc_t3530_legacy_init(void)
@@ -175,12 +175,12 @@ static void __init omap3_igep0030_rev_g_legacy_init(void)
175static void __init omap3_evm_legacy_init(void) 175static void __init omap3_evm_legacy_init(void)
176{ 176{
177 hsmmc2_internal_input_clk(); 177 hsmmc2_internal_input_clk();
178 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 149); 178 legacy_init_wl12xx(38400000, 0, 149);
179} 179}
180 180
181static void __init omap3_zoom_legacy_init(void) 181static void __init omap3_zoom_legacy_init(void)
182{ 182{
183 legacy_init_wl12xx(WL12XX_REFCLOCK_26, 0, 162); 183 legacy_init_wl12xx(26000000, 0, 162);
184} 184}
185 185
186static void am35xx_enable_emac_int(void) 186static void am35xx_enable_emac_int(void)
@@ -247,7 +247,7 @@ static void __init omap3_sbc_t3517_legacy_init(void)
247 am35xx_emac_reset(); 247 am35xx_emac_reset();
248 hsmmc2_internal_input_clk(); 248 hsmmc2_internal_input_clk();
249 omap3_sbc_t3517_wifi_init(); 249 omap3_sbc_t3517_wifi_init();
250 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 145); 250 legacy_init_wl12xx(38400000, 0, 145);
251} 251}
252 252
253static void __init am3517_evm_legacy_init(void) 253static void __init am3517_evm_legacy_init(void)
@@ -292,18 +292,17 @@ static void __init omap3_tao3530_legacy_init(void)
292#ifdef CONFIG_ARCH_OMAP4 292#ifdef CONFIG_ARCH_OMAP4
293static void __init omap4_sdp_legacy_init(void) 293static void __init omap4_sdp_legacy_init(void)
294{ 294{
295 legacy_init_wl12xx(WL12XX_REFCLOCK_26, 295 legacy_init_wl12xx(26000000, 26000000, 53);
296 WL12XX_TCXOCLOCK_26, 53);
297} 296}
298 297
299static void __init omap4_panda_legacy_init(void) 298static void __init omap4_panda_legacy_init(void)
300{ 299{
301 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 53); 300 legacy_init_wl12xx(38400000, 0, 53);
302} 301}
303 302
304static void __init var_som_om44_legacy_init(void) 303static void __init var_som_om44_legacy_init(void)
305{ 304{
306 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 41); 305 legacy_init_wl12xx(38400000, 0, 41);
307} 306}
308#endif 307#endif
309 308
@@ -318,7 +317,7 @@ static struct iommu_platform_data omap4_iommu_pdata = {
318#ifdef CONFIG_SOC_AM33XX 317#ifdef CONFIG_SOC_AM33XX
319static void __init am335x_evmsk_legacy_init(void) 318static void __init am335x_evmsk_legacy_init(void)
320{ 319{
321 legacy_init_wl12xx(WL12XX_REFCLOCK_38, 0, 31); 320 legacy_init_wl12xx(38400000, 0, 31);
322} 321}
323#endif 322#endif
324 323
diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
index 144d1f8ba473..b3f751f1e08f 100644
--- a/drivers/net/wireless/ti/wl12xx/main.c
+++ b/drivers/net/wireless/ti/wl12xx/main.c
@@ -1770,6 +1770,40 @@ wl12xx_iface_combinations[] = {
1770 }, 1770 },
1771}; 1771};
1772 1772
1773static const struct wl12xx_clock wl12xx_refclock_table[] = {
1774 { 19200000, false, WL12XX_REFCLOCK_19 },
1775 { 26000000, false, WL12XX_REFCLOCK_26 },
1776 { 26000000, true, WL12XX_REFCLOCK_26_XTAL },
1777 { 38400000, false, WL12XX_REFCLOCK_38 },
1778 { 38400000, true, WL12XX_REFCLOCK_38_XTAL },
1779 { 52000000, false, WL12XX_REFCLOCK_52 },
1780 { 0, false, 0 }
1781};
1782
1783static const struct wl12xx_clock wl12xx_tcxoclock_table[] = {
1784 { 16368000, true, WL12XX_TCXOCLOCK_16_368 },
1785 { 16800000, true, WL12XX_TCXOCLOCK_16_8 },
1786 { 19200000, true, WL12XX_TCXOCLOCK_19_2 },
1787 { 26000000, true, WL12XX_TCXOCLOCK_26 },
1788 { 32736000, true, WL12XX_TCXOCLOCK_32_736 },
1789 { 33600000, true, WL12XX_TCXOCLOCK_33_6 },
1790 { 38400000, true, WL12XX_TCXOCLOCK_38_4 },
1791 { 52000000, true, WL12XX_TCXOCLOCK_52 },
1792 { 0, false, 0 }
1793};
1794
1795static int wl12xx_get_clock_idx(const struct wl12xx_clock *table,
1796 u32 freq, bool xtal)
1797{
1798 int i;
1799
1800 for (i = 0; table[i].freq != 0; i++)
1801 if ((table[i].freq == freq) && (table[i].xtal == xtal))
1802 return table[i].hw_idx;
1803
1804 return -EINVAL;
1805}
1806
1773static int wl12xx_setup(struct wl1271 *wl) 1807static int wl12xx_setup(struct wl1271 *wl)
1774{ 1808{
1775 struct wl12xx_priv *priv = wl->priv; 1809 struct wl12xx_priv *priv = wl->priv;
@@ -1799,7 +1833,17 @@ static int wl12xx_setup(struct wl1271 *wl)
1799 wl12xx_conf_init(wl); 1833 wl12xx_conf_init(wl);
1800 1834
1801 if (!fref_param) { 1835 if (!fref_param) {
1802 priv->ref_clock = pdata->board_ref_clock; 1836 priv->ref_clock = wl12xx_get_clock_idx(wl12xx_refclock_table,
1837 pdata->ref_clock_freq,
1838 pdata->ref_clock_xtal);
1839 if (priv->ref_clock < 0) {
1840 wl1271_error("Invalid ref_clock frequency (%d Hz, %s)",
1841 pdata->ref_clock_freq,
1842 pdata->ref_clock_xtal ?
1843 "XTAL" : "not XTAL");
1844
1845 return priv->ref_clock;
1846 }
1803 } else { 1847 } else {
1804 if (!strcmp(fref_param, "19.2")) 1848 if (!strcmp(fref_param, "19.2"))
1805 priv->ref_clock = WL12XX_REFCLOCK_19; 1849 priv->ref_clock = WL12XX_REFCLOCK_19;
@@ -1817,9 +1861,17 @@ static int wl12xx_setup(struct wl1271 *wl)
1817 wl1271_error("Invalid fref parameter %s", fref_param); 1861 wl1271_error("Invalid fref parameter %s", fref_param);
1818 } 1862 }
1819 1863
1820 if (!tcxo_param) { 1864 if (!tcxo_param && pdata->tcxo_clock_freq) {
1821 priv->tcxo_clock = pdata->board_tcxo_clock; 1865 priv->tcxo_clock = wl12xx_get_clock_idx(wl12xx_tcxoclock_table,
1822 } else { 1866 pdata->tcxo_clock_freq,
1867 true);
1868 if (priv->tcxo_clock < 0) {
1869 wl1271_error("Invalid tcxo_clock frequency (%d Hz)",
1870 pdata->tcxo_clock_freq);
1871
1872 return priv->tcxo_clock;
1873 }
1874 } else if (tcxo_param) {
1823 if (!strcmp(tcxo_param, "19.2")) 1875 if (!strcmp(tcxo_param, "19.2"))
1824 priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2; 1876 priv->tcxo_clock = WL12XX_TCXOCLOCK_19_2;
1825 else if (!strcmp(tcxo_param, "26")) 1877 else if (!strcmp(tcxo_param, "26"))
diff --git a/drivers/net/wireless/ti/wl12xx/wl12xx.h b/drivers/net/wireless/ti/wl12xx/wl12xx.h
index 75c92658bfea..5952e99ace1b 100644
--- a/drivers/net/wireless/ti/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/ti/wl12xx/wl12xx.h
@@ -82,6 +82,34 @@ struct wl12xx_priv {
82 struct wl127x_rx_mem_pool_addr *rx_mem_addr; 82 struct wl127x_rx_mem_pool_addr *rx_mem_addr;
83}; 83};
84 84
85/* Reference clock values */
86enum {
87 WL12XX_REFCLOCK_19 = 0, /* 19.2 MHz */
88 WL12XX_REFCLOCK_26 = 1, /* 26 MHz */
89 WL12XX_REFCLOCK_38 = 2, /* 38.4 MHz */
90 WL12XX_REFCLOCK_52 = 3, /* 52 MHz */
91 WL12XX_REFCLOCK_38_XTAL = 4, /* 38.4 MHz, XTAL */
92 WL12XX_REFCLOCK_26_XTAL = 5, /* 26 MHz, XTAL */
93};
94
95/* TCXO clock values */
96enum {
97 WL12XX_TCXOCLOCK_19_2 = 0, /* 19.2MHz */
98 WL12XX_TCXOCLOCK_26 = 1, /* 26 MHz */
99 WL12XX_TCXOCLOCK_38_4 = 2, /* 38.4MHz */
100 WL12XX_TCXOCLOCK_52 = 3, /* 52 MHz */
101 WL12XX_TCXOCLOCK_16_368 = 4, /* 16.368 MHz */
102 WL12XX_TCXOCLOCK_32_736 = 5, /* 32.736 MHz */
103 WL12XX_TCXOCLOCK_16_8 = 6, /* 16.8 MHz */
104 WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
105};
106
107struct wl12xx_clock {
108 u32 freq;
109 bool xtal;
110 u8 hw_idx;
111};
112
85struct wl12xx_fw_packet_counters { 113struct wl12xx_fw_packet_counters {
86 /* Cumulative counter of released packets per AC */ 114 /* Cumulative counter of released packets per AC */
87 u8 tx_released_pkts[NUM_TX_QUEUES]; 115 u8 tx_released_pkts[NUM_TX_QUEUES];
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index 3876b67dbcbc..eea1e6dac4be 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -26,28 +26,6 @@
26 26
27#include <linux/err.h> 27#include <linux/err.h>
28 28
29/* Reference clock values */
30enum {
31 WL12XX_REFCLOCK_19 = 0, /* 19.2 MHz */
32 WL12XX_REFCLOCK_26 = 1, /* 26 MHz */
33 WL12XX_REFCLOCK_38 = 2, /* 38.4 MHz */
34 WL12XX_REFCLOCK_52 = 3, /* 52 MHz */
35 WL12XX_REFCLOCK_38_XTAL = 4, /* 38.4 MHz, XTAL */
36 WL12XX_REFCLOCK_26_XTAL = 5, /* 26 MHz, XTAL */
37};
38
39/* TCXO clock values */
40enum {
41 WL12XX_TCXOCLOCK_19_2 = 0, /* 19.2MHz */
42 WL12XX_TCXOCLOCK_26 = 1, /* 26 MHz */
43 WL12XX_TCXOCLOCK_38_4 = 2, /* 38.4MHz */
44 WL12XX_TCXOCLOCK_52 = 3, /* 52 MHz */
45 WL12XX_TCXOCLOCK_16_368 = 4, /* 16.368 MHz */
46 WL12XX_TCXOCLOCK_32_736 = 5, /* 32.736 MHz */
47 WL12XX_TCXOCLOCK_16_8 = 6, /* 16.8 MHz */
48 WL12XX_TCXOCLOCK_33_6 = 7, /* 33.6 MHz */
49};
50
51struct wl1251_platform_data { 29struct wl1251_platform_data {
52 int power_gpio; 30 int power_gpio;
53 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */ 31 /* SDIO only: IRQ number if WLAN_IRQ line is used, 0 for SDIO IRQs */
@@ -58,8 +36,9 @@ struct wl1251_platform_data {
58struct wl12xx_platform_data { 36struct wl12xx_platform_data {
59 int irq; 37 int irq;
60 u32 irq_trigger; 38 u32 irq_trigger;
61 int board_ref_clock; 39 bool ref_clock_xtal; /* specify whether the clock is XTAL or not */
62 int board_tcxo_clock; 40 u32 ref_clock_freq; /* in Hertz */
41 u32 tcxo_clock_freq; /* in Hertz, tcxo is always XTAL */
63 bool pwr_in_suspend; 42 bool pwr_in_suspend;
64}; 43};
65 44