static void dc_detect_do_wakeup(struct work_struct *work) { int ret; int irq; unsigned int type; struct delayed_work *delay_work; struct cw_battery *cw_bat; delay_work = container_of(work, struct delayed_work, work); cw_bat = container_of(delay_work, struct cw_battery, dc_wakeup_work); rk28_send_wakeup_key(); /* this assume if usb insert or extract dc_det pin is change */ #if 0 if(cw_bat->charger_init_mode) cw_bat->charger_init_mode=0; #endif irq = gpio_to_irq(cw_bat->plat_data->dc_det_pin); type = gpio_get_value(cw_bat->plat_data->dc_det_pin) ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; ret = irq_set_irq_type(irq, type); if (ret < 0) { pr_err("%s: irq_set_irq_type(%d, %d) failed\n", __func__, irq, type); } enable_irq(irq); }
static irqreturn_t rk28_playon_handler(s32 irq, void *dev_id) { if(rk2818_get_suspend_flags() == PM_TWOLEVEL_SLEEP) { rk28_send_wakeup_key(); } return IRQ_HANDLED; }
static void headset_timer_callback(unsigned long arg) { struct headset_priv *headset = (struct headset_priv *)(arg); struct rk_headset_pdata *pdata = headset->pdata; int level = 0; // printk("headset_timer_callback,headset->headset_status=%d\n",headset->headset_status); if(headset->headset_status == HEADSET_OUT) { printk("Headset is out\n"); goto out; } #ifdef CONFIG_SND_SOC_WM8994 if(wm8994_set_status() != 0) { // printk("wait wm8994 set the MICB2\n"); // headset_info->headset_timer.expires = jiffies + 500; headset_info->headset_timer.expires = jiffies + 10; add_timer(&headset_info->headset_timer); goto out; } #endif level = read_gpio(pdata->Hook_gpio); if(level < 0) goto out; if((level > 0 && pdata->Hook_down_type == HOOK_DOWN_LOW) || (level == 0 && pdata->Hook_down_type == HOOK_DOWN_HIGH)) { headset->isMic = 1;//have mic DBG("enable headset_hook irq\n"); enable_irq(headset_info->irq[HOOK]); headset->isHook_irq = enable; headset_info->hook_status = HOOK_UP; if(pdata->Hook_down_type == HOOK_DOWN_HIGH) irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING); else irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING); } else headset->isMic= 0;//No microphone printk("headset->isMic = %d\n",headset->isMic); headset_info->cur_headset_status = headset_info->isMic ? 1:2;//BIT_HEADSET:BIT_HEADSET_NO_MIC;// #if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610) rk2928_codec_set_spk(HEADSET_IN); if(headset_info->cur_headset_status == 1) gpio_set_value(pdata->Sw_mic_gpio, pdata->Hp_mic_io_value); #endif rk28_send_wakeup_key(); switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status); out: return; }
static void rkpm_suspend_finish(void) { //enable_hlt(); #if 0 //def CONFIG_KEYS_RK29 if(rkpm_check_ctrbits(1<<RKPM_CTR_WAKE_UP_KEY)) { rk28_send_wakeup_key(); printk("rk30_pm_finish rk28_send_wakeup_key\n"); } #endif }
static irqreturn_t sc8800_irq(int irq, void *dev_id) { struct sc8800_data *sc8800 = (struct sc8800_data *)dev_id; sc8800_dbg(sc8800->dev, "%s\n", __func__); #if 0 if(sc8800->is_suspend) rk28_send_wakeup_key(); #endif wake_lock(&sc8800->rx_wake); queue_work(sc8800->rx_wq, &sc8800->rx_work); return IRQ_HANDLED; }
static void usb_detect_do_wakeup(struct work_struct *work) { int ret; int irq = gpio_to_irq(detect_gpio); unsigned long flags; rk28_send_wakeup_key(); free_irq(irq, NULL); flags = gpio_get_value(detect_gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; ret = request_irq(irq, usb_detect_irq_handler, flags, "usb_detect", NULL); if (ret < 0) { pr_err("%s: request_irq(%d) failed\n", __func__, irq); } }
static void rk2918_battery_work(struct work_struct *work) { int ret; int irq_flag; rk28_send_wakeup_key(); free_irq(gBatteryData->dc_det_irq, gBatteryData); irq_flag = (!gpio_get_value (gBatteryData->dc_det_pin)) ? IRQF_TRIGGER_RISING : IRQF_TRIGGER_FALLING; ret = request_irq(gBatteryData->dc_det_irq, rk2918_dc_wakeup, irq_flag, "rk2918_battery", gBatteryData); if (ret) { free_irq(gBatteryData->dc_det_irq, gBatteryData); } enable_irq_wake(gBatteryData->dc_det_irq); }
static void usb_detect_do_wakeup(struct work_struct *work) { int ret; int irq = gpio_to_irq(detect_gpio); unsigned int type; rk28_send_wakeup_key(); type = gpio_get_value(detect_gpio) ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; ret = irq_set_irq_type(irq, type); if (ret < 0) { pr_err("%s: irq_set_irq_type(%d, %d) failed\n", __func__, irq, type); } enable_irq(irq); }
static void Hp_mic_work(struct work_struct *work) { int level = 0; struct rk_headset_pdata *pdata = headset_info->pdata; printk("hp_mic_work---------\n"); mutex_lock(&headset_info->mutex_lock[MIC]); if(headset_info->headset_status == HEADSET_OUT) { printk("Headset is out\n"); goto out; } level = read_gpio(pdata->Hook_gpio); if(level < 0) goto out; if((level > 0 && pdata->Hook_down_type == HOOK_DOWN_LOW) || (level == 0 && pdata->Hook_down_type == HOOK_DOWN_HIGH)) { headset_info->isMic = 1;//have mic DBG("enable headset_hook irq\n"); enable_irq(headset_info->irq[HOOK]); headset_info->isHook_irq = enable; headset_info->hook_status = HOOK_UP; if(pdata->Hook_down_type == HOOK_DOWN_HIGH) irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_RISING); else irq_set_irq_type(headset_info->irq[HOOK],IRQF_TRIGGER_FALLING); Switch_Mic_Mode(HP_MIC); } else headset_info->isMic= 0;//No microphone printk("headset->isMic = %d\n",headset_info->isMic); headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC; #if defined(CONFIG_SND_RK_SOC_RK2928) rk2928_codec_set_spk(HEADSET_IN); #endif rk28_send_wakeup_key(); switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status); out: mutex_unlock(&headset_info->mutex_lock[MIC]); return; }
static irqreturn_t bvalid_irq_handler(int irq, void *dev_id) { /* clear irq */ #ifdef CONFIG_ARCH_RK2928 writel_relaxed((1 << 31) | (1 << 15), RK2928_GRF_BASE + GRF_UOC0_CON5); #endif #ifdef CONFIG_RK_USB_UART /* usb otg dp/dm switch to usb phy */ writel_relaxed((3 << (12 + 16)),RK2928_GRF_BASE + GRF_UOC1_CON4); #endif wake_lock_timeout(&usb_wakelock, WAKE_LOCK_TIMEOUT); rk28_send_wakeup_key(); return IRQ_HANDLED; }
static void bq27541_battery_wake_work(struct work_struct *work) { int ret; struct bq27541_device_info *di = (struct bq27541_device_info *)container_of(work, struct bq27541_device_info, wakeup_work.work); rk28_send_wakeup_key(); free_irq(di->wake_irq, di); di->wake_irq = gpio_to_irq(di->bat_check_pin); ret = request_irq(di->wake_irq, bq27541_bat_wakeup, IRQF_TRIGGER_FALLING, "bq27541_battery", di); if (ret) { printk("request faild!\n"); return; } enable_irq_wake(di->wake_irq); }
/* * handle_twl6030_vlow() is a threaded BAT_VLOW interrupt handler. BAT_VLOW * is a secondary interrupt generated in twl6030_irq_thread(). */ static irqreturn_t handle_twl6030_vlow(int irq, void *unused) { #ifdef CONFIG_TWL60xx_VBAT_LOW_DETECTION rk28_send_wakeup_key(); #else pr_err("twl6030: BAT_VLOW interrupt; threshold=%dmV\n", 2300 + (vbatmin_hi_threshold - 0b110) * 50); #if 1 /* temporary */ pr_err("%s: disabling BAT_VLOW interrupt\n", __func__); disable_irq_nosync(twl6030_irq_base + TWL_VLOW_INTR_OFFSET); // WARN_ON(1); #else pr_emerg("handle_twl6030_vlow: kernel_power_off()\n"); kernel_power_off(); #endif #endif return IRQ_HANDLED; }
static enum hrtimer_restart xpt2046_dostimer(struct hrtimer *handle) { struct XPT2046_TS_EVENT *ts_dev = container_of(handle, struct XPT2046_TS_EVENT, timer); struct input_dev *xpt2046_ts_dev; int ts_io_pin_status; rk28printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__); rk28printk("************>%s.....%s.....\n",__FILE__,__FUNCTION__); spin_lock_irq(&ts_dev->lock); ts_io_pin_status = GPIOGetPinLevel(PT2046_PENIRQ); rk28printk("************>%s....PE7status=%d\n",__FUNCTION__,ts_io_pin_status); rk28printk("--------<%s>--- ts_dev->pendown = %d, PE7status = %d \n", __FUNCTION__, ts_dev->pendown, ts_io_pin_status); if(unlikely(ts_dev->pendown && ts_io_pin_status)) { xpt2046_ts_dev = ts_dev->input; rk28printk("The touchscreen up!!\n"); //printk("-------------------------------------------The touchscreen up!!\n"); input_report_key(xpt2046_ts_dev,BTN_TOUCH,0); input_sync(xpt2046_ts_dev); ts_dev->pendown = 0; gpio_irq_enable(PT2046_PENIRQ); ClearBuff(); gLastZvalue[0] = 4095; gLastZvalue[1] = 4095; } else { /*still down ,continue with the measurement*/ xpt2046_read_values(ts_dev); xpt2046_send_values(ts_dev); } spin_unlock_irq(&ts_dev->lock); #ifdef CONFIG_ANDROID_POWER if(rk2818_get_suspend_flags() != PM_AWAKE) { rk28_send_wakeup_key(); printk("touch screen wake up\n"); } #endif return HRTIMER_NORESTART; }
static irqreturn_t act8931_irq_thread(unsigned int irq, void *dev_id) { struct act8931 *act8931 = (struct act8931 *)dev_id; int ret; u8 val; val = act8931_reg_read(act8931,0x78); act8931_charge_det = (val & INDAT_MASK )? 1:0; act8931_charge_ok = (val & CHGDAT_MASK )? 1:0; DBG("usb is=%s\n",act8931_charge_det? "connect! " : "disconnect "); DBG("usb =%s\n",act8931_charge_ok? "charge ok! \n" : "charging or discharge! \n"); /* reset related regs according to spec */ ret = act8931_set_bits(act8931, 0x78, INSTAT_MASK | CHGSTAT_MASK, INSTAT_MASK | CHGSTAT_MASK); if (ret < 0) { printk("act8931 set 0x78 error!\n"); } /* FIXME: it's better that waking up screen in battery driver */ rk28_send_wakeup_key(); return IRQ_HANDLED; }
static void usb_detect_do_wakeup(struct work_struct *work) { int ret; int irq = gpio_to_irq(detect_gpio); unsigned int type; if(otg_vbus_status == 1) ; else if(otg_vbus_power_off == 1) otg_vbus_power_off = 0; else{ rk28_send_wakeup_key(); #ifdef CONFIG_BATTERY_RK30_ADC_FAC rk30_charge_det_change(); #endif } type = gpio_get_value(detect_gpio) ? IRQ_TYPE_EDGE_FALLING : IRQ_TYPE_EDGE_RISING; ret = irq_set_irq_type(irq, type); if (ret < 0) { pr_err("%s: irq_set_irq_type(%d, %d) failed\n", __func__, irq, type); } enable_irq(irq); }
static void rk29_adc_battery_dcdet_delaywork(struct work_struct *work) { int ret; struct rk29_adc_battery_platform_data *pdata = gBatteryData->pdata; int irq = gpio_to_irq(pdata->dc_det_pin); int irq_flag = gpio_get_value (pdata->dc_det_pin) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING; rk28_send_wakeup_key(); free_irq(irq, NULL); ret = request_irq(irq, rk29_adc_battery_dc_wakeup, irq_flag, "rk29_adc_battery", NULL); if (ret) { free_irq(irq, NULL); } power_supply_changed(&rk29_ac_supply); gBatteryData->bat_status_cnt = 0; //״̬�仯��ʼ���� wake_lock_timeout(&batt_wake_lock, 30 * HZ); }
static void do_wakeup(struct work_struct *work) { rk28_send_wakeup_key(); }
//1 static irqreturn_t headset_interrupt(int irq, void *dev_id) { struct rk_headset_pdata *pdata = headset_info->pdata; static unsigned int old_status = 0; int i,level = 0; int adc_value = 0; wake_lock(&headset_info->headset_on_wake); if(headset_info->heatset_irq_working == BUSY || headset_info->heatset_irq_working == WAIT) return IRQ_HANDLED; DBG("In the headset_interrupt for read headset level wake_lock headset_on_wake\n"); headset_info->heatset_irq_working = BUSY; msleep(150); for(i=0; i<3; i++) { level = gpio_get_value(pdata->Headset_gpio); if(level < 0) { printk("%s:get pin level again,pin=%d,i=%d\n",__FUNCTION__,pdata->Headset_gpio,i); msleep(1); continue; } else break; } if(level < 0) { printk("%s:get pin level err!\n",__FUNCTION__); goto out; } old_status = headset_info->headset_status; switch(pdata->headset_in_type) { case HEADSET_IN_HIGH: if(level > 0) headset_info->headset_status = HEADSET_IN; else if(level == 0) headset_info->headset_status = HEADSET_OUT; break; case HEADSET_IN_LOW: if(level == 0) headset_info->headset_status = HEADSET_IN; else if(level > 0) headset_info->headset_status = HEADSET_OUT; break; default: DBG("---- ERROR: on headset headset_in_type error -----\n"); break; } if(old_status == headset_info->headset_status) { DBG("Read Headset IO level old status == now status\n"); goto out; } DBG("(headset in is %s)headset status is %s\n", pdata->headset_in_type?"high level":"low level", headset_info->headset_status?"in":"out"); if(headset_info->headset_status == HEADSET_IN) { #if 0 while(1) { if(adc_sync_read(headset_info->client) > HOOK_DEFAULT_VAL || adc_sync_read(headset_info->client) < 0) { printk("headset is showly inside\n"); } else break; msleep(50); if(pdata->headset_in_type == HEADSET_IN_HIGH) old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_IN:HEADSET_OUT; else old_status = headset_info->headset_status = gpio_get_value(pdata->Headset_gpio)?HEADSET_OUT:HEADSET_IN; if(headset_info->headset_status == HEADSET_OUT) goto out1; msleep(5); } #endif if(pdata->Hook_adc_chn>=0 && 3>=pdata->Hook_adc_chn) { // wait for find Hook key //#ifdef CONFIG_SND_SOC_RT5625 CHECK_AGAIN: //headset_info->isMic = rt5625_headset_mic_detect(true); #ifdef CONFIG_SND_SOC_WM8994 wm8994_headset_mic_detect(true); #endif #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224) rt3261_headset_mic_detect(true); #endif #ifdef CONFIG_SND_SOC_RT5631_PHONE rt5631_headset_mic_detect(true); #endif //mdelay(400); adc_value = adc_sync_read(headset_info->client); if(adc_value >= 0 && adc_value < HOOK_LEVEL_LOW) { headset_info->isMic= 0;//No microphone #ifdef CONFIG_SND_SOC_WM8994 wm8994_headset_mic_detect(false); #endif #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224) rt3261_headset_mic_detect(false); #endif #ifdef CONFIG_SND_SOC_RT5631_PHONE rt5631_headset_mic_detect(false); #endif } else if(adc_value >= HOOK_LEVEL_HIGH) headset_info->isMic = 1;//have mic if(headset_info->isMic < 0) { printk("codec is error\n"); headset_info->heatset_irq_working = WAIT; if(pdata->headset_in_type == HEADSET_IN_HIGH) irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_LOW|IRQF_ONESHOT); else irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_HIGH|IRQF_ONESHOT); schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(0)); wake_unlock(&headset_info->headset_on_wake); return IRQ_HANDLED; } //adc_value = adc_sync_read(headset_info->client); printk("headset adc value = %d\n",adc_value); if(headset_info->isMic) { if(adc_value > HOOK_DEFAULT_VAL || adc_value < HOOK_LEVEL_HIGH) goto CHECK_AGAIN; mod_timer(&headset_info->hook_timer, jiffies + msecs_to_jiffies(1000)); } //#endif headset_info->cur_headset_status = headset_info->isMic ? BIT_HEADSET:BIT_HEADSET_NO_MIC; } else { headset_info->isMic= 0;//No microphone headset_info->cur_headset_status = BIT_HEADSET_NO_MIC; } printk("headset->isMic = %d\n",headset_info->isMic); if(pdata->headset_in_type == HEADSET_IN_HIGH) irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING); else irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING); } else if(headset_info->headset_status == HEADSET_OUT) { headset_info->cur_headset_status = ~(BIT_HEADSET|BIT_HEADSET_NO_MIC); del_timer(&headset_info->hook_timer); if(headset_info->isMic) { headset_info->hook_status = HOOK_UP; #ifdef CONFIG_SND_SOC_WM8994 //rt5625_headset_mic_detect(false); wm8994_headset_mic_detect(false); #endif #if defined (CONFIG_SND_SOC_RT3261) || defined (CONFIG_SND_SOC_RT3224) rt3261_headset_mic_detect(false); #endif #ifdef CONFIG_SND_SOC_RT5631_PHONE rt5631_headset_mic_detect(false); #endif } if(pdata->headset_in_type == HEADSET_IN_HIGH) irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING); else irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING); } rk28_send_wakeup_key(); switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); DBG("headset notice android headset status = %d\n",headset_info->cur_headset_status); // schedule_delayed_work(&headset_info->h_delayed_work[HEADSET], msecs_to_jiffies(0)); out: headset_info->heatset_irq_working = IDLE; wake_unlock(&headset_info->headset_on_wake); return IRQ_HANDLED; }
static void headsetobserve_work(struct work_struct *work) { int level = 0; int level2 = 0; struct rk_headset_pdata *pdata = headset_info->pdata; static unsigned int old_status = 0; DBG("---headsetobserve_work---\n"); mutex_lock(&headset_info->mutex_lock[HEADSET]); level = read_gpio(pdata->Headset_gpio); if(level < 0) goto out; msleep(100); level2 = read_gpio(pdata->Headset_gpio); if(level2 < 0) goto out; if(level2 != level) goto out; old_status = headset_info->headset_status; if(pdata->headset_in_type == HEADSET_IN_HIGH) headset_info->headset_status = level?HEADSET_IN:HEADSET_OUT; else headset_info->headset_status = level?HEADSET_OUT:HEADSET_IN; if(old_status == headset_info->headset_status) { DBG("old_status == headset_info->headset_status\n"); goto out; } DBG("(headset in is %s)headset status is %s\n", pdata->headset_in_type?"high level":"low level", headset_info->headset_status?"in":"out"); if(headset_info->headset_status == HEADSET_IN) { headset_info->cur_headset_status = BIT_HEADSET_NO_MIC; if(pdata->headset_in_type == HEADSET_IN_HIGH) irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING); else irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING); if (pdata->Hook_gpio) { del_timer(&headset_info->headset_timer);//Start the timer, wait for switch to the headphone channel headset_info->headset_timer.expires = jiffies + 100; add_timer(&headset_info->headset_timer); goto out; } } else if(headset_info->headset_status == HEADSET_OUT) { headset_info->hook_status = HOOK_UP; if(headset_info->isHook_irq == enable) { DBG("disable headset_hook irq\n"); headset_info->isHook_irq = disable; disable_irq(headset_info->irq[HOOK]); } headset_info->cur_headset_status = 0;//~(BIT_HEADSET|BIT_HEADSET_NO_MIC); //#if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SOC_RK3028) //rk2928_codec_set_spk(HEADSET_OUT); //#endif if(pdata->headset_in_type == HEADSET_IN_HIGH) irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_RISING); else irq_set_irq_type(headset_info->irq[HEADSET],IRQF_TRIGGER_FALLING); } rk28_send_wakeup_key(); switch_set_state(&headset_info->sdev, headset_info->cur_headset_status); #if defined(CONFIG_SND_RK_SOC_RK2928) || defined(CONFIG_SND_RK29_SOC_RK610) if (headset_info->headset_status == HEADSET_OUT) { mdelay(200); rk2928_codec_set_spk(HEADSET_OUT); gpio_set_value(pdata->Sw_mic_gpio, headset_info->pdata->Main_mic_io_value); } #endif DBG("headset_info->cur_headset_status = %d\n",headset_info->cur_headset_status); out: mutex_unlock(&headset_info->mutex_lock[HEADSET]); }
inline void do_wakeup(void) { wake_lock_timeout(&usb_wakelock, WAKE_LOCK_TIMEOUT); rk28_send_wakeup_key(); }