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,49 +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;
2455
- int wowl_dngldown = 0;
24562471
24572472 if (dhd == NULL) {
24582473 DBUSERR(("%s: dhd is NULL\n", __FUNCTION__));
24592474 return;
24602475 }
2461
- adapter = (wifi_adapter_info_t *)dhd->adapter;
2462
-#ifdef WL_EXT_WOWL
2463
- wowl_dngldown = dhd_conf_wowl_dngldown(dhd);
2464
-#endif
24652476
2466
- if ((dhd->busstate == DHD_BUS_SUSPEND && state == DBUS_STATE_DOWN) ||
2467
- (dhd->hostsleep && wowl_dngldown)) {
2468
- DBUSERR(("%s: switch state %d to %d\n", __FUNCTION__, state, DBUS_STATE_SLEEP));
2469
- state = DBUS_STATE_SLEEP;
2470
- }
24712477 switch (state) {
2478
+
24722479 case DBUS_STATE_DL_NEEDED:
24732480 DBUSERR(("%s: firmware request cannot be handled\n", __FUNCTION__));
24742481 break;
24752482 case DBUS_STATE_DOWN:
2476
- DHD_LINUX_GENERAL_LOCK(dhd, flags);
2477
- dhd_txflowcontrol(dhd, ALL_INTERFACES, ON);
24782483 DBUSTRACE(("%s: DBUS is down\n", __FUNCTION__));
24792484 dhd->busstate = DHD_BUS_DOWN;
2480
- DHD_LINUX_GENERAL_UNLOCK(dhd, flags);
24812485 break;
24822486 case DBUS_STATE_UP:
24832487 DBUSTRACE(("%s: DBUS is up\n", __FUNCTION__));
2484
- DHD_LINUX_GENERAL_LOCK(dhd, flags);
2485
- dhd_txflowcontrol(dhd, ALL_INTERFACES, OFF);
24862488 dhd->busstate = DHD_BUS_DATA;
2487
- DHD_LINUX_GENERAL_UNLOCK(dhd, flags);
24882489 break;
24892490 default:
24902491 break;
....@@ -2576,7 +2577,14 @@
25762577 struct device *
25772578 dhd_bus_to_dev(struct dhd_bus *bus)
25782579 {
2579
- 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;
25802588 }
25812589
25822590 void
....@@ -2598,91 +2606,7 @@
25982606 DBUSTRACE(("txoff\n"));
25992607 return BCME_EPERM;
26002608 }
2601
- return dbus_send_pkt(&bus->pub, pktbuf, pktbuf);
2602
-}
2603
-
2604
-int
2605
-dhd_bus_txctl(struct dhd_bus *bus, uchar *msg, uint msglen)
2606
-{
2607
- int timeleft = 0;
2608
- int ret = -1;
2609
-
2610
- DBUSTRACE(("%s: Enter\n", __FUNCTION__));
2611
-
2612
- if (bus->dhd->dongle_reset)
2613
- return -EIO;
2614
-
2615
- bus->ctl_completed = FALSE;
2616
- ret = dbus_send_ctl(bus, (void *)msg, msglen);
2617
- if (ret) {
2618
- DBUSERR(("%s: dbus_send_ctl error %d\n", __FUNCTION__, ret));
2619
- return ret;
2620
- }
2621
-
2622
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2623
- if ((!timeleft) || (!bus->ctl_completed)) {
2624
- DBUSERR(("%s: Txctl timeleft %d ctl_completed %d\n",
2625
- __FUNCTION__, timeleft, bus->ctl_completed));
2626
- ret = -1;
2627
- }
2628
-
2629
-#ifdef INTR_EP_ENABLE
2630
- /* If the ctl write is successfully completed, wait for an acknowledgement
2631
- * that indicates that it is now ok to do ctl read from the dongle
2632
- */
2633
- if (ret != -1) {
2634
- bus->ctl_completed = FALSE;
2635
- if (dbus_poll_intr(bus->pub)) {
2636
- DBUSERR(("%s: dbus_poll_intr not submitted\n", __FUNCTION__));
2637
- } else {
2638
- /* interrupt polling is sucessfully submitted. Wait for dongle to send
2639
- * interrupt
2640
- */
2641
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2642
- if (!timeleft) {
2643
- DBUSERR(("%s: intr poll wait timed out\n", __FUNCTION__));
2644
- }
2645
- }
2646
- }
2647
-#endif /* INTR_EP_ENABLE */
2648
-
2649
- return ret;
2650
-}
2651
-
2652
-int
2653
-dhd_bus_rxctl(struct dhd_bus *bus, uchar *msg, uint msglen)
2654
-{
2655
- int timeleft;
2656
- int ret = -1;
2657
-
2658
- DBUSTRACE(("%s: Enter\n", __FUNCTION__));
2659
-
2660
- if (bus->dhd->dongle_reset)
2661
- return -EIO;
2662
-
2663
- bus->ctl_completed = FALSE;
2664
- ret = dbus_recv_ctl(bus, (uchar*)msg, msglen);
2665
- if (ret) {
2666
- DBUSERR(("%s: dbus_recv_ctl error %d\n", __FUNCTION__, ret));
2667
- goto done;
2668
- }
2669
-
2670
- timeleft = dhd_os_ioctl_resp_wait(bus->dhd, &bus->ctl_completed);
2671
- if ((!timeleft) || (!bus->ctl_completed)) {
2672
- DBUSERR(("%s: Rxctl timeleft %d ctl_completed %d\n", __FUNCTION__,
2673
- timeleft, bus->ctl_completed));
2674
- ret = -ETIMEDOUT;
2675
- goto done;
2676
- }
2677
-
2678
- /* XXX FIX: Must return cdc_len, not len, because after query_ioctl()
2679
- * it subtracts sizeof(cdc_ioctl_t); The other approach is
2680
- * to have dbus_recv_ctl() return actual len.
2681
- */
2682
- ret = msglen;
2683
-
2684
-done:
2685
- return ret;
2609
+ return dbus_send_txdata(&bus->pub, pktbuf);
26862610 }
26872611
26882612 static void
....@@ -2712,8 +2636,7 @@
27122636 int timeleft;
27132637
27142638 DHD_LINUX_GENERAL_LOCK(dhdp, flags);
2715
- if (dhdp->busstate != DHD_BUS_SUSPEND)
2716
- dhdp->busstate = DHD_BUS_REMOVE;
2639
+ dhdp->busstate = DHD_BUS_REMOVE;
27172640 DHD_LINUX_GENERAL_UNLOCK(dhdp, flags);
27182641
27192642 timeleft = dhd_os_busbusy_wait_negation(dhdp, &dhdp->dhd_bus_busy_state);
....@@ -2806,160 +2729,27 @@
28062729
28072730 }
28082731
2809
-static int
2810
-dhd_dbus_sync_dongle(dhd_pub_t *pub, int dlneeded)
2811
-{
2812
- int ret = 0;
2813
-
2814
- if (dlneeded == 0) {
2815
- ret = dbus_up(pub->bus);
2816
- if (ret) {
2817
- DBUSERR(("%s: dbus_up failed!!\n", __FUNCTION__));
2818
- goto exit;
2819
- }
2820
- ret = dhd_sync_with_dongle(pub);
2821
- if (ret < 0) {
2822
- DBUSERR(("%s: failed with code ret=%d\n", __FUNCTION__, ret));
2823
- goto exit;
2824
- }
2825
- }
2826
-
2827
-exit:
2828
- return ret;
2829
-}
2830
-
2831
-static int
2832
-dbus_suspend(void *context)
2833
-{
2834
- int ret = 0;
2835
-
2836
-#if defined(LINUX)
2837
- dhd_bus_t *bus = (dhd_bus_t*)context;
2838
- unsigned long flags;
2839
-
2840
- DBUSERR(("%s Enter\n", __FUNCTION__));
2841
- if (bus->dhd == NULL) {
2842
- DBUSERR(("bus not inited\n"));
2843
- return BCME_ERROR;
2844
- }
2845
- if (bus->dhd->prot == NULL) {
2846
- DBUSERR(("prot is not inited\n"));
2847
- return BCME_ERROR;
2848
- }
2849
-
2850
- if (bus->dhd->up == FALSE) {
2851
- return BCME_OK;
2852
- }
2853
-
2854
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2855
- if (bus->dhd->busstate != DHD_BUS_DATA && bus->dhd->busstate != DHD_BUS_SUSPEND) {
2856
- DBUSERR(("not in a readystate to LPBK is not inited\n"));
2857
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2858
- return BCME_ERROR;
2859
- }
2860
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2861
- if (bus->dhd->dongle_reset) {
2862
- DBUSERR(("Dongle is in reset state.\n"));
2863
- return -EIO;
2864
- }
2865
-
2866
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2867
- /* stop all interface network queue. */
2868
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, ON);
2869
- bus->dhd->busstate = DHD_BUS_SUSPEND;
2870
-#if defined(LINUX) || defined(linux)
2871
- if (DHD_BUS_BUSY_CHECK_IN_TX(bus->dhd)) {
2872
- DBUSERR(("Tx Request is not ended\n"));
2873
- bus->dhd->busstate = DHD_BUS_DATA;
2874
- /* resume all interface network queue. */
2875
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2876
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2877
- return -EBUSY;
2878
- }
2879
-#endif /* LINUX || linux */
2880
- DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(bus->dhd);
2881
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2882
-
2883
- ret = dhd_os_check_wakelock_all(bus->dhd);
2884
-
2885
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2886
- if (ret) {
2887
- bus->dhd->busstate = DHD_BUS_DATA;
2888
- /* resume all interface network queue. */
2889
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2890
- } else {
2891
- bus->last_suspend_end_time = OSL_LOCALTIME_NS();
2892
- }
2893
- bus->dhd->hostsleep = 2;
2894
- DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(bus->dhd);
2895
- dhd_os_busbusy_wake(bus->dhd);
2896
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2897
-
2898
-#endif /* LINUX */
2899
- DBUSERR(("%s Exit ret=%d\n", __FUNCTION__, ret));
2900
- return ret;
2901
-}
2902
-
2903
-static int
2904
-dbus_resume(void *context)
2905
-{
2906
- dhd_bus_t *bus = (dhd_bus_t*)context;
2907
- ulong flags;
2908
- int dlneeded = 0;
2909
- int ret = 0;
2910
-
2911
- DBUSERR(("%s Enter\n", __FUNCTION__));
2912
-
2913
- if (bus->dhd->up == FALSE) {
2914
- return BCME_OK;
2915
- }
2916
-
2917
- dlneeded = dbus_dlneeded(bus);
2918
- if (dlneeded == 0) {
2919
- ret = dbus_up(bus);
2920
- if (ret) {
2921
- DBUSERR(("%s: dbus_up failed!!\n", __FUNCTION__));
2922
- }
2923
- }
2924
-
2925
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2926
- DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(bus->dhd);
2927
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2928
-
2929
- DHD_LINUX_GENERAL_LOCK(bus->dhd, flags);
2930
- DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(bus->dhd);
2931
- bus->dhd->hostsleep = 0;
2932
- bus->dhd->busstate = DHD_BUS_DATA;
2933
- dhd_os_busbusy_wake(bus->dhd);
2934
- /* resume all interface network queue. */
2935
- dhd_txflowcontrol(bus->dhd, ALL_INTERFACES, OFF);
2936
- DHD_LINUX_GENERAL_UNLOCK(bus->dhd, flags);
2937
-// dhd_conf_set_suspend_resume(bus->dhd, 0);
2938
-
2939
- return 0;
2940
-}
2941
-
29422732 /*
29432733 * hdrlen is space to reserve in pkt headroom for DBUS
29442734 */
2945
-static void *
2946
-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)
29472738 {
29482739 osl_t *osh = NULL;
29492740 dhd_bus_t *bus = NULL;
29502741 dhd_pub_t *pub = NULL;
29512742 uint rxsz;
2952
- int dlneeded = 0, ret = DBUS_OK;
2743
+ int dlneeded = 0;
29532744 wifi_adapter_info_t *adapter = NULL;
2954
- bool net_attach_now = TRUE;
29552745
29562746 DBUSTRACE(("%s: Enter\n", __FUNCTION__));
29572747
2958
- adapter = dhd_wifi_platform_get_adapter(USB_BUS, bus_no, slot);
2748
+ adapter = dhd_wifi_platform_get_adapter(bustype, bus_no, slot);
29592749
29602750 if (!g_pub) {
29612751 /* Ask the OS interface part for an OSL handle */
2962
- if (!(osh = osl_attach(NULL, USB_BUS, TRUE))) {
2752
+ if (!(osh = osl_attach(NULL, bustype, TRUE))) {
29632753 DBUSERR(("%s: OSL attach failed\n", __FUNCTION__));
29642754 goto fail;
29652755 }
....@@ -2986,57 +2776,35 @@
29862776 bus->dhd = pub;
29872777
29882778 dlneeded = dbus_dlneeded(bus);
2989
- if (dlneeded >= 0 && !g_pub) {
2990
- dhd_conf_reset(pub);
2991
- dhd_conf_set_chiprev(pub, bus->pub.attrib.devid, bus->pub.attrib.chiprev);
2992
- 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
+ }
29932785 }
29942786
2995
-#if defined(BCMDHD_MODULAR) && defined(INSMOD_FW_LOAD)
2996
- if (1)
2997
-#else
2998
- if (g_pub || dhd_download_fw_on_driverload)
2999
-#endif
3000
- {
3001
- if (dlneeded == 0)
2787
+ if (g_pub || dhd_download_fw_on_driverload) {
2788
+ if (dlneeded == 0) {
30022789 wifi_set_adapter_status(adapter, WIFI_STATUS_FW_READY);
30032790 #ifdef BCM_REQUEST_FW
3004
- else if (dlneeded > 0) {
3005
- struct dhd_conf *conf = pub->conf;
3006
- unsigned long flags;
3007
- bool suspended;
3008
- wifi_clr_adapter_status(adapter, WIFI_STATUS_FW_READY);
3009
- suspended = conf->suspended;
2791
+ } else if (dlneeded > 0) {
30102792 dhd_set_path(bus->dhd);
3011
- conf->suspended = suspended;
3012
- if (dbus_download_firmware(bus) != DBUS_OK)
2793
+ if (dbus_download_firmware(bus, bus->fw_path, bus->nv_path) != DBUS_OK)
30132794 goto fail;
3014
- DHD_LINUX_GENERAL_LOCK(pub, flags);
3015
- if (bus->dhd->busstate != DHD_BUS_SUSPEND)
3016
- bus->dhd->busstate = DHD_BUS_LOAD;
3017
- DHD_LINUX_GENERAL_UNLOCK(pub, flags);
3018
- }
30192795 #endif
3020
- else {
2796
+ } else {
30212797 goto fail;
30222798 }
30232799 }
3024
- }
3025
- else {
2800
+ } else {
30262801 DBUSERR(("%s: dbus_attach failed\n", __FUNCTION__));
3027
- goto fail;
30282802 }
30292803
3030
-#if defined(BCMDHD_MODULAR) && defined(INSMOD_FW_LOAD)
3031
- if (dlneeded > 0)
3032
- net_attach_now = FALSE;
3033
-#endif
3034
-
3035
- if (!net_attached && (net_attach_now || (dlneeded == 0))) {
3036
- if (dhd_dbus_sync_dongle(pub, dlneeded)) {
3037
- goto fail;
3038
- }
3039
- 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
+ {
30402808 DBUSERR(("%s: Net attach failed!!\n", __FUNCTION__));
30412809 goto fail;
30422810 }
....@@ -3044,32 +2812,14 @@
30442812 #if defined(MULTIPLE_SUPPLICANT)
30452813 wl_android_post_init(); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
30462814 #endif
3047
- net_attached = TRUE;
3048
- }
3049
- else if (net_attached && (pub->up == 1) && (dlneeded == 0)) {
3050
- // kernel resume case
3051
- pub->hostsleep = 0;
3052
- ret = dhd_dbus_sync_dongle(pub, dlneeded);
3053
-#ifdef WL_CFG80211
3054
- __wl_cfg80211_up_resume(pub);
3055
- wl_cfgp2p_start_p2p_device_resume(pub);
3056
-#endif
3057
- dhd_conf_set_suspend_resume(pub, 0);
3058
- if (ret != DBUS_OK)
3059
- goto fail;
3060
- }
3061
-
3062
- if (!g_pub) {
30632815 g_pub = pub;
30642816 }
30652817
30662818 DBUSTRACE(("%s: Exit\n", __FUNCTION__));
3067
- wifi_clr_adapter_status(adapter, WIFI_STATUS_BUS_DISCONNECTED);
3068
- if (net_attached) {
3069
- wifi_set_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED);
3070
- wake_up_interruptible(&adapter->status_event);
3071
- /* This is passed to dhd_dbus_disconnect_cb */
3072
- }
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 */
30732823 return bus;
30742824
30752825 fail:
....@@ -3092,7 +2842,7 @@
30922842 return NULL;
30932843 }
30942844
3095
-static void
2845
+void
30962846 dhd_dbus_disconnect_cb(void *arg)
30972847 {
30982848 dhd_bus_t *bus = (dhd_bus_t *)arg;
....@@ -3118,7 +2868,8 @@
31182868 dhd_dbus_advertise_bus_remove(bus->dhd);
31192869 dbus_detach(pub->bus);
31202870 pub->bus = NULL;
3121
- wifi_set_adapter_status(adapter, WIFI_STATUS_BUS_DISCONNECTED);
2871
+ wifi_clr_adapter_status(adapter, WIFI_STATUS_ATTACH);
2872
+ wifi_set_adapter_status(adapter, WIFI_STATUS_DETTACH);
31222873 wake_up_interruptible(&adapter->status_event);
31232874 } else {
31242875 osh = pub->osh;
....@@ -3129,8 +2880,6 @@
31292880 }
31302881 dhd_free(pub);
31312882 g_pub = NULL;
3132
- net_attached = FALSE;
3133
- wifi_clr_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED);
31342883 if (MALLOCED(osh)) {
31352884 DBUSERR(("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh)));
31362885 }
....@@ -3138,24 +2887,6 @@
31382887 }
31392888
31402889 DBUSTRACE(("%s: Exit\n", __FUNCTION__));
3141
-}
3142
-
3143
-int
3144
-dhd_bus_sleep(dhd_pub_t *dhdp, bool sleep, uint32 *intstatus)
3145
-{
3146
- wifi_adapter_info_t *adapter = (wifi_adapter_info_t *)dhdp->adapter;
3147
- s32 timeout = -1;
3148
- int err = 0;
3149
-
3150
- timeout = wait_event_interruptible_timeout(adapter->status_event,
3151
- wifi_get_adapter_status(adapter, WIFI_STATUS_BUS_DISCONNECTED),
3152
- msecs_to_jiffies(12000));
3153
- if (timeout <= 0) {
3154
- err = -1;
3155
- DBUSERR(("%s: bus disconnected timeout\n", __FUNCTION__));
3156
- }
3157
-
3158
- return err;
31592890 }
31602891
31612892 #ifdef LINUX_EXTERNAL_MODULE_DBUS
....@@ -3175,7 +2906,6 @@
31752906 }
31762907
31772908 EXPORT_SYMBOL(dbus_pnp_sleep);
3178
-EXPORT_SYMBOL(dhd_bus_register);
31792909 EXPORT_SYMBOL(dbus_get_devinfo);
31802910 EXPORT_SYMBOL(dbus_detach);
31812911 EXPORT_SYMBOL(dbus_get_attrib);
....@@ -3188,7 +2918,6 @@
31882918 EXPORT_SYMBOL(dbus_send_pkt);
31892919 EXPORT_SYMBOL(dbus_recv_ctl);
31902920 EXPORT_SYMBOL(dbus_attach);
3191
-EXPORT_SYMBOL(dhd_bus_unregister);
31922921
31932922 MODULE_LICENSE("GPL");
31942923