2 * Customer code to add GPIO control during WLAN start/stop
3 * Copyright (C) 1999-2012, Broadcom Corporation
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:
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.
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.
23 * $Id: dhd_custom_gpio.c 291086 2011-10-21 01:17:24Z $
31 #include <dngl_stats.h>
37 #define WL_ERROR(x) printf x
41 extern void bcm_wlan_power_off(int);
42 extern void bcm_wlan_power_on(int);
43 #endif /* CUSTOMER_HW */
44 #if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW_SAMSUNG)
45 #ifdef CONFIG_WIFI_CONTROL_FUNC
46 int wifi_set_power(int on, unsigned long msec);
47 int wifi_get_irq_number(unsigned long *irq_flags_ptr);
48 int wifi_get_mac_addr(unsigned char *buf);
49 void *wifi_get_country_code(char *ccode);
51 int wifi_set_power(int on, unsigned long msec) { return -1; }
52 int wifi_get_irq_number(unsigned long *irq_flags_ptr) { return -1; }
53 int wifi_get_mac_addr(unsigned char *buf) { return -1; }
54 void *wifi_get_country_code(char *ccode) { return NULL; }
55 #endif /* CONFIG_WIFI_CONTROL_FUNC */
56 #endif /* CUSTOMER_HW2 || CUSTOMER_HW_SAMSUNG */
58 #if defined(OOB_INTR_ONLY)
60 #if defined(BCMLXSDMMC)
61 extern int sdioh_mmc_irq(int irq);
62 #endif /* (BCMLXSDMMC) */
65 #include <mach/gpio.h>
68 /* Customer specific Host GPIO defintion */
69 static int dhd_oob_gpio_num = -1;
71 module_param(dhd_oob_gpio_num, int, 0644);
72 MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
74 /* This function will return:
75 * 1) return : Host gpio interrupt number per customer platform
76 * 2) irq_flags_ptr : Type of Host interrupt as Level or Edge
79 * Customer should check his platform definitions
80 * and his Host Interrupt spec
81 * to figure out the proper setting for his platform.
82 * Broadcom provides just reference settings as example.
85 int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr)
89 #if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW_SAMSUNG)
90 host_oob_irq = wifi_get_irq_number(irq_flags_ptr);
93 #if defined(CUSTOM_OOB_GPIO_NUM)
94 if (dhd_oob_gpio_num < 0) {
95 dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
97 #endif /* CUSTOMER_OOB_GPIO_NUM */
99 if (dhd_oob_gpio_num < 0) {
100 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
102 return (dhd_oob_gpio_num);
105 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
106 __FUNCTION__, dhd_oob_gpio_num));
108 #if defined CUSTOMER_HW
109 host_oob_irq = MSM_GPIO_TO_INT(dhd_oob_gpio_num);
110 #elif defined CUSTOMER_HW3
111 gpio_request(dhd_oob_gpio_num, "oob irq");
112 host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
113 gpio_direction_input(dhd_oob_gpio_num);
114 #endif /* CUSTOMER_HW */
115 #endif /* CUSTOMER_HW2 || CUSTOMER_HW_SAMSUNG */
117 return (host_oob_irq);
119 #endif /* defined(OOB_INTR_ONLY) */
121 /* Customer function to control hw specific wlan gpios */
123 dhd_customer_gpio_wlan_ctrl(int onoff)
127 WL_TRACE(("%s: call customer specific GPIO to insert WLAN RESET\n",
130 bcm_wlan_power_off(2);
131 #endif /* CUSTOMER_HW */
132 #if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW_SAMSUNG)
133 wifi_set_power(0, 0);
135 WL_ERROR(("=========== WLAN placed in RESET ========\n"));
139 WL_TRACE(("%s: callc customer specific GPIO to remove WLAN RESET\n",
142 bcm_wlan_power_on(2);
143 #endif /* CUSTOMER_HW */
144 #if defined(CUSTOMER_HW2) || defined(CUSTOMER_HW_SAMSUNG)
145 wifi_set_power(1, 0);
147 WL_ERROR(("=========== WLAN going back to live ========\n"));
151 WL_TRACE(("%s: call customer specific GPIO to turn off WL_REG_ON\n",
154 bcm_wlan_power_off(1);
155 #endif /* CUSTOMER_HW */
159 WL_TRACE(("%s: call customer specific GPIO to turn on WL_REG_ON\n",
162 bcm_wlan_power_on(1);
163 /* Lets customer power to get stable */
165 #endif /* CUSTOMER_HW */
170 #ifdef GET_CUSTOM_MAC_ENABLE
171 /* Function to get custom MAC address */
173 dhd_custom_get_mac_address(unsigned char *buf)
177 WL_TRACE(("%s Enter\n", __FUNCTION__));
181 /* Customer access to MAC address stored outside of DHD driver */
182 #if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
183 ret = wifi_get_mac_addr(buf);
186 #ifdef EXAMPLE_GET_MAC
189 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
190 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
192 #endif /* EXAMPLE_GET_MAC */
196 #endif /* GET_CUSTOM_MAC_ENABLE */
198 /* Customized Locale table : OPTIONAL feature */
199 const struct cntry_locales_custom translate_custom_table[] = {
200 /* Table should be filled out based on custom platform regulatory requirement */
202 {"", "XZ", 11}, /* Universal if Country code is unknown or empty */
250 #ifdef CUSTOMER_HW_SAMSUNG
251 {"IR", "XZ", 11}, /* Universal if Country code is IRAN, (ISLAMIC REPUBLIC OF) */
252 {"SD", "XZ", 11}, /* Universal if Country code is SUDAN */
253 {"SY", "XZ", 11}, /* Universal if Country code is SYRIAN ARAB REPUBLIC */
254 {"GL", "XZ", 11}, /* Universal if Country code is GREENLAND */
255 {"PS", "XZ", 11}, /* Universal if Country code is PALESTINIAN TERRITORY, OCCUPIED */
256 {"TL", "XZ", 11}, /* Universal if Country code is TIMOR-LESTE (EAST TIMOR) */
257 {"MH", "XZ", 11}, /* Universal if Country code is MARSHALL ISLANDS */
258 {"PK", "XZ", 11}, /* Universal if Country code is PAKISTAN*/
273 /* Customized Locale convertor
274 * input : ISO 3166-1 country abbreviation
275 * output: customized cspec
277 void get_customized_country_code(char *country_iso_code, wl_country_t *cspec)
279 #ifndef CUSTOMER_HW_SAMSUNG
280 struct cntry_locales_custom *cloc_ptr;
285 cloc_ptr = wifi_get_country_code(country_iso_code);
287 strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
288 cspec->rev = cloc_ptr->custom_locale_rev;
294 size = ARRAYSIZE(translate_custom_table);
302 for (i = 0; i < size; i++) {
303 if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
305 translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
306 cspec->rev = translate_custom_table[i].custom_locale_rev;
311 /* if no country code matched return first universal code from translate_custom_table */
312 memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
313 cspec->rev = translate_custom_table[0].custom_locale_rev;
314 #endif /* EXMAPLE_TABLE */
316 #endif /* CUSTOMER_HW_SAMSUNG) */