2015-08-18 19:03:09 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
* Copyright(c) 2007 - 2017 Realtek Corporation.
|
2015-08-18 19:03:09 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
2019-11-09 10:12:08 +00:00
|
|
|
*****************************************************************************/
|
2015-08-18 19:03:09 +00:00
|
|
|
#define _HCI_INTF_C_
|
|
|
|
|
|
|
|
#include <drv_types.h>
|
2017-05-11 18:47:23 +00:00
|
|
|
#include <hal_data.h>
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#include <platform_ops.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_USB_HCI
|
|
|
|
#error "CONFIG_USB_HCI shall be on!\n"
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(PLATFORM_LINUX) && defined (PLATFORM_WINDOWS)
|
2015-08-18 19:03:09 +00:00
|
|
|
#error "Shall be Linux or Windows, but not both!\n"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_80211N_HT
|
|
|
|
extern int rtw_ht_enable;
|
|
|
|
extern int rtw_bw_mode;
|
2019-11-09 10:12:08 +00:00
|
|
|
extern int rtw_ampdu_enable;/* for enable tx_ampdu */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_GLOBAL_UI_PID
|
|
|
|
int ui_pid[3] = {0, 0, 0};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
extern int pm_netdev_open(struct net_device *pnetdev, u8 bnormal);
|
2015-08-18 19:03:09 +00:00
|
|
|
static int rtw_suspend(struct usb_interface *intf, pm_message_t message);
|
|
|
|
static int rtw_resume(struct usb_interface *intf);
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid);
|
2015-08-18 19:03:09 +00:00
|
|
|
static void rtw_dev_remove(struct usb_interface *pusb_intf);
|
|
|
|
|
|
|
|
static void rtw_dev_shutdown(struct device *dev)
|
|
|
|
{
|
|
|
|
struct usb_interface *usb_intf = container_of(dev, struct usb_interface, dev);
|
|
|
|
struct dvobj_priv *dvobj = NULL;
|
|
|
|
_adapter *adapter = NULL;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s\n", __func__);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (usb_intf) {
|
2015-08-18 19:03:09 +00:00
|
|
|
dvobj = usb_get_intfdata(usb_intf);
|
2019-11-09 10:12:08 +00:00
|
|
|
if (dvobj) {
|
|
|
|
adapter = dvobj_get_primary_adapter(dvobj);
|
|
|
|
if (adapter) {
|
|
|
|
if (!rtw_is_surprise_removed(adapter)) {
|
|
|
|
#ifdef CONFIG_WOWLAN
|
|
|
|
struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(adapter);
|
|
|
|
|
|
|
|
#ifdef CONFIG_GPIO_WAKEUP
|
|
|
|
/*default wake up pin change to BT*/
|
|
|
|
RTW_INFO("%s:default wake up pin change to BT\n", __FUNCTION__);
|
|
|
|
rtw_hal_switch_gpio_wl_ctrl(adapter, WAKEUP_GPIO_IDX, _FALSE);
|
|
|
|
#endif /* CONFIG_GPIO_WAKEUP */
|
|
|
|
|
|
|
|
if (pwrctl->wowlan_mode == _TRUE)
|
|
|
|
RTW_PRINT("%s wowlan_mode ==_TRUE do not run rtw_hal_deinit()\n", __FUNCTION__);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
rtw_hal_deinit(adapter);
|
|
|
|
rtw_set_surprise_removed(adapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ATOMIC_SET(&dvobj->continual_io_error, MAX_CONTINUAL_IO_ERR + 1);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23))
|
2015-08-18 19:03:09 +00:00
|
|
|
/* Some useful macros to use to create struct usb_device_id */
|
2019-11-09 10:12:08 +00:00
|
|
|
#define USB_DEVICE_ID_MATCH_VENDOR 0x0001
|
|
|
|
#define USB_DEVICE_ID_MATCH_PRODUCT 0x0002
|
|
|
|
#define USB_DEVICE_ID_MATCH_DEV_LO 0x0004
|
|
|
|
#define USB_DEVICE_ID_MATCH_DEV_HI 0x0008
|
|
|
|
#define USB_DEVICE_ID_MATCH_DEV_CLASS 0x0010
|
|
|
|
#define USB_DEVICE_ID_MATCH_DEV_SUBCLASS 0x0020
|
|
|
|
#define USB_DEVICE_ID_MATCH_DEV_PROTOCOL 0x0040
|
|
|
|
#define USB_DEVICE_ID_MATCH_INT_CLASS 0x0080
|
|
|
|
#define USB_DEVICE_ID_MATCH_INT_SUBCLASS 0x0100
|
|
|
|
#define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
|
|
|
|
#define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define USB_DEVICE_ID_MATCH_INT_INFO \
|
2019-11-09 10:12:08 +00:00
|
|
|
(USB_DEVICE_ID_MATCH_INT_CLASS | \
|
|
|
|
USB_DEVICE_ID_MATCH_INT_SUBCLASS | \
|
|
|
|
USB_DEVICE_ID_MATCH_INT_PROTOCOL)
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
|
2019-11-09 10:12:08 +00:00
|
|
|
.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
|
|
|
|
| USB_DEVICE_ID_MATCH_DEVICE, \
|
|
|
|
.idVendor = (vend), \
|
|
|
|
.idProduct = (prod), \
|
|
|
|
.bInterfaceClass = (cl), \
|
|
|
|
.bInterfaceSubClass = (sc), \
|
|
|
|
.bInterfaceProtocol = (pr)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* USB_VENDOR_AND_INTERFACE_INFO - describe a specific usb vendor with a class of usb interfaces
|
|
|
|
* @vend: the 16 bit USB Vendor ID
|
|
|
|
* @cl: bInterfaceClass value
|
|
|
|
* @sc: bInterfaceSubClass value
|
|
|
|
* @pr: bInterfaceProtocol value
|
|
|
|
*
|
|
|
|
* This macro is used to create a struct usb_device_id that matches a
|
|
|
|
* specific vendor with a specific class of interfaces.
|
|
|
|
*
|
|
|
|
* This is especially useful when explicitly matching devices that have
|
|
|
|
* vendor specific bDeviceClass values, but standards-compliant interfaces.
|
|
|
|
*/
|
2015-08-18 19:03:09 +00:00
|
|
|
#define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \
|
2019-11-09 10:12:08 +00:00
|
|
|
.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
|
|
|
|
| USB_DEVICE_ID_MATCH_VENDOR, \
|
|
|
|
.idVendor = (vend), \
|
|
|
|
.bInterfaceClass = (cl), \
|
|
|
|
.bInterfaceSubClass = (sc), \
|
|
|
|
.bInterfaceProtocol = (pr)
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
/* ----------------------------------------------------------------------- */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define USB_VENDER_ID_REALTEK 0x0BDA
|
|
|
|
|
|
|
|
|
|
|
|
/* DID_USB_v916_20130116 */
|
2019-11-09 10:12:08 +00:00
|
|
|
static struct usb_device_id rtw_usb_id_tbl[] = {
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_RTL8188E
|
|
|
|
/*=== Realtek demoboard ===*/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179), .driver_info = RTL8188E}, /* 8188EUS */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179), .driver_info = RTL8188E}, /* 8188ETV */
|
2017-05-11 18:35:20 +00:00
|
|
|
/*=== Customer ID ===*/
|
|
|
|
/****** 8188EUS ********/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(0x07B8, 0x8179), .driver_info = RTL8188E}, /* Abocom - Abocom */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8812A
|
|
|
|
/*=== Realtek demoboard ===*/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8812), .driver_info = RTL8812}, /* Default ID */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881A), .driver_info = RTL8812}, /* Default ID */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881B), .driver_info = RTL8812}, /* Default ID */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x881C), .driver_info = RTL8812}, /* Default ID */
|
2015-08-18 19:03:09 +00:00
|
|
|
/*=== Customer ID ===*/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(0x050D, 0x1106), .driver_info = RTL8812}, /* Belkin - sercomm */
|
|
|
|
{USB_DEVICE(0x2001, 0x330E), .driver_info = RTL8812}, /* D-Link - ALPHA */
|
|
|
|
{USB_DEVICE(0x7392, 0xA822), .driver_info = RTL8812}, /* Edimax - Edimax */
|
|
|
|
{USB_DEVICE(0x0DF6, 0x0074), .driver_info = RTL8812}, /* Sitecom - Edimax */
|
|
|
|
{USB_DEVICE(0x04BB, 0x0952), .driver_info = RTL8812}, /* I-O DATA - Edimax */
|
|
|
|
{USB_DEVICE(0x0789, 0x016E), .driver_info = RTL8812}, /* Logitec - Edimax */
|
|
|
|
{USB_DEVICE(0x0409, 0x0408), .driver_info = RTL8812}, /* NEC - */
|
|
|
|
{USB_DEVICE(0x0B05, 0x17D2), .driver_info = RTL8812}, /* ASUS - Edimax */
|
|
|
|
{USB_DEVICE(0x0E66, 0x0022), .driver_info = RTL8812}, /* HAWKING - Edimax */
|
|
|
|
{USB_DEVICE(0x0586, 0x3426), .driver_info = RTL8812}, /* ZyXEL - */
|
|
|
|
{USB_DEVICE(0x2001, 0x3313), .driver_info = RTL8812}, /* D-Link - ALPHA */
|
|
|
|
{USB_DEVICE(0x1058, 0x0632), .driver_info = RTL8812}, /* WD - Cybertan*/
|
|
|
|
{USB_DEVICE(0x1740, 0x0100), .driver_info = RTL8812}, /* EnGenius - EnGenius */
|
|
|
|
{USB_DEVICE(0x2019, 0xAB30), .driver_info = RTL8812}, /* Planex - Abocom */
|
|
|
|
{USB_DEVICE(0x07B8, 0x8812), .driver_info = RTL8812}, /* Abocom - Abocom */
|
|
|
|
{USB_DEVICE(0x2001, 0x3315), .driver_info = RTL8812}, /* D-Link - Cameo */
|
|
|
|
{USB_DEVICE(0x2001, 0x3316), .driver_info = RTL8812}, /* D-Link - Cameo */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8821A
|
2019-11-09 10:12:08 +00:00
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0811), .driver_info = RTL8821}, /* Default ID */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0821), .driver_info = RTL8821}, /* Default ID */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8822), .driver_info = RTL8821}, /* Default ID */
|
2017-05-11 18:47:23 +00:00
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0xA811) , .driver_info = RTL8821},/* Default ID */
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x0820, 0xff, 0xff, 0xff), .driver_info = RTL8821}, /* 8821AU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x0823, 0xff, 0xff, 0xff), .driver_info = RTL8821}, /* 8821AU */
|
2017-05-11 18:35:20 +00:00
|
|
|
/*=== Customer ID ===*/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(0x7392, 0xA811), .driver_info = RTL8821}, /* Edimax - Edimax */
|
|
|
|
{USB_DEVICE(0x04BB, 0x0953), .driver_info = RTL8821}, /* I-O DATA - Edimax */
|
|
|
|
{USB_DEVICE(0x2001, 0x3314), .driver_info = RTL8821}, /* D-Link - Cameo */
|
|
|
|
{USB_DEVICE(0x2001, 0x3318), .driver_info = RTL8821}, /* D-Link - Cameo */
|
|
|
|
{USB_DEVICE(0x0E66, 0x0023), .driver_info = RTL8821}, /* HAWKING - Edimax */
|
2017-05-11 18:47:23 +00:00
|
|
|
{USB_DEVICE(0x056E, 0x400E) , .driver_info = RTL8821}, /* ELECOM - ELECOM */
|
|
|
|
{USB_DEVICE(0x056E, 0x400F) , .driver_info = RTL8821}, /* ELECOM - ELECOM */
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE(0x20f4, 0x804b), .driver_info = RTL8821}, /* TRENDnet */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8192E
|
|
|
|
/*=== Realtek demoboard ===*/
|
2019-11-09 10:12:08 +00:00
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x818B, 0xff, 0xff, 0xff), .driver_info = RTL8192E}, /* Default ID */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x818C, 0xff, 0xff, 0xff), .driver_info = RTL8192E}, /* Default ID */
|
2017-04-30 19:05:11 +00:00
|
|
|
/*===TPLINK ID===========*/
|
|
|
|
{USB_DEVICE(0x2357, 0x0107),.driver_info = RTL8192E}, /* TP-Link - Cameo */
|
|
|
|
{USB_DEVICE(0x2357, 0x0108),.driver_info = RTL8192E}, /* TP-Link - Cameo */
|
|
|
|
{USB_DEVICE(0x2357, 0x0109),.driver_info = RTL8192E}, /* TP-Link - Cameo */
|
2018-09-08 13:59:44 +00:00
|
|
|
{USB_DEVICE(0x2357, 0x0126),.driver_info = RTL8192E}, /* TP-Link TL-WN8200ND V2 */
|
2016-09-27 06:22:00 +00:00
|
|
|
/*=== PLANEX ===========*/
|
|
|
|
{USB_DEVICE(0x2019, 0xab33),.driver_info = RTL8192E}, /* PLANEX - GW-300S Katana */
|
2017-07-10 19:04:43 +00:00
|
|
|
/*=== Customer ID ===*/
|
|
|
|
{USB_DEVICE(0x2001, 0x3319),.driver_info = RTL8192E}, /* D-Link - DWA-131 */
|
2019-09-10 19:35:58 +00:00
|
|
|
{USB_DEVICE(0x2c4e, 0x0100),.driver_info = RTL8192E}, /* Mercusys MW300UM */
|
|
|
|
{USB_DEVICE(0x2c4e, 0x0104),.driver_info = RTL8192E}, /* Mercusys MW300UH */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8723B
|
2019-11-09 10:12:08 +00:00
|
|
|
/* === Realtek demoboard === */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xB720, 0xff, 0xff, 0xff), .driver_info = RTL8723B}, /* 8723BU 1*1 */
|
|
|
|
/* {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xB720),.driver_info = RTL8723B}, 8723BU */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8703B
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xB703, 0xff, 0xff, 0xff), .driver_info = RTL8703B}, /* 8723CU 1*1 */
|
|
|
|
/* {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xB703), .driver_info = RTL723C}, */ /* 8723CU 1*1 */
|
|
|
|
#endif /* CONFIG_RTL8703B */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8814A
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8813), .driver_info = RTL8814A},
|
2017-05-11 18:47:23 +00:00
|
|
|
{USB_DEVICE(0x2001, 0x331a), .driver_info = RTL8814A}, /* D-Link - D-Link */
|
|
|
|
{USB_DEVICE(0x0b05, 0x1817), .driver_info = RTL8814A}, /* ASUS - ASUSTeK */
|
|
|
|
{USB_DEVICE(0x056E, 0x400B), .driver_info = RTL8814A}, /* ELECOM - ELECOM */
|
|
|
|
{USB_DEVICE(0x056E, 0x400D), .driver_info = RTL8814A}, /* ELECOM - ELECOM */
|
|
|
|
{USB_DEVICE(0x7392, 0xA834), .driver_info = RTL8814A}, /* Edimax - Edimax */
|
|
|
|
#endif /* CONFIG_RTL8814A */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8188F
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xF179, 0xff, 0xff, 0xff), .driver_info = RTL8188F}, /* 8188FU 1*1 */
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188GTV
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x018C, 0xff, 0xff, 0xff), .driver_info = RTL8188GTV}, /* 8188GTV 1*1 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8822B
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xB82C, 0xff, 0xff, 0xff), .driver_info = RTL8822B}, /* Default ID for USB multi-function */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xB812, 0xff, 0xff, 0xff), .driver_info = RTL8822B}, /* Default ID for USB Single-function, WiFi only */
|
|
|
|
/*=== Customer ID ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(0x13b1, 0x0043, 0xff, 0xff, 0xff), .driver_info = RTL8822B}, /* Alpha - Alpha*/
|
|
|
|
#endif /* CONFIG_RTL8822B */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8723D
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xD723, 0xff, 0xff, 0xff), .driver_info = RTL8723D}, /* 8723DU 1*1 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8192F
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xF192, 0xff, 0xff, 0xff), .driver_info = RTL8192F}, /* 8192FU 2*2 */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8821C
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xb82b, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xb820, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC821, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC820, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC82A, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC82B, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8821CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xC811, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8811CU */
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0x8811, 0xff, 0xff, 0xff), .driver_info = RTL8821C}, /* 8811CU */
|
|
|
|
/*=== Customer ID ===*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8710B
|
|
|
|
/*=== Realtek dongle ===*/
|
|
|
|
{USB_DEVICE_AND_INTERFACE_INFO(USB_VENDER_ID_REALTEK, 0xB711, 0xff, 0xff, 0xff), .driver_info = RTL8710B}, /* 8710B = 8188GU 1*1 */
|
|
|
|
#endif
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
{} /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
|
|
|
|
|
|
|
|
int const rtw_usb_id_len = sizeof(rtw_usb_id_tbl) / sizeof(struct usb_device_id);
|
|
|
|
|
|
|
|
static struct specific_device_id specific_device_id_tbl[] = {
|
2019-11-09 10:12:08 +00:00
|
|
|
{.idVendor = USB_VENDER_ID_REALTEK, .idProduct = 0x8177, .flags = SPEC_DEV_ID_DISABLE_HT}, /* 8188cu 1*1 dongole, (b/g mode only) */
|
|
|
|
{.idVendor = USB_VENDER_ID_REALTEK, .idProduct = 0x817E, .flags = SPEC_DEV_ID_DISABLE_HT}, /* 8188CE-VAU USB minCard (b/g mode only) */
|
|
|
|
{.idVendor = 0x0b05, .idProduct = 0x1791, .flags = SPEC_DEV_ID_DISABLE_HT},
|
|
|
|
{.idVendor = 0x13D3, .idProduct = 0x3311, .flags = SPEC_DEV_ID_DISABLE_HT},
|
|
|
|
{.idVendor = 0x13D3, .idProduct = 0x3359, .flags = SPEC_DEV_ID_DISABLE_HT}, /* Russian customer -Azwave (8188CE-VAU g mode) */
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef RTK_DMP_PLATFORM
|
2019-11-09 10:12:08 +00:00
|
|
|
{.idVendor = USB_VENDER_ID_REALTEK, .idProduct = 0x8111, .flags = SPEC_DEV_ID_ASSIGN_IFNAME}, /* Realtek 5G dongle for WiFi Display */
|
|
|
|
{.idVendor = 0x2019, .idProduct = 0xAB2D, .flags = SPEC_DEV_ID_ASSIGN_IFNAME}, /* PCI-Abocom 5G dongle for WiFi Display */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif /* RTK_DMP_PLATFORM */
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rtw_usb_drv {
|
|
|
|
struct usb_driver usbdrv;
|
|
|
|
int drv_registered;
|
|
|
|
u8 hw_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct rtw_usb_drv usb_drv = {
|
2019-11-09 10:12:08 +00:00
|
|
|
.usbdrv.name = (char *)DRV_NAME,
|
2015-08-18 19:03:09 +00:00
|
|
|
.usbdrv.probe = rtw_drv_init,
|
|
|
|
.usbdrv.disconnect = rtw_dev_remove,
|
|
|
|
.usbdrv.id_table = rtw_usb_id_tbl,
|
|
|
|
.usbdrv.suspend = rtw_suspend,
|
|
|
|
.usbdrv.resume = rtw_resume,
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 22))
|
|
|
|
.usbdrv.reset_resume = rtw_resume,
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
2015-08-18 19:03:09 +00:00
|
|
|
.usbdrv.supports_autosuspend = 1,
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19))
|
2015-08-18 19:03:09 +00:00
|
|
|
.usbdrv.drvwrap.driver.shutdown = rtw_dev_shutdown,
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
2015-08-18 19:03:09 +00:00
|
|
|
.usbdrv.driver.shutdown = rtw_dev_shutdown,
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd)
|
|
|
|
{
|
|
|
|
return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj)
|
|
|
|
{
|
|
|
|
u8 rst = _SUCCESS;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_USB_VENDOR_REQ_MUTEX
|
2015-08-18 19:03:09 +00:00
|
|
|
_rtw_mutex_init(&dvobj->usb_vendor_req_mutex);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
|
2015-08-18 19:03:09 +00:00
|
|
|
dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE);
|
|
|
|
if (dvobj->usb_alloc_vendor_req_buf == NULL) {
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("alloc usb_vendor_req_buf failed... /n");
|
2015-08-18 19:03:09 +00:00
|
|
|
rst = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
dvobj->usb_vendor_req_buf =
|
2019-11-09 10:12:08 +00:00
|
|
|
(u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(dvobj->usb_alloc_vendor_req_buf), ALIGNMENT_UNIT);
|
2015-08-18 19:03:09 +00:00
|
|
|
exit:
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
return rst;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj)
|
|
|
|
{
|
|
|
|
u8 rst = _SUCCESS;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC
|
|
|
|
if (dvobj->usb_vendor_req_buf)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_mfree(dvobj->usb_alloc_vendor_req_buf, MAX_USB_IO_CTL_SIZE);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_USB_VENDOR_REQ_MUTEX
|
2015-08-18 19:03:09 +00:00
|
|
|
_rtw_mutex_free(&dvobj->usb_vendor_req_mutex);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
return rst;
|
|
|
|
}
|
2017-05-11 18:47:23 +00:00
|
|
|
static void rtw_decide_chip_type_by_usb_info(struct dvobj_priv *pdvobjpriv, const struct usb_device_id *pdid)
|
|
|
|
{
|
|
|
|
pdvobjpriv->chip_type = pdid->driver_info;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188E
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8188E)
|
|
|
|
rtl8188eu_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8812 || pdvobjpriv->chip_type == RTL8821)
|
|
|
|
rtl8812au_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8192E
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8192E)
|
|
|
|
rtl8192eu_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8723B
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8723B)
|
|
|
|
rtl8723bu_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8814A
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8814A)
|
|
|
|
rtl8814au_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_RTL8814A */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188F
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8188F)
|
|
|
|
rtl8188fu_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8188GTV
|
|
|
|
if (pdvobjpriv->chip_type == RTL8188GTV)
|
|
|
|
rtl8188gtvu_set_hw_type(pdvobjpriv);
|
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8703B
|
2017-05-11 18:47:23 +00:00
|
|
|
if (pdvobjpriv->chip_type == RTL8703B)
|
|
|
|
rtl8703bu_set_hw_type(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_RTL8703B */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8822B
|
|
|
|
if (pdvobjpriv->chip_type == RTL8822B)
|
|
|
|
rtl8822bu_set_hw_type(pdvobjpriv);
|
|
|
|
#endif /* CONFIG_RTL8822B */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8723D
|
|
|
|
if (pdvobjpriv->chip_type == RTL8723D)
|
|
|
|
rtl8723du_set_hw_type(pdvobjpriv);
|
|
|
|
#endif /* CONFIG_RTL8723D */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8821C
|
|
|
|
if (pdvobjpriv->chip_type == RTL8821C)
|
|
|
|
rtl8821cu_set_hw_type(pdvobjpriv);
|
|
|
|
#endif /* CONFIG_RTL8821C */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8710B
|
|
|
|
if (pdvobjpriv->chip_type == RTL8710B)
|
|
|
|
rtl8710bu_set_hw_type(pdvobjpriv);
|
|
|
|
#endif /* CONFIG_RTL8710B */
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8192F
|
|
|
|
if (pdvobjpriv->chip_type == RTL8192F)
|
|
|
|
rtl8192fu_set_hw_type(pdvobjpriv);
|
|
|
|
#endif /* CONFIG_RTL8192F */
|
2017-05-11 18:47:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf, const struct usb_device_id *pdid)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int status = _FAIL;
|
|
|
|
struct dvobj_priv *pdvobjpriv;
|
2019-11-09 10:12:08 +00:00
|
|
|
struct usb_device_descriptor *pdev_desc;
|
2015-08-18 19:03:09 +00:00
|
|
|
struct usb_host_config *phost_conf;
|
|
|
|
struct usb_config_descriptor *pconf_desc;
|
|
|
|
struct usb_host_interface *phost_iface;
|
|
|
|
struct usb_interface_descriptor *piface_desc;
|
|
|
|
struct usb_host_endpoint *phost_endp;
|
|
|
|
struct usb_endpoint_descriptor *pendp_desc;
|
|
|
|
struct usb_device *pusbd;
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
pdvobjpriv = devobj_init();
|
|
|
|
if (pdvobjpriv == NULL)
|
2015-08-18 19:03:09 +00:00
|
|
|
goto exit;
|
|
|
|
|
|
|
|
|
|
|
|
pdvobjpriv->pusbintf = usb_intf ;
|
|
|
|
pusbd = pdvobjpriv->pusbdev = interface_to_usbdev(usb_intf);
|
|
|
|
usb_set_intfdata(usb_intf, pdvobjpriv);
|
|
|
|
|
|
|
|
pdvobjpriv->RtNumInPipes = 0;
|
|
|
|
pdvobjpriv->RtNumOutPipes = 0;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* padapter->EepromAddressSize = 6; */
|
|
|
|
/* pdvobjpriv->nr_endpoint = 6; */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
pdev_desc = &pusbd->descriptor;
|
|
|
|
|
|
|
|
#if 0
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("\n8712_usb_device_descriptor:\n");
|
|
|
|
RTW_INFO("bLength=%x\n", pdev_desc->bLength);
|
|
|
|
RTW_INFO("bDescriptorType=%x\n", pdev_desc->bDescriptorType);
|
|
|
|
RTW_INFO("bcdUSB=%x\n", pdev_desc->bcdUSB);
|
|
|
|
RTW_INFO("bDeviceClass=%x\n", pdev_desc->bDeviceClass);
|
|
|
|
RTW_INFO("bDeviceSubClass=%x\n", pdev_desc->bDeviceSubClass);
|
|
|
|
RTW_INFO("bDeviceProtocol=%x\n", pdev_desc->bDeviceProtocol);
|
|
|
|
RTW_INFO("bMaxPacketSize0=%x\n", pdev_desc->bMaxPacketSize0);
|
|
|
|
RTW_INFO("idVendor=%x\n", pdev_desc->idVendor);
|
|
|
|
RTW_INFO("idProduct=%x\n", pdev_desc->idProduct);
|
|
|
|
RTW_INFO("bcdDevice=%x\n", pdev_desc->bcdDevice);
|
|
|
|
RTW_INFO("iManufacturer=%x\n", pdev_desc->iManufacturer);
|
|
|
|
RTW_INFO("iProduct=%x\n", pdev_desc->iProduct);
|
|
|
|
RTW_INFO("iSerialNumber=%x\n", pdev_desc->iSerialNumber);
|
|
|
|
RTW_INFO("bNumConfigurations=%x\n", pdev_desc->bNumConfigurations);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
phost_conf = pusbd->actconfig;
|
|
|
|
pconf_desc = &phost_conf->desc;
|
|
|
|
|
|
|
|
#if 0
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("\n8712_usb_configuration_descriptor:\n");
|
|
|
|
RTW_INFO("bLength=%x\n", pconf_desc->bLength);
|
|
|
|
RTW_INFO("bDescriptorType=%x\n", pconf_desc->bDescriptorType);
|
|
|
|
RTW_INFO("wTotalLength=%x\n", pconf_desc->wTotalLength);
|
|
|
|
RTW_INFO("bNumInterfaces=%x\n", pconf_desc->bNumInterfaces);
|
|
|
|
RTW_INFO("bConfigurationValue=%x\n", pconf_desc->bConfigurationValue);
|
|
|
|
RTW_INFO("iConfiguration=%x\n", pconf_desc->iConfiguration);
|
|
|
|
RTW_INFO("bmAttributes=%x\n", pconf_desc->bmAttributes);
|
|
|
|
RTW_INFO("bMaxPower=%x\n", pconf_desc->bMaxPower);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("\n***** num of altsetting = (%d) *****\n", pusb_interface->num_altsetting); */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
phost_iface = &usb_intf->altsetting[0];
|
|
|
|
piface_desc = &phost_iface->desc;
|
|
|
|
|
|
|
|
#if 0
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("\n8712_usb_interface_descriptor:\n");
|
|
|
|
RTW_INFO("bLength=%x\n", piface_desc->bLength);
|
|
|
|
RTW_INFO("bDescriptorType=%x\n", piface_desc->bDescriptorType);
|
|
|
|
RTW_INFO("bInterfaceNumber=%x\n", piface_desc->bInterfaceNumber);
|
|
|
|
RTW_INFO("bAlternateSetting=%x\n", piface_desc->bAlternateSetting);
|
|
|
|
RTW_INFO("bNumEndpoints=%x\n", piface_desc->bNumEndpoints);
|
|
|
|
RTW_INFO("bInterfaceClass=%x\n", piface_desc->bInterfaceClass);
|
|
|
|
RTW_INFO("bInterfaceSubClass=%x\n", piface_desc->bInterfaceSubClass);
|
|
|
|
RTW_INFO("bInterfaceProtocol=%x\n", piface_desc->bInterfaceProtocol);
|
|
|
|
RTW_INFO("iInterface=%x\n", piface_desc->iInterface);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces;
|
|
|
|
pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber;
|
|
|
|
pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("\ndump usb_endpoint_descriptor:\n"); */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
for (i = 0; i < pdvobjpriv->nr_endpoint; i++) {
|
2015-08-18 19:03:09 +00:00
|
|
|
phost_endp = phost_iface->endpoint + i;
|
2019-11-09 10:12:08 +00:00
|
|
|
if (phost_endp) {
|
2015-08-18 19:03:09 +00:00
|
|
|
pendp_desc = &phost_endp->desc;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("\nusb_endpoint_descriptor(%d):\n", i);
|
|
|
|
RTW_INFO("bLength=%x\n", pendp_desc->bLength);
|
|
|
|
RTW_INFO("bDescriptorType=%x\n", pendp_desc->bDescriptorType);
|
|
|
|
RTW_INFO("bEndpointAddress=%x\n", pendp_desc->bEndpointAddress);
|
|
|
|
/* RTW_INFO("bmAttributes=%x\n",pendp_desc->bmAttributes); */
|
|
|
|
RTW_INFO("wMaxPacketSize=%d\n", le16_to_cpu(pendp_desc->wMaxPacketSize));
|
|
|
|
RTW_INFO("bInterval=%x\n", pendp_desc->bInterval);
|
|
|
|
/* RTW_INFO("bRefresh=%x\n",pendp_desc->bRefresh); */
|
|
|
|
/* RTW_INFO("bSynchAddress=%x\n",pendp_desc->bSynchAddress); */
|
|
|
|
|
|
|
|
if (RT_usb_endpoint_is_bulk_in(pendp_desc)) {
|
|
|
|
RTW_INFO("RT_usb_endpoint_is_bulk_in = %x\n", RT_usb_endpoint_num(pendp_desc));
|
2015-08-18 19:03:09 +00:00
|
|
|
pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
|
|
|
pdvobjpriv->RtNumInPipes++;
|
2019-11-09 10:12:08 +00:00
|
|
|
} else if (RT_usb_endpoint_is_int_in(pendp_desc)) {
|
|
|
|
RTW_INFO("RT_usb_endpoint_is_int_in = %x, Interval = %x\n", RT_usb_endpoint_num(pendp_desc), pendp_desc->bInterval);
|
2015-08-18 19:03:09 +00:00
|
|
|
pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = RT_usb_endpoint_num(pendp_desc);
|
|
|
|
pdvobjpriv->RtNumInPipes++;
|
2019-11-09 10:12:08 +00:00
|
|
|
} else if (RT_usb_endpoint_is_bulk_out(pendp_desc)) {
|
|
|
|
RTW_INFO("RT_usb_endpoint_is_bulk_out = %x\n", RT_usb_endpoint_num(pendp_desc));
|
2015-08-18 19:03:09 +00:00
|
|
|
pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = RT_usb_endpoint_num(pendp_desc);
|
|
|
|
pdvobjpriv->RtNumOutPipes++;
|
|
|
|
}
|
|
|
|
pdvobjpriv->ep_num[i] = RT_usb_endpoint_num(pendp_desc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("nr_endpoint=%d, in_num=%d, out_num=%d\n\n", pdvobjpriv->nr_endpoint, pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes);
|
|
|
|
|
|
|
|
switch (pusbd->speed) {
|
|
|
|
case USB_SPEED_LOW:
|
|
|
|
RTW_INFO("USB_SPEED_LOW\n");
|
|
|
|
pdvobjpriv->usb_speed = RTW_USB_SPEED_1_1;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_FULL:
|
|
|
|
RTW_INFO("USB_SPEED_FULL\n");
|
|
|
|
pdvobjpriv->usb_speed = RTW_USB_SPEED_1_1;
|
|
|
|
break;
|
|
|
|
case USB_SPEED_HIGH:
|
|
|
|
RTW_INFO("USB_SPEED_HIGH\n");
|
|
|
|
pdvobjpriv->usb_speed = RTW_USB_SPEED_2;
|
|
|
|
break;
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 31))
|
|
|
|
case USB_SPEED_SUPER:
|
|
|
|
RTW_INFO("USB_SPEED_SUPER\n");
|
|
|
|
pdvobjpriv->usb_speed = RTW_USB_SPEED_3;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
RTW_INFO("USB_SPEED_UNKNOWN(%x)\n", pusbd->speed);
|
|
|
|
pdvobjpriv->usb_speed = RTW_USB_SPEED_UNKNOWN;
|
|
|
|
break;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pdvobjpriv->usb_speed == RTW_USB_SPEED_UNKNOWN) {
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("UNKNOWN USB SPEED MODE, ERROR !!!\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
goto free_dvobj;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) {
|
|
|
|
goto free_dvobj;
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
/*step 1-1., decide the chip_type via driver_info*/
|
|
|
|
pdvobjpriv->interface_type = RTW_USB;
|
|
|
|
rtw_decide_chip_type_by_usb_info(pdvobjpriv, pdid);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* .3 misc */
|
2015-08-18 19:03:09 +00:00
|
|
|
_rtw_init_sema(&(pdvobjpriv->usb_suspend_sema), 0);
|
|
|
|
rtw_reset_continual_io_error(pdvobjpriv);
|
|
|
|
|
|
|
|
usb_get_dev(pusbd);
|
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
|
|
|
free_dvobj:
|
|
|
|
if (status != _SUCCESS && pdvobjpriv) {
|
|
|
|
usb_set_intfdata(usb_intf, NULL);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
devobj_deinit(pdvobjpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
pdvobjpriv = NULL;
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return pdvobjpriv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_dvobj_deinit(struct usb_interface *usb_intf)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf);
|
|
|
|
|
|
|
|
|
|
|
|
usb_set_intfdata(usb_intf, NULL);
|
|
|
|
if (dvobj) {
|
2019-11-09 10:12:08 +00:00
|
|
|
/* Modify condition for 92DU DMDP 2010.11.18, by Thomas */
|
2015-08-18 19:03:09 +00:00
|
|
|
if ((dvobj->NumInterfaces != 2 && dvobj->NumInterfaces != 3)
|
2019-11-09 10:12:08 +00:00
|
|
|
|| (dvobj->InterfaceNumber == 1)) {
|
2015-08-18 19:03:09 +00:00
|
|
|
if (interface_to_usbdev(usb_intf)->state != USB_STATE_NOTATTACHED) {
|
2019-11-09 10:12:08 +00:00
|
|
|
/* If we didn't unplug usb dongle and remove/insert modlue, driver fails on sitesurvey for the first time when device is up . */
|
|
|
|
/* Reset usb port for sitesurvey fail issue. 2009.8.13, by Thomas */
|
|
|
|
RTW_INFO("usb attached..., try to reset usb device\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_reset_device(interface_to_usbdev(usb_intf));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rtw_deinit_intf_priv(dvobj);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
devobj_deinit(dvobj);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("%s %d\n", __func__, ATOMIC_READ(&usb_intf->dev.kobj.kref.refcount)); */
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_put_dev(interface_to_usbdev(usb_intf));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
static int usb_reprobe_switch_usb_mode(PADAPTER Adapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2017-05-11 18:47:23 +00:00
|
|
|
struct registry_priv *registry_par = &Adapter->registrypriv;
|
|
|
|
HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
u8 ret = _FALSE;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
/* efuse not allow driver to switch usb mode */
|
|
|
|
if (pHalData->EEPROMUsbSwitch == _FALSE)
|
|
|
|
goto exit;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
/* registry not allow driver to switch usb mode */
|
|
|
|
if (registry_par->switch_usb_mode == 0)
|
|
|
|
goto exit;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_hal_set_hwreg(Adapter, HW_VAR_USB_MODE, &ret);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
exit:
|
|
|
|
return ret;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
u8 rtw_set_hal_ops(_adapter *padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
/* alloc memory for HAL DATA */
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_hal_data_init(padapter) == _FAIL)
|
|
|
|
return _FAIL;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188E
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8188E)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtl8188eu_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A)
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8812 || rtw_get_chip_type(padapter) == RTL8821)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtl8812au_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8192E
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8192E)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtl8192eu_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_RTL8723B
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8723B)
|
2015-08-18 19:03:09 +00:00
|
|
|
rtl8723bu_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_RTL8814A
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8814A)
|
|
|
|
rtl8814au_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_RTL8814A */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188F
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8188F)
|
|
|
|
rtl8188fu_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8188GTV
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8188GTV)
|
|
|
|
rtl8188gtvu_set_hal_ops(padapter);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_RTL8703B
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_get_chip_type(padapter) == RTL8703B)
|
|
|
|
rtl8703bu_set_hal_ops(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_RTL8703B */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8822B
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8822B)
|
|
|
|
rtl8822bu_set_hal_ops(padapter);
|
|
|
|
#endif /* CONFIG_RTL8822B */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8723D
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8723D)
|
|
|
|
rtl8723du_set_hal_ops(padapter);
|
|
|
|
#endif /* CONFIG_RTL8723D */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8821C
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8821C) {
|
|
|
|
if (rtl8821cu_set_hal_ops(padapter) == _FAIL)
|
|
|
|
return _FAIL;
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8710B
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8710B)
|
|
|
|
rtl8710bu_set_hal_ops(padapter);
|
|
|
|
#endif /* CONFIG_RTL8710B */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_RTL8192F
|
|
|
|
if (rtw_get_chip_type(padapter) == RTL8192F)
|
|
|
|
rtl8192fu_set_hal_ops(padapter);
|
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (_FAIL == rtw_hal_ops_check(padapter))
|
|
|
|
return _FAIL;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (hal_spec_init(padapter) == _FAIL)
|
|
|
|
return _FAIL;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
return _SUCCESS;
|
|
|
|
}
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
static void usb_intf_start(_adapter *padapter)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
PHAL_DATA_TYPE hal = GET_HAL_DATA(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
rtw_hal_inirp_init(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
hal->usb_intf_start = _TRUE;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_intf_stop(_adapter *padapter)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
PHAL_DATA_TYPE hal = GET_HAL_DATA(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* disabel_hw_interrupt */
|
2017-05-11 18:47:23 +00:00
|
|
|
if (!rtw_is_surprise_removed(padapter)) {
|
2019-11-09 10:12:08 +00:00
|
|
|
/* device still exists, so driver can do i/o operation */
|
|
|
|
/* TODO: */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* cancel in irp */
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_hal_inirp_deinit(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* cancel out irp */
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_write_port_cancel(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* todo:cancel other irps */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
hal->usb_intf_start = _FALSE;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void process_spec_devid(const struct usb_device_id *pdid)
|
|
|
|
{
|
|
|
|
u16 vid, pid;
|
|
|
|
u32 flags;
|
|
|
|
int i;
|
2019-11-09 10:12:08 +00:00
|
|
|
int num = sizeof(specific_device_id_tbl) / sizeof(struct specific_device_id);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
for (i = 0; i < num; i++) {
|
2015-08-18 19:03:09 +00:00
|
|
|
vid = specific_device_id_tbl[i].idVendor;
|
|
|
|
pid = specific_device_id_tbl[i].idProduct;
|
|
|
|
flags = specific_device_id_tbl[i].flags;
|
|
|
|
|
|
|
|
#ifdef CONFIG_80211N_HT
|
2019-11-09 10:12:08 +00:00
|
|
|
if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && (flags & SPEC_DEV_ID_DISABLE_HT)) {
|
|
|
|
rtw_ht_enable = 0;
|
|
|
|
rtw_bw_mode = 0;
|
|
|
|
rtw_ampdu_enable = 0;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RTK_DMP_PLATFORM
|
2019-11-09 10:12:08 +00:00
|
|
|
/* Change the ifname to wlan10 when PC side WFD dongle plugin on DMP platform. */
|
|
|
|
/* It is used to distinguish between normal and PC-side wifi dongle/module. */
|
|
|
|
if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && (flags & SPEC_DEV_ID_ASSIGN_IFNAME)) {
|
|
|
|
extern char *ifname;
|
2015-08-18 19:03:09 +00:00
|
|
|
strncpy(ifname, "wlan10", 6);
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("%s()-%d: ifname=%s, vid=%04X, pid=%04X\n", __FUNCTION__, __LINE__, ifname, vid, pid); */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
#endif /* RTK_DMP_PLATFORM */
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SUPPORT_HW_RFOFF_DETECTED
|
2019-11-09 10:12:08 +00:00
|
|
|
int rtw_hw_suspend(_adapter *padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv;
|
|
|
|
struct usb_interface *pusb_intf;
|
|
|
|
struct net_device *pnetdev;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (NULL == padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
goto error_exit;
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
if ((_FALSE == padapter->bup) || RTW_CANNOT_RUN(padapter)) {
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("padapter->bup=%d bDriverStopped=%s bSurpriseRemoved = %s\n"
|
|
|
|
, padapter->bup
|
|
|
|
, rtw_is_drv_stopped(padapter) ? "True" : "False"
|
|
|
|
, rtw_is_surprise_removed(padapter) ? "True" : "False");
|
2015-08-18 19:03:09 +00:00
|
|
|
goto error_exit;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv = adapter_to_pwrctl(padapter);
|
|
|
|
pusb_intf = adapter_to_dvobj(padapter)->pusbintf;
|
|
|
|
pnetdev = padapter->pnetdev;
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
LeaveAllPowerSaveMode(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("==> rtw_hw_suspend\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
|
|
|
pwrpriv->bips_processing = _TRUE;
|
2019-11-09 10:12:08 +00:00
|
|
|
/* padapter->net_closed = _TRUE; */
|
|
|
|
/* s1. */
|
|
|
|
if (pnetdev) {
|
|
|
|
rtw_netif_carrier_off(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_netif_stop_queue(pnetdev);
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* s2. */
|
|
|
|
rtw_disassoc_cmd(padapter, 500, RTW_CMDF_DIRECTLY);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* s2-2. indicate disconnect to os */
|
|
|
|
/* rtw_indicate_disconnect(padapter); */
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2019-11-09 10:12:08 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2015-08-18 19:03:09 +00:00
|
|
|
_clr_fwstate_(pmlmepriv, _FW_LINKED);
|
|
|
|
rtw_led_control(padapter, LED_CTL_NO_LINK);
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_os_indicate_disconnect(padapter, 0, _FALSE);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_LPS
|
|
|
|
/* donnot enqueue cmd */
|
|
|
|
rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, RTW_CMDF_DIRECTLY);
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
/* s2-3. */
|
|
|
|
rtw_free_assoc_resources(padapter, _TRUE);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* s2-4. */
|
|
|
|
rtw_free_network_queue(padapter, _TRUE);
|
|
|
|
#ifdef CONFIG_IPS
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_ips_dev_unload(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->rf_pwrstate = rf_off;
|
|
|
|
pwrpriv->bips_processing = _FALSE;
|
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
2019-11-09 10:12:08 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
error_exit:
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s, failed\n", __FUNCTION__);
|
|
|
|
return -1;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int rtw_hw_resume(_adapter *padapter)
|
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
|
|
|
|
struct usb_interface *pusb_intf = adapter_to_dvobj(padapter)->pusbintf;
|
|
|
|
struct net_device *pnetdev = padapter->pnetdev;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("==> rtw_hw_resume\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
|
|
|
pwrpriv->bips_processing = _TRUE;
|
|
|
|
rtw_reset_drv_sw(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pm_netdev_open(pnetdev, _FALSE) != 0) {
|
2015-08-18 19:03:09 +00:00
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
goto error_exit;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_netif_device_attach(pnetdev);
|
|
|
|
rtw_netif_carrier_on(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_netif_wake_queue(pnetdev);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
pwrpriv->bkeepfwalive = _FALSE;
|
|
|
|
pwrpriv->brfoffbyhw = _FALSE;
|
|
|
|
|
|
|
|
pwrpriv->rf_pwrstate = rf_on;
|
|
|
|
pwrpriv->bips_processing = _FALSE;
|
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
error_exit:
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s, Open net dev failed\n", __FUNCTION__);
|
|
|
|
return -1;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
|
|
|
|
{
|
2017-05-11 18:35:20 +00:00
|
|
|
struct dvobj_priv *dvobj;
|
|
|
|
struct pwrctrl_priv *pwrpriv;
|
|
|
|
struct debug_priv *pdbgpriv;
|
|
|
|
PADAPTER padapter;
|
2015-08-18 19:03:09 +00:00
|
|
|
int ret = 0;
|
2017-05-11 18:35:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
dvobj = usb_get_intfdata(pusb_intf);
|
|
|
|
pwrpriv = dvobj_to_pwrctl(dvobj);
|
|
|
|
pdbgpriv = &dvobj->drv_dbg;
|
2019-11-09 10:12:08 +00:00
|
|
|
padapter = dvobj_get_primary_adapter(dvobj);
|
2017-05-11 18:35:20 +00:00
|
|
|
|
|
|
|
if (pwrpriv->bInSuspend == _TRUE) {
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s bInSuspend = %d\n", __FUNCTION__, pwrpriv->bInSuspend);
|
2017-05-11 18:35:20 +00:00
|
|
|
pdbgpriv->dbg_suspend_error_cnt++;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
if ((padapter->bup) || !rtw_is_drv_stopped(padapter) || !rtw_is_surprise_removed(padapter)) {
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pwrpriv->bInternalAutoSuspend) {
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef SUPPORT_HW_RFOFF_DETECTED
|
|
|
|
/* The FW command register update must after MAC and FW init ready. */
|
|
|
|
if ((GET_HAL_DATA(padapter)->bFWReady) && (pwrpriv->bHWPwrPindetect) && (padapter->registrypriv.usbss_enable)) {
|
2015-08-18 19:03:09 +00:00
|
|
|
u8 bOpen = _TRUE;
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_interface_ps_func(padapter, HAL_USB_SELECT_SUSPEND, &bOpen);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif/* SUPPORT_HW_RFOFF_DETECTED */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif/* CONFIG_AUTOSUSPEND */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
ret = rtw_suspend_common(padapter);
|
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
exit:
|
2015-08-18 19:03:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
int rtw_resume_process(_adapter *padapter)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
int ret;
|
|
|
|
#if defined(CONFIG_BT_COEXIST) && defined(CONFIG_AUTOSUSPEND)
|
|
|
|
int pm_cnt = 0;
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter);
|
2017-05-11 18:35:20 +00:00
|
|
|
struct dvobj_priv *pdvobj = padapter->dvobj;
|
|
|
|
struct debug_priv *pdbgpriv = &pdvobj->drv_dbg;
|
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pwrpriv->bInSuspend == _FALSE) {
|
2017-05-11 18:35:20 +00:00
|
|
|
pdbgpriv->dbg_resume_error_cnt++;
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("%s bInSuspend = %d\n", __FUNCTION__, pwrpriv->bInSuspend);
|
2017-05-11 18:35:20 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_BT_COEXIST) && defined(CONFIG_AUTOSUSPEND) /* add by amy for 8723as-vau */
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
|
|
|
RTW_INFO("%s...pm_usage_cnt(%d) pwrpriv->bAutoResume=%x. ....\n", __func__, atomic_read(&(adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt)), pwrpriv->bAutoResume);
|
|
|
|
pm_cnt = atomic_read(&(adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt));
|
|
|
|
#else /* kernel < 2.6.32 */
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt);
|
2015-08-18 19:03:09 +00:00
|
|
|
pm_cnt = adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt;
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* kernel < 2.6.32 */
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("pwrpriv->bAutoResume (%x)\n", pwrpriv->bAutoResume);
|
|
|
|
if (_TRUE == pwrpriv->bAutoResume) {
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->bInternalAutoSuspend = _FALSE;
|
2019-11-09 10:12:08 +00:00
|
|
|
pwrpriv->bAutoResume = _FALSE;
|
|
|
|
RTW_INFO("pwrpriv->bAutoResume (%x) pwrpriv->bInternalAutoSuspend(%x)\n", pwrpriv->bAutoResume, pwrpriv->bInternalAutoSuspend);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* #ifdef CONFIG_BT_COEXIST &CONFIG_AUTOSUSPEND& */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Due to usb wow suspend flow will cancel read/write port via intf_stop and
|
|
|
|
* bReadPortCancel and bWritePortCancel are set _TRUE in intf_stop.
|
2019-11-09 10:12:08 +00:00
|
|
|
* But they will not be clear in intf_start during wow resume flow.
|
2015-08-18 19:03:09 +00:00
|
|
|
* It should move to os_intf in the feature.
|
|
|
|
*/
|
|
|
|
RTW_ENABLE_FUNC(padapter, DF_RX_BIT);
|
|
|
|
RTW_ENABLE_FUNC(padapter, DF_TX_BIT);
|
|
|
|
|
|
|
|
ret = rtw_resume_common(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
|
|
|
if (pwrpriv->bInternalAutoSuspend) {
|
|
|
|
#ifdef SUPPORT_HW_RFOFF_DETECTED
|
|
|
|
/* The FW command register update must after MAC and FW init ready. */
|
|
|
|
if ((GET_HAL_DATA(padapter)->bFWReady) && (pwrpriv->bHWPwrPindetect) && (padapter->registrypriv.usbss_enable)) {
|
2015-08-18 19:03:09 +00:00
|
|
|
u8 bOpen = _FALSE;
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_interface_ps_func(padapter, HAL_USB_SELECT_SUSPEND, &bOpen);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BT_COEXIST /* for 8723as-vau */
|
|
|
|
RTW_INFO("pwrpriv->bAutoResume (%x)\n", pwrpriv->bAutoResume);
|
|
|
|
if (_TRUE == pwrpriv->bAutoResume) {
|
|
|
|
pwrpriv->bInternalAutoSuspend = _FALSE;
|
|
|
|
pwrpriv->bAutoResume = _FALSE;
|
|
|
|
RTW_INFO("pwrpriv->bAutoResume (%x) pwrpriv->bInternalAutoSuspend(%x)\n", pwrpriv->bAutoResume, pwrpriv->bInternalAutoSuspend);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#else /* #ifdef CONFIG_BT_COEXIST */
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->bInternalAutoSuspend = _FALSE;
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* #ifdef CONFIG_BT_COEXIST */
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->brfoffbyhw = _FALSE;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif/* CONFIG_AUTOSUSPEND */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
static int rtw_resume(struct usb_interface *pusb_intf)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj;
|
|
|
|
struct pwrctrl_priv *pwrpriv;
|
|
|
|
struct debug_priv *pdbgpriv;
|
|
|
|
PADAPTER padapter;
|
|
|
|
struct mlme_ext_priv *pmlmeext;
|
2015-08-18 19:03:09 +00:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
dvobj = usb_get_intfdata(pusb_intf);
|
|
|
|
pwrpriv = dvobj_to_pwrctl(dvobj);
|
|
|
|
pdbgpriv = &dvobj->drv_dbg;
|
2019-11-09 10:12:08 +00:00
|
|
|
padapter = dvobj_get_primary_adapter(dvobj);
|
2017-05-11 18:35:20 +00:00
|
|
|
pmlmeext = &padapter->mlmeextpriv;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("==> %s (%s:%d)\n", __FUNCTION__, current->comm, current->pid);
|
2017-05-11 18:35:20 +00:00
|
|
|
pdbgpriv->dbg_resume_cnt++;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
|
|
|
if (pwrpriv->bInternalAutoSuspend)
|
|
|
|
ret = rtw_resume_process(padapter);
|
|
|
|
else
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
if (pwrpriv->wowlan_mode || pwrpriv->wowlan_ap_mode) {
|
|
|
|
rtw_resume_lock_suspend();
|
2017-05-11 18:35:20 +00:00
|
|
|
ret = rtw_resume_process(padapter);
|
|
|
|
rtw_resume_unlock_suspend();
|
2019-11-09 10:12:08 +00:00
|
|
|
} else {
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_RESUME_IN_WORKQUEUE
|
2017-05-11 18:35:20 +00:00
|
|
|
rtw_resume_in_workqueue(pwrpriv);
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
|
|
|
if (rtw_is_earlysuspend_registered(pwrpriv)) {
|
2017-05-11 18:35:20 +00:00
|
|
|
/* jeff: bypass resume here, do in late_resume */
|
|
|
|
rtw_set_do_late_resume(pwrpriv, _TRUE);
|
2019-11-09 10:12:08 +00:00
|
|
|
} else {
|
|
|
|
rtw_resume_lock_suspend();
|
2017-05-11 18:35:20 +00:00
|
|
|
ret = rtw_resume_process(padapter);
|
|
|
|
rtw_resume_unlock_suspend();
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
pmlmeext->last_scan_time = rtw_get_current_time();
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("<======== %s return %d\n", __FUNCTION__, ret);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:35:20 +00:00
|
|
|
return ret;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
2019-11-09 10:12:08 +00:00
|
|
|
void autosuspend_enter(_adapter *padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
|
|
|
|
struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("==>autosuspend_enter...........\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
pwrpriv->bInternalAutoSuspend = _TRUE;
|
|
|
|
pwrpriv->bips_processing = _TRUE;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (rf_off == pwrpriv->change_rfpwrstate) {
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifndef CONFIG_BT_COEXIST
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_enable_autosuspend(dvobj->pusbdev);
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
|
|
|
dvobj->pusbdev->autosuspend_disabled = 0;/* autosuspend disabled by the user */
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
|
|
|
usb_autopm_put_interface(dvobj->pusbintf);
|
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
|
|
|
|
usb_autopm_enable(dvobj->pusbintf);
|
|
|
|
#else
|
|
|
|
usb_autosuspend_device(dvobj->pusbdev, 1);
|
|
|
|
#endif
|
|
|
|
#else /* #ifndef CONFIG_BT_COEXIST */
|
|
|
|
if (1 == pwrpriv->autopm_cnt) {
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
|
|
|
|
usb_enable_autosuspend(dvobj->pusbdev);
|
|
|
|
#else
|
|
|
|
dvobj->pusbdev->autosuspend_disabled = 0;/* autosuspend disabled by the user */
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_autopm_put_interface(dvobj->pusbintf);
|
2019-11-09 10:12:08 +00:00
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_autopm_enable(dvobj->pusbintf);
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_autosuspend_device(dvobj->pusbdev, 1);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
pwrpriv->autopm_cnt--;
|
|
|
|
} else
|
|
|
|
RTW_INFO("0!=pwrpriv->autopm_cnt[%d] didn't usb_autopm_put_interface\n", pwrpriv->autopm_cnt);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* #ifndef CONFIG_BT_COEXIST */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", atomic_read(&(dvobj->pusbintf->pm_usage_cnt)));
|
|
|
|
#else
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", dvobj->pusbintf->pm_usage_cnt);
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
}
|
2017-05-11 18:35:20 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
int autoresume_enter(_adapter *padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
int result = _SUCCESS;
|
2019-11-09 10:12:08 +00:00
|
|
|
struct security_priv *psecuritypriv = &(padapter->securitypriv);
|
2015-08-18 19:03:09 +00:00
|
|
|
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
|
|
|
|
struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info);
|
|
|
|
struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
|
|
|
|
struct pwrctrl_priv *pwrpriv = dvobj_to_pwrctl(dvobj);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("====> autoresume_enter\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (rf_off == pwrpriv->rf_pwrstate) {
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->ps_flag = _FALSE;
|
|
|
|
#ifndef CONFIG_BT_COEXIST
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
|
|
|
if (usb_autopm_get_interface(dvobj->pusbintf) < 0) {
|
|
|
|
RTW_INFO("can't get autopm: %d\n", result);
|
|
|
|
result = _FAIL;
|
|
|
|
goto error_exit;
|
|
|
|
}
|
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
|
|
|
|
usb_autopm_disable(dvobj->pusbintf);
|
|
|
|
#else
|
|
|
|
usb_autoresume_device(dvobj->pusbdev, 1);
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", atomic_read(&(dvobj->pusbintf->pm_usage_cnt)));
|
|
|
|
#else
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", dvobj->pusbintf->pm_usage_cnt);
|
|
|
|
#endif
|
|
|
|
#else /* #ifndef CONFIG_BT_COEXIST */
|
|
|
|
pwrpriv->bAutoResume = _TRUE;
|
|
|
|
if (0 == pwrpriv->autopm_cnt) {
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
|
|
|
if (usb_autopm_get_interface(dvobj->pusbintf) < 0) {
|
|
|
|
RTW_INFO("can't get autopm: %d\n", result);
|
2015-08-18 19:03:09 +00:00
|
|
|
result = _FAIL;
|
|
|
|
goto error_exit;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_autopm_disable(dvobj->pusbintf);
|
2019-11-09 10:12:08 +00:00
|
|
|
#else
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_autoresume_device(dvobj->pusbdev, 1);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", atomic_read(&(dvobj->pusbintf->pm_usage_cnt)));
|
|
|
|
#else
|
|
|
|
RTW_INFO("...pm_usage_cnt(%d).....\n", dvobj->pusbintf->pm_usage_cnt);
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
pwrpriv->autopm_cnt++;
|
2019-11-09 10:12:08 +00:00
|
|
|
} else
|
|
|
|
RTW_INFO("0!=pwrpriv->autopm_cnt[%d] didn't usb_autopm_get_interface\n", pwrpriv->autopm_cnt);
|
|
|
|
#endif /* #ifndef CONFIG_BT_COEXIST */
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("<==== autoresume_enter\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
error_exit:
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PLATFORM_RTD2880B
|
|
|
|
extern void rtd2885_wlan_netlink_sendMsg(char *action_string, char *name);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* drv_init() - a device potentially for us
|
|
|
|
*
|
|
|
|
* notes: drv_init() is called when the bus driver has located a card for us to support.
|
|
|
|
* We accept the new device by returning 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
_adapter *rtw_sw_export = NULL;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
_adapter *rtw_usb_primary_adapter_init(struct dvobj_priv *dvobj,
|
2017-05-11 18:47:23 +00:00
|
|
|
struct usb_interface *pusb_intf)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
|
|
|
_adapter *padapter = NULL;
|
|
|
|
int status = _FAIL;
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
padapter = (_adapter *)rtw_zvmalloc(sizeof(*padapter));
|
|
|
|
if (padapter == NULL)
|
2015-08-18 19:03:09 +00:00
|
|
|
goto exit;
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
if (loadparam(padapter) != _SUCCESS)
|
|
|
|
goto free_adapter;
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
padapter->dvobj = dvobj;
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
|
|
|
|
rtw_set_drv_stopped(padapter);/*init*/
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
dvobj->padapters[dvobj->iface_nums++] = padapter;
|
|
|
|
padapter->iface_id = IFACE_ID0;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* set adapter_type/iface type for primary padapter */
|
2015-08-18 19:03:09 +00:00
|
|
|
padapter->isprimary = _TRUE;
|
|
|
|
padapter->adapter_type = PRIMARY_ADAPTER;
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_MI_WITH_MBSSID_CAM/*Configure all IFACE to PORT0-MBSSID*/
|
|
|
|
padapter->hw_port = HW_PORT0;
|
|
|
|
#else
|
|
|
|
padapter->hw_port = HW_PORT0;
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step init_io_priv */
|
|
|
|
if (rtw_init_io_priv(padapter, usb_set_intf_ops) == _FAIL)
|
|
|
|
goto free_adapter;
|
|
|
|
|
|
|
|
/* step 2. hook HalFunc, allocate HalData */
|
|
|
|
if (rtw_set_hal_ops(padapter) == _FAIL)
|
2017-05-11 18:47:23 +00:00
|
|
|
goto free_hal_data;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
padapter->intf_start = &usb_intf_start;
|
|
|
|
padapter->intf_stop = &usb_intf_stop;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step read_chip_version */
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_hal_read_chip_version(padapter);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step usb endpoint mapping */
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_hal_chip_configure(padapter);
|
|
|
|
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
rtw_btcoex_Initialize(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
rtw_btcoex_wifionly_initialize(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step read efuse/eeprom data and get mac_addr */
|
|
|
|
if (rtw_hal_read_chip_info(padapter) == _FAIL)
|
|
|
|
goto free_hal_data;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step 5. */
|
|
|
|
if (rtw_init_drv_sw(padapter) == _FAIL) {
|
2015-08-18 19:03:09 +00:00
|
|
|
goto free_hal_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 18))
|
|
|
|
if (dvobj_to_pwrctl(dvobj)->bSupportRemoteWakeup) {
|
|
|
|
dvobj->pusbdev->do_remote_wakeup = 1;
|
2015-08-18 19:03:09 +00:00
|
|
|
pusb_intf->needs_remote_wakeup = 1;
|
|
|
|
device_init_wakeup(&pusb_intf->dev, 1);
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
|
|
|
|
RTW_INFO("pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n", device_may_wakeup(&pusb_intf->dev));
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_AUTOSUSPEND
|
2019-11-09 10:12:08 +00:00
|
|
|
if (padapter->registrypriv.power_mgnt != PS_MODE_ACTIVE) {
|
|
|
|
if (padapter->registrypriv.usbss_enable) { /* autosuspend (2s delay) */
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38))
|
|
|
|
dvobj->pusbdev->dev.power.autosuspend_delay = 0 * HZ;/* 15 * HZ; idle-delay time */
|
|
|
|
#else
|
|
|
|
dvobj->pusbdev->autosuspend_delay = 0 * HZ;/* 15 * HZ; idle-delay time */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))
|
2015-08-18 19:03:09 +00:00
|
|
|
usb_enable_autosuspend(dvobj->pusbdev);
|
2019-11-09 10:12:08 +00:00
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 22) && LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 34))
|
2015-08-18 19:03:09 +00:00
|
|
|
padapter->bDisableAutosuspend = dvobj->pusbdev->autosuspend_disabled ;
|
2019-11-09 10:12:08 +00:00
|
|
|
dvobj->pusbdev->autosuspend_disabled = 0;/* autosuspend disabled by the user */
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* usb_autopm_get_interface(adapter_to_dvobj(padapter)->pusbintf ); */ /* init pm_usage_cnt ,let it start from 1 */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32))
|
|
|
|
RTW_INFO("%s...pm_usage_cnt(%d).....\n", __FUNCTION__, atomic_read(&(dvobj->pusbintf->pm_usage_cnt)));
|
|
|
|
#else
|
|
|
|
RTW_INFO("%s...pm_usage_cnt(%d).....\n", __FUNCTION__, dvobj->pusbintf->pm_usage_cnt);
|
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
/* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto suspend influence */
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
|
|
|
if (usb_autopm_get_interface(pusb_intf) < 0)
|
|
|
|
RTW_INFO("can't get autopm:\n");
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
dvobj_to_pwrctl(dvobj)->autopm_cnt = 1;
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* set mac addr */
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter));
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_MI_WITH_MBSSID_CAM
|
|
|
|
rtw_mbid_camid_alloc(padapter, adapter_mac_addr(padapter));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_P2P
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter));
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_P2P */
|
|
|
|
RTW_INFO("bDriverStopped:%s, bSurpriseRemoved:%s, bup:%d, hw_init_completed:%d\n"
|
|
|
|
, rtw_is_drv_stopped(padapter) ? "True" : "False"
|
|
|
|
, rtw_is_surprise_removed(padapter) ? "True" : "False"
|
|
|
|
, padapter->bup
|
|
|
|
, rtw_get_hw_init_completed(padapter)
|
|
|
|
);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
|
|
|
free_hal_data:
|
2017-05-11 18:47:23 +00:00
|
|
|
if (status != _SUCCESS && padapter->HalData)
|
|
|
|
rtw_hal_free_data(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
free_adapter:
|
2017-05-11 18:47:23 +00:00
|
|
|
if (status != _SUCCESS && padapter) {
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef RTW_HALMAC
|
|
|
|
rtw_halmac_deinit_adapter(dvobj);
|
|
|
|
#endif
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_vmfree((u8 *)padapter, sizeof(*padapter));
|
2015-08-18 19:03:09 +00:00
|
|
|
padapter = NULL;
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return padapter;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
static void rtw_usb_primary_adapter_deinit(_adapter *padapter)
|
2015-08-18 19:03:09 +00:00
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_WOWLAN) || defined(CONFIG_BT_COEXIST)
|
|
|
|
struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter);
|
|
|
|
#endif
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter));
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED))
|
|
|
|
rtw_disassoc_cmd(padapter, 0, RTW_CMDF_DIRECTLY);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_AP_MODE
|
2019-11-09 10:12:08 +00:00
|
|
|
if (MLME_IS_AP(padapter) || MLME_IS_MESH(padapter)) {
|
|
|
|
free_mlme_ap_info(padapter);
|
|
|
|
#ifdef CONFIG_HOSTAPD_MLME
|
|
|
|
hostapd_mode_unload(padapter);
|
|
|
|
#endif
|
|
|
|
}
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/*rtw_cancel_all_timer(if1);*/
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_WOWLAN
|
2019-11-09 10:12:08 +00:00
|
|
|
pwrctl->wowlan_mode = _FALSE;
|
|
|
|
#endif /* CONFIG_WOWLAN */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_dev_unload(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("+r871xu_dev_remove, hw_init_completed=%d\n", rtw_get_hw_init_completed(padapter));
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_BT_COEXIST
|
2019-11-09 10:12:08 +00:00
|
|
|
if (1 == pwrctl->autopm_cnt) {
|
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33))
|
|
|
|
usb_autopm_put_interface(adapter_to_dvobj(padapter)->pusbintf);
|
|
|
|
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
|
|
|
|
usb_autopm_enable(adapter_to_dvobj(padapter)->pusbintf);
|
|
|
|
#else
|
|
|
|
usb_autosuspend_device(adapter_to_dvobj(padapter)->pusbdev, 1);
|
|
|
|
#endif
|
|
|
|
pwrctl->autopm_cnt--;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_free_drv_sw(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
/* TODO: use rtw_os_ndevs_deinit instead at the first stage of driver's dev deinit function */
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_os_ndev_free(padapter);
|
|
|
|
|
|
|
|
#ifdef RTW_HALMAC
|
|
|
|
rtw_halmac_deinit_adapter(adapter_to_dvobj(padapter));
|
|
|
|
#endif /* RTW_HALMAC */
|
2017-05-11 18:47:23 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_vmfree((u8 *)padapter, sizeof(_adapter));
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PLATFORM_RTD2880B
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("wlan link down\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
rtd2885_wlan_netlink_sendMsg("linkdown", "8712");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
_adapter *padapter = NULL;
|
2015-08-18 19:03:09 +00:00
|
|
|
int status = _FAIL;
|
|
|
|
struct dvobj_priv *dvobj;
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
2015-08-18 19:03:09 +00:00
|
|
|
int i;
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* RTW_INFO("+rtw_drv_init\n"); */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* step 0. */
|
2015-08-18 19:03:09 +00:00
|
|
|
process_spec_devid(pdid);
|
|
|
|
|
|
|
|
/* Initialize dvobj_priv */
|
2019-11-09 10:12:08 +00:00
|
|
|
dvobj = usb_dvobj_init(pusb_intf, pdid);
|
|
|
|
if (dvobj == NULL) {
|
2015-08-18 19:03:09 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
padapter = rtw_usb_primary_adapter_init(dvobj, pusb_intf);
|
|
|
|
if (padapter == NULL) {
|
|
|
|
RTW_INFO("rtw_usb_primary_adapter_init Failed!\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
goto free_dvobj;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
if (usb_reprobe_switch_usb_mode(padapter) == _TRUE)
|
|
|
|
goto free_if_prim;
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
2019-11-09 10:12:08 +00:00
|
|
|
if (padapter->registrypriv.virtual_iface_num > (CONFIG_IFACE_NUMBER - 1))
|
|
|
|
padapter->registrypriv.virtual_iface_num = (CONFIG_IFACE_NUMBER - 1);
|
|
|
|
|
|
|
|
for (i = 0; i < padapter->registrypriv.virtual_iface_num; i++) {
|
|
|
|
if (rtw_drv_add_vir_if(padapter, usb_set_intf_ops) == NULL) {
|
|
|
|
RTW_INFO("rtw_drv_add_iface failed! (%d)\n", i);
|
|
|
|
goto free_if_vir;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_INTEL_PROXIM
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_sw_export = padapter;
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_GLOBAL_UI_PID
|
2019-11-09 10:12:08 +00:00
|
|
|
if (ui_pid[1] != 0) {
|
|
|
|
RTW_INFO("ui_pid[1]:%d\n", ui_pid[1]);
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_signal_process(ui_pid[1], SIGUSR2);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
/* dev_alloc_name && register_netdev */
|
2017-05-11 18:47:23 +00:00
|
|
|
if (rtw_os_ndevs_init(dvobj) != _SUCCESS)
|
2019-11-09 10:12:08 +00:00
|
|
|
goto free_if_vir;
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_HOSTAPD_MLME
|
2019-11-09 10:12:08 +00:00
|
|
|
hostapd_mode_init(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_PLATFORM_RTD2880B
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("wlan link up\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
rtd2885_wlan_netlink_sendMsg("linkup", "8712");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
#if 0 /* not used now */
|
|
|
|
os_ndevs_deinit:
|
|
|
|
if (status != _SUCCESS)
|
|
|
|
rtw_os_ndevs_deinit(dvobj);
|
|
|
|
#endif
|
2019-11-09 10:12:08 +00:00
|
|
|
free_if_vir:
|
|
|
|
if (status != _SUCCESS) {
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_drv_stop_vir_ifaces(dvobj);
|
|
|
|
rtw_drv_free_vir_ifaces(dvobj);
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
free_if_prim:
|
|
|
|
if (status != _SUCCESS && padapter)
|
|
|
|
rtw_usb_primary_adapter_deinit(padapter);
|
|
|
|
|
2015-08-18 19:03:09 +00:00
|
|
|
free_dvobj:
|
|
|
|
if (status != _SUCCESS)
|
|
|
|
usb_dvobj_deinit(pusb_intf);
|
|
|
|
exit:
|
2019-11-09 10:12:08 +00:00
|
|
|
return status == _SUCCESS ? 0 : -ENODEV;
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dev_remove() - our device is being removed
|
|
|
|
*/
|
2019-11-09 10:12:08 +00:00
|
|
|
/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both */
|
2015-08-18 19:03:09 +00:00
|
|
|
static void rtw_dev_remove(struct usb_interface *pusb_intf)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
|
2019-11-09 10:12:08 +00:00
|
|
|
#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_ANDROID_POWER)
|
2015-08-18 19:03:09 +00:00
|
|
|
struct pwrctrl_priv *pwrctl = dvobj_to_pwrctl(dvobj);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
|
|
|
_adapter *padapter = dvobj_get_primary_adapter(dvobj);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("+rtw_dev_remove\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
dvobj->processing_dev_remove = _TRUE;
|
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
/* TODO: use rtw_os_ndevs_deinit instead at the first stage of driver's dev deinit function */
|
|
|
|
rtw_os_ndevs_unregister(dvobj);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (usb_drv.drv_registered == _TRUE) {
|
|
|
|
/* RTW_INFO("r871xu_dev_remove():padapter->bSurpriseRemoved == _TRUE\n"); */
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_set_surprise_removed(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
}
|
|
|
|
/*else
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
|
|
|
|
rtw_set_hw_init_completed(padapter, _FALSE);
|
2015-08-18 19:03:09 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_HAS_EARLYSUSPEND) || defined(CONFIG_ANDROID_POWER)
|
|
|
|
rtw_unregister_early_suspend(pwrctl);
|
|
|
|
#endif
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
if (GET_HAL_DATA(padapter)->bFWReady == _TRUE) {
|
2017-05-11 18:47:23 +00:00
|
|
|
rtw_pm_set_ips(padapter, IPS_NONE);
|
|
|
|
rtw_pm_set_lps(padapter, PS_MODE_ACTIVE);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2017-05-11 18:47:23 +00:00
|
|
|
LeaveAllPowerSaveMode(padapter);
|
|
|
|
}
|
|
|
|
rtw_set_drv_stopped(padapter); /*for stop thread*/
|
|
|
|
rtw_stop_cmd_thread(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
|
|
|
rtw_drv_stop_vir_ifaces(dvobj);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_CONCURRENT_MODE */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
#ifdef CONFIG_BT_COEXIST
|
|
|
|
#ifdef CONFIG_BT_COEXIST_SOCKET_TRX
|
2017-05-11 18:47:23 +00:00
|
|
|
if (GET_HAL_DATA(padapter)->EEPROMBluetoothCoexist)
|
|
|
|
rtw_btcoex_close_socket(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
rtw_btcoex_HaltNotify(padapter);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_usb_primary_adapter_deinit(padapter);
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_CONCURRENT_MODE
|
|
|
|
rtw_drv_free_vir_ifaces(dvobj);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_CONCURRENT_MODE */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
usb_dvobj_deinit(pusb_intf);
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_INFO("-r871xu_dev_remove, done\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_INTEL_PROXIM
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_sw_export = NULL;
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
|
2015-08-18 19:03:09 +00:00
|
|
|
extern int console_suspend_enabled;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int __init rtw_drv_entry(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_PRINT("module init start\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
dump_drv_version(RTW_DBGDUMP);
|
|
|
|
#ifdef BTCOEXVERSION
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_PRINT(DRV_NAME" BT-Coex version = %s\n", BTCOEXVERSION);
|
|
|
|
#endif /* BTCOEXVERSION */
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
ret = platform_wifi_power_on();
|
2019-11-09 10:12:08 +00:00
|
|
|
if (ret != 0) {
|
|
|
|
RTW_INFO("%s: power on failed!!(%d)\n", __FUNCTION__, ret);
|
2015-08-18 19:03:09 +00:00
|
|
|
ret = -1;
|
|
|
|
goto exit;
|
|
|
|
}
|
2019-11-09 10:12:08 +00:00
|
|
|
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
|
|
|
|
/* console_suspend_enabled=0; */
|
2015-08-18 19:03:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
usb_drv.drv_registered = _TRUE;
|
|
|
|
rtw_suspend_lock_init();
|
|
|
|
rtw_drv_proc_init();
|
|
|
|
rtw_ndev_notifier_register();
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_inetaddr_notifier_register();
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
ret = usb_register(&usb_drv.usbdrv);
|
|
|
|
|
|
|
|
if (ret != 0) {
|
|
|
|
usb_drv.drv_registered = _FALSE;
|
|
|
|
rtw_suspend_lock_uninit();
|
|
|
|
rtw_drv_proc_deinit();
|
|
|
|
rtw_ndev_notifier_unregister();
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_inetaddr_notifier_unregister();
|
2015-08-18 19:03:09 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_PRINT("module init ret=%d\n", ret);
|
2015-08-18 19:03:09 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit rtw_drv_halt(void)
|
|
|
|
{
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_PRINT("module exit start\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
usb_drv.drv_registered = _FALSE;
|
|
|
|
|
|
|
|
usb_deregister(&usb_drv.usbdrv);
|
|
|
|
|
|
|
|
platform_wifi_power_off();
|
|
|
|
|
|
|
|
rtw_suspend_lock_uninit();
|
|
|
|
rtw_drv_proc_deinit();
|
|
|
|
rtw_ndev_notifier_unregister();
|
2019-11-09 10:12:08 +00:00
|
|
|
rtw_inetaddr_notifier_unregister();
|
2015-08-18 19:03:09 +00:00
|
|
|
|
2019-11-09 10:12:08 +00:00
|
|
|
RTW_PRINT("module exit success\n");
|
2015-08-18 19:03:09 +00:00
|
|
|
|
|
|
|
rtw_mstat_dump(RTW_DBGDUMP);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
module_init(rtw_drv_entry);
|
|
|
|
module_exit(rtw_drv_halt);
|
|
|
|
|
|
|
|
#ifdef CONFIG_INTEL_PROXIM
|
|
|
|
_adapter *rtw_usb_get_sw_pointer(void)
|
|
|
|
{
|
|
|
|
return rtw_sw_export;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(rtw_usb_get_sw_pointer);
|
2019-11-09 10:12:08 +00:00
|
|
|
#endif /* CONFIG_INTEL_PROXIM */
|