hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux_platdev.c
old mode 100644new mode 100755
....@@ -42,6 +42,9 @@
4242 #else
4343 #include <dhd_plat.h>
4444 #endif /* CONFIG_WIFI_CONTROL_FUNC */
45
+#ifdef BCMDBUS
46
+#include <dbus.h>
47
+#endif
4548 #ifdef CONFIG_DTS
4649 #include<linux/regulator/consumer.h>
4750 #include<linux/of_gpio.h>
....@@ -167,7 +170,7 @@
167170 return NULL;
168171 plat_data = adapter->wifi_plat_data;
169172 if (plat_data->mem_prealloc) {
170
-#if defined(BCMDHD_MDRIVER) && !defined(DHD_STATIC_IN_DRIVER)
173
+#ifdef BCMDHD_MDRIVER
171174 alloc_ptr = plat_data->mem_prealloc(adapter->bus_type, adapter->index, section, size);
172175 #else
173176 alloc_ptr = plat_data->mem_prealloc(section, size);
....@@ -566,7 +569,16 @@
566569 return -ENOMEM;
567570 }
568571 adapter->name = "DHD generic adapter";
572
+ adapter->index = -1;
573
+#if defined(BCMDHD_MDRIVER) && !defined(DHD_STATIC_IN_DRIVER)
574
+#ifdef BCMSDIO
569575 adapter->index = 0;
576
+#elif defined(BCMPCIE)
577
+ adapter->index = 1;
578
+#elif defined(BCMDBUS)
579
+ adapter->index = 2;
580
+#endif
581
+#endif
570582 adapter->bus_type = -1;
571583 adapter->bus_num = -1;
572584 adapter->slot_num = -1;
....@@ -759,11 +771,10 @@
759771 err = dhd_bus_register();
760772 } else {
761773 #ifdef DHD_SUPPORT_HDM
762
- if (dhd_download_fw_on_driverload || hdm_trigger_init)
774
+ if (dhd_download_fw_on_driverload || hdm_trigger_init) {
763775 #else
764
- if (dhd_download_fw_on_driverload)
776
+ if (dhd_download_fw_on_driverload) {
765777 #endif /* DHD_SUPPORT_HDM */
766
- {
767778 /* power up all adapters */
768779 for (i = 0; i < dhd_wifi_platdata->num_adapters; i++) {
769780 int retry = POWERUP_MAX_RETRY;
....@@ -885,9 +896,7 @@
885896 for (i = 0; i < dhd_wifi_platdata->num_adapters; i++) {
886897 bool chip_up = FALSE;
887898 int retry = POWERUP_MAX_RETRY;
888
-#ifndef DHD_INSMOD_NOWAIT
889899 struct semaphore dhd_chipup_sem;
890
-#endif
891900
892901 adapter = &dhd_wifi_platdata->adapters[i];
893902
....@@ -898,18 +907,6 @@
898907 adapter->bus_type, adapter->bus_num, adapter->slot_num));
899908
900909 do {
901
-#ifdef DHD_INSMOD_NOWAIT
902
- err = wifi_platform_set_power(adapter, TRUE, WIFI_TURNON_DELAY);
903
- if (err) {
904
- DHD_ERROR(("%s: wifi pwr on error ! \n", __FUNCTION__));
905
- wifi_platform_set_power(adapter, FALSE, WIFI_TURNOFF_DELAY);
906
- continue;
907
- } else {
908
- wifi_platform_bus_enumerate(adapter, TRUE);
909
- chip_up = TRUE;
910
- break;
911
- }
912
-#else
913910 sema_init(&dhd_chipup_sem, 0);
914911 err = dhd_bus_reg_sdio_notify(&dhd_chipup_sem);
915912 if (err) {
....@@ -938,7 +935,6 @@
938935 dhd_bus_unreg_sdio_notify();
939936 wifi_platform_set_power(adapter, FALSE, WIFI_TURNOFF_DELAY);
940937 wifi_platform_bus_enumerate(adapter, FALSE);
941
-#endif
942938 } while (retry--);
943939
944940 if (!chip_up) {
....@@ -955,7 +951,6 @@
955951 goto fail;
956952 }
957953
958
-#ifndef DHD_INSMOD_NOWAIT
959954 /*
960955 * Wait till MMC sdio_register_driver callback called and made driver attach.
961956 * It's needed to make sync up exit from dhd insmod and
....@@ -967,7 +962,6 @@
967962 dhd_bus_unregister();
968963 goto fail;
969964 }
970
-#endif
971965
972966 return err;
973967
....@@ -1000,6 +994,7 @@
1000994 wifi_adapter_info_t *adapter;
1001995 s32 timeout = -1;
1002996 int i;
997
+ enum wifi_adapter_status wait_status;
1003998 #endif
1004999
10051000 #if !defined(DHD_PRELOAD)
....@@ -1008,7 +1003,7 @@
10081003 adapter = &dhd_wifi_platdata->adapters[i];
10091004 wifi_platform_set_power(adapter, FALSE, 0);
10101005 if (err) {
1011
- DHD_ERROR(("failed to wifi_platform_set_power off %s\n", adapter->name));
1006
+ DHD_ERROR(("failed to wifi_platform_set_power on %s\n", adapter->name));
10121007 goto exit;
10131008 }
10141009 }
....@@ -1035,8 +1030,12 @@
10351030 DHD_ERROR(("failed to wifi_platform_set_power on %s\n", adapter->name));
10361031 goto fail;
10371032 }
1033
+ if (dhd_download_fw_on_driverload)
1034
+ wait_status = WIFI_STATUS_ATTACH;
1035
+ else
1036
+ wait_status = WIFI_STATUS_DETTACH;
10381037 timeout = wait_event_interruptible_timeout(adapter->status_event,
1039
- wifi_get_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED),
1038
+ wifi_get_adapter_status(adapter, wait_status),
10401039 msecs_to_jiffies(DHD_REGISTRATION_TIMEOUT));
10411040 if (timeout <= 0) {
10421041 err = -1;
....@@ -1068,7 +1067,7 @@
10681067 }
10691068 #endif /* BCMDBUS */
10701069
1071
-static int dhd_wifi_platform_load()
1070
+static int dhd_wifi_platform_load(void)
10721071 {
10731072 int err = 0;
10741073 printf("%s: Enter\n", __FUNCTION__);