wmt_chrdev_wifi.c :
#define WIFI_DEV_MAJOR 153 <--->对应init.rc中创建的设备节点 /xxx/mediatek/custom/jrdsh75_cu_jb/factory/init.rc
static int WIFI_major = WIFI_DEV_MAJOR;
WIFI_init()
dev_t dev = MKDEV(WIFI_major, 0);
-->cdev_init (&WIFI_cdev, &WIFI_fops)-->struct file_operations WIFI_fops = {
.open = WIFI_open,
.release = WIFI_close,
.write = WIFI_write,
};
-->WIFI_open()
-->WIFI_close()
-->WIFI_write()
上层开wifi调用驱动
mtk_wifi.c:
-->wifi_set_power(int enable)
-->halDoCommand("load wifi");//调用驱动
。。。。。
HaldController.cpp
-->int HaldController::loadDriver(const char *ifname)
{
ALOGD("Start load wifi driver.");
/*load wifi driver*/
sDriverCtrl->load(NETWORK_IFACE_WIFI);
/*turn on wifi power*/
powerOn();
/*set flag*/
isWifiActive = true;
return 0;
}
-->powerOn()
{
setPower(1);
}
-->void HaldController::setPower(int enable)
{
373 const char buffer = (enable ? '1' : '0');
374
375
fd = open(WIFI_POWER_PATH, O_WRONLY); //打开节点?? #define WIFI_POWER_PATH "/dev/wmtWifi"
376 if (fd < 0) {
377 ALOGE("Open \"%s\" failed", WIFI_POWER_PATH);
378 goto out;
379 }
380
sz = write(fd, &buffer, 1);
381 if (sz < 0) {
382 ALOGE("Set \"%s\" [%c] failed", WIFI_POWER_PATH, buffer);
383 goto out;
384 }
}
//节点创建 init.rc
mknod /dev/wmtWifi c 153 0 <---> 对应wmt_chrdev_wifi.c #define WIFI_DEV_MAJOR 153
因此上层从
fd = open(WIFI_POWER_PATH, O_WRONLY);执行到wmt_chrdev_wifi.c 中open
sz = write(fd, &buffer, 1); 执行到wmt_chrdev_wifi.c 中write
Settings.java(mWifiEnabler)-->WifiEnabler.java(mWifiManager)-->WifiManager.java(mservices)-->IWifiManager.aidl-->WifiService.java( mWifiStateMachine.setWifiEnabled(enable);
)-->WifiStateMachine.java({
public void setWifiEnabled(boolean enable) {
mLastEnableUid.set(Binder.getCallingUid());
if (enable) {
/* Argument is the state that is entered prior to load */
sendMessage(obtainMessage(CMD_LOAD_DRIVER, WIFI_STATE_ENABLING, 0));//加载驱动
sendMessage(CMD_START_SUPPLICANT);//用于数据通信
} else {
sendMessage(CMD_STOP_SUPPLICANT);
/* Argument is the state that is entered upon success */
sendMessage(obtainMessage(CMD_UNLOAD_DRIVER, WIFI_STATE_DISABLED, 0));
}
}
})-->WifiNative.java(mwifinative.loadDriver())-->android_net_wifi_wifi.cpp(android_net_wifi_loadDriver())-->mtk_wifi.c(wifi_load_driver())??(有木有已经和上面接轨了!!)
芯片上电
wmt_ctrl.c -->wmt_ctrl_hw_pwr_on(P_WMT_CTRL_DATA pWmtCtrlData)
--wmt_plat_alps.c-->INT32 wmt_plat_pwr_ctrl ( ENUM_FUNC_STATE state )--< case FUNC_ON:
// TODO:[ChangeFeature][George] always output this or by request throuth /proc or sysfs?
wmt_plat_dump_pin_conf();
ret = mtk_wcn_cmb_hw_pwr_on();
>----mtk_wcn_cmb_hw_6628.c-->(mtk_wcn_cmb_hw_pwr_on (VOID)--->找到wifi的管脚中断WIFI_EINT(GPIO15)及外部中断号WIFI_EINT_NUM(18)
)
/XXX/mediatek/custom/jrdsh75_cu_jb/kernel/core/src/board.c -->中断请求
-->通过中断号WIFI_EINT_NUM(18)-->mtk_wcn_cmb_sdio_eint_num=CUST_EINT_WIFI_NUM=18
static void mtk_wcn_cmb_sdio_request_eirq(sdio_irq_handler_t irq_handler, void *data)
{
mtk_wcn_sdio_irq_flag_set (0);
mtk_wcn_cmb_sdio_eirq_data = data;
mtk_wcn_cmb_sdio_eirq_handler = irq_handler;
mt65xx_eint_set_sens(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_SENSITIVE); /*CUST_EINT_WIFI_NUM */
mt65xx_eint_set_hw_debounce(mtk_wcn_cmb_sdio_eint_num, CUST_EINT_WIFI_DEBOUNCE_CN); /*CUST_EINT_WIFI_NUM */
mt_set_gpio_pull_enable(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_ENABLE);
mt_set_gpio_pull_select(mtk_wcn_cmb_sdio_eint_pin, GPIO_PULL_UP);
mt65xx_eint_registration(mtk_wcn_cmb_sdio_eint_num/*CUST_EINT_WIFI_NUM */,
CUST_EINT_WIFI_DEBOUNCE_EN,
CUST_EINT_WIFI_POLARITY,
mtk_wcn_cmb_sdio_eirq_handler_stub,
0);
mt65xx_eint_mask(mtk_wcn_cmb_sdio_eint_num);/*CUST_EINT_WIFI_NUM */
}
--> .request_sdio_eirq = mtk_wcn_cmb_sdio_request_eirq,
再找request_sdio_eirq相关中断请求----->找到sd.c
if (hw->request_sdio_eirq) /* set to combo_sdio_request_eirq() for WIFI */
hw->request_sdio_eirq(msdc_eirq_sdio, (void*)host); /* msdc_eirq_sdio() will be called when EIRQ */
-->找到msdc_eirq_sdio------------->中断处理函数
/* msdc_eirq_sdio() will be called when EIRQ(for WIFI) */
static void msdc_eirq_sdio(void *data)
{
struct msdc_host *host = (struct msdc_host *)data;
N_MSG(INT, "SDIO EINT");
mmc_signal_sdio_irq(host->mmc);
}
Gl_init.c-->启动gl_kal.c的tx_thread线程,当这个线程启动后就等待中断处理网络数据的发送与接收。<----->网络驱动函数
sdio.c ------->static void mtk_sdio_interrupt(struct sdio_func *func)-->wake_up_interruptible(&prGlueInfo->waitq);就会去调用
gl_kal.c --->int tx_thread(void *data)-->ret = wait_event_interruptible(prGlueInfo->waitq,(prGlueInfo->u4Flag != 0));
wlan_lib.c---->wlanTxPendingPackets (
IN P_ADAPTER_T prAdapter,
IN OUT PBOOLEAN pfgHwAccess
)