2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
|
2013-05-19 04:28:07 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _HCI_INTF_C_
|
|
|
|
|
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <recv_osdep.h>
|
|
|
|
#include <xmit_osdep.h>
|
|
|
|
#include <hal_intf.h>
|
2013-05-25 20:45:50 +00:00
|
|
|
#include <linux/usb.h>
|
2014-11-16 00:18:30 +00:00
|
|
|
#include <linux/vmalloc.h>
|
2013-06-03 19:52:18 +00:00
|
|
|
#include <osdep_intf.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
#include <usb_ops_linux.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
#include <usb_hal.h>
|
2013-06-03 19:52:18 +00:00
|
|
|
#include <rtw_ioctl.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
int ui_pid[3] = {0, 0, 0};
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
#define USB_VENDER_ID_REALTEK 0x0bda
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
/* DID_USB_v916_20130116 */
|
2013-08-12 01:59:28 +00:00
|
|
|
static struct usb_device_id rtw_usb_id_tbl[] = {
|
|
|
|
/*=== Realtek demoboard ===*/
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */
|
|
|
|
{USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */
|
|
|
|
/*=== Customer ID ===*/
|
|
|
|
/****** 8188EUS ********/
|
2014-11-16 00:18:30 +00:00
|
|
|
{USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */
|
|
|
|
{USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */
|
2013-09-26 17:39:39 +00:00
|
|
|
{USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */
|
2014-11-16 00:18:30 +00:00
|
|
|
{USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */
|
|
|
|
{USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */
|
2013-05-08 21:45:39 +00:00
|
|
|
{} /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int status = _FAIL;
|
|
|
|
struct dvobj_priv *pdvobjpriv;
|
2013-08-12 01:59:28 +00:00
|
|
|
struct usb_host_config *phost_conf;
|
|
|
|
struct usb_config_descriptor *pconf_desc;
|
|
|
|
struct usb_host_interface *phost_iface;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct usb_interface_descriptor *piface_desc;
|
2013-08-12 01:59:28 +00:00
|
|
|
struct usb_host_endpoint *phost_endp;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct usb_endpoint_descriptor *pendp_desc;
|
2013-08-12 01:59:28 +00:00
|
|
|
struct usb_device *pusbd;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL);
|
2013-08-12 01:59:28 +00:00
|
|
|
if (pdvobjpriv == NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
pdvobjpriv->pusbintf = usb_intf;
|
|
|
|
pusbd = interface_to_usbdev(usb_intf);
|
|
|
|
pdvobjpriv->pusbdev = pusbd;
|
2013-05-08 21:45:39 +00:00
|
|
|
usb_set_intfdata(usb_intf, pdvobjpriv);
|
|
|
|
|
|
|
|
pdvobjpriv->RtNumInPipes = 0;
|
|
|
|
pdvobjpriv->RtNumOutPipes = 0;
|
|
|
|
|
|
|
|
phost_conf = pusbd->actconfig;
|
|
|
|
pconf_desc = &phost_conf->desc;
|
|
|
|
|
|
|
|
phost_iface = &usb_intf->altsetting[0];
|
|
|
|
piface_desc = &phost_iface->desc;
|
|
|
|
|
|
|
|
pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces;
|
|
|
|
pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber;
|
|
|
|
pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints;
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
for (i = 0; i < pdvobjpriv->nr_endpoint; i++) {
|
2014-11-16 00:18:30 +00:00
|
|
|
int ep_num;
|
2013-05-08 21:45:39 +00:00
|
|
|
phost_endp = phost_iface->endpoint + i;
|
2014-11-16 00:18:30 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if (phost_endp) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pendp_desc = &phost_endp->desc;
|
2014-11-16 00:18:30 +00:00
|
|
|
ep_num = usb_endpoint_num(pendp_desc);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
if (usb_endpoint_is_bulk_in(pendp_desc)) {
|
|
|
|
pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdvobjpriv->RtNumInPipes++;
|
2014-11-16 00:18:30 +00:00
|
|
|
} else if (usb_endpoint_is_int_in(pendp_desc)) {
|
|
|
|
pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdvobjpriv->RtNumInPipes++;
|
2014-11-16 00:18:30 +00:00
|
|
|
} else if (usb_endpoint_is_bulk_out(pendp_desc)) {
|
|
|
|
pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = ep_num;
|
2013-05-08 21:45:39 +00:00
|
|
|
pdvobjpriv->RtNumOutPipes++;
|
|
|
|
}
|
2014-11-16 00:18:30 +00:00
|
|
|
pdvobjpriv->ep_num[i] = ep_num;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
if (pusbd->speed == USB_SPEED_HIGH)
|
2013-05-26 03:02:10 +00:00
|
|
|
pdvobjpriv->ishighspeed = true;
|
2014-11-16 00:18:30 +00:00
|
|
|
else
|
2013-05-26 03:02:10 +00:00
|
|
|
pdvobjpriv->ishighspeed = false;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
mutex_init(&pdvobjpriv->usb_vendor_req_mutex);
|
|
|
|
pdvobjpriv->usb_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
if (!pdvobjpriv->usb_vendor_req_buf)
|
|
|
|
goto free_dvobj;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
usb_get_dev(pusbd);
|
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
|
|
|
free_dvobj:
|
|
|
|
if (status != _SUCCESS && pdvobjpriv) {
|
|
|
|
usb_set_intfdata(usb_intf, NULL);
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(pdvobjpriv);
|
2013-05-08 21:45:39 +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) {
|
2013-08-12 01:59:28 +00:00
|
|
|
/* Modify condition for 92DU DMDP 2010.11.18, by Thomas */
|
|
|
|
if ((dvobj->NumInterfaces != 2 &&
|
|
|
|
dvobj->NumInterfaces != 3) ||
|
|
|
|
(dvobj->InterfaceNumber == 1)) {
|
|
|
|
if (interface_to_usbdev(usb_intf)->state !=
|
|
|
|
USB_STATE_NOTATTACHED) {
|
|
|
|
/* If we didn't unplug usb dongle and
|
|
|
|
* remove/insert module, driver fails
|
|
|
|
* on sitesurvey for the first time when
|
|
|
|
* device is up . Reset usb port for sitesurvey
|
|
|
|
* fail issue. */
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("usb attached..., try to reset usb device\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
usb_reset_device(interface_to_usbdev(usb_intf));
|
|
|
|
}
|
|
|
|
}
|
2014-11-16 00:18:30 +00:00
|
|
|
|
|
|
|
kfree(dvobj->usb_vendor_req_buf);
|
|
|
|
mutex_destroy(&dvobj->usb_vendor_req_mutex);
|
2013-10-19 17:45:47 +00:00
|
|
|
kfree(dvobj);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
usb_put_dev(interface_to_usbdev(usb_intf));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void usb_intf_start(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_inirp_init(padapter);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void usb_intf_stop(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n"));
|
|
|
|
|
|
|
|
/* disabel_hw_interrupt */
|
|
|
|
if (!padapter->bSurpriseRemoved) {
|
|
|
|
/* device still exists, so driver can do i/o operation */
|
|
|
|
/* TODO: */
|
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_,
|
|
|
|
("SurpriseRemoved == false\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* cancel in irp */
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_hal_inirp_deinit(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* cancel out irp */
|
2014-11-16 00:18:30 +00:00
|
|
|
usb_write_port_cancel(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* todo:cancel other irps */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void rtw_dev_unload(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if (padapter->bup) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("===> rtw_dev_unload\n");
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bDriverStopped = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
if (padapter->xmitpriv.ack_tx)
|
|
|
|
rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP);
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s3. */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (padapter->intf_stop)
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter->intf_stop(padapter);
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s4. */
|
|
|
|
if (!padapter->pwrctrlpriv.bInternalAutoSuspend)
|
|
|
|
rtw_stop_drv_threads(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s5. */
|
|
|
|
if (!padapter->bSurpriseRemoved) {
|
2013-10-19 17:45:47 +00:00
|
|
|
rtw_hal_deinit(padapter);
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bSurpriseRemoved = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bup = false;
|
2013-08-12 01:59:28 +00:00
|
|
|
} else {
|
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_,
|
|
|
|
("r871x_dev_unload():padapter->bup == false\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("<=== rtw_dev_unload\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = dvobj->if1;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct net_device *pnetdev = padapter->pnetdev;
|
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
|
|
|
int ret = 0;
|
2014-11-16 00:18:30 +00:00
|
|
|
u32 start_time = jiffies;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if ((!padapter->bup) || (padapter->bDriverStopped) ||
|
|
|
|
(padapter->bSurpriseRemoved)) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n",
|
2013-08-12 01:59:28 +00:00
|
|
|
padapter->bup, padapter->bDriverStopped,
|
|
|
|
padapter->bSurpriseRemoved);
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bInSuspend = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_cancel_all_timer(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
LeaveAllPowerSaveMode(padapter);
|
|
|
|
|
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s1. */
|
|
|
|
if (pnetdev) {
|
2013-05-08 21:45:39 +00:00
|
|
|
netif_carrier_off(pnetdev);
|
2014-11-16 00:18:30 +00:00
|
|
|
netif_tx_stop_all_queues(pnetdev);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s2. */
|
2013-05-26 03:02:10 +00:00
|
|
|
rtw_disassoc_cmd(padapter, 0, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) &&
|
|
|
|
check_fwstate(pmlmepriv, _FW_LINKED)) {
|
|
|
|
DBG_88E("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n",
|
|
|
|
__func__, __LINE__,
|
2013-05-30 20:51:53 +00:00
|
|
|
pmlmepriv->cur_network.network.Ssid.Ssid,
|
|
|
|
pmlmepriv->cur_network.network.MacAddress,
|
|
|
|
pmlmepriv->cur_network.network.Ssid.SsidLength,
|
|
|
|
pmlmepriv->assoc_ssid.SsidLength);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
pmlmepriv->to_roaming = 1;
|
|
|
|
}
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s2-2. indicate disconnect to os */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_indicate_disconnect(padapter);
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s2-3. */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_assoc_resources(padapter, 1);
|
2013-08-12 01:59:28 +00:00
|
|
|
/* s2-4. */
|
2013-05-26 03:02:10 +00:00
|
|
|
rtw_free_network_queue(padapter, true);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_dev_unload(padapter);
|
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY))
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_indicate_scan_done(padapter, 1);
|
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING))
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_indicate_disconnect(padapter);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
exit:
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("<=== %s return %d.............. in %dms\n", __func__
|
2013-05-08 21:45:39 +00:00
|
|
|
, ret, rtw_get_passing_time_ms(start_time));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
static int rtw_resume_process(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct net_device *pnetdev;
|
2013-10-19 17:45:47 +00:00
|
|
|
struct pwrctrl_priv *pwrpriv = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = -1;
|
2014-11-16 00:18:30 +00:00
|
|
|
u32 start_time = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (padapter) {
|
2013-08-12 01:59:28 +00:00
|
|
|
pnetdev = padapter->pnetdev;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
} else {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
|
|
|
rtw_reset_drv_sw(padapter);
|
2014-11-16 00:18:30 +00:00
|
|
|
pwrpriv->bkeepfwalive = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive);
|
|
|
|
if (pm_netdev_open(pnetdev, true) != 0)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
netif_device_attach(pnetdev);
|
2013-05-08 21:45:39 +00:00
|
|
|
netif_carrier_on(pnetdev);
|
|
|
|
|
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if (padapter->pid[1] != 0) {
|
|
|
|
DBG_88E("pid[1]:%d\n", padapter->pid[1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_signal_process(padapter->pid[1], SIGUSR2);
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_roaming(padapter, NULL);
|
|
|
|
|
|
|
|
ret = 0;
|
|
|
|
exit:
|
2013-09-05 22:21:46 +00:00
|
|
|
if (pwrpriv)
|
|
|
|
pwrpriv->bInSuspend = false;
|
2013-10-19 17:45:47 +00:00
|
|
|
DBG_88E("<=== %s return %d.............. in %dms\n", __func__,
|
|
|
|
ret, rtw_get_passing_time_ms(start_time));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
static int rtw_resume(struct usb_interface *pusb_intf)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
|
|
|
|
struct adapter *padapter = dvobj->if1;
|
|
|
|
|
|
|
|
return rtw_resume_process(padapter);
|
|
|
|
}
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
/*
|
|
|
|
* drv_init() - a device potentially for us
|
|
|
|
*
|
2013-08-12 01:59:28 +00:00
|
|
|
* notes: drv_init() is called when the bus driver has located
|
|
|
|
* a card for us to support.
|
2013-05-08 21:45:39 +00:00
|
|
|
* We accept the new device by returning 0.
|
2013-08-12 01:59:28 +00:00
|
|
|
*/
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
|
2013-05-08 21:45:39 +00:00
|
|
|
struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
|
|
|
|
{
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = NULL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct net_device *pnetdev = NULL;
|
|
|
|
int status = _FAIL;
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
padapter = (struct adapter *)vzalloc(sizeof(*padapter));
|
2013-08-12 01:59:28 +00:00
|
|
|
if (padapter == NULL)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
padapter->dvobj = dvobj;
|
|
|
|
dvobj->if1 = padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
padapter->bDriverStopped = true;
|
2014-11-16 00:18:30 +00:00
|
|
|
mutex_init(&padapter->hw_init_mutex);
|
|
|
|
padapter->chip_type = RTL8188E;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
pnetdev = rtw_init_netdev(padapter);
|
|
|
|
if (pnetdev == NULL)
|
2014-11-16 00:18:30 +00:00
|
|
|
goto free_adapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
|
|
|
|
padapter = rtw_netdev_priv(pnetdev);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step 2. hook HalFunc, allocate HalData */
|
2013-05-08 21:45:39 +00:00
|
|
|
hal_set_hal_ops(padapter);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
padapter->intf_start = &usb_intf_start;
|
|
|
|
padapter->intf_stop = &usb_intf_stop;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step read_chip_version */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_read_chip_version(padapter);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step usb endpoint mapping */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_chip_configure(padapter);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step read efuse/eeprom data and get mac_addr */
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_hal_read_chip_info(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step 5. */
|
|
|
|
if (rtw_init_drv_sw(padapter) == _FAIL) {
|
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_,
|
|
|
|
("Initialize driver software resource Failed!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto free_hal_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM
|
2013-08-12 01:59:28 +00:00
|
|
|
if (padapter->pwrctrlpriv.bSupportRemoteWakeup) {
|
|
|
|
dvobj->pusbdev->do_remote_wakeup = 1;
|
2013-05-19 04:28:07 +00:00
|
|
|
pusb_intf->needs_remote_wakeup = 1;
|
2013-05-08 21:45:39 +00:00
|
|
|
device_init_wakeup(&pusb_intf->dev, 1);
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
|
2013-10-19 17:45:47 +00:00
|
|
|
DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n",
|
|
|
|
device_may_wakeup(&pusb_intf->dev));
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto
|
|
|
|
* suspend influence */
|
|
|
|
if (usb_autopm_get_interface(pusb_intf) < 0)
|
|
|
|
DBG_88E("can't get autopm:\n");
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* alloc dev name after read efuse. */
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
|
|
|
|
rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
|
2013-10-19 17:45:47 +00:00
|
|
|
memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("MAC Address from pnetdev->dev_addr = %pM\n",
|
|
|
|
pnetdev->dev_addr);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
/* step 6. Tell the network stack we exist */
|
2013-05-08 21:45:39 +00:00
|
|
|
if (register_netdev(pnetdev) != 0) {
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto free_hal_data;
|
|
|
|
}
|
|
|
|
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
|
2013-05-08 21:45:39 +00:00
|
|
|
, padapter->bDriverStopped
|
|
|
|
, padapter->bSurpriseRemoved
|
|
|
|
, padapter->bup
|
|
|
|
, padapter->hw_init_completed
|
|
|
|
);
|
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
|
|
|
free_hal_data:
|
2013-11-29 22:10:20 +00:00
|
|
|
if (status != _SUCCESS)
|
2013-06-03 19:52:18 +00:00
|
|
|
kfree(padapter->HalData);
|
2013-05-08 21:45:39 +00:00
|
|
|
free_adapter:
|
|
|
|
if (status != _SUCCESS) {
|
|
|
|
if (pnetdev)
|
|
|
|
rtw_free_netdev(pnetdev);
|
|
|
|
else if (padapter)
|
2014-11-16 00:18:30 +00:00
|
|
|
vfree(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
padapter = NULL;
|
|
|
|
}
|
|
|
|
exit:
|
|
|
|
return padapter;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static void rtw_usb_if1_deinit(struct adapter *if1)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct net_device *pnetdev = if1->pnetdev;
|
2013-08-12 01:59:28 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &if1->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED))
|
2013-05-26 03:02:10 +00:00
|
|
|
rtw_disassoc_cmd(if1, 0, false);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_AP_MODE
|
2013-05-08 21:45:39 +00:00
|
|
|
free_mlme_ap_info(if1);
|
|
|
|
#endif
|
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
if (pnetdev) {
|
|
|
|
/* will call netdev_close() */
|
|
|
|
unregister_netdev(pnetdev);
|
|
|
|
rtw_proc_remove_one(pnetdev);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
rtw_cancel_all_timer(if1);
|
|
|
|
|
|
|
|
rtw_dev_unload(if1);
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n",
|
|
|
|
if1->hw_init_completed);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_drv_sw(if1);
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pnetdev)
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_free_netdev(pnetdev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
|
|
|
|
{
|
2013-10-19 17:45:47 +00:00
|
|
|
struct adapter *if1 = NULL;
|
2014-11-16 00:18:30 +00:00
|
|
|
int status = _FAIL;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct dvobj_priv *dvobj;
|
|
|
|
|
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n"));
|
|
|
|
|
|
|
|
/* Initialize dvobj_priv */
|
2013-08-12 01:59:28 +00:00
|
|
|
dvobj = usb_dvobj_init(pusb_intf);
|
|
|
|
if (dvobj == NULL) {
|
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_,
|
|
|
|
("initialize device object priv Failed!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid);
|
|
|
|
if (if1 == NULL) {
|
2013-07-27 01:08:39 +00:00
|
|
|
DBG_88E("rtw_init_primarystruct adapter Failed!\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
goto free_dvobj;
|
|
|
|
}
|
|
|
|
|
2013-07-18 15:12:28 +00:00
|
|
|
if (ui_pid[1] != 0) {
|
2013-08-12 01:59:28 +00:00
|
|
|
DBG_88E("ui_pid[1]:%d\n", ui_pid[1]);
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_signal_process(ui_pid[1], SIGUSR2);
|
|
|
|
}
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
status = _SUCCESS;
|
|
|
|
|
|
|
|
free_dvobj:
|
|
|
|
if (status != _SUCCESS)
|
|
|
|
usb_dvobj_deinit(pusb_intf);
|
|
|
|
exit:
|
2013-08-12 01:59:28 +00:00
|
|
|
return status == _SUCCESS ? 0 : -ENODEV;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dev_remove() - our device is being removed
|
|
|
|
*/
|
2013-08-12 01:59:28 +00:00
|
|
|
/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both */
|
2013-05-08 21:45:39 +00:00
|
|
|
static void rtw_dev_remove(struct usb_interface *pusb_intf)
|
|
|
|
{
|
|
|
|
struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf);
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = dvobj->if1;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("+rtw_dev_remove\n");
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n"));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
if (!pusb_intf->unregistering)
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bSurpriseRemoved = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_pm_set_ips(padapter, IPS_NONE);
|
|
|
|
rtw_pm_set_lps(padapter, PS_MODE_ACTIVE);
|
|
|
|
|
|
|
|
LeaveAllPowerSaveMode(padapter);
|
|
|
|
|
|
|
|
rtw_usb_if1_deinit(padapter);
|
|
|
|
|
|
|
|
usb_dvobj_deinit(pusb_intf);
|
|
|
|
|
2013-08-12 01:59:28 +00:00
|
|
|
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n"));
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("-r871xu_dev_remove, done\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-21 04:27:16 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
static struct usb_driver rtl8188e_usb_drv = {
|
|
|
|
.name = "r8188eu",
|
|
|
|
.probe = rtw_drv_init,
|
|
|
|
.disconnect = rtw_dev_remove,
|
|
|
|
.id_table = rtw_usb_id_tbl,
|
|
|
|
.suspend = rtw_suspend,
|
|
|
|
.resume = rtw_resume,
|
|
|
|
.reset_resume = rtw_resume,
|
|
|
|
};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-11-16 00:18:30 +00:00
|
|
|
module_usb_driver(rtl8188e_usb_drv)
|