예제 #1
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;
}
예제 #2
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;
}
예제 #3
0
/*
 * 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.
 */
static int rtw_drv_init(
	struct sdio_func *func,
	const struct sdio_device_id *id)
{
	struct net_device *pnetdev;
	PADAPTER padapter;
	struct dvobj_priv *pdvobjpriv;
	PSDIO_DATA psdio;


	RT_TRACE(_module_hci_intfs_c_, _drv_info_,
		 ("+rtw_drv_init: vendor=0x%04x device=0x%04x class=0x%02x\n",
		  func->vendor, func->device, func->class));

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

	SET_NETDEV_DEV(pnetdev, &func->dev);

	padapter = rtw_netdev_priv(pnetdev);
	pdvobjpriv = &padapter->dvobjpriv;
	pdvobjpriv->padapter = padapter;
	psdio = &pdvobjpriv->intf_data;
	psdio->func = func;

#ifdef CONFIG_IOCTL_CFG80211
	rtw_wdev_alloc(padapter, &func->dev);
#endif

	//3 2. set interface private data
	sdio_set_drvdata(func, pdvobjpriv);

	//3 3. init driver special setting, interface, OS and hardware relative
	// set interface_type to sdio
	padapter->interface_type = RTW_SDIO;
	decide_chip_type_by_device_id(padapter, (u32)func->device);

	//4 3.1 set hardware operation functions
	padapter->HalData = rtw_zmalloc(sizeof(HAL_DATA_TYPE));
	if (padapter->HalData == NULL) {
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			 ("rtw_drv_init: can't alloc memory for HAL DATA\n"));
		goto error;
	}
	padapter->hal_data_sz = sizeof(HAL_DATA_TYPE);
	set_hal_ops(padapter);

	//3 4. interface init
	if (sdio_init(padapter) != _SUCCESS) {
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			 ("rtw_drv_init: initialize device object priv Failed!\n"));
		goto error;
	}

	padapter->intf_start = &sd_intf_start;
	padapter->intf_stop = &sd_intf_stop;

	//3 5. register I/O operations
	if (rtw_init_io_priv(padapter) == _FAIL)
	{
		RT_TRACE(_module_hci_intfs_c_, _drv_err_,
			("rtw_drv_init: Can't init io_priv\n"));
		goto deinit;
	}

	//3 6.
	intf_read_chip_version(padapter);

	//3 7.
	intf_chip_configure(padapter);

	//3 8. read efuse/eeprom data
	intf_read_chip_info(padapter);

	//3 9. 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 deinit;
	}

	//3 10. get WLan MAC address
	// alloc dev name after read efuse.
	rtw_init_netdev_name(pnetdev, ifname);

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


#ifdef CONFIG_PROC_DEBUG
#ifdef RTK_DMP_PLATFORM
	rtw_proc_init_one(pnetdev);
#endif
#endif

#ifdef CONFIG_HOSTAPD_MLME
	hostapd_mode_init(padapter);
#endif

#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;	
	padapter->hw_init_mutex = &drvpriv.hw_init_mutex;	
#endif

#ifdef CONFIG_PLATFORM_RTD2880B
	DBG_871X("wlan link up\n");
	rtd2885_wlan_netlink_sendMsg("linkup", "8712");
#endif


#ifdef CONFIG_GLOBAL_UI_PID
	if(ui_pid[1]!=0) {
		DBG_871X("ui_pid[1]:%d\n",ui_pid[1]);
		rtw_signal_process(ui_pid[1], SIGUSR2);
	}
#endif

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


	//3 8. 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 deinit;
	}

#ifdef CONFIG_CONCURRENT_MODE
	if(rtw_drv_if2_init(padapter)==_FAIL)
	{
		goto deinit;
	}	
#endif

	RT_TRACE(_module_hci_intfs_c_, _drv_info_,
		 ("-rtw_drv_init: Success. bDriverStopped=%d bSurpriseRemoved=%d\n",
		  padapter->bDriverStopped, padapter->bSurpriseRemoved));

	return 0;

deinit:
	sdio_deinit(padapter);

error:
	if (padapter)
	{
		if (padapter->HalData && padapter->hal_data_sz>0) {			
			rtw_mfree(padapter->HalData, padapter->hal_data_sz);
			padapter->HalData = NULL;
		}
	}

	if (pnetdev)
		rtw_free_netdev(pnetdev);

	RT_TRACE(_module_hci_intfs_c_, _drv_crit_, ("-rtw_drv_init: FAIL!\n"));

	return -1;
}