/*
 * 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 /*__devinit*/  rtw_drv_probe(struct spi_device *spi)
{
	int status = _FAIL;
	struct dvobj_priv *dvobj;
	struct net_device *pnetdev;
	PADAPTER if1 = NULL, if2 = NULL;


	DBG_8192C("RTW: %s line:%d", __FUNCTION__, __LINE__);

	if ((dvobj = gspi_dvobj_init(spi)) == NULL) {
		DBG_871X("%s: Initialize device object priv Failed!\n", __FUNCTION__);
		goto exit;
	}

	if ((if1 = rtw_gspi_if1_init(dvobj)) == NULL) {
		DBG_871X("rtw_init_primary_adapter Failed!\n");
		goto free_dvobj;
	}

#ifdef CONFIG_CONCURRENT_MODE
	if ((if2 = rtw_drv_if2_init(if1, NULL, spi_set_intf_ops)) == NULL) {
		goto free_if1;
	}
#endif

	//dev_alloc_name && register_netdev
	if((status = rtw_drv_register_netdev(if1)) != _SUCCESS) {
		goto free_if2;
	}

#ifdef CONFIG_HOSTAPD_MLME
	hostapd_mode_init(if1);
#endif

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

	if (gspi_alloc_irq(dvobj) != _SUCCESS)
		goto free_if2;

#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

	RT_TRACE(_module_hci_intfs_c_,_drv_err_,("-871x_drv - drv_init, success!\n"));

	status = _SUCCESS;

free_if2:
	if (status != _SUCCESS && if2) {
		#ifdef CONFIG_CONCURRENT_MODE
		rtw_drv_if2_stop(if2);
		rtw_drv_if2_free(if2);
		#endif
	}

free_if1:
	if (status != _SUCCESS && if1) {
		rtw_gspi_if1_deinit(if1);
	}

free_dvobj:
	if (status != _SUCCESS)
		gspi_dvobj_deinit(spi);

exit:
	return status == _SUCCESS?0:-ENODEV;
}
예제 #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;
}
예제 #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;
}