update dhd to 100.10.545.11 [1/1]
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_dhd-driver.git] / bcmdhd.100.10.315.x / dhd_custom_gpio.c
CommitLineData
d2839953
RC
1/*
2 * Customer code to add GPIO control during WLAN start/stop
3 *
965f77c4 4 * Copyright (C) 1999-2019, Broadcom.
d2839953
RC
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 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.
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)
49extern int sdioh_mmc_irq(int irq);
50#endif /* (BCMLXSDMMC) */
51
52/* Customer specific Host GPIO defintion */
53static int dhd_oob_gpio_num = -1;
54
55module_param(dhd_oob_gpio_num, int, 0644);
56MODULE_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 */
69int 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 */
80int
81dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff)
82{
83 int err = 0;
84
85 return err;
86}
87
3910ce8e 88#if 0
d2839953
RC
89/* Function to get custom MAC address */
90int
91dhd_custom_get_mac_address(void *adapter, unsigned char *buf)
92{
93 int ret = 0;
94
95 WL_TRACE(("%s Enter\n", __FUNCTION__));
96 if (!buf)
97 return -EINVAL;
98
99 /* Customer access to MAC address stored outside of DHD driver */
100#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
101 ret = wifi_platform_get_mac_addr(adapter, buf);
102#endif // endif
103
104#ifdef EXAMPLE_GET_MAC
105 /* EXAMPLE code */
106 {
107 struct ether_addr ea_example = {{0x00, 0x11, 0x22, 0x33, 0x44, 0xFF}};
108 bcopy((char *)&ea_example, buf, sizeof(struct ether_addr));
109 }
110#endif /* EXAMPLE_GET_MAC */
111
112 return ret;
113}
114#endif /* GET_CUSTOM_MAC_ENABLE */
115
116/* Customized Locale table : OPTIONAL feature */
117const struct cntry_locales_custom translate_custom_table[] = {
118/* Table should be filled out based on custom platform regulatory requirement */
119#ifdef EXAMPLE_TABLE
120 {"", "XY", 4}, /* Universal if Country code is unknown or empty */
121 {"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
122 {"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
123 {"EU", "EU", 5}, /* European union countries to : EU regrev 05 */
124 {"AT", "EU", 5},
125 {"BE", "EU", 5},
126 {"BG", "EU", 5},
127 {"CY", "EU", 5},
128 {"CZ", "EU", 5},
129 {"DK", "EU", 5},
130 {"EE", "EU", 5},
131 {"FI", "EU", 5},
132 {"FR", "EU", 5},
133 {"DE", "EU", 5},
134 {"GR", "EU", 5},
135 {"HU", "EU", 5},
136 {"IE", "EU", 5},
137 {"IT", "EU", 5},
138 {"LV", "EU", 5},
139 {"LI", "EU", 5},
140 {"LT", "EU", 5},
141 {"LU", "EU", 5},
142 {"MT", "EU", 5},
143 {"NL", "EU", 5},
144 {"PL", "EU", 5},
145 {"PT", "EU", 5},
146 {"RO", "EU", 5},
147 {"SK", "EU", 5},
148 {"SI", "EU", 5},
149 {"ES", "EU", 5},
150 {"SE", "EU", 5},
151 {"GB", "EU", 5},
152 {"KR", "XY", 3},
153 {"AU", "XY", 3},
154 {"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
155 {"TW", "XY", 3},
156 {"AR", "XY", 3},
157 {"MX", "XY", 3},
158 {"IL", "IL", 0},
159 {"CH", "CH", 0},
160 {"TR", "TR", 0},
161 {"NO", "NO", 0},
162#endif /* EXMAPLE_TABLE */
163#if defined(BCM4335_CHIP)
164 {"", "XZ", 11}, /* Universal if Country code is unknown or empty */
165#endif // endif
166 {"AE", "AE", 1},
167 {"AR", "AR", 1},
168 {"AT", "AT", 1},
169 {"AU", "AU", 2},
170 {"BE", "BE", 1},
171 {"BG", "BG", 1},
172 {"BN", "BN", 1},
173 {"CA", "CA", 2},
174 {"CH", "CH", 1},
175 {"CY", "CY", 1},
176 {"CZ", "CZ", 1},
177 {"DE", "DE", 3},
178 {"DK", "DK", 1},
179 {"EE", "EE", 1},
180 {"ES", "ES", 1},
181 {"FI", "FI", 1},
182 {"FR", "FR", 1},
183 {"GB", "GB", 1},
184 {"GR", "GR", 1},
185 {"HR", "HR", 1},
186 {"HU", "HU", 1},
187 {"IE", "IE", 1},
188 {"IS", "IS", 1},
189 {"IT", "IT", 1},
190 {"ID", "ID", 1},
191 {"JP", "JP", 8},
192 {"KR", "KR", 24},
193 {"KW", "KW", 1},
194 {"LI", "LI", 1},
195 {"LT", "LT", 1},
196 {"LU", "LU", 1},
197 {"LV", "LV", 1},
198 {"MA", "MA", 1},
199 {"MT", "MT", 1},
200 {"MX", "MX", 1},
201 {"NL", "NL", 1},
202 {"NO", "NO", 1},
203 {"PL", "PL", 1},
204 {"PT", "PT", 1},
205 {"PY", "PY", 1},
206 {"RO", "RO", 1},
207 {"SE", "SE", 1},
208 {"SI", "SI", 1},
209 {"SK", "SK", 1},
210 {"TR", "TR", 7},
211 {"TW", "TW", 1},
212 {"IR", "XZ", 11}, /* Universal if Country code is IRAN, (ISLAMIC REPUBLIC OF) */
213 {"SD", "XZ", 11}, /* Universal if Country code is SUDAN */
214 {"SY", "XZ", 11}, /* Universal if Country code is SYRIAN ARAB REPUBLIC */
215 {"GL", "XZ", 11}, /* Universal if Country code is GREENLAND */
216 {"PS", "XZ", 11}, /* Universal if Country code is PALESTINIAN TERRITORY, OCCUPIED */
217 {"TL", "XZ", 11}, /* Universal if Country code is TIMOR-LESTE (EAST TIMOR) */
218 {"MH", "XZ", 11}, /* Universal if Country code is MARSHALL ISLANDS */
219};
220
221/* Customized Locale convertor
222* input : ISO 3166-1 country abbreviation
223* output: customized cspec
224*/
225void
226#ifdef CUSTOM_COUNTRY_CODE
227get_customized_country_code(void *adapter, char *country_iso_code,
228 wl_country_t *cspec, u32 flags)
229#else
230get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec)
231#endif /* CUSTOM_COUNTRY_CODE */
232{
233#if (defined(CUSTOMER_HW) || defined(CUSTOMER_HW2)) && (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39))
234
235 struct cntry_locales_custom *cloc_ptr;
236
237 if (!cspec)
238 return;
239#ifdef CUSTOM_COUNTRY_CODE
240 cloc_ptr = wifi_platform_get_country_code(adapter, country_iso_code, flags);
241#else
242 cloc_ptr = wifi_platform_get_country_code(adapter, country_iso_code);
243#endif /* CUSTOM_COUNTRY_CODE */
244
245 if (cloc_ptr) {
246 strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
247 cspec->rev = cloc_ptr->custom_locale_rev;
248 }
249 return;
250#else
251 int size, i;
252
253 size = ARRAYSIZE(translate_custom_table);
254
255 if (cspec == 0)
256 return;
257
258 if (size == 0)
259 return;
260
261 for (i = 0; i < size; i++) {
262 if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
263 memcpy(cspec->ccode,
264 translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
265 cspec->rev = translate_custom_table[i].custom_locale_rev;
266 return;
267 }
268 }
269#ifdef EXAMPLE_TABLE
270 /* if no country code matched return first universal code from translate_custom_table */
271 memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
272 cspec->rev = translate_custom_table[0].custom_locale_rev;
273#endif /* EXMAPLE_TABLE */
274 return;
275#endif /* (defined(CUSTOMER_HW2) || defined(BOARD_HIKEY)) &&
276 * (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36))
277 */
278}