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; }
int standby(u8 enable) { #if 1 if(gLcd_info) gLcd_info->io_init(); if(enable) { spi_screenreg_set(0x03, 0xde); } else { spi_screenreg_set(0x03, 0x5f); } if(gLcd_info) gLcd_info->io_deinit(); #else GPIOSetPinDirection(GPIOPortB_Pin3, GPIO_OUT); GPIOSetPinDirection(GPIOPortB_Pin2, GPIO_OUT); if(enable) { GPIOSetPinLevel(GPIOPortB_Pin3, GPIO_LOW); GPIOSetPinLevel(GPIOPortB_Pin2, GPIO_HIGH); } else { GPIOSetPinLevel(GPIOPortB_Pin3, GPIO_HIGH); GPIOSetPinLevel(GPIOPortB_Pin2, GPIO_LOW); } #endif return 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 }
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); }
static void rk30_gpiolib_dbg_show(struct seq_file *s, struct gpio_chip *chip) { //#if 0 int i; for (i = 0; i < chip->ngpio; i++) { unsigned pin = chip->base + i; struct gpio_chip *chip = pin_to_gpio_chip(pin); u32 bit = gpio_to_bit(pin); //pin_to_bit const char *gpio_label; if(!chip ||!bit) return; gpio_label = gpiochip_is_requested(chip, i); if (gpio_label) { //seq_printf(s, "[%s] GPIO%s%d: ",gpio_label, chip->label, i); printk("[%s] GPIO%s%d: ", gpio_label, chip->label, i); if (!chip || !bit) { //seq_printf(s, "!chip || !bit\t"); printk("!chip || !bit\t"); return; } GPIOSetPinDirection(chip,bit,GPIO_IN); //seq_printf(s, "pin=%d,level=%d\t", pin,GPIOGetPinLevel(chip,bit)); //seq_printf(s, "\t"); printk("pin=%d,level=%d\t", pin, GPIOGetPinLevel(chip,bit)); printk("\t"); } } //#endif }
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); }
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; }
static int rk30_gpiolib_direction_input(struct gpio_chip *chip,unsigned offset) { struct rk30_gpio_bank *bank = to_rk30_gpio_bank(chip); unsigned long flags; spin_lock_irqsave(&bank->lock, flags); GPIOSetPinDirection(bank->regbase, offset_to_bit(offset), GPIO_IN); spin_unlock_irqrestore(&bank->lock, flags); return 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 ); }
static int rk30_gpiolib_direction_output(struct gpio_chip *chip, unsigned offset, int val) { struct rk30_gpio_bank *bank = to_rk30_gpio_bank(chip); u32 bit = offset_to_bit(offset); unsigned long flags; spin_lock_irqsave(&bank->lock, flags); GPIOSetPinDirection(bank->regbase, bit, GPIO_OUT); GPIOSetPinLevel(bank->regbase, bit, val); spin_unlock_irqrestore(&bank->lock, flags); return 0; }
static int rk30_gpio_irq_set_type(struct irq_data *d, unsigned int type) { struct rk30_gpio_bank *bank = irq_data_get_irq_chip_data(d); u32 bit = gpio_to_bit(irq_to_gpio(d->irq)); eGPIOIntType_t int_type; unsigned long flags; switch (type) { case IRQ_TYPE_EDGE_RISING: int_type = GPIOEdgelRising; break; case IRQ_TYPE_EDGE_FALLING: int_type = GPIOEdgelFalling; break; case IRQ_TYPE_LEVEL_HIGH: int_type = GPIOLevelHigh; break; case IRQ_TYPE_LEVEL_LOW: int_type = GPIOLevelLow; break; default: return -EINVAL; } spin_lock_irqsave(&bank->lock, flags); //设置为中断之前,必须先设置为输入状态 GPIOSetPinDirection(bank->regbase, bit, GPIO_IN); GPIOSetIntrType(bank->regbase, bit, int_type); spin_unlock_irqrestore(&bank->lock, flags); if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) __irq_set_handler_locked(d->irq, handle_level_irq); else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) __irq_set_handler_locked(d->irq, handle_edge_irq); return 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__); } } }
static int __devinit rk28_AD_button_probe(struct platform_device *pdev) { struct rk28_AD_button *AD_button; struct input_dev *input_dev; int error,i; AD_button = kzalloc(sizeof(struct rk28_AD_button), GFP_KERNEL); /* Create and register the input driver. */ input_dev = input_allocate_device(); if (!input_dev || !AD_button) { dev_err(&pdev->dev, "failed to allocate input device\n"); error = -ENOMEM; goto failed1; } //a@nzy int ret = request_irq(IRQ_NR_ADC, rk28_AD_irq_handler, 0, "ADC", NULL); if (ret < 0) { printk(KERN_CRIT "Can't register IRQ for ADC\n"); return ret; } memcpy(AD_button->keycodes, initkey_code, sizeof(AD_button->keycodes)); input_dev->name = pdev->name; input_dev->open = rk28_AD_button_open; input_dev->close = rk28_AD_button_close; input_dev->dev.parent = &pdev->dev; input_dev->phys = KEY_PHYS_NAME; input_dev->id.vendor = 0x0001; input_dev->id.product = 0x0001; input_dev->id.version = 0x0100; input_dev->keycode = AD_button->keycodes; input_dev->keycodesize = sizeof(unsigned char); input_dev->keycodemax = ARRAY_SIZE(initkey_code); for (i = 0; i < ARRAY_SIZE(initkey_code); i++) set_bit(initkey_code[i], input_dev->keybit); clear_bit(0, input_dev->keybit); AD_button->input_dev = input_dev; input_set_drvdata(input_dev, AD_button); input_dev->evbit[0] = BIT_MASK(EV_KEY) ; platform_set_drvdata(pdev, AD_button); ADCInit(); prockAD_button=AD_button; /* Register the input device */ error = input_register_device(input_dev); if (error) { dev_err(&pdev->dev, "failed to register input device\n"); goto failed2; } setup_timer(&AD_button->timer, rk28_adkeyscan_timer, (unsigned long)AD_button); //mod_timer(&AD_button->timer, 100); AD_button->timer.expires = jiffies + 3; add_timer(&AD_button->timer); #if defined(CONFIG_BOARD_NX7005) GPIOSetPinDirection(GPIOPortB_Pin4,GPIO_IN); GPIOSetPinDirection(GPIOPortB_Pin5,GPIO_IN); GPIOSetPinDirection(GPIOPortB_Pin6,GPIO_IN); GPIOSetPinDirection(GPIOPortB_Pin7,GPIO_IN); #endif #ifdef CONFIG_MACH_RK2808SDK error = request_gpio_irq(WAKEUP_KEY_PORT,rk28_AD_irq_handler,GPIOEdgelFalling,NULL); if(error) { printk("unable to request recover key IRQ\n"); goto failed2; } #endif #ifdef CONFIG_MACH_PWS700AA error = request_gpio_irq(GPIOPortE_Pin3,rk28_AD_irq_handler,GPIOEdgelRising,NULL); GPIOPullUpDown(GPIOPortE_Pin3,GPIOPullDown); if(error) { printk("unable to request recover key IRQ\n"); goto failed2; } #endif return 0; failed2: input_unregister_device(AD_button->input_dev); platform_set_drvdata(pdev, NULL); failed1: input_free_device(input_dev); kfree(AD_button); return error; }
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__); } }
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;