Ejemplo n.º 1
0
/*!
 * \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;
}
Ejemplo n.º 2
0
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;
}
int wmt_detect_read_ext_cmb_status (void)
{
	int retval = 0;
	/*read WIFI_EINT pin status*/
	if (COMBO_WIFI_EINT_PIN == INVALID_PIN_ID)
	{
		retval = 0;
		WMT_DETECT_ERR_FUNC("WMT-DETECT: no WIFI_EINT pin set\n");
	}
	else
	{
		retval = _wmt_detect_read_gpio_input(COMBO_WIFI_EINT_PIN);
		WMT_DETECT_ERR_FUNC("WMT-DETECT: WIFI_EINT input status:%d\n", retval);
		
	}
	return retval;
}
Ejemplo n.º 4
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*/
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
0
static int 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_DBG_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_DBG_FUNC("COMBO COMMON driver init, i_ret:%d\n", i_ret);
	i_ret += i_ret_tmp;

#else
	i_ret = -1;
	WMT_DETECT_ERR_FUNC("SOC chip is not supported, please check kernel makefile or project fonfig, i_ret:%d\n",
			     i_ret);
#endif

	WMT_DETECT_DBG_FUNC("TBD........\n");
	return i_ret;
}
Ejemplo n.º 7
0
int do_connectivity_driver_init(int chip_id)
{
	int i_ret = 0;
	int tmp_ret = 0;

	tmp_ret = do_common_drv_init(chip_id);
	i_ret += tmp_ret;
	if (tmp_ret)
	{
		WMT_DETECT_ERR_FUNC("do common driver init failed, ret:%d\n", tmp_ret);
		WMT_DETECT_ERR_FUNC("abort connectivity driver init, because common part is not ready\n");
		return i_ret;
	}
	
	tmp_ret = do_bluetooth_drv_init(chip_id);
	i_ret += tmp_ret;
	if (tmp_ret)
	{
		WMT_DETECT_ERR_FUNC("do common driver init failed, ret:%d\n", tmp_ret);
	}
		
	tmp_ret = do_gps_drv_init(chip_id);
	i_ret += tmp_ret;
	if (tmp_ret)
	{
		WMT_DETECT_ERR_FUNC("do common driver init failed, ret:%d\n", tmp_ret);
	}
			

	tmp_ret = do_fm_drv_init(chip_id);
	i_ret += tmp_ret;
	if (tmp_ret)
	{
		WMT_DETECT_ERR_FUNC("do fm module init failed, ret:%d\n", tmp_ret);
	}

	tmp_ret = do_wlan_drv_init(chip_id);
	i_ret += tmp_ret;
	if (tmp_ret)
	{
		WMT_DETECT_ERR_FUNC("do wlan module init failed, ret:%d\n", tmp_ret);
	}
	
	return i_ret;
	
}
Ejemplo n.º 8
0
static int 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_DBG_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_DBG_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_DBG_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_DBG_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_DBG_FUNC("STP-SDIO driver init, i_ret:%d\n", i_ret);
	i_ret += i_ret_tmp;

#else
	i_ret = -1;
	WMT_DETECT_ERR_FUNC("COMBO chip is not supported, please check kernel makefile or project fonfig, i_ret:%d\n",
			     i_ret);
#endif
	WMT_DETECT_DBG_FUNC("finish combo driver init\n");
	return i_ret;
}
Ejemplo n.º 9
0
int __weak do_wlan_drv_init(int chip_id)
{
    WMT_DETECT_ERR_FUNC("Can not find wlan module for chip: %d !\n",chip_id);
	return 0;
}
Ejemplo n.º 10
0
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;
}
Ejemplo n.º 11
0
/*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;
}
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;
}
int __weak mtk_wcn_wlan_soc_init(void)
{
    WMT_DETECT_ERR_FUNC("mtk_wcn_wlan_soc_init is not define!\n");
	return 0;
}