2 * Customer code to add GPIO control during WLAN start/stop
4 * Copyright (C) 1999-2016, Broadcom Corporation
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
20 * Notwithstanding the above, under no circumstances may you combine this
21 * software in any way with any other Broadcom software provided under a license
22 * other than the GPL, without Broadcom's express prior written consent.
25 * <<Broadcom-WL-IPTag/Open:>>
27 * $Id: dhd_custom_gpio.c 591129 2015-10-07 05:22:14Z $
34 #include <dngl_stats.h>
36 #include <dhd_linux.h>
39 #if defined(WL_WIRELESS_EXT)
43 #define WL_ERROR(x) printf x
46 #if defined(OOB_INTR_ONLY)
48 #if defined(BCMLXSDMMC)
49 extern int sdioh_mmc_irq(int irq
);
50 #endif /* (BCMLXSDMMC) */
52 /* Customer specific Host GPIO defintion */
53 static int dhd_oob_gpio_num
= -1;
55 module_param(dhd_oob_gpio_num
, int, 0644);
56 MODULE_PARM_DESC(dhd_oob_gpio_num
, "DHD oob gpio number");
58 /* This function will return:
59 * 1) return : Host gpio interrupt number per customer platform
60 * 2) irq_flags_ptr : Type of Host interrupt as Level or Edge
63 * Customer should check his platform definitions
64 * and his Host Interrupt spec
65 * to figure out the proper setting for his platform.
66 * Broadcom provides just reference settings as example.
69 int dhd_customer_oob_irq_map(void *adapter
, unsigned long *irq_flags_ptr
)
73 #if defined(CUSTOMER_HW2)
74 host_oob_irq
= wifi_platform_get_irq_number(adapter
, irq_flags_ptr
);
77 #if defined(CUSTOM_OOB_GPIO_NUM)
78 if (dhd_oob_gpio_num
< 0) {
79 dhd_oob_gpio_num
= CUSTOM_OOB_GPIO_NUM
;
81 #endif /* CUSTOMER_OOB_GPIO_NUM */
83 if (dhd_oob_gpio_num
< 0) {
84 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
86 return (dhd_oob_gpio_num
);
89 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
90 __FUNCTION__
, dhd_oob_gpio_num
));
94 return (host_oob_irq
);
98 /* Customer function to control hw specific wlan gpios */
100 dhd_customer_gpio_wlan_ctrl(void *adapter
, int onoff
)
107 #ifdef GET_CUSTOM_MAC_ENABLE
108 /* Function to get custom MAC address */
110 dhd_custom_get_mac_address(void *adapter
, unsigned char *buf
)
114 WL_TRACE(("%s Enter\n", __FUNCTION__
));
118 /* Customer access to MAC address stored outside of DHD driver */
119 #if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
120 ret
= wifi_platform_get_mac_addr(adapter
, buf
);
123 #ifdef EXAMPLE_GET_MAC
126 struct ether_addr ea_example
= {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
127 bcopy((char *)&ea_example
, buf
, sizeof(struct ether_addr
));
129 #endif /* EXAMPLE_GET_MAC */
133 #endif /* GET_CUSTOM_MAC_ENABLE */
135 #if !defined(WL_WIRELESS_EXT)
136 struct cntry_locales_custom
{
137 char iso_abbrev
[WLC_CNTRY_BUF_SZ
]; /* ISO 3166-1 country abbreviation */
138 char custom_locale
[WLC_CNTRY_BUF_SZ
]; /* Custom firmware locale */
139 int32 custom_locale_rev
; /* Custom local revisin default -1 */
141 #endif /* WL_WIRELESS_EXT */
143 /* Customized Locale table : OPTIONAL feature */
144 const struct cntry_locales_custom translate_custom_table
[] = {
145 /* Table should be filled out based on custom platform regulatory requirement */
147 {"", "XY", 4}, /* Universal if Country code is unknown or empty */
148 {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
149 {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
150 {"EU", "EU", 5}, /* European union countries to : EU regrev 05 */
181 {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
189 #endif /* EXMAPLE_TABLE */
190 #if defined(CUSTOMER_HW2)
191 #if defined(BCM4335_CHIP)
192 {"", "XZ", 11}, /* Universal if Country code is unknown or empty */
240 {"IR", "XZ", 11}, /* Universal if Country code is IRAN, (ISLAMIC REPUBLIC OF) */
241 {"SD", "XZ", 11}, /* Universal if Country code is SUDAN */
242 {"SY", "XZ", 11}, /* Universal if Country code is SYRIAN ARAB REPUBLIC */
243 {"GL", "XZ", 11}, /* Universal if Country code is GREENLAND */
244 {"PS", "XZ", 11}, /* Universal if Country code is PALESTINIAN TERRITORY, OCCUPIED */
245 {"TL", "XZ", 11}, /* Universal if Country code is TIMOR-LESTE (EAST TIMOR) */
246 {"MH", "XZ", 11}, /* Universal if Country code is MARSHALL ISLANDS */
255 /* Customized Locale convertor
256 * input : ISO 3166-1 country abbreviation
257 * output: customized cspec
260 #ifdef CUSTOM_COUNTRY_CODE
261 get_customized_country_code(void *adapter
, char *country_iso_code
,
262 wl_country_t
*cspec
, u32 flags
)
264 get_customized_country_code(void *adapter
, char *country_iso_code
, wl_country_t
*cspec
)
265 #endif /* CUSTOM_COUNTRY_CODE */
267 #if (defined(CUSTOMER_HW) || defined(CUSTOMER_HW2)) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
269 struct cntry_locales_custom
*cloc_ptr
;
273 #ifdef CUSTOM_COUNTRY_CODE
274 cloc_ptr
= wifi_platform_get_country_code(adapter
, country_iso_code
,
277 cloc_ptr
= wifi_platform_get_country_code(adapter
, country_iso_code
);
278 #endif /* CUSTOM_COUNTRY_CODE */
280 strlcpy(cspec
->ccode
, cloc_ptr
->custom_locale
, WLC_CNTRY_BUF_SZ
);
281 cspec
->rev
= cloc_ptr
->custom_locale_rev
;
287 size
= ARRAYSIZE(translate_custom_table
);
295 for (i
= 0; i
< size
; i
++) {
296 if (strcmp(country_iso_code
, translate_custom_table
[i
].iso_abbrev
) == 0) {
298 translate_custom_table
[i
].custom_locale
, WLC_CNTRY_BUF_SZ
);
299 cspec
->rev
= translate_custom_table
[i
].custom_locale_rev
;
304 /* if no country code matched return first universal code from translate_custom_table */
305 memcpy(cspec
->ccode
, translate_custom_table
[0].custom_locale
, WLC_CNTRY_BUF_SZ
);
306 cspec
->rev
= translate_custom_table
[0].custom_locale_rev
;
307 #endif /* EXMAPLE_TABLE */
309 #endif /* defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) */