hc
2024-05-10 23fa18eaa71266feff7ba8d83022d9e1cc83c65a
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_gpio.c
old mode 100644new mode 100755
....@@ -1,14 +1,7 @@
11 /* SPDX-License-Identifier: GPL-2.0 */
2
-
32 #include <osl.h>
43 #include <dhd_linux.h>
54 #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
125 #ifdef CUSTOMER_HW_ROCKCHIP
136 #include <linux/rfkill-wlan.h>
147 #endif
....@@ -25,7 +18,7 @@
2518 extern int dhd_static_buf_init(void);
2619 extern void dhd_static_buf_exit(void);
2720 #endif /* DHD_STATIC_IN_DRIVER */
28
-#if defined(BCMDHD_MDRIVER) && !defined(DHD_STATIC_IN_DRIVER)
21
+#ifdef BCMDHD_MDRIVER
2922 extern void *dhd_wlan_mem_prealloc(uint bus_type, int index,
3023 int section, unsigned long size);
3124 #else
....@@ -40,7 +33,7 @@
4033
4134 #ifdef BCMDHD_DTS
4235 /* This is sample code in dts file.
43
-bcmdhd_wlan {
36
+bcmdhd {
4437 compatible = "android,bcmdhd_wlan";
4538 gpio_wl_reg_on = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>;
4639 gpio_wl_host_wake = <&gpio GPIOZ_15 GPIO_ACTIVE_HIGH>;
....@@ -69,7 +62,7 @@
6962 #ifdef CUSTOMER_HW_ROCKCHIP
7063 rockchip_wifi_power(1);
7164 #ifdef BCMPCIE
72
-// rk_pcie_power_on_atu_fixup();
65
+ //rk_pcie_power_on_atu_fixup();
7366 #endif
7467 #endif
7568 #ifdef BUS_POWER_RESTORE
....@@ -134,14 +127,12 @@
134127 return err;
135128 }
136129
137
-static int
138
-dhd_wlan_set_reset(int onoff)
130
+static int dhd_wlan_set_reset(int onoff)
139131 {
140132 return 0;
141133 }
142134
143
-static int
144
-dhd_wlan_set_carddetect(int present)
135
+static int dhd_wlan_set_carddetect(int present)
145136 {
146137 int err = 0;
147138
....@@ -165,7 +156,7 @@
165156 err = sdhci_force_presence_change(&sdmmc_channel, 0);
166157 #endif /* CUSTOMER_HW_PLATFORM */
167158 #ifdef CUSTOMER_HW_ROCKCHIP
168
- rockchip_wifi_set_carddetect(0);
159
+ rockchip_wifi_set_carddetect(0);
169160 #endif
170161 #elif defined(BCMPCIE)
171162 printf("======== Card detection to remove PCIE card! ========\n");
....@@ -176,8 +167,7 @@
176167 return err;
177168 }
178169
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)
181171 {
182172 int err = 0;
183173
....@@ -275,17 +265,16 @@
275265 .get_country_code = dhd_wlan_get_country_code,
276266 };
277267
278
-static int
279
-dhd_wlan_init_gpio(wifi_adapter_info_t *adapter)
268
+int dhd_wlan_init_gpio(wifi_adapter_info_t *adapter)
280269 {
281270 #ifdef BCMDHD_DTS
282271 char wlan_node[32];
283272 struct device_node *root_node = NULL;
284273 #endif
285274 int err = 0;
286
- int gpio_wl_reg_on = -1;
275
+ int gpio_wl_reg_on;
287276 #ifdef CUSTOMER_OOB
288
- int gpio_wl_host_wake = -1;
277
+ int gpio_wl_host_wake;
289278 int host_oob_irq = -1;
290279 uint host_oob_irq_flags = 0;
291280 #ifdef CUSTOMER_HW_ROCKCHIP
....@@ -299,19 +288,9 @@
299288 * WL_REG_ON and WL_HOST_WAKE.
300289 */
301290 #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
311291 strcpy(wlan_node, DHD_DT_COMPAT_ENTRY);
312
- root_node = of_find_compatible_node(NULL, NULL, wlan_node);
313
-#endif
314292 printf("======== Get GPIO from DTS(%s) ========\n", wlan_node);
293
+ root_node = of_find_compatible_node(NULL, NULL, wlan_node);
315294 if (root_node) {
316295 gpio_wl_reg_on = of_get_named_gpio(root_node, GPIO_WL_REG_ON_PROPNAME, 0);
317296 #ifdef CUSTOMER_OOB
....@@ -329,8 +308,8 @@
329308 if (gpio_wl_reg_on >= 0) {
330309 err = gpio_request(gpio_wl_reg_on, "WL_REG_ON");
331310 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);
334313 gpio_wl_reg_on = -1;
335314 }
336315 }
....@@ -340,22 +319,22 @@
340319 if (gpio_wl_host_wake >= 0) {
341320 err = gpio_request(gpio_wl_host_wake, "bcmdhd");
342321 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);
345324 return -1;
346325 }
347326 adapter->gpio_wl_host_wake = gpio_wl_host_wake;
348327 err = gpio_direction_input(gpio_wl_host_wake);
349328 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);
352331 gpio_free(gpio_wl_host_wake);
353332 return -1;
354333 }
355334 host_oob_irq = gpio_to_irq(gpio_wl_host_wake);
356335 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);
359338 gpio_free(gpio_wl_host_wake);
360339 return -1;
361340 }
....@@ -395,8 +374,7 @@
395374 return 0;
396375 }
397376
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)
400378 {
401379 int gpio_wl_reg_on = adapter->gpio_wl_reg_on;
402380 #ifdef CUSTOMER_OOB
....@@ -417,53 +395,14 @@
417395 #endif /* CUSTOMER_OOB */
418396 }
419397
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)
460399 {
461400 int err = 0;
462401
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
+ }
467406 err = dhd_wlan_init_gpio(adapter);
468407 if (err)
469408 goto exit;
....@@ -476,9 +415,9 @@
476415 return err;
477416 }
478417
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)
481419 {
420
+ printf("======== %s ========\n", __FUNCTION__);
482421 #ifdef DHD_STATIC_IN_DRIVER
483422 dhd_static_buf_exit();
484423 #endif