2 * Customer code to add GPIO control during WLAN start/stop
3 * $Copyright Open Broadcom Corporation$
5 * $Id: dhd_custom_gpio.c 493822 2014-07-29 13:20:26Z $
12 #include <dngl_stats.h>
14 #include <dhd_linux.h>
19 #define WL_ERROR(x) printf x
22 #if defined(CUSTOMER_HW2)
24 #if defined(PLATFORM_MPS)
25 int __attribute__ ((weak)) wifi_get_fw_nv_path(char *fw, char *nv) { return 0;};
30 #if defined(OOB_INTR_ONLY)
32 #if defined(BCMLXSDMMC)
33 extern int sdioh_mmc_irq(int irq);
34 #endif /* (BCMLXSDMMC) */
36 #if defined(CUSTOMER_HW3) || defined(PLATFORM_MPS)
37 #include <mach/gpio.h>
40 /* Customer specific Host GPIO defintion */
41 static int dhd_oob_gpio_num = -1;
43 module_param(dhd_oob_gpio_num, int, 0644);
44 MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
46 /* This function will return:
47 * 1) return : Host gpio interrupt number per customer platform
48 * 2) irq_flags_ptr : Type of Host interrupt as Level or Edge
51 * Customer should check his platform definitions
52 * and his Host Interrupt spec
53 * to figure out the proper setting for his platform.
54 * Broadcom provides just reference settings as example.
57 int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr)
61 #if defined(CUSTOMER_HW2) && !defined(PLATFORM_MPS)
62 host_oob_irq = wifi_platform_get_irq_number(adapter, irq_flags_ptr);
65 #if defined(CUSTOM_OOB_GPIO_NUM)
66 if (dhd_oob_gpio_num < 0) {
67 dhd_oob_gpio_num = CUSTOM_OOB_GPIO_NUM;
69 #endif /* CUSTOMER_OOB_GPIO_NUM */
71 if (dhd_oob_gpio_num < 0) {
72 WL_ERROR(("%s: ERROR customer specific Host GPIO is NOT defined \n",
74 return (dhd_oob_gpio_num);
77 WL_ERROR(("%s: customer specific Host GPIO number is (%d)\n",
78 __FUNCTION__, dhd_oob_gpio_num));
80 #if defined CUSTOMER_HW3 || defined(PLATFORM_MPS)
81 gpio_request(dhd_oob_gpio_num, "oob irq");
82 host_oob_irq = gpio_to_irq(dhd_oob_gpio_num);
83 gpio_direction_input(dhd_oob_gpio_num);
84 #endif /* defined CUSTOMER_HW3 || defined(PLATFORM_MPS) */
87 return (host_oob_irq);
91 /* Customer function to control hw specific wlan gpios */
93 dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff)
100 #ifdef GET_CUSTOM_MAC_ENABLE
101 /* Function to get custom MAC address */
103 dhd_custom_get_mac_address(void *adapter, unsigned char *buf)
107 WL_TRACE(("%s Enter\n", __FUNCTION__));
111 /* Customer access to MAC address stored outside of DHD driver */
112 #if (defined(CUSTOMER_HW2) || defined(CUSTOMER_HW10)) && (LINUX_VERSION_CODE >= \
113 KERNEL_VERSION(2, 6, 35))
114 ret = wifi_platform_get_mac_addr(adapter, buf);
117 #ifdef EXAMPLE_GET_MAC
120 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
121 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
123 #endif /* EXAMPLE_GET_MAC */
127 #endif /* GET_CUSTOM_MAC_ENABLE */
129 /* Customized Locale table : OPTIONAL feature */
130 const struct cntry_locales_custom translate_custom_table[] = {
131 /* Table should be filled out based on custom platform regulatory requirement */
133 {"", "XY", 4}, /* Universal if Country code is unknown or empty */
134 {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
135 {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
136 {"EU", "EU", 5}, /* European union countries to : EU regrev 05 */
167 {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
175 #endif /* EXMAPLE_TABLE */
176 #if defined(CUSTOMER_HW2) && !defined(CUSTOMER_HW5)
177 #if defined(BCM4335_CHIP)
178 {"", "XZ", 11}, /* Universal if Country code is unknown or empty */
226 {"IR", "XZ", 11}, /* Universal if Country code is IRAN, (ISLAMIC REPUBLIC OF) */
227 {"SD", "XZ", 11}, /* Universal if Country code is SUDAN */
228 {"SY", "XZ", 11}, /* Universal if Country code is SYRIAN ARAB REPUBLIC */
229 {"GL", "XZ", 11}, /* Universal if Country code is GREENLAND */
230 {"PS", "XZ", 11}, /* Universal if Country code is PALESTINIAN TERRITORY, OCCUPIED */
231 {"TL", "XZ", 11}, /* Universal if Country code is TIMOR-LESTE (EAST TIMOR) */
232 {"MH", "XZ", 11}, /* Universal if Country code is MARSHALL ISLANDS */
238 #elif defined(CUSTOMER_HW5)
373 #endif /* CUSTOMER_HW2 and CUSTOMER_HW5 */
377 /* Customized Locale convertor
378 * input : ISO 3166-1 country abbreviation
379 * output: customized cspec
381 void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec)
383 #if defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
385 struct cntry_locales_custom *cloc_ptr;
390 cloc_ptr = wifi_platform_get_country_code(adapter, country_iso_code);
392 strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
393 cspec->rev = cloc_ptr->custom_locale_rev;
399 size = ARRAYSIZE(translate_custom_table);
407 for (i = 0; i < size; i++) {
408 if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
410 translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
411 cspec->rev = translate_custom_table[i].custom_locale_rev;
416 /* if no country code matched return first universal code from translate_custom_table */
417 memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
418 cspec->rev = translate_custom_table[0].custom_locale_rev;
419 #endif /* EXMAPLE_TABLE */
421 #endif /* defined(CUSTOMER_HW2) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36)) */