• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Customer code to add GPIO control during WLAN start/stop
3  *
4  * Copyright (C) 1999-2019, Broadcom.
5  *
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:
11  *
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
16  * of the license of that module.  An independent module is a module which is
17  * not derived from this software.  The special exception does not apply to any
18  * modifications of the software.
19  *
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.
23  *
24  *
25  * <<Broadcom-WL-IPTag/Open:>>
26  *
27  * $Id: dhd_custom_gpio.c 717227 2017-08-23 13:51:13Z $
28  */
29 
30 #include <typedefs.h>
31 #include <linuxver.h>
32 #include <osl.h>
33 #include <bcmutils.h>
34 #include <dngl_stats.h>
35 #include <dhd.h>
36 #include <dhd_linux.h>
37 
38 #include <wlioctl.h>
39 #if defined(WL_WIRELESS_EXT)
40 #include <wl_iw.h>
41 #endif // endif
42 
43 #define WL_ERROR(x) printf x
44 #define WL_TRACE(x)
45 
46 #if defined(OOB_INTR_ONLY) || defined(BCMSPI_ANDROID)
47 
48 #if defined(BCMLXSDMMC)
49 extern int sdioh_mmc_irq(int irq);
50 #endif /* (BCMLXSDMMC)  */
51 
52 /* Customer specific Host GPIO defintion  */
53 static int dhd_oob_gpio_num = -1;
54 
55 module_param(dhd_oob_gpio_num, int, 0644);
56 MODULE_PARM_DESC(dhd_oob_gpio_num, "DHD oob gpio number");
57 
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
61  *
62  *  NOTE :
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.
67  *
68  */
dhd_customer_oob_irq_map(void * adapter,unsigned long * irq_flags_ptr)69 int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr)
70 {
71     int host_oob_irq = 0;
72 
73     host_oob_irq = wifi_platform_get_irq_number(adapter, irq_flags_ptr);
74 
75     return (host_oob_irq);
76 }
77 #endif /* defined(OOB_INTR_ONLY) || defined(BCMSPI_ANDROID) */
78 
79 /* Customer function to control hw specific wlan gpios */
dhd_customer_gpio_wlan_ctrl(void * adapter,int onoff)80 int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff)
81 {
82     int err = 0;
83 
84     return err;
85 }
86 
87 /* Customized Locale table : OPTIONAL feature */
88 const struct cntry_locales_custom translate_custom_table[] = {
89 /* Table should be filled out based on custom platform regulatory requirement */
90 #ifdef EXAMPLE_TABLE
91     {"", "XY", 4},    /* Universal if Country code is unknown or empty */
92     {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
93     {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
94     {"EU", "EU", 5},  /* European union countries to : EU regrev 05 */
95     {"AT", "EU", 5},  {"BE", "EU", 5}, {"BG", "EU", 5},  {"CY", "EU", 5},
96     {"CZ", "EU", 5},  {"DK", "EU", 5}, {"EE", "EU", 5},  {"FI", "EU", 5},
97     {"FR", "EU", 5},  {"DE", "EU", 5}, {"GR", "EU", 5},  {"HU", "EU", 5},
98     {"IE", "EU", 5},  {"IT", "EU", 5}, {"LV", "EU", 5},  {"LI", "EU", 5},
99     {"LT", "EU", 5},  {"LU", "EU", 5}, {"MT", "EU", 5},  {"NL", "EU", 5},
100     {"PL", "EU", 5},  {"PT", "EU", 5}, {"RO", "EU", 5},  {"SK", "EU", 5},
101     {"SI", "EU", 5},  {"ES", "EU", 5}, {"SE", "EU", 5},  {"GB", "EU", 5},
102     {"KR", "XY", 3},  {"AU", "XY", 3}, {"CN", "XY", 3}, /* input ISO "CN" to :
103                                                            XY regrev 03 */
104     {"TW", "XY", 3},  {"AR", "XY", 3}, {"MX", "XY", 3},  {"IL", "IL", 0},
105     {"CH", "CH", 0},  {"TR", "TR", 0}, {"NO", "NO", 0},
106 #endif /* EXMAPLE_TABLE */
107 #if defined(BCM4335_CHIP)
108     {"", "XZ", 11}, /* Universal if Country code is unknown or empty */
109 #endif              // endif
110     {"AE", "AE", 1},  {"AR", "AR", 1}, {"AT", "AT", 1},  {"AU", "AU", 2},
111     {"BE", "BE", 1},  {"BG", "BG", 1}, {"BN", "BN", 1},  {"CA", "CA", 2},
112     {"CH", "CH", 1},  {"CY", "CY", 1}, {"CZ", "CZ", 1},  {"DE", "DE", 3},
113     {"DK", "DK", 1},  {"EE", "EE", 1}, {"ES", "ES", 1},  {"FI", "FI", 1},
114     {"FR", "FR", 1},  {"GB", "GB", 1}, {"GR", "GR", 1},  {"HR", "HR", 1},
115     {"HU", "HU", 1},  {"IE", "IE", 1}, {"IS", "IS", 1},  {"IT", "IT", 1},
116     {"ID", "ID", 1},  {"JP", "JP", 8}, {"KR", "KR", 24}, {"KW", "KW", 1},
117     {"LI", "LI", 1},  {"LT", "LT", 1}, {"LU", "LU", 1},  {"LV", "LV", 1},
118     {"MA", "MA", 1},  {"MT", "MT", 1}, {"MX", "MX", 1},  {"NL", "NL", 1},
119     {"NO", "NO", 1},  {"PL", "PL", 1}, {"PT", "PT", 1},  {"PY", "PY", 1},
120     {"RO", "RO", 1},  {"SE", "SE", 1}, {"SI", "SI", 1},  {"SK", "SK", 1},
121     {"TR", "TR", 7},  {"TW", "TW", 1}, {"IR", "XZ", 11}, /* Universal if Country
122                                                             code is IRAN,
123                                                             (ISLAMIC REPUBLIC
124                                                             OF) */
125     {"SD", "XZ", 11}, /* Universal if Country code is SUDAN */
126     {"SY", "XZ", 11}, /* Universal if Country code is SYRIAN ARAB REPUBLIC */
127     {"GL", "XZ", 11}, /* Universal if Country code is GREENLAND */
128     {"PS", "XZ", 11}, /* Universal if Country code is PALESTINIAN TERRITORY,
129                          OCCUPIED */
130     {"TL", "XZ", 11}, /* Universal if Country code is TIMOR-LESTE (EAST TIMOR)
131                        */
132     {"MH", "XZ", 11}, /* Universal if Country code is MARSHALL ISLANDS */
133 };
134 
135 /* Customized Locale convertor
136  *  input : ISO 3166-1 country abbreviation
137  *  output: customized cspec
138  */
139 void
140 #ifdef CUSTOM_COUNTRY_CODE
get_customized_country_code(void * adapter,char * country_iso_code,wl_country_t * cspec,u32 flags)141 get_customized_country_code(void *adapter, char *country_iso_code,
142     wl_country_t *cspec, u32 flags)
143 #else
144 get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec)
145 #endif /* CUSTOM_COUNTRY_CODE */
146 {
147 #if (defined(CUSTOMER_HW) || defined(CUSTOMER_HW2)) &&                         \
148     (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
149 
150     struct cntry_locales_custom *cloc_ptr;
151 
152     if (!cspec) {
153         return;
154     }
155 #ifdef CUSTOM_COUNTRY_CODE
156     cloc_ptr = wifi_platform_get_country_code(adapter, country_iso_code, flags);
157 #else
158     cloc_ptr = wifi_platform_get_country_code(adapter, country_iso_code);
159 #endif /* CUSTOM_COUNTRY_CODE */
160     if (cloc_ptr) {
161         strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
162         cspec->rev = cloc_ptr->custom_locale_rev;
163     }
164     return;
165 #else
166     int size, i;
167 
168     size = ARRAYSIZE(translate_custom_table);
169 
170     if (cspec == 0) {
171         return;
172     }
173 
174     if (size == 0) {
175         return;
176     }
177 
178     for (i = 0; i < size; i++) {
179         if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) ==
180             0) {
181             memcpy(cspec->ccode, translate_custom_table[i].custom_locale,
182                    WLC_CNTRY_BUF_SZ);
183             cspec->rev = translate_custom_table[i].custom_locale_rev;
184             return;
185         }
186     }
187 #ifdef EXAMPLE_TABLE
188     /* if no country code matched return first universal code from
189      * translate_custom_table */
190     memcpy(cspec->ccode, translate_custom_table[0].custom_locale,
191            WLC_CNTRY_BUF_SZ);
192     cspec->rev = translate_custom_table[0].custom_locale_rev;
193 #endif /* EXMAPLE_TABLE */
194     return;
195 #endif /* (defined(CUSTOMER_HW2) || defined(BOARD_HIKEY)) &&                   \
196         * (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36))                     \
197         */
198 }
199