old mode 100644new mode 100755| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 1 | 2 | /** @file dbus.c |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Hides details of USB / SDIO / SPI interfaces and OS details. It is intended to shield details and |
|---|
| .. | .. |
|---|
| 42 | 43 | #include <dhd_wlfc.h> |
|---|
| 43 | 44 | #endif |
|---|
| 44 | 45 | #include <dhd_config.h> |
|---|
| 45 | | -#ifdef WL_CFG80211 |
|---|
| 46 | | -#include <wl_cfg80211.h> |
|---|
| 47 | | -#include <wl_cfgp2p.h> |
|---|
| 48 | | -#endif |
|---|
| 49 | 46 | |
|---|
| 50 | | -#include <bcmdevs_legacy.h> |
|---|
| 51 | 47 | #if defined(BCM_REQUEST_FW) |
|---|
| 52 | 48 | #include <bcmsrom_fmt.h> |
|---|
| 53 | 49 | #include <trxhdr.h> |
|---|
| .. | .. |
|---|
| 99 | 95 | bool txoverride; /* flow control related */ |
|---|
| 100 | 96 | bool rxoff; |
|---|
| 101 | 97 | bool tx_timer_ticking; |
|---|
| 102 | | - uint ctl_completed; |
|---|
| 98 | + |
|---|
| 103 | 99 | |
|---|
| 104 | 100 | dbus_irbq_t *rx_q; |
|---|
| 105 | 101 | dbus_irbq_t *tx_q; |
|---|
| .. | .. |
|---|
| 119 | 115 | #endif |
|---|
| 120 | 116 | char *fw_path; /* module_param: path to firmware image */ |
|---|
| 121 | 117 | char *nv_path; /* module_param: path to nvram vars file */ |
|---|
| 122 | | - uint64 last_suspend_end_time; |
|---|
| 123 | 118 | } dhd_bus_t; |
|---|
| 124 | 119 | |
|---|
| 125 | 120 | struct exec_parms { |
|---|
| .. | .. |
|---|
| 158 | 153 | static struct dbus_irb *dbus_if_getirb(void *cbarg, bool send); |
|---|
| 159 | 154 | static void dbus_if_rxerr_indicate(void *handle, bool on); |
|---|
| 160 | 155 | |
|---|
| 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); |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | /** functions in this file that are called by lower DBUS levels, e.g. dbus_usb.c */ |
|---|
| 168 | 162 | static dbus_intf_callbacks_t dbus_intf_cbs = { |
|---|
| .. | .. |
|---|
| 187 | 181 | * can be called inside disconnect() |
|---|
| 188 | 182 | */ |
|---|
| 189 | 183 | 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; |
|---|
| 190 | 188 | |
|---|
| 191 | 189 | #if defined(BCM_REQUEST_FW) |
|---|
| 192 | 190 | int8 *nonfwnvram = NULL; /* stand-alone multi-nvram given with driver load */ |
|---|
| .. | .. |
|---|
| 204 | 202 | static int dbus_irbq_deinit(dhd_bus_t *dhd_bus, dbus_irbq_t *q, int size_irb); |
|---|
| 205 | 203 | static int dbus_rxirbs_fill(dhd_bus_t *dhd_bus); |
|---|
| 206 | 204 | 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); |
|---|
| 207 | 208 | |
|---|
| 208 | 209 | #if defined(BCM_REQUEST_FW) |
|---|
| 209 | 210 | extern char * dngl_firmware; |
|---|
| .. | .. |
|---|
| 602 | 603 | |
|---|
| 603 | 604 | #ifdef EXTERNAL_FW_PATH |
|---|
| 604 | 605 | 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) |
|---|
| 606 | 607 | { |
|---|
| 607 | 608 | int bcmerror = -1, i; |
|---|
| 608 | 609 | uint len, total_len; |
|---|
| .. | .. |
|---|
| 617 | 618 | struct trx_header *hdr; |
|---|
| 618 | 619 | uint32 img_offset = 0; |
|---|
| 619 | 620 | int offset = 0; |
|---|
| 620 | | - char *pfw_path = dhd_bus->fw_path; |
|---|
| 621 | | - char *pnv_path = dhd_bus->nv_path; |
|---|
| 622 | 621 | |
|---|
| 623 | 622 | /* For Get nvram */ |
|---|
| 624 | 623 | file_exists = ((pnv_path != NULL) && (pnv_path[0] != '\0')); |
|---|
| .. | .. |
|---|
| 751 | 750 | * the dongle |
|---|
| 752 | 751 | */ |
|---|
| 753 | 752 | 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) |
|---|
| 755 | 754 | { |
|---|
| 756 | 755 | int err = DBUS_OK; |
|---|
| 757 | 756 | |
|---|
| 758 | | - err = dbus_get_fw_nvram(dhd_bus); |
|---|
| 757 | + err = dbus_get_fw_nvram(dhd_bus, pfw_path, pnv_path); |
|---|
| 759 | 758 | if (err) { |
|---|
| 760 | 759 | DBUSERR(("dbus_do_download: fail to get nvram %d\n", err)); |
|---|
| 761 | 760 | return err; |
|---|
| .. | .. |
|---|
| 863 | 862 | nvram_words_pad = 4 - dhd_bus->nvram_len % 4; |
|---|
| 864 | 863 | |
|---|
| 865 | 864 | 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 |
|---|
| 870 | 865 | dhd_bus->image = MALLOC(dhd_bus->pub.osh, len); |
|---|
| 871 | | -#endif /* CONFIG_DHD_USE_STATIC_BUF */ |
|---|
| 872 | 866 | dhd_bus->image_len = len; |
|---|
| 873 | 867 | if (dhd_bus->image == NULL) { |
|---|
| 874 | 868 | DBUSERR(("%s: malloc failed!\n", __FUNCTION__)); |
|---|
| .. | .. |
|---|
| 947 | 941 | #if defined(BCM_REQUEST_FW) |
|---|
| 948 | 942 | dhd_bus->firmware = dbus_get_fw_nvfile(dhd_bus->pub.attrib.devid, |
|---|
| 949 | 943 | 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); |
|---|
| 951 | 945 | if (!dhd_bus->firmware) |
|---|
| 952 | 946 | return DBUS_ERR; |
|---|
| 953 | 947 | #endif |
|---|
| .. | .. |
|---|
| 973 | 967 | nonfwnvramlen = 0; |
|---|
| 974 | 968 | dhd_bus->nvfile = dbus_get_fw_nvfile(dhd_bus->pub.attrib.devid, |
|---|
| 975 | 969 | dhd_bus->pub.attrib.chiprev, (void *)&temp_nvram, &temp_len, |
|---|
| 976 | | - DBUS_NVFILE, boardtype, boardrev, dhd_bus->nv_path); |
|---|
| 970 | + DBUS_NVFILE, boardtype, boardrev); |
|---|
| 977 | 971 | if (dhd_bus->nvfile) { |
|---|
| 978 | 972 | int8 *tmp = MALLOC(dhd_bus->pub.osh, temp_len); |
|---|
| 979 | 973 | if (tmp) { |
|---|
| .. | .. |
|---|
| 1004 | 998 | err = DBUS_ERR; |
|---|
| 1005 | 999 | |
|---|
| 1006 | 1000 | 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 |
|---|
| 1010 | 1001 | MFREE(dhd_bus->pub.osh, dhd_bus->image, dhd_bus->image_len); |
|---|
| 1011 | | -#endif /* CONFIG_DHD_USE_STATIC_BUF */ |
|---|
| 1012 | 1002 | dhd_bus->image = dhd_bus->fw; |
|---|
| 1013 | 1003 | dhd_bus->image_len = (uint32)dhd_bus->fwlen; |
|---|
| 1014 | 1004 | } |
|---|
| .. | .. |
|---|
| 1041 | 1031 | } /* dbus_do_download */ |
|---|
| 1042 | 1032 | #endif /* EXTERNAL_FW_PATH */ |
|---|
| 1043 | 1033 | #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 | +} |
|---|
| 1044 | 1044 | |
|---|
| 1045 | 1045 | /** |
|---|
| 1046 | 1046 | * This function is called when the sent irb times out without a tx response status. |
|---|
| .. | .. |
|---|
| 1373 | 1373 | return irb; |
|---|
| 1374 | 1374 | } |
|---|
| 1375 | 1375 | |
|---|
| 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. |
|---|
| 1379 | 1379 | */ |
|---|
| 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 | + } |
|---|
| 1380 | 1389 | |
|---|
| 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 | +} |
|---|
| 1387 | 1392 | |
|---|
| 1388 | 1393 | /** |
|---|
| 1389 | 1394 | * As part of initialization, higher level (e.g. dhd_linux.c) requests DBUS to prepare for |
|---|
| .. | .. |
|---|
| 1396 | 1401 | |
|---|
| 1397 | 1402 | DBUSTRACE(("%s: Enter\n", __FUNCTION__)); |
|---|
| 1398 | 1403 | |
|---|
| 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); |
|---|
| 1400 | 1410 | |
|---|
| 1401 | 1411 | /* Device not detected */ |
|---|
| 1402 | 1412 | if (err == DBUS_ERR_NODEVICE) |
|---|
| .. | .. |
|---|
| 1406 | 1416 | } |
|---|
| 1407 | 1417 | |
|---|
| 1408 | 1418 | dhd_pub_t *g_pub = NULL; |
|---|
| 1409 | | -bool net_attached = FALSE; |
|---|
| 1410 | 1419 | void |
|---|
| 1411 | 1420 | dhd_bus_unregister(void) |
|---|
| 1412 | 1421 | { |
|---|
| 1422 | + int ret; |
|---|
| 1423 | + |
|---|
| 1413 | 1424 | DBUSTRACE(("%s\n", __FUNCTION__)); |
|---|
| 1414 | 1425 | |
|---|
| 1415 | 1426 | DHD_MUTEX_LOCK(); |
|---|
| .. | .. |
|---|
| 1419 | 1430 | dhd_dbus_disconnect_cb(g_pub->bus); |
|---|
| 1420 | 1431 | } |
|---|
| 1421 | 1432 | } |
|---|
| 1433 | + probe_cb = NULL; |
|---|
| 1422 | 1434 | DHD_MUTEX_UNLOCK(); |
|---|
| 1423 | | - dbus_bus_deregister(); |
|---|
| 1435 | + ret = dbus_bus_deregister(); |
|---|
| 1436 | + disconnect_cb = NULL; |
|---|
| 1437 | + probe_arg = NULL; |
|---|
| 1424 | 1438 | } |
|---|
| 1425 | 1439 | |
|---|
| 1426 | 1440 | /** As part of initialization, data structures have to be allocated and initialized */ |
|---|
| .. | .. |
|---|
| 1586 | 1600 | } |
|---|
| 1587 | 1601 | |
|---|
| 1588 | 1602 | #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) |
|---|
| 1590 | 1604 | { |
|---|
| 1591 | 1605 | dhd_bus_t *dhd_bus = (dhd_bus_t *) pub; |
|---|
| 1592 | 1606 | int err = DBUS_OK; |
|---|
| .. | .. |
|---|
| 1599 | 1613 | DBUSTRACE(("%s: state %d\n", __FUNCTION__, dhd_bus->pub.busstate)); |
|---|
| 1600 | 1614 | |
|---|
| 1601 | 1615 | 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 |
|---|
| 1602 | 1619 | err = dbus_do_download(dhd_bus); |
|---|
| 1620 | +#endif /* EXTERNAL_FW_PATH */ |
|---|
| 1603 | 1621 | if (err == DBUS_OK) { |
|---|
| 1604 | 1622 | dhd_bus->pub.busstate = DBUS_STATE_DL_DONE; |
|---|
| 1605 | 1623 | } else { |
|---|
| .. | .. |
|---|
| 1700 | 1718 | return DBUS_ERR; |
|---|
| 1701 | 1719 | } |
|---|
| 1702 | 1720 | |
|---|
| 1721 | +int dbus_send_txdata(dbus_pub_t *dbus, void *pktbuf) |
|---|
| 1722 | +{ |
|---|
| 1723 | + return dbus_send_pkt(dbus, pktbuf, pktbuf /* pktinfo */); |
|---|
| 1724 | +} |
|---|
| 1725 | + |
|---|
| 1703 | 1726 | int |
|---|
| 1704 | 1727 | dbus_send_buf(dbus_pub_t *pub, uint8 *buf, int len, void *info) |
|---|
| 1705 | 1728 | { |
|---|
| 1706 | 1729 | return dbus_send_irb(pub, buf, len, NULL, info); |
|---|
| 1707 | 1730 | } |
|---|
| 1708 | 1731 | |
|---|
| 1709 | | -static int |
|---|
| 1732 | +int |
|---|
| 1710 | 1733 | dbus_send_pkt(dbus_pub_t *pub, void *pkt, void *info) |
|---|
| 1711 | 1734 | { |
|---|
| 1712 | 1735 | return dbus_send_irb(pub, NULL, 0, pkt, info); |
|---|
| 1713 | 1736 | } |
|---|
| 1714 | 1737 | |
|---|
| 1715 | | -static int |
|---|
| 1738 | +int |
|---|
| 1716 | 1739 | dbus_send_ctl(struct dhd_bus *pub, uint8 *buf, int len) |
|---|
| 1717 | 1740 | { |
|---|
| 1718 | 1741 | dhd_bus_t *dhd_bus = (dhd_bus_t *) pub; |
|---|
| .. | .. |
|---|
| 1733 | 1756 | return DBUS_ERR; |
|---|
| 1734 | 1757 | } |
|---|
| 1735 | 1758 | |
|---|
| 1736 | | -static int |
|---|
| 1759 | +int |
|---|
| 1737 | 1760 | dbus_recv_ctl(struct dhd_bus *pub, uint8 *buf, int len) |
|---|
| 1738 | 1761 | { |
|---|
| 1739 | 1762 | dhd_bus_t *dhd_bus = (dhd_bus_t *) pub; |
|---|
| .. | .. |
|---|
| 1745 | 1768 | dhd_bus->pub.busstate == DBUS_STATE_SLEEP) { |
|---|
| 1746 | 1769 | if (dhd_bus->drvintf && dhd_bus->drvintf->recv_ctl) |
|---|
| 1747 | 1770 | 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)); |
|---|
| 1750 | 1771 | } |
|---|
| 1751 | 1772 | |
|---|
| 1752 | 1773 | return DBUS_ERR; |
|---|
| .. | .. |
|---|
| 1785 | 1806 | return DBUS_ERR; |
|---|
| 1786 | 1807 | } |
|---|
| 1787 | 1808 | |
|---|
| 1788 | | -#ifdef INTR_EP_ENABLE |
|---|
| 1789 | 1809 | /** only called by dhd_cdc.c (Dec 2012) */ |
|---|
| 1790 | | -static int |
|---|
| 1810 | +int |
|---|
| 1791 | 1811 | dbus_poll_intr(dbus_pub_t *pub) |
|---|
| 1792 | 1812 | { |
|---|
| 1793 | 1813 | dhd_bus_t *dhd_bus = (dhd_bus_t *) pub; |
|---|
| .. | .. |
|---|
| 1805 | 1825 | } |
|---|
| 1806 | 1826 | return status; |
|---|
| 1807 | 1827 | } |
|---|
| 1808 | | -#endif /* INTR_EP_ENABLE */ |
|---|
| 1809 | 1828 | |
|---|
| 1810 | 1829 | /** called by nobody (Dec 2012) */ |
|---|
| 1811 | 1830 | void * |
|---|
| .. | .. |
|---|
| 2442 | 2461 | dhd->tx_ctlerrs++; |
|---|
| 2443 | 2462 | } |
|---|
| 2444 | 2463 | |
|---|
| 2445 | | - dhd->bus->ctl_completed = TRUE; |
|---|
| 2446 | | - dhd_os_ioctl_resp_wake(dhd); |
|---|
| 2464 | + dhd_prot_ctl_complete(dhd); |
|---|
| 2447 | 2465 | } |
|---|
| 2448 | 2466 | |
|---|
| 2449 | 2467 | static void |
|---|
| 2450 | 2468 | dhd_dbus_state_change(void *handle, int state) |
|---|
| 2451 | 2469 | { |
|---|
| 2452 | 2470 | dhd_pub_t *dhd = (dhd_pub_t *)handle; |
|---|
| 2453 | | - unsigned long flags; |
|---|
| 2454 | | - wifi_adapter_info_t *adapter; |
|---|
| 2455 | | - int wowl_dngldown = 0; |
|---|
| 2456 | 2471 | |
|---|
| 2457 | 2472 | if (dhd == NULL) { |
|---|
| 2458 | 2473 | DBUSERR(("%s: dhd is NULL\n", __FUNCTION__)); |
|---|
| 2459 | 2474 | return; |
|---|
| 2460 | 2475 | } |
|---|
| 2461 | | - adapter = (wifi_adapter_info_t *)dhd->adapter; |
|---|
| 2462 | | -#ifdef WL_EXT_WOWL |
|---|
| 2463 | | - wowl_dngldown = dhd_conf_wowl_dngldown(dhd); |
|---|
| 2464 | | -#endif |
|---|
| 2465 | 2476 | |
|---|
| 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 | | - } |
|---|
| 2471 | 2477 | switch (state) { |
|---|
| 2478 | + |
|---|
| 2472 | 2479 | case DBUS_STATE_DL_NEEDED: |
|---|
| 2473 | 2480 | DBUSERR(("%s: firmware request cannot be handled\n", __FUNCTION__)); |
|---|
| 2474 | 2481 | break; |
|---|
| 2475 | 2482 | case DBUS_STATE_DOWN: |
|---|
| 2476 | | - DHD_LINUX_GENERAL_LOCK(dhd, flags); |
|---|
| 2477 | | - dhd_txflowcontrol(dhd, ALL_INTERFACES, ON); |
|---|
| 2478 | 2483 | DBUSTRACE(("%s: DBUS is down\n", __FUNCTION__)); |
|---|
| 2479 | 2484 | dhd->busstate = DHD_BUS_DOWN; |
|---|
| 2480 | | - DHD_LINUX_GENERAL_UNLOCK(dhd, flags); |
|---|
| 2481 | 2485 | break; |
|---|
| 2482 | 2486 | case DBUS_STATE_UP: |
|---|
| 2483 | 2487 | DBUSTRACE(("%s: DBUS is up\n", __FUNCTION__)); |
|---|
| 2484 | | - DHD_LINUX_GENERAL_LOCK(dhd, flags); |
|---|
| 2485 | | - dhd_txflowcontrol(dhd, ALL_INTERFACES, OFF); |
|---|
| 2486 | 2488 | dhd->busstate = DHD_BUS_DATA; |
|---|
| 2487 | | - DHD_LINUX_GENERAL_UNLOCK(dhd, flags); |
|---|
| 2488 | 2489 | break; |
|---|
| 2489 | 2490 | default: |
|---|
| 2490 | 2491 | break; |
|---|
| .. | .. |
|---|
| 2576 | 2577 | struct device * |
|---|
| 2577 | 2578 | dhd_bus_to_dev(struct dhd_bus *bus) |
|---|
| 2578 | 2579 | { |
|---|
| 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; |
|---|
| 2580 | 2588 | } |
|---|
| 2581 | 2589 | |
|---|
| 2582 | 2590 | void |
|---|
| .. | .. |
|---|
| 2598 | 2606 | DBUSTRACE(("txoff\n")); |
|---|
| 2599 | 2607 | return BCME_EPERM; |
|---|
| 2600 | 2608 | } |
|---|
| 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); |
|---|
| 2686 | 2610 | } |
|---|
| 2687 | 2611 | |
|---|
| 2688 | 2612 | static void |
|---|
| .. | .. |
|---|
| 2712 | 2636 | int timeleft; |
|---|
| 2713 | 2637 | |
|---|
| 2714 | 2638 | 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; |
|---|
| 2717 | 2640 | DHD_LINUX_GENERAL_UNLOCK(dhdp, flags); |
|---|
| 2718 | 2641 | |
|---|
| 2719 | 2642 | timeleft = dhd_os_busbusy_wait_negation(dhdp, &dhdp->dhd_bus_busy_state); |
|---|
| .. | .. |
|---|
| 2806 | 2729 | |
|---|
| 2807 | 2730 | } |
|---|
| 2808 | 2731 | |
|---|
| 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 | | - |
|---|
| 2942 | 2732 | /* |
|---|
| 2943 | 2733 | * hdrlen is space to reserve in pkt headroom for DBUS |
|---|
| 2944 | 2734 | */ |
|---|
| 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) |
|---|
| 2947 | 2738 | { |
|---|
| 2948 | 2739 | osl_t *osh = NULL; |
|---|
| 2949 | 2740 | dhd_bus_t *bus = NULL; |
|---|
| 2950 | 2741 | dhd_pub_t *pub = NULL; |
|---|
| 2951 | 2742 | uint rxsz; |
|---|
| 2952 | | - int dlneeded = 0, ret = DBUS_OK; |
|---|
| 2743 | + int dlneeded = 0; |
|---|
| 2953 | 2744 | wifi_adapter_info_t *adapter = NULL; |
|---|
| 2954 | | - bool net_attach_now = TRUE; |
|---|
| 2955 | 2745 | |
|---|
| 2956 | 2746 | DBUSTRACE(("%s: Enter\n", __FUNCTION__)); |
|---|
| 2957 | 2747 | |
|---|
| 2958 | | - adapter = dhd_wifi_platform_get_adapter(USB_BUS, bus_no, slot); |
|---|
| 2748 | + adapter = dhd_wifi_platform_get_adapter(bustype, bus_no, slot); |
|---|
| 2959 | 2749 | |
|---|
| 2960 | 2750 | if (!g_pub) { |
|---|
| 2961 | 2751 | /* 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))) { |
|---|
| 2963 | 2753 | DBUSERR(("%s: OSL attach failed\n", __FUNCTION__)); |
|---|
| 2964 | 2754 | goto fail; |
|---|
| 2965 | 2755 | } |
|---|
| .. | .. |
|---|
| 2986 | 2776 | bus->dhd = pub; |
|---|
| 2987 | 2777 | |
|---|
| 2988 | 2778 | 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 | + } |
|---|
| 2993 | 2785 | } |
|---|
| 2994 | 2786 | |
|---|
| 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) { |
|---|
| 3002 | 2789 | wifi_set_adapter_status(adapter, WIFI_STATUS_FW_READY); |
|---|
| 3003 | 2790 | #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) { |
|---|
| 3010 | 2792 | 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) |
|---|
| 3013 | 2794 | 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 | | - } |
|---|
| 3019 | 2795 | #endif |
|---|
| 3020 | | - else { |
|---|
| 2796 | + } else { |
|---|
| 3021 | 2797 | goto fail; |
|---|
| 3022 | 2798 | } |
|---|
| 3023 | 2799 | } |
|---|
| 3024 | | - } |
|---|
| 3025 | | - else { |
|---|
| 2800 | + } else { |
|---|
| 3026 | 2801 | DBUSERR(("%s: dbus_attach failed\n", __FUNCTION__)); |
|---|
| 3027 | | - goto fail; |
|---|
| 3028 | 2802 | } |
|---|
| 3029 | 2803 | |
|---|
| 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 | + { |
|---|
| 3040 | 2808 | DBUSERR(("%s: Net attach failed!!\n", __FUNCTION__)); |
|---|
| 3041 | 2809 | goto fail; |
|---|
| 3042 | 2810 | } |
|---|
| .. | .. |
|---|
| 3044 | 2812 | #if defined(MULTIPLE_SUPPLICANT) |
|---|
| 3045 | 2813 | wl_android_post_init(); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe |
|---|
| 3046 | 2814 | #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) { |
|---|
| 3063 | 2815 | g_pub = pub; |
|---|
| 3064 | 2816 | } |
|---|
| 3065 | 2817 | |
|---|
| 3066 | 2818 | 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 */ |
|---|
| 3073 | 2823 | return bus; |
|---|
| 3074 | 2824 | |
|---|
| 3075 | 2825 | fail: |
|---|
| .. | .. |
|---|
| 3092 | 2842 | return NULL; |
|---|
| 3093 | 2843 | } |
|---|
| 3094 | 2844 | |
|---|
| 3095 | | -static void |
|---|
| 2845 | +void |
|---|
| 3096 | 2846 | dhd_dbus_disconnect_cb(void *arg) |
|---|
| 3097 | 2847 | { |
|---|
| 3098 | 2848 | dhd_bus_t *bus = (dhd_bus_t *)arg; |
|---|
| .. | .. |
|---|
| 3118 | 2868 | dhd_dbus_advertise_bus_remove(bus->dhd); |
|---|
| 3119 | 2869 | dbus_detach(pub->bus); |
|---|
| 3120 | 2870 | 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); |
|---|
| 3122 | 2873 | wake_up_interruptible(&adapter->status_event); |
|---|
| 3123 | 2874 | } else { |
|---|
| 3124 | 2875 | osh = pub->osh; |
|---|
| .. | .. |
|---|
| 3129 | 2880 | } |
|---|
| 3130 | 2881 | dhd_free(pub); |
|---|
| 3131 | 2882 | g_pub = NULL; |
|---|
| 3132 | | - net_attached = FALSE; |
|---|
| 3133 | | - wifi_clr_adapter_status(adapter, WIFI_STATUS_NET_ATTACHED); |
|---|
| 3134 | 2883 | if (MALLOCED(osh)) { |
|---|
| 3135 | 2884 | DBUSERR(("%s: MEMORY LEAK %d bytes\n", __FUNCTION__, MALLOCED(osh))); |
|---|
| 3136 | 2885 | } |
|---|
| .. | .. |
|---|
| 3138 | 2887 | } |
|---|
| 3139 | 2888 | |
|---|
| 3140 | 2889 | 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; |
|---|
| 3159 | 2890 | } |
|---|
| 3160 | 2891 | |
|---|
| 3161 | 2892 | #ifdef LINUX_EXTERNAL_MODULE_DBUS |
|---|
| .. | .. |
|---|
| 3175 | 2906 | } |
|---|
| 3176 | 2907 | |
|---|
| 3177 | 2908 | EXPORT_SYMBOL(dbus_pnp_sleep); |
|---|
| 3178 | | -EXPORT_SYMBOL(dhd_bus_register); |
|---|
| 3179 | 2909 | EXPORT_SYMBOL(dbus_get_devinfo); |
|---|
| 3180 | 2910 | EXPORT_SYMBOL(dbus_detach); |
|---|
| 3181 | 2911 | EXPORT_SYMBOL(dbus_get_attrib); |
|---|
| .. | .. |
|---|
| 3188 | 2918 | EXPORT_SYMBOL(dbus_send_pkt); |
|---|
| 3189 | 2919 | EXPORT_SYMBOL(dbus_recv_ctl); |
|---|
| 3190 | 2920 | EXPORT_SYMBOL(dbus_attach); |
|---|
| 3191 | | -EXPORT_SYMBOL(dhd_bus_unregister); |
|---|
| 3192 | 2921 | |
|---|
| 3193 | 2922 | MODULE_LICENSE("GPL"); |
|---|
| 3194 | 2923 | |
|---|