aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/bcm4329/dhd_custom_gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/bcm4329/dhd_custom_gpio.c')
-rw-r--r--drivers/net/wireless/bcm4329/dhd_custom_gpio.c272
1 files changed, 272 insertions, 0 deletions
diff --git a/drivers/net/wireless/bcm4329/dhd_custom_gpio.c b/drivers/net/wireless/bcm4329/dhd_custom_gpio.c
new file mode 100644
index 00000000000..4d32863e298
--- /dev/null
+++ b/drivers/net/wireless/bcm4329/dhd_custom_gpio.c
@@ -0,0 +1,272 @@
1/*
2* Customer code to add GPIO control during WLAN start/stop
3* Copyright (C) 1999-2010, Broadcom Corporation
4*
5* Unless you and Broadcom execute a separate written software license
6* agreement governing use of this software, this software is licensed to you
7* under the terms of the GNU General Public License version 2 (the "GPL"),
8* available at http://www.broadcom.com/licenses/GPLv2.php, with the
9* following added to such license:
10*
11* As a special exception, the copyright holders of this software give you
12* permission to link this software with independent modules, and to copy and
13* distribute the resulting executable under terms of your choice, provided that
14* you also meet, for each linked independent module, the terms and conditions of
15* the license of that module. An independent module is a module which is not
16* derived from this software. The special exception does not apply to any
17* modifications of the software.
18*
19* Notwithstanding the above, under no circumstances may you combine this
20* software in any way with any other Broadcom software provided under a license
21* other than the GPL, without Broadcom's express prior written consent.
22*
23* $Id: dhd_custom_gpio.c,v 1.1.4.8.4.4 2011/01/20 20:23:09 Exp $
24*/
25
26
27#include <typedefs.h>
28#include <linuxver.h>
29#include <osl.h>
30#include <bcmutils.h>
31
32#include <dngl_stats.h>
33#include <dhd.h>
34
35#include <wlioctl.h>
36#include <wl_iw.h>
37
38#define WL_ERROR(x) printf x
39#define WL_TRACE(x)
40
41#ifdef CUSTOMER_HW
42extern void bcm_wlan_power_off(int);
43extern void bcm_wlan_power_on(int);
44#endif /* CUSTOMER_HW */
45#ifdef CUSTOMER_HW2
46int wifi_set_carddetect(int on);
47int wifi_set_power(int on, unsigned long msec);
48int wifi_get_irq_number(unsigned long *irq_flags_ptr);
49int wifi_get_mac_addr(unsigned char *buf);
50void *wifi_get_country_code(char *ccode);
51#endif
52
53#if defined(OOB_INTR_ONLY)
54
55#if defined(BCMLXSDMMC)
56extern int sdioh_mmc_irq(int irq);
57#endif /* (BCMLXSDMMC) */
58
59#ifdef CUSTOMER_HW3
60#include <mach/gpio.h>
61#endif
62
63/* Customer specific Host GPIO defintion */
64static int dhd_oob_gpio_num = -1; /* GG 19 */
65
66module_param(dhd_oob_gpio_num, int, 0644);
67MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
68
69int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr)
70{
71 int host_oob_irq = 0;
72
73#ifdef CUSTOMER_HW2
74 host_oob_irq = wifi_get_irq_number(irq_flags_ptr);
75
76#else /* for NOT CUSTOMER_HW2 */
77#if defined(CUSTOM_OOB_GPIO_NUM)
78 if (dhd_oob_gpio_num < 0) {
79 dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
80 }
81#endif
82
83 if (dhd_oob_gpio_num < 0) {
84 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
85 __FUNCTION__));
86 return (dhd_oob_gpio_num);
87 }
88
89 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
90 __FUNCTION__, dhd_oob_gpio_num));
91
92#if defined CUSTOMER_HW
93 host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num);
94#elif defined CUSTOMER_HW3
95 gpio_request(dhd_oob_gpio_num, "oob irq");
96 host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
97 gpio_direction_input(dhd_oob_gpio_num);
98#endif /* CUSTOMER_HW */
99#endif /* CUSTOMER_HW2 */
100
101 return (host_oob_irq);
102}
103#endif /* defined(OOB_INTR_ONLY) */
104
105/* Customer function to control hw specific wlan gpios */
106void
107dhd_customer_gpio_wlan_ctrl(int onoff)
108{
109 switch (onoff) {
110 case WLAN_RESET_OFF:
111 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
112 __FUNCTION__));
113#ifdef CUSTOMER_HW
114 bcm_wlan_power_off(2);
115#endif /* CUSTOMER_HW */
116#ifdef CUSTOMER_HW2
117 wifi_set_power(0, 0);
118#endif
119 WL_ERROR(("=========== WLAN placed in RESET ========\n"));
120 break;
121
122 case WLAN_RESET_ON:
123 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
124 __FUNCTION__));
125#ifdef CUSTOMER_HW
126 bcm_wlan_power_on(2);
127#endif /* CUSTOMER_HW */
128#ifdef CUSTOMER_HW2
129 wifi_set_power(1, 0);
130#endif
131 WL_ERROR(("=========== WLAN going back to live ========\n"));
132 break;
133
134 case WLAN_POWER_OFF:
135 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
136 __FUNCTION__));
137#ifdef CUSTOMER_HW
138 bcm_wlan_power_off(1);
139#endif /* CUSTOMER_HW */
140 break;
141
142 case WLAN_POWER_ON:
143 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
144 __FUNCTION__));
145#ifdef CUSTOMER_HW
146 bcm_wlan_power_on(1);
147 /* Lets customer power to get stable */
148 OSL_DELAY(50);
149#endif /* CUSTOMER_HW */
150 break;
151 }
152}
153
154#ifdef GET_CUSTOM_MAC_ENABLE
155/* Function to get custom MAC address */
156int
157dhd_custom_get_mac_address(unsigned char *buf)
158{
159 int ret = 0;
160
161 WL_TRACE(("%s Enter\n", __FUNCTION__));
162 if (!buf)
163 return -EINVAL;
164
165 /* Customer access to MAC address stored outside of DHD driver */
166#ifdef CUSTOMER_HW2
167 ret = wifi_get_mac_addr(buf);
168#endif
169
170#ifdef EXAMPLE_GET_MAC
171 /* EXAMPLE code */
172 {
173 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
174 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
175 }
176#endif /* EXAMPLE_GET_MAC */
177
178 return ret;
179}
180#endif /* GET_CUSTOM_MAC_ENABLE */
181
182/* Customized Locale table : OPTIONAL feature */
183const struct cntry_locales_custom translate_custom_table[] = {
184/* Table should be filled out based on custom platform regulatory requirement */
185#ifdef EXAMPLE_TABLE
186 {"", "XY", 4}, /* universal */
187 {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
188 {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
189 {"EU", "EU", 5}, /* European union countries */
190 {"AT", "EU", 5},
191 {"BE", "EU", 5},
192 {"BG", "EU", 5},
193 {"CY", "EU", 5},
194 {"CZ", "EU", 5},
195 {"DK", "EU", 5},
196 {"EE", "EU", 5},
197 {"FI", "EU", 5},
198 {"FR", "EU", 5},
199 {"DE", "EU", 5},
200 {"GR", "EU", 5},
201 {"HU", "EU", 5},
202 {"IE", "EU", 5},
203 {"IT", "EU", 5},
204 {"LV", "EU", 5},
205 {"LI", "EU", 5},
206 {"LT", "EU", 5},
207 {"LU", "EU", 5},
208 {"MT", "EU", 5},
209 {"NL", "EU", 5},
210 {"PL", "EU", 5},
211 {"PT", "EU", 5},
212 {"RO", "EU", 5},
213 {"SK", "EU", 5},
214 {"SI", "EU", 5},
215 {"ES", "EU", 5},
216 {"SE", "EU", 5},
217 {"GB", "EU", 5}, /* input ISO "GB" to : EU regrev 05 */
218 {"IL", "IL", 0},
219 {"CH", "CH", 0},
220 {"TR", "TR", 0},
221 {"NO", "NO", 0},
222 {"KR", "XY", 3},
223 {"AU", "XY", 3},
224 {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
225 {"TW", "XY", 3},
226 {"AR", "XY", 3},
227 {"MX", "XY", 3}
228#endif /* EXAMPLE_TABLE */
229};
230
231
232/* Customized Locale convertor
233* input : ISO 3166-1 country abbreviation
234* output: customized cspec
235*/
236void get_customized_country_code(char *country_iso_code, wl_country_t *cspec)
237{
238#ifdef CUSTOMER_HW2
239 struct cntry_locales_custom *cloc_ptr;
240
241 if (!cspec)
242 return;
243
244 cloc_ptr = wifi_get_country_code(country_iso_code);
245 if (cloc_ptr) {
246 strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
247 cspec->rev = cloc_ptr->custom_locale_rev;
248 }
249 return;
250#else
251 int size, i;
252
253 size = ARRAYSIZE(translate_custom_table);
254
255 if (cspec == 0)
256 return;
257
258 if (size == 0)
259 return;
260
261 for (i = 0; i < size; i++) {
262 if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
263 memcpy(cspec->ccode, translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
264 cspec->rev = translate_custom_table[i].custom_locale_rev;
265 return;
266 }
267 }
268 memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
269 cspec->rev = translate_custom_table[0].custom_locale_rev;
270 return;
271#endif
272}