Пример #1
0
static void rk28_power_on(void)
{

	rockchip_mux_api_set((char *)DDR_CTL_IOMUX_PINNAME,(unsigned int)DDR_CTL_IOMUX_PINDIR);
	GPIOSetPinLevel(DDR_CTL_IOPIN,GPIO_LOW);
	GPIOSetPinDirection(DDR_CTL_IOPIN,GPIO_OUT);
	GPIOPullUpDown(DDR_CTL_IOPIN,GPIONormal);
	GPIOSetPinLevel(DDR_CTL_IOPIN,GPIO_LOW);

	rockchip_mux_api_set((char *)HOST_ON_IOMUX_PINNAME,(unsigned int)HOST_ON_IOMUX_PINDIR);
	GPIOSetPinLevel(HOST_ON_IOPIN,GPIO_LOW);
	GPIOSetPinDirection(HOST_ON_IOPIN,GPIO_OUT);
	GPIOPullUpDown(HOST_ON_IOPIN,GPIONormal);
	GPIOSetPinLevel(HOST_ON_IOPIN,GPIO_LOW);

	rockchip_mux_api_set((char *)SLEEP_CTL_IOMUX_PINNAME,(unsigned int)SLEEP_CTL_IOMUX_PINDIR);
	GPIOSetPinLevel(SLEEP_CTL_IOPIN,GPIO_HIGH);
	GPIOSetPinDirection(SLEEP_CTL_IOPIN,GPIO_OUT);
	GPIOPullUpDown(SLEEP_CTL_IOPIN,GPIONormal);
	GPIOSetPinLevel(SLEEP_CTL_IOPIN,GPIO_HIGH);

	rockchip_mux_api_set((char *)PWR_ON_IOMUX_PINNAME,(unsigned int)PWR_ON_IOMUX_PINDIR);
	GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_HIGH);
	GPIOSetPinDirection(PWR_ON_IOPIN,GPIO_OUT);
	GPIOPullUpDown(PWR_ON_IOPIN,GPIOPullUp);
	GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_HIGH);

#if defined (CONFIG_SND_SOC_ES8388)
	/*disable audio output */
	rockchip_mux_api_set((char *)GPIOE_SPI1_FLASH_SEL2_NAME, (unsigned int)IOMUXA_GPIO1_A3B7);
	GPIOSetPinLevel(GPIOPortF_Pin7,GPIO_LOW);
	GPIOSetPinDirection(GPIOPortF_Pin7, GPIO_OUT);
	GPIOSetPinLevel(GPIOPortF_Pin7,GPIO_LOW);
