Пример #1
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;
}
Пример #2
0
void mt6620_power_off(void)
{
    printk(KERN_INFO "[mt6620] power off\n");

    //printk(KERN_INFO "[mt6620] mt_combo_bgf_disable_irq\n");
    mt_combo_bgf_disable_irq();

    //printk(KERN_INFO "[mt6620] set BGF_EINT input pull down\n");
    mt_set_gpio_mode(GPIO_COMBO_BGF_EINT_PIN, GPIO_COMBO_BGF_EINT_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_COMBO_BGF_EINT_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_select(GPIO_COMBO_BGF_EINT_PIN, GPIO_PULL_DOWN);
    mt_set_gpio_pull_enable(GPIO_COMBO_BGF_EINT_PIN, GPIO_PULL_ENABLE);

    //printk(KERN_INFO "[mt6620] ALL_EINT NC\n");
#ifdef GPIO_COMBO_ALL_EINT_PIN
    //printk(KERN_INFO "[mt6620] set ALL_EINT input pull down\n");
    mt_set_gpio_mode(GPIO_COMBO_ALL_EINT_PIN, GPIO_MODE_00);
    mt_set_gpio_dir(GPIO_COMBO_ALL_EINT_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_select(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_DOWN);
    mt_set_gpio_pull_enable(GPIO_COMBO_ALL_EINT_PIN, GPIO_PULL_ENABLE);
#endif
    //printk(KERN_INFO "[mt6620] set COMBO_AUDIO_STATE_0\n");
    mt_combo_audio_ctrl_ex(COMBO_AUDIO_STATE_0, 0);

//MT6620 I2S0 related pin defination has been added to the .dws file
#ifndef FM_ANALOG_INPUT
	mt_set_gpio_mode(GPIO_I2S0_CK_PIN, GPIO_I2S0_CK_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_I2S0_CK_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_select(GPIO_I2S0_CK_PIN, GPIO_PULL_DOWN);
    mt_set_gpio_pull_enable(GPIO_I2S0_CK_PIN, GPIO_PULL_ENABLE);
    mt_set_gpio_mode(GPIO_I2S0_WS_PIN, GPIO_I2S0_WS_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_I2S0_WS_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_select(GPIO_I2S0_WS_PIN, GPIO_PULL_DOWN);
    mt_set_gpio_pull_enable(GPIO_I2S0_WS_PIN, GPIO_PULL_ENABLE);
    mt_set_gpio_mode(GPIO_I2S0_DAT_PIN, GPIO_I2S0_DAT_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_I2S0_DAT_PIN, GPIO_DIR_IN);
    mt_set_gpio_pull_select(GPIO_I2S0_DAT_PIN, GPIO_PULL_DOWN);
    mt_set_gpio_pull_enable(GPIO_I2S0_DAT_PIN, GPIO_PULL_ENABLE);
#endif    
    //printk(KERN_INFO "[mt6620] set SYSRST_B 0 and PMU_EN 0 \n");
    /* 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);

#if defined(CONFIG_MTK_COMBO_SDIO_SLOT) && (CONFIG_MTK_COMBO_SDIO_SLOT == 0)
	printk(KERN_INFO "[mt6620] pull down sd0 bus(gpio169~gpio175(exclude gpio174))\n");
    mt_set_gpio_pull_enable(GPIO172, GPIO_PULL_DOWN);	//->CLK
    mt_set_gpio_pull_select(GPIO172, GPIO_PULL_ENABLE);		
    mt_set_gpio_pull_enable(GPIO171, GPIO_PULL_DOWN);	//->CMD
    mt_set_gpio_pull_select(GPIO171, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO175, GPIO_PULL_DOWN);	//->DAT0
    mt_set_gpio_pull_select(GPIO175, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO173, GPIO_PULL_DOWN);	//->DAT1
    mt_set_gpio_pull_select(GPIO173, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO169, GPIO_PULL_DOWN);	//->DAT2
    mt_set_gpio_pull_select(GPIO169, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO170, GPIO_PULL_DOWN);	//->DAT3
    mt_set_gpio_pull_select(GPIO170, GPIO_PULL_ENABLE);
#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 down sd2 bus(gpio182~187)\n");
    mt_set_gpio_pull_enable(GPIO182, GPIO_PULL_DOWN);	//->CLK
    mt_set_gpio_pull_select(GPIO182, GPIO_PULL_ENABLE);		
    mt_set_gpio_pull_enable(GPIO184, GPIO_PULL_DOWN);	//->CMD
    mt_set_gpio_pull_select(GPIO184, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO186, GPIO_PULL_DOWN);	//->DAT0
    mt_set_gpio_pull_select(GPIO186, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO187, GPIO_PULL_DOWN);	//->DAT1
    mt_set_gpio_pull_select(GPIO187, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO185, GPIO_PULL_DOWN);	//->DAT2
    mt_set_gpio_pull_select(GPIO185, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO183, GPIO_PULL_DOWN);	//->DAT3
    mt_set_gpio_pull_select(GPIO183, GPIO_PULL_ENABLE);
#elif (CONFIG_MTK_COMBO_SDIO_SLOT == 3)
	printk(KERN_INFO "[mt6620] pull down sd3 bus (GPIO89~GPIO94)\n");
    mt_set_gpio_pull_enable(GPIO92, GPIO_PULL_DOWN);	//->CLK
    mt_set_gpio_pull_select(GPIO92, GPIO_PULL_ENABLE);		
    mt_set_gpio_pull_enable(GPIO91, GPIO_PULL_DOWN);	//->CMD
    mt_set_gpio_pull_select(GPIO91, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO94, GPIO_PULL_DOWN);	//->DAT0
    mt_set_gpio_pull_select(GPIO94, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO90, GPIO_PULL_DOWN);	//->DAT1
    mt_set_gpio_pull_select(GPIO90, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO89, GPIO_PULL_DOWN);	//->DAT2
    mt_set_gpio_pull_select(GPIO89, GPIO_PULL_ENABLE);
    mt_set_gpio_pull_enable(GPIO93, GPIO_PULL_DOWN);	//->DAT3
    mt_set_gpio_pull_select(GPIO93, GPIO_PULL_ENABLE);
#else
	#error "error:unsupported CONFIG_MTK_COMBO_SDIO_SLOT" CONFIG_MTK_COMBO_SDIO_SLOT
#endif
    //printk(KERN_INFO "[mt6620] set UART GPIO Mode output 0\n");
    mt_set_gpio_mode(GPIO_UART_URXD3_PIN, GPIO_UART_URXD3_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_UART_URXD3_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_UART_URXD3_PIN, GPIO_OUT_ZERO);

    mt_set_gpio_mode(GPIO_UART_UTXD3_PIN, GPIO_UART_UTXD3_PIN_M_GPIO);
    mt_set_gpio_dir(GPIO_UART_UTXD3_PIN, GPIO_DIR_OUT);
    mt_set_gpio_out(GPIO_UART_UTXD3_PIN, GPIO_OUT_ZERO);

    //printk(KERN_INFO "[mt6620] disable RTC CLK \n");
	printk("[mt6620]not to rtc_gpio_disable_32k(RTC_GPIO_USER_GPS)  \n");
    return;
}
static int rda_5990_pw_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
	int ret = 0;

	switch(cmd)
	{
		case RDA_WIFI_POWER_ON_IOCTL:
            ret = rda_wifi_power_on();
			break;

		case RDA_WIFI_POWER_OFF_IOCTL:
            ret = rda_wifi_power_off();
			break;

		case RDA_WIFI_POWER_SET_TEST_MODE_IOCTL:
			wifi_in_test_mode = 1;
			printk("****set rda wifi in test mode");
			break;

		case RDA_WIFI_POWER_CANCEL_TEST_MODE_IOCTL:
			wifi_in_test_mode = 0;
			printk("****set rda wifi in normal mode");
			break;

        case RDA_WIFI_DEBUG_MODE_IOCTL:
            ret = rda_wifi_debug_en();
            break;
		case RDA_BT_POWER_ON_IOCTL:
			{
				ret = rda_bt_power_on();
				mt_combo_bgf_enable_irq();
			}
			break;

			/* should call thif function after bt_power_on*/
		case RDA_BT_EN_CLK:
			ret = RDA5990_bt_enable_clk();
			break;

		case RD_BT_RF_INIT_IOCTL:
			ret = RDA5990_bt_rf_init();
			break;

		case RD_BT_DC_CAL_IOCTL:	
			ret = RDA5990_bt_dc_cal();
			break;

		case RD_BT_DC_DIG_RESET_IOCTL:	
			ret = RDA5990_bt_dig_reset();
			break;

		case RD_BT_SET_RF_SWITCH_IOCTL:
			ret = RDA5990_bt_set_rf_switch();			
			break;

		case RDA_BT_POWER_OFF_IOCTL:
			{
				mt_combo_bgf_disable_irq();
				ret = rda_bt_power_off();               
			}
			break;

		default:
			break;
	}

	printk(KERN_INFO "rda_bt_pw_ioctl cmd=0x%02x \n", cmd);

	return ret;
}