예제 #1
0
static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
                                        struct usb_interface *pusb_intf, const struct usb_device_id *pdid)
{
    struct adapter *padapter = NULL;
    struct net_device *pnetdev = NULL;
    int status = _FAIL;

    padapter = (struct adapter *)vzalloc(sizeof(*padapter));
    if (padapter == NULL)
        goto exit;
    padapter->dvobj = dvobj;
    dvobj->if1 = padapter;

    padapter->bDriverStopped = true;
    mutex_init(&padapter->hw_init_mutex);
    padapter->chip_type = RTL8188E;

    pnetdev = rtw_init_netdev(padapter);
    if (pnetdev == NULL)
        goto free_adapter;
    SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
    padapter = rtw_netdev_priv(pnetdev);

    /* step 2. hook HalFunc, allocate HalData */
    hal_set_hal_ops(padapter);

    padapter->intf_start = &usb_intf_start;
    padapter->intf_stop = &usb_intf_stop;

    /* step read_chip_version */
    rtw_hal_read_chip_version(padapter);

    /* step usb endpoint mapping */
    rtw_hal_chip_configure(padapter);

    /* step read efuse/eeprom data and get mac_addr */
    rtw_hal_read_chip_info(padapter);

    /* step 5. */
    if (rtw_init_drv_sw(padapter) == _FAIL) {
        RT_TRACE(_module_hci_intfs_c_, _drv_err_,
                 ("Initialize driver software resource Failed!\n"));
        goto free_hal_data;
    }

#ifdef CONFIG_PM
    if (padapter->pwrctrlpriv.bSupportRemoteWakeup) {
        dvobj->pusbdev->do_remote_wakeup = 1;
        pusb_intf->needs_remote_wakeup = 1;
        device_init_wakeup(&pusb_intf->dev, 1);
        DBG_88E("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n");
        DBG_88E("\n  padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n",
                device_may_wakeup(&pusb_intf->dev));
    }
#endif

    /* 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");

    /*  alloc dev name after read efuse. */
    rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
    rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
    memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);
    DBG_88E("MAC Address from pnetdev->dev_addr =  %pM\n",
            pnetdev->dev_addr);

    /* step 6. Tell the network stack we exist */
    if (register_netdev(pnetdev) != 0) {
        RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n"));
        goto free_hal_data;
    }

    DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
            , padapter->bDriverStopped
            , padapter->bSurpriseRemoved
            , padapter->bup
            , padapter->hw_init_completed
           );

    status = _SUCCESS;

free_hal_data:
    if (status != _SUCCESS)
        kfree(padapter->HalData);
free_adapter:
    if (status != _SUCCESS) {
        if (pnetdev)
            rtw_free_netdev(pnetdev);
        else if (padapter)
            vfree(padapter);
        padapter = NULL;
    }
exit:
    return padapter;
}
예제 #2
0
static PADAPTER rtw_gspi_if1_init(struct dvobj_priv *dvobj)
{
	int status = _FAIL;
	struct net_device *pnetdev;
	PADAPTER padapter = NULL;


	padapter = (PADAPTER)rtw_zvmalloc(sizeof(*padapter));
	if (NULL == padapter) {
		goto exit;
	}

	padapter->dvobj = dvobj;
	dvobj->if1 = padapter;

	padapter->bDriverStopped = _TRUE;

#if defined(CONFIG_CONCURRENT_MODE) || defined(CONFIG_DUALMAC_CONCURRENT)
	//set adapter_type/iface type for primary padapter
	padapter->isprimary = _TRUE;
	padapter->adapter_type = PRIMARY_ADAPTER;
	#ifndef CONFIG_HWPORT_SWAP
	padapter->iface_type = IFACE_PORT0;
	#else
	padapter->iface_type = IFACE_PORT1;
	#endif
#endif

	padapter->hw_init_mutex = &drvpriv.hw_init_mutex;
#ifdef CONFIG_CONCURRENT_MODE
	//set global variable to primary adapter
	padapter->ph2c_fwcmd_mutex = &drvpriv.h2c_fwcmd_mutex;
	padapter->psetch_mutex = &drvpriv.setch_mutex;
	padapter->psetbw_mutex = &drvpriv.setbw_mutex;
#endif

	padapter->interface_type = RTW_GSPI;
	decide_chip_type_by_device_id(padapter);

	//3 1. init network device data
	pnetdev = rtw_init_netdev(padapter);
	if (!pnetdev)
		goto free_adapter;

	SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));

#ifdef CONFIG_IOCTL_CFG80211
	rtw_wdev_alloc(padapter, dvobj_to_dev(dvobj));
#endif


	//3 3. init driver special setting, interface, OS and hardware relative
	//4 3.1 set hardware operation functions
	hal_set_hal_ops(padapter);


	//3 5. initialize Chip version
	padapter->intf_start = &gspi_intf_start;
	padapter->intf_stop = &gspi_intf_stop;

	if (rtw_init_io_priv(padapter, spi_set_intf_ops) == _FAIL)
	{
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			("rtw_drv_init: Can't init io_priv\n"));
		goto free_hal_data;
	}

	{
		u32 ret = 0;
		DBG_8192C("read start:\n");
		//spi_write8_endian(padapter, SPI_LOCAL_OFFSET | 0xF0, 0x01, 1);
		rtw_write8(padapter, SPI_LOCAL_OFFSET | 0xF0, 0x03);
		ret = rtw_read32(padapter, SPI_LOCAL_OFFSET | 0xF0);
		DBG_8192C("read end 0xF0 read32:%x:\n", ret);
		DBG_8192C("read end 0xF0 read8:%x:\n", rtw_read8(padapter, SPI_LOCAL_OFFSET | 0xF0));

	}

	rtw_hal_read_chip_version(padapter);

	rtw_hal_chip_configure(padapter);


	//3 6. read efuse/eeprom data
	rtw_hal_read_chip_info(padapter);


	//3 7. init driver common data
	if (rtw_init_drv_sw(padapter) == _FAIL) {
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			 ("rtw_drv_init: Initialize driver software resource Failed!\n"));
		goto free_hal_data;
	}


	//3 8. get WLan MAC address
	// alloc dev name after read efuse.
	rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);

	rtw_macaddr_cfg(padapter->eeprompriv.mac_addr);
	_rtw_memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN);

	rtw_hal_disable_interrupt(padapter);


	//3 9. Tell the network stack we exist
	if (register_netdev(pnetdev) != 0) {
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			 ("rtw_drv_init: register_netdev() failed\n"));
		goto free_hal_data;
	}

	DBG_871X("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n"
		,padapter->bDriverStopped
		,padapter->bSurpriseRemoved
		,padapter->bup
		,padapter->hw_init_completed
	);

#ifdef CONFIG_HOSTAPD_MLME
	hostapd_mode_init(padapter);
#endif

	status = _SUCCESS;

free_hal_data:
	if (status != _SUCCESS && padapter->HalData)
		rtw_mfree(padapter->HalData, sizeof(*(padapter->HalData)));

free_wdev:
	if (status != _SUCCESS) {
		#ifdef CONFIG_IOCTL_CFG80211
		rtw_wdev_free(padapter->rtw_wdev);
		#endif
	}

free_adapter:
	if (status != _SUCCESS) {
	if (pnetdev)
		rtw_free_netdev(pnetdev);
		else if (padapter)
			rtw_vmfree((u8*)padapter, sizeof(*padapter));
		padapter = NULL;
	}

exit:
	return padapter;
}