#endif
}
Пример #2
0
int lcd_init(void)
{
    if(gLcd_info)
        gLcd_info->io_init();
	
	spi_screenreg_set(0x0,0x1c);
	mdelay(10);

	
    #if 0 
    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_GPIO1_A45);

    spi_screenreg_set(0x02, 0x07);
    spi_screenreg_set(0x03, 0x5f);
    spi_screenreg_set(0x04, 0x17);
    spi_screenreg_set(0x05, 0x20);
    spi_screenreg_set(0x06, 0x08);
    spi_screenreg_set(0x07, 0x20);
    spi_screenreg_set(0x08, 0x20);
    spi_screenreg_set(0x09, 0x20);
    spi_screenreg_set(0x0a, 0x20);
    spi_screenreg_set(0x0b, 0x22);
    spi_screenreg_set(0x0c, 0x22);
    spi_screenreg_set(0x0d, 0x22);
    spi_screenreg_set(0x0e, 0x10);
    spi_screenreg_set(0x0f, 0x10);
    spi_screenreg_set(0x10, 0x10);

    spi_screenreg_set(0x11, 0x15);
    spi_screenreg_set(0x12, 0xAA);
    spi_screenreg_set(0x13, 0xFF);
    spi_screenreg_set(0x14, 0xb0);
    spi_screenreg_set(0x15, 0x8e);
    spi_screenreg_set(0x16, 0xd6);
    spi_screenreg_set(0x17, 0xfe);
    spi_screenreg_set(0x18, 0x28);
    spi_screenreg_set(0x19, 0x52);
    spi_screenreg_set(0x1A, 0x7c);

    spi_screenreg_set(0x1B, 0xe9);
    spi_screenreg_set(0x1C, 0x42);
    spi_screenreg_set(0x1D, 0x88);
    spi_screenreg_set(0x1E, 0xb8);
    spi_screenreg_set(0x1F, 0xFF);
    spi_screenreg_set(0x20, 0xF0);
    spi_screenreg_set(0x21, 0xF0);
    spi_screenreg_set(0x22, 0x09);

    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
    #endif

    if(gLcd_info)
        gLcd_info->io_deinit();
    return 0;
}
Пример #3
0
int lcd_standby(u8 enable)
{
    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_GPIO1_A45);
	if(enable) {
		spi_screenreg_set(0x43, 0x20);
	} else {
		spi_screenreg_set(0x43, 0xE0);
	}
    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
    return 0;
}
Пример #4
0
static void rk28_codec_mask_noise(void)
{
	rockchip_mux_api_set((char *)RK1000_RST_IOMUX_PINNAME,(unsigned int)RK1000_RST_IOMUX_PINDIR);
	GPIOSetPinDirection(RK1000_RST_IOPIN,GPIO_OUT);
	GPIOSetPinLevel(RK1000_RST_IOPIN,GPIO_LOW);

	rockchip_mux_api_set((char *)SPK_CTL_IOMUX_PINNAME,(unsigned int)SPK_CTL_IOMUX_PINDIR);
	GPIOSetPinDirection(SPK_CTL_IOPIN,GPIO_OUT);
	GPIOSetPinLevel(SPK_CTL_IOPIN,GPIO_LOW);
	mdelay(5);
}
Пример #5
0
void screen_set_iomux(u8 enable)
{
    int ret=-1;
    if(enable)
    {
        rockchip_mux_api_set(GPIOA4_I2SLRCK_SEL_NAME, 0);
        rockchip_mux_api_set(GPIOE_U1IR_I2C1_NAME, 0);   
    }
    else
    {
         rockchip_mux_api_set(GPIOA4_I2SLRCK_SEL_NAME, 1);
         rockchip_mux_api_set(GPIOE_U1IR_I2C1_NAME, 2);
    }
    
    return ;
}
Пример #6
0
static void rk28_gtt8205_init( void )
{
	rockchip_mux_api_set((char *)TOUCH_INT_IOMUX_PINNAME,(unsigned int)TOUCH_INT_IOMUX_PINDIR);
	GPIOSetPinDirection(TOUCH_INT_IOPIN, GPIO_IN);
	GPIOSetPinLevel(TOUCH_INT_IOPIN,GPIO_LOW);
	mdelay(10);
	GPIOSetPinLevel(TOUCH_INT_IOPIN,GPIO_HIGH);
}
Пример #7
0
static void key_signal_io_init_hw(void)
{
	int ret = 0;

	rockchip_mux_api_set(GPIOA0_HOSTDATA16_SEL_NAME, PAGE_DOWN_IOMUX_PINDIR);   
	GPIOPullUpDown(PAGE_DOWN_IOPIN,GPIOPullUp);
	GPIOSetPinDirection(PAGE_DOWN_IOPIN, GPIO_IN);

	rockchip_mux_api_set(GPIOA1_HOSTDATA17_SEL_NAME, IOMUXB_GPIO0_A1);  
	GPIOPullUpDown(PAGE_UP_IOPIN,GPIOPullUp);
	GPIOSetPinDirection(PAGE_UP_IOPIN, GPIO_IN);

	rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_GPIO1_A45);   
	GPIOPullUpDown(VOL_UP_IOPIN,GPIOPullUp);
	GPIOSetPinDirection(VOL_UP_IOPIN, GPIO_IN);

	rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_GPIO1_A45);  
	GPIOPullUpDown(VOL_DOWN_IOPIN,GPIOPullUp);
	GPIOSetPinDirection(VOL_DOWN_IOPIN, GPIO_IN);

	ret = request_gpio_irq(PAGE_DOWN_IOPIN,(pFunc)rk28_key_down_irq_handler,GPIOEdgelRising,NULL);
	if (ret)
		goto fail;

	ret = request_gpio_irq(PAGE_UP_IOPIN,(pFunc)rk28_key_up_irq_handler,GPIOEdgelRising,NULL);
	if (ret)
		goto fail;

	ret = request_gpio_irq(VOL_UP_IOPIN,(pFunc)rk28_key_vol_up_irq_handler,GPIOEdgelRising,NULL);
	if (ret)
		goto fail;

	ret = request_gpio_irq(VOL_DOWN_IOPIN,(pFunc)rk28_key_vol_down_irq_handler,GPIOEdgelRising,NULL);
	if (ret)
		goto fail;
	INIT_WORK(&scan_page_up_task,page_up_key_handle);
	INIT_WORK(&scan_page_down_task,page_down_key_handle);
	INIT_WORK(&scan_vol_up_task,vol_up_key_handle);
	INIT_WORK(&scan_vol_down_task,vol_down_key_handle);
	
	return;
