概述
1、驱动加载入口
module_init(wifi_drv_init_module);
module_exit(wifi_drv_cleanup_module);
完成对驱动的注册调用
static int __init wifi_drv_init_module(void)
{
int status = 0;
os_module_init();
#ifdef RTMP_PCI_SUPPORT
status = rt_pci_init_module();
if (status)
MTWF_LOG(DBG_CAT_INIT, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Register PCI device driver failed(%d)!n", status));
#endif /* RTMP_PCI_SUPPORT */
return status;
}
static void __exit wifi_drv_cleanup_module(void)
{
#ifdef RTMP_PCI_SUPPORT
rt_pci_cleanup_module();
MTWF_LOG(DBG_CAT_INIT, DBG_SUBCAT_ALL, DBG_LVL_ERROR,
("Unregister PCI device drivern"));
#endif /* RTMP_PCI_SUPPORT */
os_module_exit();
}
module_init(wifi_drv_init_module);
module_exit(wifi_drv_cleanup_module);
2、RTMP接口的初始化
在这个函数初始化各个接口,包括wifi配置、wifi网络设置等
VOID RtmpDrvOpsInit(
OUT VOID *pDrvOpsOrg,
INOUT VOID *pDrvNetOpsOrg,
IN RTMP_PCI_CONFIG *pPciConfig,
IN RTMP_USB_CONFIG *pUsbConfig)
{
RTMP_DRV_ABL_OPS *pDrvOps = (RTMP_DRV_ABL_OPS *)pDrvOpsOrg;
/* init PCI/USB configuration in different OS */
if (pPciConfig != NULL)
RtmpPciConfig = *pPciConfig;
if (pUsbConfig != NULL)
RtmpUsbConfig = *pUsbConfig;
/* init operators provided from us (DRIVER module) */
pDrvOps->RTMPAllocAdapterBlock = RTMPAllocAdapterBlock;
pDrvOps->RTMPFreeAdapter = RTMPFreeAdapter;
pDrvOps->RtmpRaDevCtrlExit = RtmpRaDevCtrlExit;
pDrvOps->RtmpRaDevCtrlInit = RtmpRaDevCtrlInit;
#ifdef RTMP_MAC_PCI
pDrvOps->RTMPHandleInterrupt = mtd_isr;
#endif /* RTMP_MAC_PCI */
pDrvOps->RTMPSendPackets = RTMPSendPackets;
#ifdef P2P_SUPPORT
pDrvOps->P2P_PacketSend = P2P_PacketSend;
#endif /* P2P_SUPPORT */
pDrvOps->RTMP_COM_IoctlHandle = RTMP_COM_IoctlHandle;
#ifdef CONFIG_AP_SUPPORT
pDrvOps->RTMP_AP_IoctlHandle = RTMP_AP_IoctlHandle;
#endif /* CONFIG_AP_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
pDrvOps->RTMP_STA_IoctlHandle = RTMP_STA_IoctlHandle;
#endif /* CONFIG_STA_SUPPORT */
pDrvOps->RTMPDrvOpen = RTMPDrvOpen;
pDrvOps->RTMPDrvClose = RTMPDrvClose;
pDrvOps->mt_wifi_init = mt_wifi_init;
/* init operators provided from us and netif module */
*pDrvNetOps = *pRtmpDrvNetOps;
}
2.1软硬件前期初始化
static INT RtmpChipOpsRegister(RTMP_ADAPTER *pAd, INT infType)
{
ret = RtmpChipOpsHook(pAd);
WfSysPreInit(pAd);
}
2.2 mt_wifi_init 初始化
/*rename from rt28xx_init*/
int mt_wifi_init(VOID *pAdSrc, RTMP_STRING *pDefaultMac, RTMP_STRING *pHostName)
{
/*for software system initialize*/
if (rtmp_sys_init(pAd, pHostName) != TRUE) //wifi软件系统初始化
goto err2
}
static INT rtmp_sys_init(RTMP_ADAPTER *pAd, RTMP_STRING *pHostName)
{
/* Initialize pAd->StaCfg[], pAd->ApCfg, pAd->CommonCfg to manufacture default*/
if (rtmp_cfg_init(pAd, pHostName) != TRUE) //配置初始化
goto err2;
}
INT rtmp_cfg_init(RTMP_ADAPTER *pAd, RTMP_STRING *pHostName)
{
* For Vxworks we have already configured through IOCTL instead of profile, no need to init user cfg again */
UserCfgInit(pAd);
}
3、网络设备的初始化
PNET_DEV RtmpPhyNetDevInit(VOID *pAd, RTMP_OS_NETDEV_OP_HOOK *pNetDevHook)
{
pNetDevHook->open = main_virtual_if_open;
pNetDevHook->stop = main_virtual_if_close;
pNetDevHook->xmit = rt28xx_send_packets;
#ifdef IKANOS_VX_1X0
pNetDevHook->xmit = IKANOS_DataFramesTx;
}
3.1 加载wifi ra0、rai0设备
int main_virtual_if_open(struct net_device *net_dev)
{
if (VIRTUAL_IF_INIT(pAd, net_dev) != 0) //判断raxx是否加载
return -1;
if (VIRTUAL_IF_UP(pAd, net_dev) != 0)
return -1;
}
加载ra0设备
int mt_wifi_open(VOID *dev)
{
/* Chip & other init */
if (mt_wifi_init(pAd, mac, hostname) == FALSE) //wifi 配置相关初始化
goto err;
mt_service_init(pAd); //MT
}
最后
以上就是大意万宝路为你收集整理的MTK wifi驱动源码分析的全部内容,希望文章能够帮你解决MTK wifi驱动源码分析所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复