int do_common_drv_init(int chip_id) { int i_ret = 0; WMT_DETECT_INFO_FUNC("start to do common driver init, chipid:0x%08x\n", chip_id); switch (chip_id) { case 0x6620: case 0x6628: case 0x6630: i_ret = do_combo_common_drv_init(chip_id); break; case 0x6572: case 0x6582: case 0x6592: case 0x6571: case 0x8127: case 0x6752: case 0x6735: case 0x8163: case 0x6580: case 0x6755: i_ret = do_soc_common_drv_init(chip_id); break; } WMT_DETECT_INFO_FUNC("finish common driver init\n"); return i_ret; }
/*! * \brief hif_sdio probe function * * hif_sdio probe function called by mmc driver when any matched SDIO function * is detected by it. * * \param func * \param id * * \retval 0 register successfully * \retval < 0 list error code here */ static int sdio_detect_probe ( struct sdio_func *func, const struct sdio_device_id *id ) { int chipId = 0; WMT_DETECT_INFO_FUNC("vendor(0x%x) device(0x%x) num(0x%x)\n", func->vendor, func->device, func->num); chipId = hif_sdio_match_chipid_by_dev_id(id); if ((0x6630 == chipId) && (1 == func->num)) { int ret = 0; g_func = func; WMT_DETECT_INFO_FUNC("autok function detected, func:0x%p\n", g_func); sdio_claim_host(func); ret = sdio_enable_func(func); sdio_release_host(func); if (ret) { WMT_DETECT_ERR_FUNC("sdio_enable_func failed!\n"); } } return 0; }
static ssize_t wmt_detect_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { WMT_DETECT_INFO_FUNC(" ++\n"); WMT_DETECT_INFO_FUNC(" --\n"); return 0; }
int do_bluetooth_drv_init(int chip_id) { int i_ret = -1; WMT_DETECT_INFO_FUNC("start to do bluetooth driver init\n"); i_ret = mtk_wcn_stpbt_drv_init(); WMT_DETECT_INFO_FUNC("finish bluetooth driver init, i_ret:%d\n", i_ret); return i_ret; }
int do_gps_drv_init(int chip_id) { int i_ret = -1; WMT_DETECT_INFO_FUNC("start to do gps driver init \n"); i_ret = mtk_wcn_stpgps_drv_init(); WMT_DETECT_INFO_FUNC("finish gps driver init, i_ret:%d\n", i_ret); return i_ret; }
int do_fm_drv_init(int chip_id) { WMT_DETECT_INFO_FUNC("start to do fm module init \n"); #ifdef MTK_FM_SUPPORT mtk_wcn_fm_init(); #endif WMT_DETECT_INFO_FUNC("finish fm module init\n"); return 0; }
int do_bluetooth_drv_init(int chip_id) { int i_ret = -1; #ifdef CONFIG_MTK_COMBO_BT WMT_DETECT_INFO_FUNC("start to do bluetooth driver init\n"); i_ret = mtk_wcn_stpbt_drv_init(); WMT_DETECT_INFO_FUNC("finish bluetooth driver init, i_ret:%d\n", i_ret); #else WMT_DETECT_INFO_FUNC("CONFIG_MTK_COMBO_BT is not defined\n"); #endif return i_ret; }
int do_bluetooth_drv_init(int chip_id) { int i_ret = -1; #ifdef MTK_WCN_REMOVE_KERNEL_MODULE WMT_DETECT_INFO_FUNC("start to do bluetooth driver init \n"); i_ret = mtk_hci_init(); WMT_DETECT_INFO_FUNC("finish bluetooth driver init, i_ret:%d\n", i_ret); #else WMT_DETECT_INFO_FUNC("start to do bluetooth driver init \n"); i_ret = mtk_wcn_stpbt_drv_init(); WMT_DETECT_INFO_FUNC("finish bluetooth driver init, i_ret:%d\n", i_ret); #endif return i_ret; }
int hif_sdio_match_chipid_by_dev_id (const struct sdio_device_id *id) { int maxIndex = sizeof (gChipInfoArray) / sizeof (gChipInfoArray[0]); int index = 0; struct sdio_device_id *localId = NULL; int chipId = -1; for (index = 0; index < maxIndex; index++) { localId = &(gChipInfoArray[index].deviceId); if ((localId->vendor == id->vendor) && (localId->device == id->device)) { chipId = gChipInfoArray[index].chipId; WMT_DETECT_INFO_FUNC("valid chipId found, index(%d), vendor id(0x%x), device id(0x%x), chip id(0x%x)\n", index, localId->vendor, localId->device, chipId); gComboChipId = chipId; mtk_wcn_wmt_set_chipid(gComboChipId); break; } } if (0 > chipId) { WMT_DETECT_ERR_FUNC("No valid chipId found, vendor id(0x%x), device id(0x%x)\n", id->vendor, id->device); } return chipId; }
static void wmt_detect_exit (void) { dev_t dev = MKDEV(gWmtDetectMajor, 0); if(pDetectDev) { device_destroy(pDetectClass, dev); pDetectDev = NULL; } if(pDetectClass) { class_destroy(pDetectClass); pDetectClass = NULL; } cdev_del(&gWmtDetectCdev); unregister_chrdev_region(dev, WMT_DETECT_DEV_NUM); #if !(MTK_WCN_REMOVE_KO) /*deinit SDIO-DETECT module*/ sdio_detect_exit(); #endif WMT_DETECT_INFO_FUNC("done\n"); }
int sdio_detect_init(void) { int ret = -1; //register to mmc driver ret = sdio_register_driver(&mtk_sdio_client_drv); WMT_DETECT_INFO_FUNC("sdio_register_driver() ret=%d\n", ret); return 0; }
int sdio_detect_exit(void) { g_func = NULL; //register to mmc driver sdio_unregister_driver(&mtk_sdio_client_drv); WMT_DETECT_INFO_FUNC("sdio_unregister_driver\n"); return 0; }
int wmt_detect_ext_chip_pwr_off(void) { /*pre power off external chip*/ //wmt_plat_pwr_ctrl(FUNC_OFF); WMT_DETECT_INFO_FUNC("--\n"); wmt_detect_sdio_pwr_ctrl(0); return wmt_detect_chip_pwr_ctrl(0); }
int static do_combo_common_drv_init(int chip_id) { int i_ret = 0; #ifdef MTK_WCN_COMBO_CHIP_SUPPORT int i_ret_tmp = 0; WMT_DETECT_INFO_FUNC("start to do combo driver init, chipid:0x%08x\n", chip_id); /*HIF-SDIO driver init*/ i_ret_tmp = mtk_wcn_hif_sdio_drv_init(); WMT_DETECT_INFO_FUNC("HIF-SDIO driver init, i_ret:%d\n", i_ret); i_ret += i_ret_tmp; /*WMT driver init*/ i_ret_tmp = mtk_wcn_combo_common_drv_init(); WMT_DETECT_INFO_FUNC("COMBO COMMON driver init, i_ret:%d\n", i_ret); i_ret += i_ret_tmp; /*STP-UART driver init*/ i_ret_tmp = mtk_wcn_stp_uart_drv_init(); WMT_DETECT_INFO_FUNC("STP-UART driver init, i_ret:%d\n", i_ret); i_ret += i_ret_tmp; /*STP-SDIO driver init*/ i_ret_tmp = mtk_wcn_stp_sdio_drv_init(); WMT_DETECT_INFO_FUNC("STP-SDIO driver init, i_ret:%d\n", i_ret); i_ret += i_ret_tmp; #else i_ret = -1; WMT_DETECT_INFO_FUNC("COMBO chip is not supported, please check kernel makefile or project fonfig, i_ret:%d\n", i_ret); #endif WMT_DETECT_INFO_FUNC("finish combo driver init\n"); return i_ret; }
static int wmt_detect_open(struct inode *inode, struct file *file) { WMT_DETECT_INFO_FUNC("open major %d minor %d (pid %d)\n", imajor(inode), iminor(inode), current->pid ); return 0; }
int static do_soc_common_drv_init(int chip_id) { int i_ret = 0; #ifdef MTK_WCN_SOC_CHIP_SUPPORT int i_ret_tmp = 0; WMT_DETECT_INFO_FUNC("start to do soc common driver init, chipid:0x%08x\n", chip_id); /*WMT driver init*/ i_ret_tmp = mtk_wcn_soc_common_drv_init(); WMT_DETECT_INFO_FUNC("COMBO COMMON driver init, i_ret:%d\n", i_ret); i_ret += i_ret_tmp; #else i_ret = -1; WMT_DETECT_INFO_FUNC("SOC chip is not supported, please check kernel makefile or project fonfig, i_ret:%d\n", i_ret); #endif WMT_DETECT_INFO_FUNC("TBD........\n"); return i_ret; }
static void sdio_detect_remove ( struct sdio_func *func ) { if (g_func == func) { sdio_claim_host(func); sdio_disable_func(func); sdio_release_host(func); g_func = NULL; } WMT_DETECT_INFO_FUNC("do sdio remove\n"); return ; }
int wmt_detect_ext_chip_pwr_on(void) { /*pre power on external chip*/ //wmt_plat_pwr_ctrl(FUNC_ON); WMT_DETECT_INFO_FUNC("++\n"); if (0 != wmt_detect_chip_pwr_ctrl(1)) { return -1; } if (0 != wmt_detect_sdio_pwr_ctrl(1)) { return -2; } return 0; }
int wmt_detect_ext_chip_detect(void) { int iRet = -1; unsigned int chipId = -1; /*if there is no external combo chip, return -1*/ int bgfEintStatus = -1; WMT_DETECT_INFO_FUNC("++\n"); /*wait for a stable time*/ msleep (10); /*read BGF_EINT_PIN status*/ bgfEintStatus = wmt_detect_read_ext_cmb_status();; /*EINT status is not important for detect chipid,So ingnore it */ #ifdef WMT_NO_EINT_VALUE bgfEintStatus = 1 ; #endif if (0 == bgfEintStatus) { /*external chip does not exist*/ WMT_DETECT_INFO_FUNC("external combo chip not detected\n"); } else if (1 == bgfEintStatus) { /*combo chip exists*/ WMT_DETECT_INFO_FUNC("external combo chip detected\n"); /*detect chipid by sdio_detect module*/ chipId = sdio_detect_query_chipid(1); if (0 <= hif_sdio_is_chipid_valid(chipId)) { WMT_DETECT_INFO_FUNC("valid external combo chip id (0x%x)\n", chipId); } else { WMT_DETECT_INFO_FUNC("invalid_external combo chip id (0x%x)\n", chipId); } iRet = 0; } else { /*Error exists*/ WMT_DETECT_ERR_FUNC("error happens when detecting combo chip\n"); } WMT_DETECT_INFO_FUNC("--\n"); /*return 0*/ return iRet; /*todo: if there is external combo chip, power on chip return 0*/ }
int hif_sdio_is_chipid_valid (int chipId) { int index = -1; int left = 0; int middle = 0; int right = sizeof (gChipInfoArray) / sizeof (gChipInfoArray[0]) - 1; if ((chipId < gChipInfoArray[left].chipId) || (chipId > gChipInfoArray[right].chipId)) return index; middle = (left + right) / 2; while (left <= right) { if (chipId > gChipInfoArray[middle].chipId) { left = middle + 1; } else if (chipId < gChipInfoArray[middle].chipId) { right = middle - 1; } else { index = middle; break; } middle = (left + right) / 2; } if (0 > index) { WMT_DETECT_ERR_FUNC("no supported chipid found\n"); } else { WMT_DETECT_INFO_FUNC("index:%d, chipId:0x%x\n", index, gChipInfoArray[index].chipId); } return index; }
int sdio_detect_do_autok(int chipId) { #if MTK_HIF_SDIO_AUTOK_ENABLED BOOTMODE boot_mode; boot_mode = get_boot_mode(); if (boot_mode == META_BOOT) { WMT_DETECT_INFO_FUNC("omit autok in meta mode\n"); return 0; } if (0x6630 == chipId) { #ifdef CONFIG_SDIOAUTOK_SUPPORT if (NULL!= g_func) { WMT_DETECT_INFO_FUNC("wait_sdio_autok_ready++\n"); wait_sdio_autok_ready(g_func->card->host); WMT_DETECT_INFO_FUNC("wait_sdio_autok_ready--\n"); } else { WMT_DETECT_INFO_FUNC("g_func NULL, omit autok\n"); } #else WMT_DETECT_INFO_FUNC("MTK_SDIOAUTOK_SUPPORT not defined\n"); #endif } else { WMT_DETECT_INFO_FUNC("MT%x does not support SDIO3.0 autoK is not needed\n", chipId); } #else WMT_DETECT_INFO_FUNC("MTK_HIF_SDIO_AUTOK_ENABLED is not defined\n"); #endif return 0; }
extern UINT32 wmt_plat_get_soc_chipid(void) { WMT_DETECT_INFO_FUNC("no soc chip supported, due to MTK_WCN_SOC_CHIP_SUPPORT is not set.\n"); return -1; }
/*This power on sequence must support all combo chip's basic power on sequence 1. LDO control is a must, if external LDO exist 2. PMU control is a must 3. RST control is a must 4. WIFI_EINT pin control is a must, used for GPIO mode for EINT status checkup 5. RTC32k clock control is a must */ static int wmt_detect_chip_pwr_on (void) { int retval = -1; /*setting validiation check*/ if ((COMBO_PMU_PIN == INVALID_PIN_ID) || \ (COMBO_RST_PIN == INVALID_PIN_ID) || \ (COMBO_WIFI_EINT_PIN == INVALID_PIN_ID) ) { WMT_DETECT_ERR_FUNC("WMT-DETECT: either PMU(%d) or RST(%d) or WIFI_EINT(%d) is not set\n",\ COMBO_PMU_PIN, \ COMBO_RST_PIN, \ COMBO_WIFI_EINT_PIN); return retval; } /*set LDO/PMU/RST to output 0, no pull*/ if (COMBO_LDO_PIN != INVALID_PIN_ID) { _wmt_detect_set_output_mode(COMBO_LDO_PIN); _wmt_detect_output_low(COMBO_LDO_PIN); } _wmt_detect_set_output_mode(COMBO_PMU_PIN); _wmt_detect_output_low(COMBO_PMU_PIN); _wmt_detect_set_output_mode(COMBO_RST_PIN); _wmt_detect_output_low(COMBO_RST_PIN); #ifdef CONFIG_MTK_COMBO_COMM_NPWR if ((COMBO_I2S_DAT_PIN != INVALID_PIN_ID) && \ (COMBO_PCM_SYNC_PIN != INVALID_PIN_ID) ) { _wmt_detect_set_output_mode(COMBO_I2S_DAT_PIN); _wmt_detect_output_low(COMBO_I2S_DAT_PIN); _wmt_detect_set_output_mode(COMBO_PCM_SYNC_PIN); _wmt_detect_output_low(COMBO_PCM_SYNC_PIN); if (COMBO_PCM_IN_PIN != INVALID_PIN_ID) { _wmt_detect_set_output_mode(COMBO_PCM_IN_PIN); _wmt_detect_output_low(COMBO_PCM_IN_PIN); } if (COMBO_PCM_OUT_PIN != INVALID_PIN_ID) { _wmt_detect_set_output_mode(COMBO_PCM_OUT_PIN); _wmt_detect_output_low(COMBO_PCM_OUT_PIN); } if (COMBO_PCM_CLK_PIN != INVALID_PIN_ID) { _wmt_detect_set_output_mode(COMBO_PCM_CLK_PIN); _wmt_detect_output_low(COMBO_PCM_CLK_PIN); } } else { WMT_DETECT_INFO_FUNC("WMT-DETECT: PCM SYNC (%d) and I2S DAT (%d) is not defined\n", COMBO_PCM_SYNC_PIN, COMBO_I2S_DAT_PIN); } _wmt_detect_set_output_mode(COMBO_RST_PIN); _wmt_detect_output_low(COMBO_RST_PIN); #endif #if 0 _wmt_detect_set_output_mode(COMBO_WIFI_EINT_PIN); _wmt_detect_output_low(COMBO_WIFI_EINT_PIN); #endif /*pull high LDO*/ _wmt_detect_output_high(COMBO_LDO_PIN); /*sleep for LDO stable time*/ msleep(MAX_LDO_STABLE_TIME); /*export RTC clock, sleep for RTC stable time*/ rtc_gpio_enable_32k(RTC_GPIO_USER_GPS); msleep(MAX_RTC_STABLE_TIME); /*PMU output low, RST output low, to make chip power off completely*/ /*always done*/ /*sleep for power off stable time*/ msleep(MAX_OFF_STABLE_TIME); /*PMU output high, and sleep for reset stable time*/ _wmt_detect_output_high(COMBO_PMU_PIN); #ifdef CONFIG_MTK_COMBO_COMM_NPWR if ((COMBO_I2S_DAT_PIN != INVALID_PIN_ID) && \ (COMBO_PCM_SYNC_PIN != INVALID_PIN_ID) ) { msleep(20); _wmt_detect_set_output_mode(COMBO_PCM_SYNC_PIN); _wmt_detect_output_high(COMBO_PCM_SYNC_PIN); msleep(20); _wmt_detect_set_output_mode(COMBO_I2S_DAT_PIN); _wmt_detect_output_high(COMBO_I2S_DAT_PIN); msleep(20); _wmt_detect_set_output_mode(COMBO_I2S_DAT_PIN); _wmt_detect_output_low(COMBO_I2S_DAT_PIN); msleep(20); _wmt_detect_set_output_mode(COMBO_PCM_SYNC_PIN); _wmt_detect_output_low(COMBO_PCM_SYNC_PIN); msleep(20); } #endif msleep(MAX_RST_STABLE_TIME); /*RST output high, and sleep for power on stable time*/ _wmt_detect_output_high(COMBO_RST_PIN); msleep(MAX_ON_STABLE_TIME); retval = 0; return retval; }
/*copied form WMT module*/ static int wmt_detect_dump_pin_conf (void) { WMT_DETECT_INFO_FUNC( "[WMT-DETECT]=>dump wmt pin configuration start<=\n"); #ifdef GPIO_COMBO_6620_LDO_EN_PIN WMT_DETECT_INFO_FUNC( "LDO(GPIO%d)\n", GPIO_COMBO_6620_LDO_EN_PIN); #else WMT_DETECT_INFO_FUNC( "LDO(not defined)\n"); #endif #ifdef GPIO_COMBO_PMU_EN_PIN WMT_DETECT_INFO_FUNC( "PMU(GPIO%d)\n", GPIO_COMBO_PMU_EN_PIN); #else WMT_DETECT_INFO_FUNC( "PMU(not defined)\n"); #endif #ifdef GPIO_COMBO_PMUV28_EN_PIN WMT_DETECT_INFO_FUNC( "PMUV28(GPIO%d)\n", GPIO_COMBO_PMUV28_EN_PIN); #else WMT_DETECT_INFO_FUNC( "PMUV28(not defined)\n"); #endif #ifdef GPIO_COMBO_RST_PIN WMT_DETECT_INFO_FUNC( "RST(GPIO%d)\n", GPIO_COMBO_RST_PIN); #else WMT_DETECT_INFO_FUNC( "RST(not defined)\n"); #endif #ifdef GPIO_COMBO_BGF_EINT_PIN WMT_DETECT_INFO_FUNC( "BGF_EINT(GPIO%d)\n", GPIO_COMBO_BGF_EINT_PIN); #else WMT_DETECT_INFO_FUNC( "BGF_EINT(not defined)\n"); #endif #ifdef CUST_EINT_COMBO_BGF_NUM WMT_DETECT_INFO_FUNC( "BGF_EINT_NUM(%d)\n", CUST_EINT_COMBO_BGF_NUM); #else WMT_DETECT_INFO_FUNC( "BGF_EINT_NUM(not defined)\n"); #endif #ifdef GPIO_WIFI_EINT_PIN WMT_DETECT_INFO_FUNC( "WIFI_EINT(GPIO%d)\n", GPIO_WIFI_EINT_PIN); #else WMT_DETECT_INFO_FUNC( "WIFI_EINT(not defined)\n"); #endif #ifdef CUST_EINT_WIFI_NUM WMT_DETECT_INFO_FUNC( "WIFI_EINT_NUM(%d)\n", CUST_EINT_WIFI_NUM); #else WMT_DETECT_INFO_FUNC( "WIFI_EINT_NUM(not defined)\n"); #endif WMT_DETECT_INFO_FUNC( "[WMT-PLAT]=>dump wmt pin configuration emds<=\n"); return 0; }
int do_wlan_drv_init(int chip_id) { int i_ret = 0; int ret = 0; #ifdef CONFIG_MTK_COMBO_WIFI WMT_DETECT_INFO_FUNC("start to do wlan module init 0x%x\n", chip_id); switch (chip_id) { case 0x6620: #ifdef MT6620 /* WMT-WIFI char dev init */ ret = mtk_wcn_wmt_wifi_init(); WMT_DETECT_INFO_FUNC("WMT-WIFI char dev init, ret:%d\n", ret); i_ret += ret; /* WLAN driver init*/ ret = mtk_wcn_wlan_6620_init(); WMT_DETECT_INFO_FUNC("WLAN driver init, ret:%d\n", ret); i_ret += ret; #else WMT_DETECT_ERR_FUNC("MT6620 is not supported, please check kernel makefile or project config\n"); i_ret = -1; #endif break; case 0x6628: #ifdef MT6628 /* WMT-WIFI char dev init */ ret = mtk_wcn_wmt_wifi_init(); WMT_DETECT_INFO_FUNC("WMT-WIFI char dev init, ret:%d\n", ret); i_ret += ret; /* WLAN driver init*/ ret = mtk_wcn_wlan_6628_init(); WMT_DETECT_INFO_FUNC("WLAN driver init, ret:%d\n", ret); i_ret += ret; #else WMT_DETECT_ERR_FUNC("MT6628 is not supported, please check kernel makefile or project config\n"); i_ret = -1; #endif break; case 0x6630: #ifdef MT6630 /* WMT-WIFI char dev init */ ret = mtk_wcn_wmt_wifi_init(); WMT_DETECT_INFO_FUNC("WMT-WIFI char dev init, ret:%d\n", ret); i_ret += ret; /* WLAN driver init*/ ret = mtk_wcn_wlan_6630_init(); WMT_DETECT_INFO_FUNC("WLAN driver init, ret:%d\n", ret); i_ret += ret; #else WMT_DETECT_ERR_FUNC("MT6630 is not supported, please check kernel makefile or project config\n"); i_ret = -1; #endif break; case 0x6572: case 0x6582: case 0x6592: case 0x6571: case 0x8127: case 0x6752: case 0x6735: #ifdef MTK_WCN_SOC_CHIP_SUPPORT /* WMT-WIFI char dev init */ ret = mtk_wcn_wmt_wifi_soc_init(); WMT_DETECT_INFO_FUNC("WMT-WIFI char dev init, ret:%d\n", ret); i_ret += ret; /* WLAN driver init*/ ret = mtk_wcn_wlan_soc_init(); WMT_DETECT_INFO_FUNC("WLAN driver init, ret:%d\n", ret); i_ret += ret; #else WMT_DETECT_ERR_FUNC("SOC is not supported, please check kernel makefile or project config\n"); i_ret = -1; #endif break; } WMT_DETECT_INFO_FUNC("finish wlan module init\n"); #else WMT_DETECT_INFO_FUNC("WLAN function not supported, skip\n"); #endif return i_ret; }
static long wmt_detect_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { int retval = 0; WMT_DETECT_INFO_FUNC("cmd (%d),arg(%ld)\n", cmd,arg); switch(cmd){ case COMBO_IOCTL_GET_CHIP_ID: /*just get chipid from sdio-detect module*/ /*check if external combo chip exists or not*/ /*if yes, just return combo chip id*/ /*if no, get soc chipid*/ retval = mtk_wcn_wmt_chipid_query(); break; case COMBO_IOCTL_SET_CHIP_ID: mtk_wcn_wmt_set_chipid(arg); break; case COMBO_IOCTL_EXT_CHIP_PWR_ON: retval = wmt_detect_ext_chip_pwr_on(); break; case COMBO_IOCTL_EXT_CHIP_DETECT: retval = wmt_detect_ext_chip_detect(); break; case COMBO_IOCTL_EXT_CHIP_PWR_OFF: retval = wmt_detect_ext_chip_pwr_off(); break; case COMBO_IOCTL_DO_SDIO_AUDOK: retval = sdio_detect_do_autok(arg); break; case COMBO_IOCTL_GET_SOC_CHIP_ID: retval = wmt_plat_get_soc_chipid(); /*get soc chipid by HAL interface*/ break; case COMBO_IOCTL_MODULE_CLEANUP: #if (MTK_WCN_REMOVE_KO) /*deinit SDIO-DETECT module*/ retval = sdio_detect_exit(); #else WMT_DETECT_INFO_FUNC("no MTK_WCN_REMOVE_KO defined\n"); #endif break; case COMBO_IOCTL_DO_MODULE_INIT: #if (MTK_WCN_REMOVE_KO) /*deinit SDIO-DETECT module*/ retval = do_connectivity_driver_init(arg); #else WMT_DETECT_INFO_FUNC("no MTK_WCN_REMOVE_KO defined\n"); #endif break; default: WMT_DETECT_WARN_FUNC("unknown cmd (%d)\n", cmd); retval = 0; break; } return retval; }
static int wmt_detect_init(void) { dev_t devID = MKDEV(gWmtDetectMajor, 0); int cdevErr = -1; int ret = -1; ret = register_chrdev_region(devID, WMT_DETECT_DEV_NUM, WMT_DETECT_DRVIER_NAME); if (ret) { WMT_DETECT_ERR_FUNC("fail to register chrdev\n"); return ret; } cdev_init(&gWmtDetectCdev, &gWmtDetectFops); gWmtDetectCdev.owner = THIS_MODULE; cdevErr = cdev_add(&gWmtDetectCdev, devID, WMT_DETECT_DEV_NUM); if (cdevErr) { WMT_DETECT_ERR_FUNC("cdev_add() fails (%d) \n", cdevErr); goto err1; } pDetectClass = class_create(THIS_MODULE, WMT_DETECT_DEVICE_NAME); if(IS_ERR(pDetectClass)) { WMT_DETECT_ERR_FUNC("class create fail, error code(%ld)\n",PTR_ERR(pDetectClass)); goto err1; } pDetectDev = device_create(pDetectClass,NULL,devID,NULL,WMT_DETECT_DEVICE_NAME); if(IS_ERR(pDetectDev)) { WMT_DETECT_ERR_FUNC("device create fail, error code(%ld)\n",PTR_ERR(pDetectDev)); goto err2; } WMT_DETECT_INFO_FUNC("driver(major %d) installed success\n", gWmtDetectMajor); /*init SDIO-DETECT module*/ sdio_detect_init(); return 0; err2: if(pDetectClass) { class_destroy(pDetectClass); pDetectClass = NULL; } err1: if (cdevErr == 0) { cdev_del(&gWmtDetectCdev); } if (ret == 0) { unregister_chrdev_region(devID, WMT_DETECT_DEV_NUM); gWmtDetectMajor = -1; } WMT_DETECT_ERR_FUNC("fail \n"); return -1; }