fail:
	printk("%s %d\n", __FUNCTION__,__LINE__);
	return;
}
Пример #8
0
void rk28_power_off(void)
{
	local_irq_enable();     /* open for some logs */
	rockchip_mux_api_set((char *)PLAY_ON_IOMUX_PINNAME,(unsigned int)PLAY_ON_IOMUX_PINDIR);
	GPIOPullUpDown(PLAY_ON_IOPIN,GPIOPullDown);
	
	rockchip_mux_api_set((char *)PWR_ON_IOMUX_PINNAME,PWR_ON_IOMUX_PINDIR);
	GPIOSetPinDirection(PWR_ON_IOPIN,GPIO_OUT);
	GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_LOW);
	while( 1 ) {
		rockchip_mux_api_set((char *)PWR_ON_IOMUX_PINNAME,(unsigned int)PWR_ON_IOMUX_PINDIR);
		GPIOSetPinDirection(PWR_ON_IOPIN,GPIO_OUT);
		if(GPIOGetPinLevel(PWR_ON_IOPIN) == GPIO_HIGH)
			GPIOSetPinLevel(PWR_ON_IOPIN,GPIO_LOW);
		if(GPIOGetPinLevel(PLAY_ON_IOPIN) == GPIO_HIGH)
			break;
	}
	rk28_restart( 0 );
}
Пример #9
0
static void key_in_gpio_init(void)
{
	int	i;

	rockchip_mux_api_set(KROW0_IOMUX_PINNAME,0);
	rockchip_mux_api_set(KROW1_IOMUX_PINNAME,0);
	rockchip_mux_api_set(KROW2_IOMUX_PINNAME,0);
	rockchip_mux_api_set(KCOL0_IOMUX_PINNAME,0);
	rockchip_mux_api_set(KCOL1_IOMUX_PINNAME,0);
	rockchip_mux_api_set(KCOL2_IOMUX_PINNAME,0);
	
	for(i = 0; i <MAX_GPIO_IN_CNT; i++) {
		GPIOSetPinLevel(gpio_in[i], GPIO_HIGH);
		GPIOSetPinDirection(gpio_in[i], GPIO_IN);
		GPIOPullUpDown(gpio_in[i],GPIONormal);
	}

	for(i = 0; i < MAX_GPIO_OUT_CNT; i++) {
		GPIOSetPinLevel(gpio_out[i], GPIO_HIGH);
		GPIOSetPinDirection(gpio_out[i], GPIO_OUT);
		GPIOPullUpDown(gpio_out[i],GPIONormal);
	}

	return;
}
Пример #10
0
int lcd_init(void)
{
    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_GPIO1_A45);
	
	//R(0xess (A5~A0) Data(D7~D0)
