2 * Customer code to add GPIO control during WLAN start/stop
3 * $Copyright Open Broadcom Corporation$
5 * $Id: dhd_custom_gpio.c 417465 2013-08-09 11:47:27Z $
13 #include <dngl_stats.h>
19 #define WL_ERROR(x) printf x
22 #ifdef CUSTOMER_HW_AMLOGIC
23 extern void sdio_reinit(void);
24 extern void extern_wifi_set_enable(int is_on
);
25 #endif /* CUSTOMER_HW_AMLOGIC */
28 #if defined(CUSTOMER_OOB)
29 extern int bcm_wlan_get_oob_irq(void);
31 extern void bcm_wlan_power_off(int);
32 extern void bcm_wlan_power_on(int);
33 #endif /* CUSTOMER_HW */
34 #if defined(CUSTOMER_HW2)
36 #if defined(PLATFORM_MPS)
37 int __attribute__ ((weak
)) wifi_get_fw_nv_path(char *fw
, char *nv
) { return 0;};
40 #ifdef CONFIG_WIFI_CONTROL_FUNC
41 int wifi_set_power(int on
, unsigned long msec
);
42 int wifi_get_irq_number(unsigned long *irq_flags_ptr
);
43 int wifi_get_mac_addr(unsigned char *buf
);
44 void *wifi_get_country_code(char *ccode
);
46 int wifi_set_power(int on
, unsigned long msec
) { return -1; }
47 int wifi_get_irq_number(unsigned long *irq_flags_ptr
) { return -1; }
48 int wifi_get_mac_addr(unsigned char *buf
) { return -1; }
49 void *wifi_get_country_code(char *ccode
) { return NULL
; }
50 #endif /* CONFIG_WIFI_CONTROL_FUNC */
53 #if defined(OOB_INTR_ONLY)
55 #if defined(BCMLXSDMMC)
56 extern int sdioh_mmc_irq(int irq
);
57 #endif /* (BCMLXSDMMC) */
59 #if defined(CUSTOMER_HW3) || defined(PLATFORM_MPS)
60 #include <mach/gpio.h>
63 /* Customer specific Host GPIO defintion */
64 static int dhd_oob_gpio_num
= -1;
66 module_param(dhd_oob_gpio_num
, int, 0644);
67 MODULE_PARM_DESC(dhd_oob_gpio_num
, "DHD oob gpio number");
69 /* This function will return:
70 * 1) return : Host gpio interrupt number per customer platform
71 * 2) irq_flags_ptr : Type of Host interrupt as Level or Edge
74 * Customer should check his platform definitions
75 * and his Host Interrupt spec
76 * to figure out the proper setting for his platform.
77 * Broadcom provides just reference settings as example.
80 int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr
)
82 int host_oob_irq
= CUSTOM_OOB_GPIO_NUM
;
84 #if defined(CUSTOMER_HW2) && !defined(PLATFORM_MPS)
85 host_oob_irq
= wifi_get_irq_number(irq_flags_ptr
);
87 #elif defined(CUSTOMER_OOB)
88 host_oob_irq
= bcm_wlan_get_oob_irq();
91 #if defined(CUSTOM_OOB_GPIO_NUM)
92 if (dhd_oob_gpio_num
< 0) {
93 dhd_oob_gpio_num
= CUSTOM_OOB_GPIO_NUM
;
95 #endif /* CUSTOMER_OOB_GPIO_NUM */
97 if (dhd_oob_gpio_num
< 0) {
98 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
100 return (dhd_oob_gpio_num
);
103 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
104 __FUNCTION__
, dhd_oob_gpio_num
));
106 #if defined CUSTOMER_HW
107 host_oob_irq
= MSM_GPIO_TO_INT(dhd_oob_gpio_num
);
108 #elif defined CUSTOMER_HW3 || defined(PLATFORM_MPS)
109 gpio_request(dhd_oob_gpio_num
, "oob irq");
110 host_oob_irq
= gpio_to_irq(dhd_oob_gpio_num
);
111 gpio_direction_input(dhd_oob_gpio_num
);
112 #endif /* CUSTOMER_HW */
115 return (host_oob_irq
);
119 /* Customer function to control hw specific wlan gpios */
121 dhd_customer_gpio_wlan_ctrl(int onoff
)
125 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
128 bcm_wlan_power_off(2);
129 #endif /* CUSTOMER_HW */
130 #if defined(CUSTOMER_HW2)
131 wifi_set_power(0, WIFI_TURNOFF_DELAY
);
133 WL_ERROR(("=========== WLAN placed in RESET ========\n"));
137 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
140 bcm_wlan_power_on(2);
142 #endif /* CUSTOMER_HW */
143 #if defined(CUSTOMER_HW2)
144 wifi_set_power(1, 200);
146 #ifdef CUSTOMER_HW_AMLOGIC
147 extern_wifi_set_enable(0);
149 extern_wifi_set_enable(1);
152 #endif /* CUSTOMER_HW_AMLOGIC */
154 WL_ERROR(("=========== WLAN going back to live ========\n"));
158 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
161 bcm_wlan_power_off(1);
162 #endif /* CUSTOMER_HW */
164 #ifdef CUSTOMER_HW_AMLOGIC
165 extern_wifi_set_enable(0);
166 #endif /* CUSTOMER_HW_AMLOGIC */
167 WL_ERROR(("=========== WLAN placed in POWER OFF ========\n"));
171 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
174 bcm_wlan_power_on(1);
175 #endif /* CUSTOMER_HW */
177 #ifdef CUSTOMER_HW_AMLOGIC
178 extern_wifi_set_enable(0);
180 extern_wifi_set_enable(1);
183 #endif /* CUSTOMER_HW_AMLOGIC */
184 /* Lets customer power to get stable */
186 WL_ERROR(("=========== WLAN placed in POWER ON ========\n"));
191 #ifdef GET_CUSTOM_MAC_ENABLE
192 /* Function to get custom MAC address */
194 dhd_custom_get_mac_address(unsigned char *buf
)
198 WL_TRACE(("%s Enter\n", __FUNCTION__
));
202 /* Customer access to MAC address stored outside of DHD driver */
203 #if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
204 ret
= wifi_get_mac_addr(buf
);
207 #ifdef EXAMPLE_GET_MAC
210 struct ether_addr ea_example
= {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
211 bcopy((char *)&ea_example
, buf
, sizeof(struct ether_addr
));
213 #endif /* EXAMPLE_GET_MAC */
217 #endif /* GET_CUSTOM_MAC_ENABLE */
219 /* Customized Locale table : OPTIONAL feature */
220 const struct cntry_locales_custom translate_custom_table
[] = {
221 /* Table should be filled out based on custom platform regulatory requirement */
223 {"", "XY", 4}, /* Universal if Country code is unknown or empty */
224 {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
225 {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
226 {"EU", "EU", 5}, /* European union countries to : EU regrev 05 */
257 {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
265 #endif /* EXMAPLE_TABLE */
269 /* Customized Locale convertor
270 * input : ISO 3166-1 country abbreviation
271 * output: customized cspec
273 void get_customized_country_code(char *country_iso_code
, wl_country_t
*cspec
)
275 #if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
277 struct cntry_locales_custom
*cloc_ptr
;
282 cloc_ptr
= wifi_get_country_code(country_iso_code
);
284 strlcpy(cspec
->ccode
, cloc_ptr
->custom_locale
, WLC_CNTRY_BUF_SZ
);
285 cspec
->rev
= cloc_ptr
->custom_locale_rev
;
291 size
= ARRAYSIZE(translate_custom_table
);
299 for (i
= 0; i
< size
; i
++) {
300 if (strcmp(country_iso_code
, translate_custom_table
[i
].iso_abbrev
) == 0) {
302 translate_custom_table
[i
].custom_locale
, WLC_CNTRY_BUF_SZ
);
303 cspec
->rev
= translate_custom_table
[i
].custom_locale_rev
;
308 /* if no country code matched return first universal code from translate_custom_table */
309 memcpy(cspec
->ccode
, translate_custom_table
[0].custom_locale
, WLC_CNTRY_BUF_SZ
);
310 cspec
->rev
= translate_custom_table
[0].custom_locale_rev
;
311 #endif /* EXMAPLE_TABLE */
313 #endif /* defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) */