old mode 100644new mode 100755.. | .. |
---|
1 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | | - |
---|
3 | 2 | #include <osl.h> |
---|
4 | 3 | #include <dhd_linux.h> |
---|
5 | 4 | #include <linux/gpio.h> |
---|
6 | | -#ifdef BCMDHD_DTS |
---|
7 | | -#include <linux/of_gpio.h> |
---|
8 | | -#endif |
---|
9 | | -#ifdef BCMDHD_PLATDEV |
---|
10 | | -#include <linux/platform_device.h> |
---|
11 | | -#endif |
---|
12 | 5 | #ifdef CUSTOMER_HW_ROCKCHIP |
---|
13 | 6 | #include <linux/rfkill-wlan.h> |
---|
14 | 7 | #endif |
---|
.. | .. |
---|
25 | 18 | extern int dhd_static_buf_init(void); |
---|
26 | 19 | extern void dhd_static_buf_exit(void); |
---|
27 | 20 | #endif /* DHD_STATIC_IN_DRIVER */ |
---|
28 | | -#if defined(BCMDHD_MDRIVER) && !defined(DHD_STATIC_IN_DRIVER) |
---|
| 21 | +#ifdef BCMDHD_MDRIVER |
---|
29 | 22 | extern void *dhd_wlan_mem_prealloc(uint bus_type, int index, |
---|
30 | 23 | int section, unsigned long size); |
---|
31 | 24 | #else |
---|
.. | .. |
---|
40 | 33 | |
---|
41 | 34 | #ifdef BCMDHD_DTS |
---|
42 | 35 | /* This is sample code in dts file. |
---|
43 | | -bcmdhd_wlan { |
---|
| 36 | +bcmdhd { |
---|
44 | 37 | compatible = "android,bcmdhd_wlan"; |
---|
45 | 38 | gpio_wl_reg_on = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>; |
---|
46 | 39 | gpio_wl_host_wake = <&gpio GPIOZ_15 GPIO_ACTIVE_HIGH>; |
---|
.. | .. |
---|
69 | 62 | #ifdef CUSTOMER_HW_ROCKCHIP |
---|
70 | 63 | rockchip_wifi_power(1); |
---|
71 | 64 | #ifdef BCMPCIE |
---|
72 | | -// rk_pcie_power_on_atu_fixup(); |
---|
| 65 | + //rk_pcie_power_on_atu_fixup(); |
---|
73 | 66 | #endif |
---|
74 | 67 | #endif |
---|
75 | 68 | #ifdef BUS_POWER_RESTORE |
---|
.. | .. |
---|
134 | 127 | return err; |
---|
135 | 128 | } |
---|
136 | 129 | |
---|
137 | | -static int |
---|
138 | | -dhd_wlan_set_reset(int onoff) |
---|
| 130 | +static int dhd_wlan_set_reset(int onoff) |
---|
139 | 131 | { |
---|
140 | 132 | return 0; |
---|
141 | 133 | } |
---|
142 | 134 | |
---|
143 | | -static int |
---|
144 | | -dhd_wlan_set_carddetect(int present) |
---|
| 135 | +static int dhd_wlan_set_carddetect(int present) |
---|
145 | 136 | { |
---|
146 | 137 | int err = 0; |
---|
147 | 138 | |
---|
.. | .. |
---|
165 | 156 | err = sdhci_force_presence_change(&sdmmc_channel, 0); |
---|
166 | 157 | #endif /* CUSTOMER_HW_PLATFORM */ |
---|
167 | 158 | #ifdef CUSTOMER_HW_ROCKCHIP |
---|
168 | | - rockchip_wifi_set_carddetect(0); |
---|
| 159 | + rockchip_wifi_set_carddetect(0); |
---|
169 | 160 | #endif |
---|
170 | 161 | #elif defined(BCMPCIE) |
---|
171 | 162 | printf("======== Card detection to remove PCIE card! ========\n"); |
---|
.. | .. |
---|
176 | 167 | return err; |
---|
177 | 168 | } |
---|
178 | 169 | |
---|
179 | | -static int |
---|
180 | | -dhd_wlan_get_mac_addr(unsigned char *buf, int ifidx) |
---|
| 170 | +static int dhd_wlan_get_mac_addr(unsigned char *buf, int ifidx) |
---|
181 | 171 | { |
---|
182 | 172 | int err = 0; |
---|
183 | 173 | |
---|
.. | .. |
---|
275 | 265 | .get_country_code = dhd_wlan_get_country_code, |
---|
276 | 266 | }; |
---|
277 | 267 | |
---|
278 | | -static int |
---|
279 | | -dhd_wlan_init_gpio(wifi_adapter_info_t *adapter) |
---|
| 268 | +int dhd_wlan_init_gpio(wifi_adapter_info_t *adapter) |
---|
280 | 269 | { |
---|
281 | 270 | #ifdef BCMDHD_DTS |
---|
282 | 271 | char wlan_node[32]; |
---|
283 | 272 | struct device_node *root_node = NULL; |
---|
284 | 273 | #endif |
---|
285 | 274 | int err = 0; |
---|
286 | | - int gpio_wl_reg_on = -1; |
---|
| 275 | + int gpio_wl_reg_on; |
---|
287 | 276 | #ifdef CUSTOMER_OOB |
---|
288 | | - int gpio_wl_host_wake = -1; |
---|
| 277 | + int gpio_wl_host_wake; |
---|
289 | 278 | int host_oob_irq = -1; |
---|
290 | 279 | uint host_oob_irq_flags = 0; |
---|
291 | 280 | #ifdef CUSTOMER_HW_ROCKCHIP |
---|
.. | .. |
---|
299 | 288 | * WL_REG_ON and WL_HOST_WAKE. |
---|
300 | 289 | */ |
---|
301 | 290 | #ifdef BCMDHD_DTS |
---|
302 | | -#ifdef BCMDHD_PLATDEV |
---|
303 | | - if (adapter->pdev) { |
---|
304 | | - root_node = adapter->pdev->dev.of_node; |
---|
305 | | - strcpy(wlan_node, root_node->name); |
---|
306 | | - } else { |
---|
307 | | - printf("%s: adapter->pdev is NULL\n", __FUNCTION__); |
---|
308 | | - return -1; |
---|
309 | | - } |
---|
310 | | -#else |
---|
311 | 291 | strcpy(wlan_node, DHD_DT_COMPAT_ENTRY); |
---|
312 | | - root_node = of_find_compatible_node(NULL, NULL, wlan_node); |
---|
313 | | -#endif |
---|
314 | 292 | printf("======== Get GPIO from DTS(%s) ========\n", wlan_node); |
---|
| 293 | + root_node = of_find_compatible_node(NULL, NULL, wlan_node); |
---|
315 | 294 | if (root_node) { |
---|
316 | 295 | gpio_wl_reg_on = of_get_named_gpio(root_node, GPIO_WL_REG_ON_PROPNAME, 0); |
---|
317 | 296 | #ifdef CUSTOMER_OOB |
---|
.. | .. |
---|
329 | 308 | if (gpio_wl_reg_on >= 0) { |
---|
330 | 309 | err = gpio_request(gpio_wl_reg_on, "WL_REG_ON"); |
---|
331 | 310 | if (err < 0) { |
---|
332 | | - printf("%s: gpio_request(%d) for WL_REG_ON failed %d\n", |
---|
333 | | - __FUNCTION__, gpio_wl_reg_on, err); |
---|
| 311 | + printf("%s: gpio_request(%d) for WL_REG_ON failed\n", |
---|
| 312 | + __FUNCTION__, gpio_wl_reg_on); |
---|
334 | 313 | gpio_wl_reg_on = -1; |
---|
335 | 314 | } |
---|
336 | 315 | } |
---|
.. | .. |
---|
340 | 319 | if (gpio_wl_host_wake >= 0) { |
---|
341 | 320 | err = gpio_request(gpio_wl_host_wake, "bcmdhd"); |
---|
342 | 321 | if (err < 0) { |
---|
343 | | - printf("%s: gpio_request(%d) for WL_HOST_WAKE failed %d\n", |
---|
344 | | - __FUNCTION__, gpio_wl_host_wake, err); |
---|
| 322 | + printf("%s: gpio_request(%d) for WL_HOST_WAKE failed\n", |
---|
| 323 | + __FUNCTION__, gpio_wl_host_wake); |
---|
345 | 324 | return -1; |
---|
346 | 325 | } |
---|
347 | 326 | adapter->gpio_wl_host_wake = gpio_wl_host_wake; |
---|
348 | 327 | err = gpio_direction_input(gpio_wl_host_wake); |
---|
349 | 328 | if (err < 0) { |
---|
350 | | - printf("%s: gpio_direction_input(%d) for WL_HOST_WAKE failed %d\n", |
---|
351 | | - __FUNCTION__, gpio_wl_host_wake, err); |
---|
| 329 | + printf("%s: gpio_direction_input(%d) for WL_HOST_WAKE failed\n", |
---|
| 330 | + __FUNCTION__, gpio_wl_host_wake); |
---|
352 | 331 | gpio_free(gpio_wl_host_wake); |
---|
353 | 332 | return -1; |
---|
354 | 333 | } |
---|
355 | 334 | host_oob_irq = gpio_to_irq(gpio_wl_host_wake); |
---|
356 | 335 | if (host_oob_irq < 0) { |
---|
357 | | - printf("%s: gpio_to_irq(%d) for WL_HOST_WAKE failed %d\n", |
---|
358 | | - __FUNCTION__, gpio_wl_host_wake, host_oob_irq); |
---|
| 336 | + printf("%s: gpio_to_irq(%d) for WL_HOST_WAKE failed\n", |
---|
| 337 | + __FUNCTION__, gpio_wl_host_wake); |
---|
359 | 338 | gpio_free(gpio_wl_host_wake); |
---|
360 | 339 | return -1; |
---|
361 | 340 | } |
---|
.. | .. |
---|
395 | 374 | return 0; |
---|
396 | 375 | } |
---|
397 | 376 | |
---|
398 | | -static void |
---|
399 | | -dhd_wlan_deinit_gpio(wifi_adapter_info_t *adapter) |
---|
| 377 | +static void dhd_wlan_deinit_gpio(wifi_adapter_info_t *adapter) |
---|
400 | 378 | { |
---|
401 | 379 | int gpio_wl_reg_on = adapter->gpio_wl_reg_on; |
---|
402 | 380 | #ifdef CUSTOMER_OOB |
---|
.. | .. |
---|
417 | 395 | #endif /* CUSTOMER_OOB */ |
---|
418 | 396 | } |
---|
419 | 397 | |
---|
420 | | -#if defined(BCMDHD_MDRIVER) |
---|
421 | | -static void |
---|
422 | | -dhd_wlan_init_adapter(wifi_adapter_info_t *adapter) |
---|
423 | | -{ |
---|
424 | | -#ifdef ADAPTER_IDX |
---|
425 | | - if (ADAPTER_IDX == 0) { |
---|
426 | | - adapter->bus_num = 1; |
---|
427 | | - adapter->slot_num = 1; |
---|
428 | | - } else if (ADAPTER_IDX == 1) { |
---|
429 | | - adapter->bus_num = 2; |
---|
430 | | - adapter->slot_num = 1; |
---|
431 | | - } |
---|
432 | | - adapter->index = ADAPTER_IDX; |
---|
433 | | -#ifdef BCMSDIO |
---|
434 | | - adapter->bus_type = SDIO_BUS; |
---|
435 | | -#elif defined(BCMPCIE) |
---|
436 | | - adapter->bus_type = PCI_BUS; |
---|
437 | | -#elif defined(BCMDBUS) |
---|
438 | | - adapter->bus_type = USB_BUS; |
---|
439 | | -#endif |
---|
440 | | - printf("bus_type=%d, bus_num=%d, slot_num=%d\n", |
---|
441 | | - adapter->bus_type, adapter->bus_num, adapter->slot_num); |
---|
442 | | -#endif /* ADAPTER_IDX */ |
---|
443 | | - |
---|
444 | | -#ifdef DHD_STATIC_IN_DRIVER |
---|
445 | | - adapter->index = 0; |
---|
446 | | -#elif !defined(ADAPTER_IDX) |
---|
447 | | -#ifdef BCMSDIO |
---|
448 | | - adapter->index = 0; |
---|
449 | | -#elif defined(BCMPCIE) |
---|
450 | | - adapter->index = 1; |
---|
451 | | -#elif defined(BCMDBUS) |
---|
452 | | - adapter->index = 2; |
---|
453 | | -#endif |
---|
454 | | -#endif /* DHD_STATIC_IN_DRIVER */ |
---|
455 | | -} |
---|
456 | | -#endif /* BCMDHD_MDRIVER */ |
---|
457 | | - |
---|
458 | | -int |
---|
459 | | -dhd_wlan_init_plat_data(wifi_adapter_info_t *adapter) |
---|
| 398 | +int dhd_wlan_init_plat_data(wifi_adapter_info_t *adapter) |
---|
460 | 399 | { |
---|
461 | 400 | int err = 0; |
---|
462 | 401 | |
---|
463 | | -#ifdef BCMDHD_MDRIVER |
---|
464 | | - dhd_wlan_init_adapter(adapter); |
---|
465 | | -#endif /* BCMDHD_MDRIVER */ |
---|
466 | | - |
---|
| 402 | + printf("======== %s ========\n", __FUNCTION__); |
---|
| 403 | + if (adapter->index == -1) { |
---|
| 404 | + adapter->index = 0; |
---|
| 405 | + } |
---|
467 | 406 | err = dhd_wlan_init_gpio(adapter); |
---|
468 | 407 | if (err) |
---|
469 | 408 | goto exit; |
---|
.. | .. |
---|
476 | 415 | return err; |
---|
477 | 416 | } |
---|
478 | 417 | |
---|
479 | | -void |
---|
480 | | -dhd_wlan_deinit_plat_data(wifi_adapter_info_t *adapter) |
---|
| 418 | +void dhd_wlan_deinit_plat_data(wifi_adapter_info_t *adapter) |
---|
481 | 419 | { |
---|
| 420 | + printf("======== %s ========\n", __FUNCTION__); |
---|
482 | 421 | #ifdef DHD_STATIC_IN_DRIVER |
---|
483 | 422 | dhd_static_buf_exit(); |
---|
484 | 423 | #endif |
---|