#if 0
    spi_screenreg_set(0x03, 0x86);
    spi_screenreg_set(0x05, 0x33);
    spi_screenreg_set(0x09, 0xFF);
    spi_screenreg_set(0x3A, 0x95);
    spi_screenreg_set(0x3C, 0xE0);
    spi_screenreg_set(0x3D, 0xF4);
    spi_screenreg_set(0x3E, 0x21);
    spi_screenreg_set(0x3F, 0x87);
    spi_screenreg_set(0x15, 0x55);
    spi_screenreg_set(0x16, 0xAF);
    spi_screenreg_set(0x17, 0xFC);
    spi_screenreg_set(0x18, 0x00);
    spi_screenreg_set(0x19, 0x4B);
    spi_screenreg_set(0x1A, 0x80);
    spi_screenreg_set(0x1B, 0xFF);
    spi_screenreg_set(0x1C, 0x39);
    spi_screenreg_set(0x1D, 0x69);
    spi_screenreg_set(0x1E, 0x9F);
    spi_screenreg_set(0x1F, 0x09);
    spi_screenreg_set(0x20, 0x8F);
    spi_screenreg_set(0x21, 0xF0);
    spi_screenreg_set(0x22, 0x2B);
    spi_screenreg_set(0x23, 0x58);
    spi_screenreg_set(0x24, 0x7C);
    spi_screenreg_set(0x25, 0xA5);
    spi_screenreg_set(0x26, 0xFF);
#endif

    rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
    return 0;
}
Пример #11
0
static void rk28_adkeyscan_timer(unsigned long data)
{
	unsigned int ADKEY1,code = 0,i;
	/*Enable  AD controller to sample */
	prockAD_button->timer.expires  = jiffies+msecs_to_jiffies(10);
	add_timer(&prockAD_button->timer);
	RockAdcScanning();
	if (ADSampleTimes < 4)
	{
		ADSampleTimes ++;		
		goto scan_io_key;  	/* scan gpio button event*/
	}
	ADSampleTimes = 0;	
#if 0
	rockchip_mux_api_set(GPIOF5_APWM3_DPWM3_NAME, IOMUXB_GPIO1_B5);
	GPIOSetPinDirection(GPIOPortF_Pin5, GPIO_OUT);
	if (gpioflag)
	{
		GPIOSetPinLevel(GPIOPortF_Pin5, GPIO_HIGH);
		gpioflag = 0;
	}
	else
	{
		GPIOSetPinLevel(GPIOPortF_Pin5, GPIO_LOW);
		gpioflag = 1;
	}
#endif
	/*Get button value*/
	ADKEY1=get_rock_adc1();
	if(ADKEY1<EmptyADValue)
		printk("\n ADC1 value=%d  \n",ADKEY1);
#if 1	//ffhh
	if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue))  
		goto scan_io_key1;
#endif	
	valuecount++;
 	if(valuecount < 2)
		goto scan_code;	
	code=find_rock_adkeycode(ADKEY1,ad2valuetab);
	valuecount = 2;	
	goto scan_code;  ///scan_code;	
scan_io_key1:
	valuecount = 0;	

scan_code:	
	if((g_code == 0) && (code == 0)){
	    goto scan_io_key; 
	}
	///DBG("\n key button PE2 == %d  \n",GPIOGetPinLevel(GPIOPortE_Pin2)); 
	if(code != 0){
		if(valuecount<2)
			goto scan_io_key; 
		if(g_code == 0){
			g_code = code;
			DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d  \n",__func__,__LINE__,g_code);
			input_report_key(prockAD_button->input_dev,g_code,1);
	        	input_sync(prockAD_button->input_dev);
	        	goto scan_io_key; 
		}else{
			if(g_code != code){
				DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d  \n",__func__,__LINE__,g_code);
				input_report_key(prockAD_button->input_dev,g_code,0);
	            		input_sync(prockAD_button->input_dev);
	            		DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d  \n",__func__,__LINE__,code);
	            		input_report_key(prockAD_button->input_dev,code,1);
	            		input_sync(prockAD_button->input_dev);
	            		g_code = code;
	           		goto scan_io_key; 
			}
		}
    
    	}
	if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){
		DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d  \n",__func__,__LINE__,g_code);
	    	input_report_key(prockAD_button->input_dev,g_code,0);
	    	input_sync(prockAD_button->input_dev);
		valuecount = 0;
		g_code = 0;
		goto scan_io_key;
	}
