void enable_32k_rtc(void)
{
#ifndef GPIO_BT_CLK_PIN 

	rtc_gpio_enable_32k(RTC_GPIO_USER_GPS);
	rtc_gpio_enable_32k(RTC_GPIO_USER_WIFI);

#else
 mt_set_gpio_mode(GPIO_BT_CLK_PIN , GPIO_BT_CLK_PIN_M_CLK);
  mt_set_clock_output(GPIO_BT_CLK_PIN_CLK, CLK_SRC_F32K, 1);
#endif 
	msleep(100);
}
INT32
wmt_plat_rtc_ctrl (
    ENUM_PIN_STATE state
    )
{
    switch(state)
    {
    case PIN_STA_INIT:
        rtc_gpio_enable_32k(RTC_GPIO_USER_GPS);
        WMT_DBG_FUNC("WMT-PLAT:RTC init \n");
        break;

    default:
        WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on RTC\n", state);
        break;
    }
    return 0;
}
INT32 wmt_plat_rtc_ctrl(ENUM_PIN_STATE state)
{
	switch (state) {
	case PIN_STA_INIT:
		rtc_gpio_enable_32k(RTC_GPIO_USER_GPS);
		WMT_DBG_FUNC("WMT-PLAT:RTC init\n");
		break;
	case PIN_STA_SHOW:
		WMT_INFO_FUNC("WMT-PLAT:RTC PIN_STA_SHOW start\n");
		/* TakMan: Temp. solution for building pass. Hongcheng Xia should check with vend_ownen.chen */
		/* WMT_INFO_FUNC("WMT-PLAT:RTC Status(%d)\n", rtc_gpio_32k_status()); */
		WMT_INFO_FUNC("WMT-PLAT:RTC PIN_STA_SHOW end\n");
		break;
	default:
		WMT_WARN_FUNC("WMT-PLAT:Warnning, invalid state(%d) on RTC\n", state);
		break;
	}
	return 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;
}
Example #5
0
void mt6620_power_on(void)
{
    int result = 0;
    static int _32k_set = 0;
	/*log MT6620 GPIO Settings*/
	mt6620_print_pin_configure();
    /* disable interrupt firstly */
    mt_combo_bgf_disable_irq();

#define MT6620_OFF_TIME (10) /* in ms, workable value */
#define MT6620_RST_TIME (30) /* in ms, workable value */
#define MT6620_STABLE_TIME (30) /* in ms, workable value */
#define MT6620_EXT_INT_TIME (5) /* in ms, workable value */
#define MT6620_32K_STABLE_TIME (100) /* in ms, test value */

    
    
#if defined(CONFIG_MTK_COMBO_SDIO_SLOT) && (CONFIG_MTK_COMBO_SDIO_SLOT == 0)
	printk(KERN_INFO "[mt6620] pull up sd0 bus(gpio169~gpio175(exclude gpio174))\n");
    mt_set_gpio_pull_enable(GPIO172, GPIO_PULL_ENABLE);	//->CLK
    mt_set_gpio_pull_select(GPIO172, GPIO_PULL_UP);		
    mt_set_gpio_pull_enable(GPIO171, GPIO_PULL_ENABLE);	//->CMD
    mt_set_gpio_pull_select(GPIO171, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO175, GPIO_PULL_ENABLE);	//->DAT0
    mt_set_gpio_pull_select(GPIO175, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO173, GPIO_PULL_ENABLE);	//->DAT1
    mt_set_gpio_pull_select(GPIO173, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO169, GPIO_PULL_ENABLE);	//->DAT2
    mt_set_gpio_pull_select(GPIO169, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO170, GPIO_PULL_ENABLE);	//->DAT3
    mt_set_gpio_pull_select(GPIO170, GPIO_PULL_UP);
#elif (CONFIG_MTK_COMBO_SDIO_SLOT == 1)
	#error "error:MSDC1 is not reserved for MT6620 on MT6575EVB"
#elif (CONFIG_MTK_COMBO_SDIO_SLOT == 2)
    printk(KERN_INFO "[mt6620] pull up sd2 bus(gpio182~187)\n");
    mt_set_gpio_pull_enable(GPIO182, GPIO_PULL_ENABLE);	//->CLK
    mt_set_gpio_pull_select(GPIO182, GPIO_PULL_UP);		
    mt_set_gpio_pull_enable(GPIO184, GPIO_PULL_ENABLE);	//->CMD
    mt_set_gpio_pull_select(GPIO184, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO186, GPIO_PULL_ENABLE);	//->DAT0
    mt_set_gpio_pull_select(GPIO186, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO187, GPIO_PULL_ENABLE);	//->DAT1
    mt_set_gpio_pull_select(GPIO187, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO185, GPIO_PULL_ENABLE);	//->DAT2
    mt_set_gpio_pull_select(GPIO185, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO183, GPIO_PULL_ENABLE);	//->DAT3
    mt_set_gpio_pull_select(GPIO183, GPIO_PULL_UP);
#elif (CONFIG_MTK_COMBO_SDIO_SLOT == 3)
	printk(KERN_INFO "[mt6620] pull up sd3 bus (GPIO89~GPIO94)\n");
    mt_set_gpio_pull_enable(GPIO92, GPIO_PULL_ENABLE);	//->CLK
    mt_set_gpio_pull_select(GPIO92, GPIO_PULL_UP);		
    mt_set_gpio_pull_enable(GPIO91, GPIO_PULL_ENABLE);	//->CMD
    mt_set_gpio_pull_select(GPIO91, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO94, GPIO_PULL_ENABLE);	//->DAT0
    mt_set_gpio_pull_select(GPIO94, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO90, GPIO_PULL_ENABLE);	//->DAT1
    mt_set_gpio_pull_select(GPIO90, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO89, GPIO_PULL_ENABLE);	//->DAT2
    mt_set_gpio_pull_select(GPIO89, GPIO_PULL_UP);
    mt_set_gpio_pull_enable(GPIO93, GPIO_PULL_ENABLE);	//->DAT3
    mt_set_gpio_pull_select(GPIO93, GPIO_PULL_UP);
#else
	#error "error:unsupported CONFIG_MTK_COMBO_SDIO_SLOT" CONFIG_MTK_COMBO_SDIO_SLOT
#endif

    //printk(KERN_INFO "[mt6620] enable RTC CLK\n");
	if(_32k_set == 0){
		//rtc_gpio_export_32k(true); //old 32k export API
		/*
		* To fix RTC32k clocks stops after system reboot
		*/
		rtc_gpio_enable_32k(RTC_GPIO_USER_GPS);
		_32k_set = 1;
		printk("[mt6620]rtc_gpio_enable_32k(RTC_GPIO_USER_GPS) \n");
	} else {
		printk("[mt6620]not to rtc_gpio_enable_32k(RTC_GPIO_USER_GPS)\n");
	}
    msleep(MT6620_32K_STABLE_TIME);


    /* UART Mode */
    result += mt_set_gpio_mode(GPIO_UART_URXD3_PIN, GPIO_UART_URXD3_PIN_M_URXD);//GPIO_MODE_01->GPIO_UART_URXD3_PIN_M_URXD
    result += mt_set_gpio_mode(GPIO_UART_UTXD3_PIN, GPIO_UART_UTXD3_PIN_M_UTXD);//GPIO_MODE_01->GPIO_UART_UTXD3_PIN_M_UTXD
    //printk(KERN_INFO "[mt6620] set UART GPIO Mode [%d]\n", result);

    /* FIXME! GeorgeKuo: added for MT6620 GPIO initialization */
    /* disable pull */

	mt_set_gpio_pull_enable(GPIO_COMBO_PMU_EN_PIN, GPIO_PULL_DISABLE);

    mt_set_gpio_pull_enable(GPIO_COMBO_RST_PIN, GPIO_PULL_DISABLE);
    /* set output */

	mt_set_gpio_dir(GPIO_COMBO_PMU_EN_PIN, GPIO_DIR_OUT);

    mt_set_gpio_dir(GPIO_COMBO_RST_PIN, GPIO_DIR_OUT);
    /* set gpio mode */

	mt_set_gpio_mode(GPIO_COMBO_PMU_EN_PIN, GPIO_MODE_GPIO);

    mt_set_gpio_mode(GPIO_COMBO_RST_PIN, GPIO_MODE_GPIO);

    /* SYSRST_B low */
    mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ZERO);
    /* PMU_EN low */
	mt_set_gpio_out(GPIO_COMBO_PMU_EN_PIN, GPIO_OUT_ZERO);

    msleep(MT6620_OFF_TIME);

    /* PMU_EN high, SYSRST_B low */
	mt_set_gpio_out(GPIO_COMBO_PMU_EN_PIN, GPIO_OUT_ONE);
    msleep(MT6620_RST_TIME);

    /* SYSRST_B high */
    mt_set_gpio_out(GPIO_COMBO_RST_PIN, GPIO_OUT_ONE);
    msleep(MT6620_STABLE_TIME);

    /* BT PCM bus default mode. Real control is done by audio and mt_combo.c */
    mt_combo_audio_ctrl_ex(COMBO_AUDIO_STATE_1, 0);

    /* EINT1 for BGF_INT_B */
    mt_set_gpio_mode(GPIO_COMBO_BGF_EINT_PIN, GPIO_COMBO_BGF_EINT_PIN_M_GPIO);
    mt_set_gpio_pull_enable(GPIO_COMBO_BGF_EINT_PIN, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_select(GPIO_COMBO_BGF_EINT_PIN, GPIO_PULL_UP);
    mt_set_gpio_mode(GPIO_COMBO_BGF_EINT_PIN, GPIO_COMBO_BGF_EINT_PIN_M_EINT);

    /* request IRQ (EINT1) */
    mt_combo_bgf_request_irq(NULL);

    printk(KERN_INFO "[mt6620] power on \n");

    return;
}