static int switch_resume(struct platform_device *pdev) { struct gpio_switch_data *switch_data; pr_debug("[headset]:resume start\n"); if (check_scene_locked(SCENE_TALKING_STANDBY) != 0) { hmic_wr_control(SUNXI_HMIC_CTL, 0xf, HMIC_M, 0x0); /*0xf should be get from hw_debug 28*/ hmic_wr_control(SUNXI_HMIC_CTL, 0xf, HMIC_N, 0x0); /*0xf should be get from hw_debug 24*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1, HMIC_EARPHONE_OUT_IRQ_EN, 0x1); /*20*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1, HMIC_EARPHONE_IN_IRQ_EN, 0x1); /*19*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1, HMIC_KEY_UP_IRQ_EN, 0x1); /*18*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1, HMIC_KEY_DOWN_IRQ_EN, 0x1); /*17*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1, HMIC_DATA_IRQ_EN, 0x1); /*16*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x3, HMIC_DS_SAMP, 0x0); /*14*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1f, HMIC_TH2_KEY, 0x0); /*0xf should be get from hw_debug 8*/ hmic_wr_control(SUNXI_HMIC_CTL, 0x1f, HMIC_TH1_EARPHONE, 0x1); /*0x1 should be get from hw_debug 0*/ } #ifdef CONFIG_ARCH_SUN8IW8 enable_irq(SUNXI_IRQ_CODEC); #endif switch_data = (struct gpio_switch_data *)platform_get_drvdata(pdev); if (switch_data != NULL) { queue_work(resume_switch_work_queue, &switch_data->resume_work); } return 0; }
static int switch_suspend(struct platform_device *pdev,pm_message_t state) { int headphone_mute_used = 0; script_item_u val; script_item_value_type_e type; pr_debug("[headset]:suspend start\n"); /* check if called in talking standby */ if (check_scene_locked(SCENE_TALKING_STANDBY) == 0) { pr_debug("In talking standby, do not suspend!!\n"); return 0; } type = script_get_item("audio0", "headphone_mute_used", &val); if (SCIRPT_ITEM_VALUE_TYPE_INT != type) { pr_err("[audiocodec] headphone_mute_used type err!\n"); } headphone_mute_used = val.val; if (headphone_mute_used) { gpio_set_value(item_mute.gpio.gpio, 0); } msleep(150); /*fix the resume blaze blaze noise*/ hmic_wr_prcm_control(ADDA_APT2, 0x1, PA_SLOPE_SELECT, 0x1); /*disable pa*/ hmic_wr_prcm_control(PAEN_HP_CTRL, 0x1, HPPAEN, 0x0); hmic_wr_prcm_control(MIC1G_MICBIAS_CTRL, 0x1, HMICBIASEN, 0x0); msleep(350); #ifdef CONFIG_ARCH_SUN8IW8 disable_irq(SUNXI_IRQ_CODEC); #endif return 0; }
/** * extended_standby_show_state - show current standby state, for debug purpose. * * function: standby state including locked_scene, power_supply dependancy, the wakeup src. * * return value: succeed, return 0, else return -1. */ int extended_standby_show_state(void) { unsigned long irqflags; printk("scence_lock: "); if (!check_scene_locked(SCENE_USB_STANDBY)) printk("usb_standby "); if (!check_scene_locked(SCENE_TALKING_STANDBY)) printk("talking_standby "); if (!check_scene_locked(SCENE_MP3_STANDBY)) printk("mp3_standby"); printk("\n"); spin_lock_irqsave(&data_lock, irqflags); printk("wakeup_src 0x%lx\n", extended_standby_manager.event); printk("wakeup_gpio_map 0x%lx\n", extended_standby_manager.wakeup_gpio_map); printk("wakeup_gpio_group 0x%lx\n", extended_standby_manager.wakeup_gpio_group); if (NULL != extended_standby_manager.pextended_standby) printk("extended_standby id = 0x%lx\n", extended_standby_manager.pextended_standby->id); spin_unlock_irqrestore(&data_lock, irqflags); return 0; }