scan_io_key :
//	if(!GPIOGetPinLevel(GPIOPortF_Pin0))
    if(g_wake_press)
    {
        pwrscantimes = 0;
        g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT);
        if(g_wake_press) return;
    }
	if(!GPIOGetPinLevel(GPIOPortE_Pin2))
	{
		pwrscantimes += 1;
		if(pwrscantimes == (SEC_NUM * ONESEC_TIMES))
		{
			input_report_key(prockAD_button->input_dev,ENDCALL,1);
			input_sync(prockAD_button->input_dev);
			DBG("the kernel come to power down!!!\n");
		
		}
		if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES))
		{
			pwrscantimes = 0;
			input_report_key(prockAD_button->input_dev,ENDCALL,0);
			input_sync(prockAD_button->input_dev);
			DBG("the kernel come to power up!!!\n");
		
		}
		return ;
	}
	
	if( pwrscantimes > SLEEP_TIME)
	{
		pwrscantimes = 0;
        printk("========== %s: g_enable_sleep=%d\n", __FUNCTION__, g_enable_sleep);
		if(g_enable_sleep)
		{
			input_report_key(prockAD_button->input_dev,AD1KEY5,1);
			input_sync(prockAD_button->input_dev);
			input_report_key(prockAD_button->input_dev,AD1KEY5,0);
			input_sync(prockAD_button->input_dev);
			printk("\n%s^^level 1^^Wake or sleep ^^^^^!!\n",__FUNCTION__);
	}
}
}
Пример #12
0
static void rk28_adkeyscan_timer(unsigned long data)
{
	unsigned int ADKEY1,ADKEY2,code = 0,i;
	/*Enable  AD controller to sample */

	prockAD_button->timer.expires  = jiffies+msecs_to_jiffies(20);
	add_timer(&prockAD_button->timer);
	//	printk("\n LED_Delay_Counter=%d  \n",LED_Delay_Counter);
	if(timercount)
	{
		timercount --;
		if(!timercount)
			pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW);
	}


	RockAdcScanning();
	if (ADSampleTimes < 4)
	{
		ADSampleTimes ++;		
		goto scan_io_key;  	/* scan gpio button event*/
	}
	ADSampleTimes = 0;	
	/*Get button value*/
	ADKEY1=get_rock_adc1();
	//ADKEY2=get_rock_adc2();
	
	if(ADKEY1<EmptyADValue)
		printk("\n ADC1 value=%d  \n",ADKEY1);
		
	//printk("\n ADC2 value=%d  \n",ADKEY2);

	/*
	if(backligh_back_vallue!=ADKEY2){
	backligh_back_vallue=ADKEY2;
	backligh_just_vallue=ADKEY2/3;
	if(backligh_just_vallue>255)
		backligh_just_vallue=255;
	//printk("\n backligh_just_vallue value=%d  \n",backligh_just_vallue);
	//rk28_bl_update_status_for_Test(255-backligh_just_vallue);
	}
	*/
#if 1	//ffhh
	if((ADKEY1>EmptyADValue)&&(ADKEY1<=InvalidADValue))  
		goto scan_io_key1;
#endif	
	valuecount++;
 	if(valuecount < 2)
		goto scan_code;	
	if(ADKEY1<50)
	code=AD1KEY3;
	else
	code=find_rock_adkeycode(ADKEY1,ad2valuetab);
	valuecount = 2;	
	goto scan_code;  ///scan_code;	
scan_io_key1:
	valuecount = 0;	

scan_code:	
	if((g_code == 0) && (code == 0)){
	    goto scan_io_key; 
	}
	///DBG("\n key button PE2 == %d  \n",GPIOGetPinLevel(GPIOPortE_Pin2)); 
	if(code != 0){
		if(valuecount<2)
			goto scan_io_key; 
		if(g_code == 0){
			g_code = code;
			DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d  \n",__func__,__LINE__,g_code);
			input_report_key(prockAD_button->input_dev,g_code,1);
	        	input_sync(prockAD_button->input_dev);
                     pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_HIGH);	 
			timercount = 20;
            //         mdelay(500);
             //        pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW);	
	        	goto scan_io_key; 
		}else{
			if(g_code != code){
				DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d  \n",__func__,__LINE__,g_code);
				input_report_key(prockAD_button->input_dev,g_code,0);
	            		input_sync(prockAD_button->input_dev);
	            		DBG("\n %s::%d rock adc1 key scan ,find press down a key=%d  \n",__func__,__LINE__,code);
	            		input_report_key(prockAD_button->input_dev,code,1);
	            		input_sync(prockAD_button->input_dev);
				
	            		g_code = code;
				
	           		goto scan_io_key; 
			}
		}
    
    	}
	if((g_code != 0)&&(code == 0)&&(ADSampleTimes == 0)){
		DBG("\n %s::%d rock adc1 key scan ,find press up a key=%d  \n",__func__,__LINE__,g_code);
	    	input_report_key(prockAD_button->input_dev,g_code,0);
	    	input_sync(prockAD_button->input_dev);
		
		valuecount = 0;
		g_code = 0;
		goto scan_io_key;
	}
