forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dbus.c
old mode 100644new mode 100755
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0 */
12 /** @file dbus.c
23 *
34 * Hides details of USB / SDIO / SPI interfaces and OS details. It is intended to shield details and
....@@ -42,12 +43,7 @@
4243 #include <dhd_wlfc.h>
4344 #endif
4445 #include <dhd_config.h>
45
-#ifdef WL_CFG80211
46
-#include <wl_cfg80211.h>
47
-#include <wl_cfgp2p.h>
48
-#endif
4946
50
-#include <bcmdevs_legacy.h>
5147 #if defined(BCM_REQUEST_FW)
5248 #include <bcmsrom_fmt.h>
5349 #include <trxhdr.h>
....@@ -99,7 +95,7 @@
9995 bool txoverride; /* flow control related */
10096 bool rxoff;
10197 bool tx_timer_ticking;
102
- uint ctl_completed;
98
+
10399
104100 dbus_irbq_t *rx_q;
105101 dbus_irbq_t *tx_q;
....@@ -119,7 +115,6 @@
119115 #endif
120116 char *fw_path; /* module_param: path to firmware image */
121117 char *nv_path; /* module_param: path to nvram vars file */
122
- uint64 last_suspend_end_time;
123118 } dhd_bus_t;
124119
125120 struct exec_parms {
....@@ -158,11 +153,10 @@
158153 static struct dbus_irb *dbus_if_getirb(void *cbarg, bool send);
159154 static void dbus_if_rxerr_indicate(void *handle, bool on);
160155
161
-static int dbus_suspend(void *context);
162
-static int dbus_resume(void *context);
163
-static void * dhd_dbus_probe_cb(uint16 bus_no, uint16 slot, uint32 hdrlen);
164
-static void dhd_dbus_disconnect_cb(void *arg);
165
-static void dbus_detach(dhd_bus_t *pub);
156
+void * dhd_dbus_probe_cb(void *arg, const char *desc, uint32 bustype,
157
+ uint16 bus_no, uint16 slot, uint32 hdrlen);
158
+void dhd_dbus_disconnect_cb(void *arg);
159
+void dbus_detach(dhd_bus_t *pub);
166160
167161 /** functions in this file that are called by lower DBUS levels, e.g. dbus_usb.c */
168162 static dbus_intf_callbacks_t dbus_intf_cbs = {
....@@ -187,6 +181,10 @@
187181 * can be called inside disconnect()
188182 */
189183 static dbus_intf_t *g_busintf = NULL;
184
+static probe_cb_t probe_cb = NULL;
185
+static disconnect_cb_t disconnect_cb = NULL;
186
+static void *probe_arg = NULL;
187
+static void *disc_arg = NULL;
190188
191189 #if defined(BCM_REQUEST_FW)
192190 int8 *nonfwnvram = NULL; /* stand-alone multi-nvram given with driver load */
....@@ -204,6 +202,9 @@
204202 static int dbus_irbq_deinit(dhd_bus_t *dhd_bus, dbus_irbq_t *q, int size_irb);
205203 static int dbus_rxirbs_fill(dhd_bus_t *dhd_bus);
206204 static int dbus_send_irb(dbus_pub_t *pub, uint8 *buf, int len, void *pkt, void *info);
205
+static void dbus_disconnect(void *handle);
206
+static void *dbus_probe(void *arg, const char *desc, uint32 bustype,
207
+ uint16 bus_no, uint16 slot, uint32 hdrlen);
207208
208209 #if defined(BCM_REQUEST_FW)
209210 extern char * dngl_firmware;
....@@ -602,7 +603,7 @@
602603
603604 #ifdef EXTERNAL_FW_PATH
604605 static int
605
-dbus_get_fw_nvram(dhd_bus_t *dhd_bus)
606
+dbus_get_fw_nvram(dhd_bus_t *dhd_bus, char *pfw_path, char *pnv_path)
606607 {
607608 int bcmerror = -1, i;
608609 uint len, total_len;
....@@ -617,8 +618,6 @@
617618 struct trx_header *hdr;
618619 uint32 img_offset = 0;
619620 int offset = 0;
620
- char *pfw_path = dhd_bus->fw_path;
621
- char *pnv_path = dhd_bus->nv_path;
622621
623622 /* For Get nvram */
624623 file_exists = ((pnv_path != NULL) && (pnv_path[0] != '\0'));
....@@ -751,11 +750,11 @@
751750 * the dongle
752751 */
753752 static int
754
-dbus_do_download(dhd_bus_t *dhd_bus)
753
+dbus_do_download(dhd_bus_t *dhd_bus, char *pfw_path, char *pnv_path)
755754 {
756755 int err = DBUS_OK;
757756
758
- err = dbus_get_fw_nvram(dhd_bus);
757
+ err = dbus_get_fw_nvram(dhd_bus, pfw_path, pnv_path);
759758 if (err) {
760759 DBUSERR(("dbus_do_download: fail to get nvram %d\n", err));
761760 return err;
....@@ -863,12 +862,7 @@
863862 nvram_words_pad = 4 - dhd_bus->nvram_len % 4;
864863
865864 len = actual_fwlen + dhd_bus->nvram_len + nvram_words_pad;
866
-#if defined(CONFIG_DHD_USE_STATIC_BUF)
867
- dhd_bus->image = (uint8*)DHD_OS_PREALLOC(dhd_bus->dhd,
868
- DHD_PREALLOC_MEMDUMP_RAM, len);
869
-#else
870865 dhd_bus->image = MALLOC(dhd_bus->pub.osh, len);
871
-#endif /* CONFIG_DHD_USE_STATIC_BUF */
872866 dhd_bus->image_len = len;
873867 if (dhd_bus->image == NULL) {
874868 DBUSERR(("%s: malloc failed!\n", __FUNCTION__));
....@@ -947,7 +941,7 @@
947941 #if defined(BCM_REQUEST_FW)
948942 dhd_bus->firmware = dbus_get_fw_nvfile(dhd_bus->pub.attrib.devid,
949943 dhd_bus->pub.attrib.chiprev, &dhd_bus->fw, &dhd_bus->fwlen,
950
- DBUS_FIRMWARE, 0, 0, dhd_bus->fw_path);
944
+ DBUS_FIRMWARE, 0, 0);
951945 if (!dhd_bus->firmware)
952946 return DBUS_ERR;
953947 #endif
....@@ -973,7 +967,7 @@
973967 nonfwnvramlen = 0;
974968 dhd_bus->nvfile = dbus_get_fw_nvfile(dhd_bus->pub.attrib.devid,
975969 dhd_bus->pub.attrib.chiprev, (void *)&temp_nvram, &temp_len,
976
- DBUS_NVFILE, boardtype, boardrev, dhd_bus->nv_path);
970
+ DBUS_NVFILE, boardtype, boardrev);
977971 if (dhd_bus->nvfile) {
978972 int8 *tmp = MALLOC(dhd_bus->pub.osh, temp_len);
979973 if (tmp) {
....@@ -1004,11 +998,7 @@
1004998 err = DBUS_ERR;
1005999
10061000 if (dhd_bus->nvram) {
1007
-#if defined(CONFIG_DHD_USE_STATIC_BUF)
1008
- DHD_OS_PREFREE(dhd_bus->dhd, dhd_bus->image, dhd_bus->image_len);
1009
-#else
10101001 MFREE(dhd_bus->pub.osh, dhd_bus->image, dhd_bus->image_len);
1011
-#endif /* CONFIG_DHD_USE_STATIC_BUF */
10121002 dhd_bus->image = dhd_bus->fw;
10131003 dhd_bus->image_len = (uint32)dhd_bus->fwlen;
10141004 }
....@@ -1041,6 +1031,16 @@
10411031 } /* dbus_do_download */
10421032 #endif /* EXTERNAL_FW_PATH */
10431033 #endif
1034
+
1035
+/** required for DBUS deregistration */
1036
+static void
1037
+dbus_disconnect(void *handle)
1038
+{
1039
+ DBUSTRACE(("%s\n", __FUNCTION__));
1040
+
1041
+ if (disconnect_cb)
1042
+ disconnect_cb(disc_arg);
1043
+}
10441044
10451045 /**
10461046 * This function is called when the sent irb times out without a tx response status.
....@@ -1373,17 +1373,22 @@
13731373 return irb;
13741374 }
13751375
1376
-/* Register/Unregister functions are called by the main DHD entry
1377
- * point (e.g. module insertion) to link with the bus driver, in
1378
- * order to look for or await the device.
1376
+/**
1377
+ * Called as part of DBUS bus registration. Calls back into higher level (e.g. dhd_linux.c) probe
1378
+ * function.
13791379 */
1380
+static void *
1381
+dbus_probe(void *arg, const char *desc, uint32 bustype, uint16 bus_no,
1382
+ uint16 slot, uint32 hdrlen)
1383
+{
1384
+ DBUSTRACE(("%s\n", __FUNCTION__));
1385
+ if (probe_cb) {
1386
+ disc_arg = probe_cb(probe_arg, desc, bustype, bus_no, slot, hdrlen);
1387
+ return disc_arg;
1388
+ }
13801389
1381
-static dbus_driver_t dhd_dbus = {
1382
- dhd_dbus_probe_cb,
1383
- dhd_dbus_disconnect_cb,
1384
- dbus_suspend,
1385
- dbus_resume
1386
-};
1390
+ return (void *)DBUS_ERR;
1391
+}
13871392
13881393 /**
13891394 * As part of initialization, higher level (e.g. dhd_linux.c) requests DBUS to prepare for
....@@ -1396,7 +1401,12 @@
13961401
13971402 DBUSTRACE(("%s: Enter\n", __FUNCTION__));
13981403
1399
- err = dbus_bus_register(&dhd_dbus, &g_busintf);
1404
+ probe_cb = dhd_dbus_probe_cb;
1405
+ disconnect_cb = dhd_dbus_disconnect_cb;
1406
+ probe_arg = NULL;
1407
+
1408
+ err = dbus_bus_register(0xa5c, 0x48f, dbus_probe, /* call lower DBUS level register function */
1409
+ dbus_disconnect, NULL, &g_busintf, NULL, NULL);
14001410
14011411 /* Device not detected */
14021412 if (err == DBUS_ERR_NODEVICE)
....@@ -1406,10 +1416,11 @@
14061416 }
14071417
14081418 dhd_pub_t *g_pub = NULL;
1409
-bool net_attached = FALSE;
14101419 void
14111420 dhd_bus_unregister(void)
14121421 {
1422
+ int ret;
1423
+
14131424 DBUSTRACE(("%s\n", __FUNCTION__));
14141425
14151426 DHD_MUTEX_LOCK();
....@@ -1419,8 +1430,11 @@
14191430 dhd_dbus_disconnect_cb(g_pub->bus);
14201431 }
14211432 }
1433
+ probe_cb = NULL;
14221434 DHD_MUTEX_UNLOCK();
1423
- dbus_bus_deregister();
1435
+ ret = dbus_bus_deregister();
1436
+ disconnect_cb = NULL;
1437
+ probe_arg = NULL;
14241438 }
14251439
14261440 /** As part of initialization, data structures have to be allocated and initialized */
....@@ -1586,7 +1600,7 @@
15861600 }
15871601
15881602 #if defined(BCM_REQUEST_FW)
1589
-int dbus_download_firmware(dhd_bus_t *pub)
1603
+int dbus_download_firmware(dhd_bus_t *pub, char *pfw_path, char *pnv_path)
15901604 {
15911605 dhd_bus_t *dhd_bus = (dhd_bus_t *) pub;
15921606 int err = DBUS_OK;
....@@ -1599,7 +1613,11 @@
15991613 DBUSTRACE(("%s: state %d\n", __FUNCTION__, dhd_bus->pub.busstate));
16001614
16011615 dhd_bus->pub.busstate = DBUS_STATE_DL_PENDING;
1616
+#ifdef EXTERNAL_FW_PATH
1617
+ err = dbus_do_download(dhd_bus, pfw_path, pnv_path);
1618
+#else
16021619 err = dbus_do_download(dhd_bus);
1620
+#endif /* EXTERNAL_FW_PATH */
16031621 if (err == DBUS_OK) {
16041622 dhd_bus->pub.busstate = DBUS_STATE_DL_DONE;
16051623 } else {
....@@ -1700,19 +1718,24 @@
17001718 return DBUS_ERR;
17011719 }
17021720
1721
+int dbus_send_txdata(dbus_pub_t *dbus, void *pktbuf)
1722
+{
1723
+ return dbus_send_pkt(dbus, pktbuf, pktbuf /* pktinfo */);
1724
+}
1725
+
17031726 int
17041727 dbus_send_buf(dbus_pub_t *pub, uint8 *buf, int len, void *info)
17051728 {
17061729 return dbus_send_irb(pub, buf, len, NULL, info);
17071730 }
17081731
1709
-static int
1732
+int
17101733 dbus_send_pkt(dbus_pub_t *pub, void *pkt, void *info)
17111734 {
17121735 return dbus_send_irb(pub, NULL, 0, pkt, info);
17131736 }
17141737
1715
-static int
1738
+int
17161739 dbus_send_ctl(struct dhd_bus *pub, uint8 *buf, int len)
17171740 {
17181741 dhd_bus_t *dhd_bus = (dhd_bus_t *) pub;
....@@ -1733,7 +1756,7 @@
17331756 return DBUS_ERR;
17341757 }
17351758
1736
-static int
1759
+int
17371760 dbus_recv_ctl(struct dhd_bus *pub, uint8 *buf, int len)
17381761 {
17391762 dhd_bus_t *dhd_bus = (dhd_bus_t *) pub;
....@@ -1745,8 +1768,6 @@
17451768 dhd_bus->pub.busstate == DBUS_STATE_SLEEP) {
17461769 if (dhd_bus->drvintf && dhd_bus->drvintf->recv_ctl)
17471770 return dhd_bus->drvintf->recv_ctl(dhd_bus->bus_info, buf, len);
1748
- } else {
1749
- DBUSERR(("%s: bustate=%d\n", __FUNCTION__, dhd_bus->pub.busstate));
17501771 }
17511772
17521773 return DBUS_ERR;
....@@ -1785,9 +1806,8 @@
17851806 return DBUS_ERR;
17861807 }
17871808
1788
-#ifdef INTR_EP_ENABLE
17891809 /** only called by dhd_cdc.c (Dec 2012) */
1790
-static int
1810
+int
17911811 dbus_poll_intr(dbus_pub_t *pub)
17921812 {
17931813 dhd_bus_t *dhd_bus = (dhd_bus_t *) pub;
....@@ -1805,7 +1825,6 @@
18051825 }
18061826 return status;
18071827 }
1808
-#endif /* INTR_EP_ENABLE */
18091828
18101829 /** called by nobody (Dec 2012) */
18111830 void *
....@@ -2442,44 +2461,31 @@
24422461 dhd->tx_ctlerrs++;
24432462 }
24442463
2445
- dhd->bus->ctl_completed = TRUE;
2446
- dhd_os_ioctl_resp_wake(dhd);
2464
+ dhd_prot_ctl_complete(dhd);
24472465 }
24482466
24492467 static void
24502468 dhd_dbus_state_change(void *handle, int state)
24512469 {
24522470 dhd_pub_t *dhd = (dhd_pub_t *)handle;
2453
- unsigned long flags;
2454
- wifi_adapter_info_t *adapter;
24552471
24562472 if (dhd == NULL) {
24572473 DBUSERR(("%s: dhd is NULL\n", __FUNCTION__));
24582474 return;
24592475 }
2460
- adapter = (wifi_adapter_info_t *)dhd->adapter;
24612476
2462
- if (dhd->busstate == DHD_BUS_SUSPEND && state == DBUS_STATE_DOWN) {
2463
- DBUSERR(("%s: switch state %d to %d\n", __FUNCTION__, state, DBUS_STATE_SLEEP));
2464
- state = DBUS_STATE_SLEEP;
2465
- }
24662477 switch (state) {
2478
+
24672479 case DBUS_STATE_DL_NEEDED:
24682480 DBUSERR(("%s: firmware request cannot be handled\n", __FUNCTION__));
24692481 break;
24702482 case DBUS_STATE_DOWN:
2471
- DHD_LINUX_GENERAL_LOCK(dhd, flags);
2472
- dhd_txflowcontrol(dhd, ALL_INTERFACES, ON);
24732483 DBUSTRACE(("%s: DBUS is down\n", __FUNCTION__));
24742484 dhd->busstate = DHD_BUS_DOWN;
2475
- DHD_LINUX_GENERAL_UNLOCK(dhd, flags);
24762485 break;
24772486 case DBUS_STATE_UP:
24782487 DBUSTRACE(("%s: DBUS is up\n", __FUNCTION__));
2479
- DHD_LINUX_GENERAL_LOCK(dhd, flags);
2480
- dhd_txflowcontrol(dhd, ALL_INTERFACES, OFF);
24812488 dhd->busstate = DHD_BUS_DATA;
2482
- DHD_LINUX_GENERAL_UNLOCK(dhd, flags);
24832489 break;
24842490 default:
24852491 break;
....@@ -2571,7 +2577,14 @@
25712577 struct device *
25722578 dhd_bus_to_dev(struct dhd_bus *bus)
25732579 {
2574
- return dbus_get_dev();
2580
+ struct usb_device *pdev;
2581
+
2582
+ pdev = (struct usb_device *)bus->pub.dev_info;
2583
+
2584
+ if (pdev)
2585
+ return &pdev->dev;
2586
+ else
2587
+ return NULL;
25752588 }
25762589
25772590 void
....@@ -2593,91 +2606,7 @@
25932606 DBUSTRACE(("txoff\n"));
25942607 return BCME_EPERM;
25952608 }
2596
- return dbus_send_pkt(&bus->pub, pktbuf, pktbuf);
2597
-}
2598
-
2599
-int
2600
-dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen)
2601
-{
2602
- int timeleft = 0;
2603
- int ret = -1;
2604
-
2605
- DBUSTRACE(("%s: Enter\n", __FUNCTION__));
2606
-
2607
- if (bus->dhd->dongle_reset)
2608
- return -EIO;
2609
-
2610
- bus->ctl_completed = FALSE;
2611
- ret = dbus_send_ctl(bus, (void *)msg, msglen);
2612
- if (ret) {
2613
- DBUSERR(("%s: dbus_send_ctl error %d\n", __FUNCTION__, ret));
2614
- return ret;
2615
- }
2616
-
2617
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2618
- if ((!timeleft) || (!bus->ctl_completed)) {
2619
- DBUSERR(("%s: Txctl timeleft %d ctl_completed %d\n",
2620
- __FUNCTION__, timeleft, bus->ctl_completed));
2621
- ret = -1;
2622
- }
2623
-
2624
-#ifdef INTR_EP_ENABLE
2625
- /* If the ctl write is successfully completed, wait for an acknowledgement
2626
- * that indicates that it is now ok to do ctl read from the dongle
2627
- */
2628
- if (ret != -1) {
2629
- bus->ctl_completed = FALSE;
2630
- if (dbus_poll_intr(bus->pub)) {
2631
- DBUSERR(("%s: dbus_poll_intr not submitted\n", __FUNCTION__));
2632
- } else {
2633
- /* interrupt polling is sucessfully submitted. Wait for dongle to send
2634
- * interrupt
2635
- */
2636
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2637
- if (!timeleft) {
2638
- DBUSERR(("%s: intr poll wait timed out\n", __FUNCTION__));
2639
- }
2640
- }
2641
- }
2642
-#endif /* INTR_EP_ENABLE */
2643
-
2644
- return ret;
2645
-}
2646
-
2647
-int
2648
-dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen)
2649
-{
2650
- int timeleft;
2651
- int ret = -1;
2652
-
2653
- DBUSTRACE(("%s: Enter\n", __FUNCTION__));
2654
-
2655
- if (bus->dhd->dongle_reset)
2656
- return -EIO;
2657
-
2658
- bus->ctl_completed = FALSE;
2659
- ret = dbus_recv_ctl(bus, (uchar*)msg, msglen);
2660
- if (ret) {
2661
- DBUSERR(("%s: dbus_recv_ctl error %d\n", __FUNCTION__, ret));
2662
- goto done;
2663
- }
2664
-
2665
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2666
- if ((!timeleft) || (!bus->ctl_completed)) {
2667
- DBUSERR(("%s: Rxctl timeleft %d ctl_completed %d\n", __FUNCTION__,
2668
- timeleft, bus->ctl_completed));
2669
- ret = -ETIMEDOUT;
2670
- goto done;
2671
- }
2672
-
2673
- /* XXX FIX: Must return cdc_len, not len, because after query_ioctl()
2674
- * it subtracts sizeof(cdc_ioctl_t); The other approach is
2675
- * to have dbus_recv_ctl() return actual len.
2676
- */
2677
- ret = msglen;
2678
-
2679
-done:
2680
- return ret;
2609
+ return dbus_send_txdata(&bus->pub, pktbuf);
26812610 }
26822611
26832612 static void
....@@ -2707,8 +2636,7 @@
27072636 int timeleft;
27082637
27092638 DHD_LINUX_GENERAL_LOCK(dhdp, flags);
2710
- if (dhdp->busstate != DHD_BUS_SUSPEND)
2711
- dhdp->busstate = DHD_BUS_REMOVE;
2639
+ dhdp->busstate = DHD_BUS_REMOVE;
27122640 DHD_LINUX_GENERAL_UNLOCK(dhdp, flags);
27132641
27142642 timeleft = dhd_os_busbusy_wait_negation(dhdp, &dhdp->dhd_bus_busy_state);
....@@ -2801,160 +2729,27 @@
28012729
28022730 }
28032731
2804
-static int
2805
-dhd_dbus_sync_dongle(dhd_pub_t *pub, int dlneeded)
2806
-{
2807
- int ret = 0;
2808
-
2809
- if (dlneeded == 0) {
2810
- ret = dbus_up(pub->bus);
2811
- if (ret) {
2812
- DBUSERR(("%s: dbus_up failed!!\n", __FUNCTION__));
2813
- goto exit;
2814
- }
2815
- ret = dhd_sync_with_dongle(pub);
2816
- if (ret < 0) {
2817
- DBUSERR(("%s: failed with code ret=%d\n", __FUNCTION__, ret));
2818
- goto exit;
2819
- }
2820
- }
2821
-
2822
-exit:
2823
- return ret;
2824
-}
2825
-
2826
-static int
2827
-dbus_suspend(void *context)
2828
-{
2829
- int ret = 0;
2830
-
2831
-#if defined(LINUX)
2832
- dhd_bus_t *bus = (dhd_bus_t*)context;
2833
- unsigned long flags;
2834
-
2835
- DBUSERR(("%s Enter\n", __FUNCTION__));
2836
- if (bus->dhd == NULL) {
2837
- DBUSERR(("bus not inited\n"));
2838
- return BCME_ERROR;
2839
- }
2840
- if (bus->dhd->prot == NULL) {
2841
- DBUSERR(("prot is not inited\n"));
2842
- return BCME_ERROR;
2843
- }
2844
-
2845
- if (bus->dhd->up == FALSE) {
2846
- return BCME_OK;
2847
- }
2848
-
2849
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2850
- if (bus->dhd->busstate != DHD_BUS_DATA && bus->dhd->busstate != DHD_BUS_SUSPEND) {
2851
- DBUSERR(("not in a readystate to LPBK is not inited\n"));
2852
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2853
- return BCME_ERROR;
2854
- }
2855
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2856
- if (bus->dhd->dongle_reset) {
2857
- DBUSERR(("Dongle is in reset state.\n"));
2858
- return -EIO;
2859
- }
2860
-
2861
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2862
- /* stop all interface network queue. */
2863
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON);
2864
- bus->dhd->busstate = DHD_BUS_SUSPEND;
2865
-#if defined(LINUX) || defined(linux)
2866
- if (DHD_BUS_BUSY_CHECK_IN_TX(bus->dhd)) {
2867
- DBUSERR(("Tx Request is not ended\n"));
2868
- bus->dhd->busstate = DHD_BUS_DATA;
2869
- /* resume all interface network queue. */
2870
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2871
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2872
- return -EBUSY;
2873
- }
2874
-#endif /* LINUX || linux */
2875
- DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd);
2876
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2877
-
2878
- ret = dhd_os_check_wakelock_all(bus->dhd);
2879
-
2880
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2881
- if (ret) {
2882
- bus->dhd->busstate = DHD_BUS_DATA;
2883
- /* resume all interface network queue. */
2884
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2885
- } else {
2886
- bus->last_suspend_end_time = OSL_LOCALTIME_NS();
2887
- }
2888
- bus->dhd->hostsleep = 2;
2889
- DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd);
2890
- dhd_os_busbusy_wake(bus->dhd);
2891
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2892
-
2893
-#endif /* LINUX */
2894
- DBUSERR(("%s Exit ret=%d\n", __FUNCTION__, ret));
2895
- return ret;
2896
-}
2897
-
2898
-static int
2899
-dbus_resume(void *context)
2900
-{
2901
- dhd_bus_t *bus = (dhd_bus_t*)context;
2902
- ulong flags;
2903
- int dlneeded = 0;
2904
- int ret = 0;
2905
-
2906
- DBUSERR(("%s Enter\n", __FUNCTION__));
2907
-
2908
- if (bus->dhd->up == FALSE) {
2909
- return BCME_OK;
2910
- }
2911
-
2912
- dlneeded = dbus_dlneeded(bus);
2913
- if (dlneeded == 0) {
2914
- ret = dbus_up(bus);
2915
- if (ret) {
2916
- DBUSERR(("%s: dbus_up failed!!\n", __FUNCTION__));
2917
- }
2918
- }
2919
-
2920
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2921
- DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd);
2922
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2923
-
2924
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2925
- DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd);
2926
- bus->dhd->hostsleep = 0;
2927
- bus->dhd->busstate = DHD_BUS_DATA;
2928
- dhd_os_busbusy_wake(bus->dhd);
2929
- /* resume all interface network queue. */
2930
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2931
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2932
-// dhd_conf_set_suspend_resume(bus->dhd, 0);
2933
-
2934
- return 0;
2935
-}
2936
-
29372732 /*
29382733 * hdrlen is space to reserve in pkt headroom for DBUS
29392734 */
2940
-static void *
2941
-dhd_dbus_probe_cb(uint16 bus_no, uint16 slot, uint32 hdrlen)
2735
+void *
2736
+dhd_dbus_probe_cb(void *arg, const char *desc, uint32 bustype,
2737
+ uint16 bus_no, uint16 slot, uint32 hdrlen)
29422738 {
29432739 osl_t *osh = NULL;
29442740 dhd_bus_t *bus = NULL;
29452741 dhd_pub_t *pub = NULL;
29462742 uint rxsz;
2947
- int dlneeded = 0, ret = DBUS_OK;
2743
+ int dlneeded = 0;
29482744 wifi_adapter_info_t *adapter = NULL;
2949
- bool net_attach_now = TRUE;
29502745
29512746 DBUSTRACE(("%s: Enter\n", __FUNCTION__));
29522747
2953
- adapter = dhd_wifi_platform_get_adapter(USB_BUS, bus_no, slot);
2748
+ adapter = dhd_wifi_platform_get_adapter(bustype, bus_no, slot);
29542749
29552750 if (!g_pub) {
29562751 /* Ask the OS interface part for an OSL handle */
2957
- if (!(osh = osl_attach(NULL, USB_BUS, TRUE))) {
2752
+ if (!(osh = osl_attach(NULL, bustype, TRUE))) {
29582753 DBUSERR(("%s: OSL attach failed\n", __FUNCTION__));
29592754 goto fail;
29602755 }
....@@ -2981,57 +2776,35 @@
29812776 bus->dhd = pub;
29822777
29832778 dlneeded = dbus_dlneeded(bus);
2984
- if (dlneeded >= 0 && !g_pub) {
2985
- dhd_conf_reset(pub);
2986
- dhd_conf_set_chiprev(pub, bus->pub.attrib.devid, bus->pub.attrib.chiprev);
2987
- dhd_conf_preinit(pub);
2779
+ if (dlneeded >= 0) {
2780
+ if (!g_pub) {
2781
+ dhd_conf_reset(pub);
2782
+ dhd_conf_set_chiprev(pub, bus->pub.attrib.devid, bus->pub.attrib.chiprev);
2783
+ dhd_conf_preinit(pub);
2784
+ }
29882785 }
29892786
2990
-#if defined(BCMDHD_MODULAR) && defined(INSMOD_FW_LOAD)
2991
- if (1)
2992
-#else
2993
- if (g_pub || dhd_download_fw_on_driverload)
2994
-#endif
2995
- {
2996
- if (dlneeded == 0)
2787
+ if (g_pub || dhd_download_fw_on_driverload) {
2788
+ if (dlneeded == 0) {
29972789 wifi_set_adapter_status(adapter, WIFI_STATUS_FW_READY);
29982790 #ifdef BCM_REQUEST_FW
2999
- else if (dlneeded > 0) {
3000
- struct dhd_conf *conf = pub->conf;
3001
- unsigned long flags;
3002
- bool suspended;
3003
- wifi_clr_adapter_status(adapter, WIFI_STATUS_FW_READY);
3004
- suspended = conf->suspended;
2791
+ } else if (dlneeded > 0) {
30052792 dhd_set_path(bus->dhd);
3006
- conf->suspended = suspended;
3007
- if (dbus_download_firmware(bus) != DBUS_OK)
2793
+ if (dbus_download_firmware(bus, bus->fw_path, bus->nv_path) != DBUS_OK)
30082794 goto fail;
3009
- DHD_LINUX_GENERAL_LOCK(pub, flags);
3010
- if (bus->dhd->busstate != DHD_BUS_SUSPEND)
3011
- bus->dhd->busstate = DHD_BUS_LOAD;
3012
- DHD_LINUX_GENERAL_UNLOCK(pub, flags);
3013
- }
30142795 #endif
3015
- else {
2796
+ } else {
30162797 goto fail;
30172798 }
30182799 }
3019
- }
3020
- else {
2800
+ } else {
30212801 DBUSERR(("%s: dbus_attach failed\n", __FUNCTION__));
3022
- goto fail;
30232802 }
30242803
3025
-#if defined(BCMDHD_MODULAR) && defined(INSMOD_FW_LOAD)
3026
- if (dlneeded > 0)
3027
- net_attach_now = FALSE;
3028
-#endif
3029
-
3030
- if (!net_attached && (net_attach_now || (dlneeded == 0))) {
3031
- if (dhd_dbus_sync_dongle(pub, dlneeded)) {
3032
- goto fail;
3033
- }
3034
- if (dhd_attach_net(bus->dhd, TRUE) != 0) {
2804
+ if (!g_pub) {
2805
+ /* Ok, have the per-port tell the stack we're open for business */
2806
+ if (dhd_attach_net(bus->dhd, TRUE) != 0)
2807
+ {
30352808 DBUSERR(("%s: Net attach failed!!\n", __FUNCTION__));
30362809 goto fail;
30372810 }
....@@ -3039,31 +2812,14 @@
30392812 #if defined(MULTIPLE_SUPPLICANT)
30402813 wl_android_post_init(); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
30412814 #endif
3042
- net_attached = TRUE;
3043
- }
3044
- else if (net_attached && (pub->up == 1) && (dlneeded == 0)) {
3045
- // kernel resume case
3046
- pub->hostsleep = 0;
3047
- ret = dhd_dbus_sync_dongle(pub, dlneeded);
3048
-#ifdef WL_CFG80211
3049
- __wl_cfg80211_up_resume(pub);
3050
- wl_cfgp2p_start_p2p_device_resume(pub);
3051
-#endif
3052
- dhd_conf_set_suspend_resume(pub, 0);
3053
- if (ret != DBUS_OK)
3054
- goto fail;
3055
- }
3056
-
3057
- if (!g_pub) {
30582815 g_pub = pub;
30592816 }
30602817
30612818 DBUSTRACE(("%s: Exit\n", __FUNCTION__));
3062
- if (net_attached) {
3063
- wifi_set_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED);
3064
- wake_up_interruptible(&adapter->status_event);
3065
- /* This is passed to dhd_dbus_disconnect_cb */
3066
- }
2819
+ wifi_clr_adapter_status(adapter, WIFI_STATUS_DETTACH);
2820
+ wifi_set_adapter_status(adapter, WIFI_STATUS_ATTACH);
2821
+ wake_up_interruptible(&adapter->status_event);
2822
+ /* This is passed to dhd_dbus_disconnect_cb */
30672823 return bus;
30682824
30692825 fail:
....@@ -3086,7 +2842,7 @@
30862842 return NULL;
30872843 }
30882844
3089
-static void
2845
+void
30902846 dhd_dbus_disconnect_cb(void *arg)
30912847 {
30922848 dhd_bus_t *bus = (dhd_bus_t *)arg;
....@@ -3112,6 +2868,8 @@
31122868 dhd_dbus_advertise_bus_remove(bus->dhd);
31132869 dbus_detach(pub->bus);
31142870 pub->bus = NULL;
2871
+ wifi_clr_adapter_status(adapter, WIFI_STATUS_ATTACH);
2872
+ wifi_set_adapter_status(adapter, WIFI_STATUS_DETTACH);
31152873 wake_up_interruptible(&adapter->status_event);
31162874 } else {
31172875 osh = pub->osh;
....@@ -3122,8 +2880,6 @@
31222880 }
31232881 dhd_free(pub);
31242882 g_pub = NULL;
3125
- net_attached = FALSE;
3126
- wifi_clr_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED);
31272883 if (MALLOCED(osh)) {
31282884 DBUSERR(("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh)));
31292885 }
....@@ -3150,7 +2906,6 @@
31502906 }
31512907
31522908 EXPORT_SYMBOL(dbus_pnp_sleep);
3153
-EXPORT_SYMBOL(dhd_bus_register);
31542909 EXPORT_SYMBOL(dbus_get_devinfo);
31552910 EXPORT_SYMBOL(dbus_detach);
31562911 EXPORT_SYMBOL(dbus_get_attrib);
....@@ -3163,7 +2918,6 @@
31632918 EXPORT_SYMBOL(dbus_send_pkt);
31642919 EXPORT_SYMBOL(dbus_recv_ctl);
31652920 EXPORT_SYMBOL(dbus_attach);
3166
-EXPORT_SYMBOL(dhd_bus_unregister);
31672921
31682922 MODULE_LICENSE("GPL");
31692923