scan_io_key :
 //  rockchip_mux_api_set(GPIOF5_APWM3_DPWM3_NAME, IOMUXB_GPIO1_B5);
   //GPIOSetPinDirection(GPIOPortF_Pin5,GPIO_IN);
   #if 0
   if(needfirstonwifi){
   if(GPIOGetPinLevel(GPIOPortF_Pin5)){
   	if(!Wifi_turn_on_flag)
   		{
   		 

	        if(firstonwifi!=1){
   		  wifi_turn_on_card();
		 wifi_power_up_wifi();
   		 printk("GPIOPortF_Pin5  HIGH  \n");
		  Wifi_turn_on_flag=1;
		  Wifi_turn_off_flag=0;
	       }
   		}
   	}
   else {
   	      if(!Wifi_turn_off_flag)
   		{
   		  if(firstonwifi!=2){
		    
   		  wifi_turn_off_card();
		 wifi_power_up_wifi();
   		  printk("GPIOPortF_Pin5  LOW  \n");
		  Wifi_turn_on_flag=0;
		  Wifi_turn_off_flag=1;
   		  	}
   		}
			
   	}
   	}
   #endif
for(i=0;i<4;i++){	
	GPIOSetPinDirection(IoCode[i][0],GPIO_IN);
	
#if 1	
	if(GPIOGetPinLevel(IoCode[i][0])){
			if((IOkeyback!=IoCode[i][1])&&(IOkeyback)){
			input_report_key(prockAD_button->input_dev,IOkeyback,0);
			input_sync(prockAD_button->input_dev);
			DBG("Key Pb%d up code=%d!!!\n",i,IOkeyback);
			}
			IOkeyback=IoCode[i][1];
			input_report_key(prockAD_button->input_dev,IoCode[i][1],1);
			input_sync(prockAD_button->input_dev);
			DBG("Key Pb%d down code=%d!!!\n",i,IoCode[i][1]);
			pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_HIGH);	 
			timercount = 20;
        //             mdelay(500);
       //              pca955x_gpio_direction_output(PCA955X_Pin12,GPIO_LOW);	
			break;
	}else if(IOkeyback==IoCode[i][1]){
			IOkeyback=0;
			input_report_key(prockAD_button->input_dev,IoCode[i][1],0);
			input_sync(prockAD_button->input_dev);
			DBG("Key Pb%d up code=%d!!!\n",i,IoCode[i][1]);
			
			break;
	}
#endif	
}


    if(g_wake_press)
    {
        pwrscantimes = 0;
        g_wake_press = !GPIOGetPinLevel(WAKEUP_KEY_PORT);
        if(g_wake_press) return;
    }

//	if(!GPIOGetPinLevel(GPIOPortF_Pin0))
	if(!GPIOGetPinLevel(WAKEUP_KEY_PORT))
	{
		pwrscantimes += 1;
		if(pwrscantimes == (SEC_NUM * ONESEC_TIMES))
		{
			input_report_key(prockAD_button->input_dev,ENDCALL,1);
			input_sync(prockAD_button->input_dev);
			DBG("the kernel come to power down!!!\n");
			LED_Delay_Counter=LED_LIGHT_TIME;
		}
		if(pwrscantimes ==( (SEC_NUM + 1)* ONESEC_TIMES))
		{
			pwrscantimes = 0;
			input_report_key(prockAD_button->input_dev,ENDCALL,0);
			input_sync(prockAD_button->input_dev);
			DBG("the kernel come to power up!!!\n");
			
		}
		return ;
	}
	
	if( pwrscantimes > SLEEP_TIME)
	{
		pwrscantimes = 0;
        DBG("========== %s: g_enable_sleep=%d\n", __FUNCTION__, g_enable_sleep);
		if(g_enable_sleep)
		{
			input_report_key(prockAD_button->input_dev,AD1KEY5,1);
			input_sync(prockAD_button->input_dev);
			input_report_key(prockAD_button->input_dev,AD1KEY5,0);
			input_sync(prockAD_button->input_dev);
                     rockchip_mux_api_set(GPIOE_I2C0_SEL_NAME, IOMUXA_I2C0);
                     
                     rockchip_mux_api_set(GPIOE_U1IR_I2C1_NAME, IOMUXA_I2C1);
                    
		}
		 DBG("\n%s^^^^Wake Up ^^^^^!!\n",__FUNCTION__);
	}
}
Пример #13
0
static int __init rk28_ts_ak4183_init(void)
{
	int ret;
	struct AK4183_TS_EVENT *ts_dev = NULL;

	GPIOSetPinDirection(GPIOPortE_Pin3,GPIO_IN);
	GPIOSetPinLevel(GPIOPortE_Pin3,GPIO_HIGH);

	ts_dev = kzalloc(sizeof(struct AK4183_TS_EVENT), GFP_KERNEL);
	if(ts_dev == NULL)
	{
		E("ts_dev kzalloc failed!\n");
		ret = -ENOMEM;
		goto err1;
	}

	ts_dev->input = input_allocate_device();
	if(ts_dev->input == NULL)
	{
		E("input_allocate_device err!\n"); 
		ret = -ENOMEM;

		goto err2;
	}	

	ts_dev->irq = 7;
	
	ts_dev->input->name = "ak4183";	
	ts_dev->input->phys = "ak4183_TS/input0";
	ts_dev->input->evbit[0] = BIT_MASK(EV_ABS)|BIT_MASK(EV_KEY);
	ts_dev->input->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
	input_set_abs_params(ts_dev->input, ABS_X, 0, LCD_MAX_LENGTH - 1, 0, 0);
	input_set_abs_params(ts_dev->input, ABS_Y, 0, LCD_MAX_WIDTH - 1, 0, 0);
	
	ret = input_register_device(ts_dev->input);
	if(ret < 0){
		goto err3;

	}
#ifdef CONFIG_ANDROID_POWER
	ts_early_suspend.suspend = ak4183_suspend;
    ts_early_suspend.resume = ak4183_resume;
    android_register_early_suspend(&ts_early_suspend);
#endif

    rockchip_mux_api_set(GPIOB_SPI0_MMC0_NAME, 0);
	rockchip_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
	GPIOSetPinDirection(GPIOPortB_Pin4,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin4,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin5,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin5,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin6,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin6,GPIO_HIGH);
	GPIOSetPinDirection(GPIOPortB_Pin7,GPIO_IN);
	GPIOSetPinLevel(GPIOPortB_Pin7,GPIO_HIGH);

	INIT_DELAYED_WORK(&ts_dev->work, ak4183_delay_work);

	ret = request_gpio_irq(GPIOPortE_Pin3, (void *)ak4183_isr, GPIOEdgelFalling, ts_dev);
	if(ret < 0){
		E("ak4183 request irq err, ret = %d\n", ret);
		goto err4;
	}	

	ret =  i2c_add_driver(&ak4183_i2c_driver);
	if(ret < 0){
		E("i2c_add_driver err, ret = %d\n", ret);
		goto err5;
	}
	
	g_ts_dev = ts_dev;
	
	ret = driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_touchcheck);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_touchadc);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_calistatus);
	ret += driver_create_file(&ak4183_i2c_driver.driver, &driver_attr_debug_ak4183);

	I("ak4183 init success!\n");

	return 0;

err5:
	free_irq(7, NULL);
err4:
	input_unregister_device(ts_dev->input);
err3:
	input_free_device(ts_dev->input);
err2:
	kfree(ts_dev);
err1:
	return ret;