void active_reset(int high) { if (high) { pm8xxx_mpp_config( PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_HIGH_CONFIG); } else { pm8xxx_mpp_config( PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_LOW_CONFIG); } }
static int32_t msm_camera_8960_ext_power_ctrl(int enable) { int rc = 0; if (enable) { rc = pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(12), &privacy_light_on_config); } else { rc = pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(12), &privacy_light_off_config); } return rc; }
static void dlp_china_set_backlight(struct msm_fb_data_type *mfd) { int rc; write_display_brightness[2] = dlp_china_shrink_pwm((unsigned char)(mfd->bl_level)); if (resume_blk || board_mfg_mode() == 5) { resume_blk = 0; rc = pm8xxx_mpp_config(BL_HW_EN_MPP_8, &MPP_ENABLE); if (rc < 0) { pr_err("enable bl_hw failed, rc=%d\n", rc); } rc = i2c_smbus_write_byte_data(blk_pwm_client, 0x10, 0xC5); if (rc) pr_err("i2c write fail\n"); rc = i2c_smbus_write_byte_data(blk_pwm_client, 0x19, 0x13); if (rc) pr_err("i2c write fail\n"); rc = i2c_smbus_write_byte_data(blk_pwm_client, 0x14, 0xC2); if (rc) pr_err("i2c write fail\n"); rc = i2c_smbus_write_byte_data(blk_pwm_client, 0x79, 0xFF); if (rc) pr_err("i2c write fail\n"); rc = i2c_smbus_write_byte_data(blk_pwm_client, 0x1D, 0xFA); if (rc) pr_err("i2c write fail\n"); } cmdreq.cmds = (struct dsi_cmd_desc*)&renesas_cmd_backlight_cmds; cmdreq.cmds_cnt = 1; cmdreq.flags = CMD_REQ_COMMIT; cmdreq.rlen = 0; cmdreq.cb = NULL; mipi_dsi_cmdlist_put(&cmdreq); if((mfd->bl_level) == 0) { rc = pm8xxx_mpp_config(BL_HW_EN_MPP_8, &MPP_DISABLE); if (rc < 0) { pr_err("disable bl_hw failed, rc=%d\n", rc); } resume_blk = 1; } return; }
static bool sec_fg_gpio_init(void) { struct pm_gpio param = { .direction = PM_GPIO_DIR_IN, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_S4, .function = PM_GPIO_FUNC_NORMAL, }; /* FUEL_ALERT Setting */ if (system_rev == 0x0) { sec_battery_pdata.fg_irq = PM8921_GPIO_IRQ(PM8921_IRQ_BASE, GPIO_FUEL_INT_04A); pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(GPIO_FUEL_INT_04A), ¶m); #if defined(CONFIG_MACH_JF_ATT) || defined(CONFIG_MACH_JF_TMO) } else if (system_rev >= 8) { #else } else if (system_rev >= 9) { #endif /* FUEL_ALERT Registration */ struct pm8xxx_mpp_config_data fuel_alert_mppcfg = { .type = PM8XXX_MPP_TYPE_D_INPUT, .level = PM8921_MPP_DIG_LEVEL_S4, .control = PM8XXX_MPP_DOUT_CTRL_LOW, }; sec_battery_pdata.fg_irq = PM8921_MPP_IRQ(PM8921_IRQ_BASE, 6); pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(6), &fuel_alert_mppcfg); } else
static int mipi_dsi_power_octa_request(void) { int rc = 0; reg_L30 = regulator_get(&msm_mipi_dsi1_device.dev, "3000mV_LCD"); if (IS_ERR_OR_NULL(reg_L30)) { pr_err("could not get 8917_L30, rc = %ld\n", PTR_ERR(reg_L30)); return -ENODEV; } rc = regulator_set_voltage(reg_L30, 3000000, 3000000); if (rc) { pr_err("set_voltage L30 failed, rc=%d\n", rc); return -EINVAL; } pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_LOW_CONFIG); msleep(100); return rc; }
void __init pm8921_gpio_mpp_init(struct pm8xxx_gpio_init *pm8921_gpios, unsigned gpio_size, struct pm8xxx_mpp_init *pm8921_mpps, unsigned mpp_size) { int i, rc; for (i = 0; i < gpio_size; i++) { rc = pm8xxx_gpio_config(pm8921_gpios[i].gpio, &pm8921_gpios[i].config); if (rc) { pr_err("%s: pm8xxx_gpio_config: rc=%d\n", __func__, rc); break; } } for (i = 0; i < mpp_size; i++) { rc = pm8xxx_mpp_config(pm8921_mpps[i].mpp, &pm8921_mpps[i].config); if (rc) { pr_err("%s: pm8xxx_mpp_config: rc=%d\n", __func__, rc); break; } } }
static void m7wl_audio_pmic_mpp_config(void) { unsigned ret; struct pm8xxx_mpp_config_data m7wl_audio_pmic_mpp = { .type = PM8XXX_MPP_TYPE_D_OUTPUT, .level = PM8921_MPP_DIG_LEVEL_S4, .control = PM8XXX_MPP_DOUT_CTRL_LOW, }; ret = pm8xxx_mpp_config(PM8921_MPP_PM_TO_SYS(9), &m7wl_audio_pmic_mpp); if (ret < 0) pr_err("%s:MPP_9 configuration failed\n", __func__); }
int msm_camio_sensor_clk_off(struct platform_device *pdev) { int rc = 0; struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; msm_camera_vreg_disable(); if (sinfo->sensor_platform_info->privacy_light) { struct msm8960_privacy_light_cfg *privacy_light_config = sinfo->sensor_platform_info->privacy_light_info; pm8xxx_mpp_config(privacy_light_config->mpp, &privacy_light_off_config); } rc = config_gpio_table(0); if (rc < 0) return rc; return msm_camio_clk_disable(CAMIO_CAM_MCLK_CLK); }
static int Remote_Interrupt_Enable(int en) { int ret =0; struct pm8xxx_mpp_config_data sky_handset_digital_adc = { .type = PM8XXX_MPP_TYPE_D_INPUT, .level = PM8058_MPP_DIG_LEVEL_S3, .control = PM8XXX_MPP_DIN_TO_INT, }; if(en) { ret=gpio_get_value_cansleep(hspd->ear_det); if(ret!=hspd->ear_det_active) { printk("EARJACK_DET %d\n",ret); return -1; } if(hspd->curr_state == MSM_HEADSET && hspd->remote_is_int==0) { #if AT1_BDVER_GE(AT1_WS22) ret = pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(XOADC_MPP_3), &sky_handset_digital_adc); if (ret < 0) printk("%s: pm8058_mpp_config_DIG ret=%d\n",__func__, ret); /* ret = pm8058_mpp_config_digital_in(PM8058_MPP_SYS_TO_PM(hspd->remote_det), PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT); */ #else gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #endif enable_irq(gpio_to_irq(hspd->remote_det)); irq_set_irq_wake(gpio_to_irq(hspd->remote_det),1); hspd->remote_is_int = 1; } } else { if(hspd->remote_is_int==1) { irq_set_irq_wake(gpio_to_irq(hspd->remote_det),0); disable_irq(gpio_to_irq(hspd->remote_det)); hspd->remote_is_int = 0; #if AT1_BDVER_E(AT1_WS21) gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #endif } } return 0; }
int msm_camio_sensor_clk_on(struct platform_device *pdev) { int rc = 0; struct msm_camera_sensor_info *sinfo = pdev->dev.platform_data; struct msm_camera_device_platform_data *camdev = sinfo->pdata; camio_dev = pdev; camio_clk = camdev->ioclk; msm_camera_vreg_enable(pdev); if (sinfo->sensor_platform_info->privacy_light) { struct msm8960_privacy_light_cfg *privacy_light_config = sinfo->sensor_platform_info->privacy_light_info; pm8xxx_mpp_config(privacy_light_config->mpp, &privacy_light_on_config); } msleep(20); rc = config_gpio_table(1); if (rc < 0) return rc; return msm_camio_clk_enable(CAMIO_CAM_MCLK_CLK); }
static int mipi_panel_power_tft(int enable) { int rc = 0; #if defined(CONFIG_MACH_JACTIVE_ATT) if(first_boot < 2) { first_boot++; printk("<0> First init Occurred ..... Finished Successfully \n"); return 0; } #endif pr_info("%s %d", __func__, enable); if (enable) { #if defined(CONFIG_MACH_JACTIVE_EUR) rc = regulator_set_optimum_mode(reg_LVS1, 100000); /*IOVDD */ if (rc < 0) { pr_err("set_optimum_mode LVS1 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_LVS1); if (rc) { pr_err("enable LVS1 failed, rc=%d\n", rc); return -ENODEV; } #elif defined(CONFIG_MACH_JACTIVE) if (system_rev >= 11) { rc = regulator_set_optimum_mode(reg_LVS1, 100000); /*IOVDD */ if (rc < 0) { pr_err("set_optimum_mode LVS1 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_LVS1); if (rc) { pr_err("enable LVS1 failed, rc=%d\n", rc); return -ENODEV; } } #endif rc = regulator_set_optimum_mode(reg_L15, 100000); /*IOVDD */ if (rc < 0) { pr_err("set_optimum_mode L15 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_L15); if (rc) { pr_err("enable L15 failed, rc=%d\n", rc); return -ENODEV; } #if defined(CONFIG_MACH_JACTIVE_ATT) if(system_rev < 10) gpio_direction_output(gpio33, 1); else gpio_direction_output(LCD_22V_EN, 1); #else gpio_direction_output(LCD_22V_EN, 1); #if defined(CONFIG_FB_MSM_ENABLE_LCD_EN2) if( system_rev >= 16 ) // rev0.6 + 10 { mdelay(10); gpio_direction_output(LCD_22V_EN_2, 1); } #endif #endif #if !defined(CONFIG_MACH_JACTIVE_ATT) && !defined(CONFIG_MACH_JACTIVE_EUR) /*active_reset_ldi(gpio43);*/ if (system_rev == 0) gpio_direction_output(gpio43, 1); else pm8xxx_mpp_config( PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_HIGH_CONFIG); msleep(20); #endif #if defined(CONFIG_MACH_JACTIVE_EUR) if( system_rev >= 15 ) // rev0.5 + 10 { rc = regulator_set_optimum_mode(reg_L16, 100000); /*IOVDD */ if (rc < 0) { pr_err("set_optimum_mode L16 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_L16); if (rc) { pr_err("enable L16 failed, rc=%d\n", rc); return -ENODEV; } msleep ( 10 ); } #elif defined(CONFIG_MACH_JACTIVE_ATT) if( system_rev >= 11 ) // rev0.3 + 8 { rc = regulator_set_optimum_mode(reg_L16, 100000); /*IOVDD */ if (rc < 0) { pr_err("set_optimum_mode L16 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_L16); if (rc) { pr_err("enable L16 failed, rc=%d\n", rc); return -ENODEV; } msleep ( 10 ); } #endif gpio_direction_output(gpio27, 1);/*LED_DRIVER(gpio27);*/ } else { if (system_rev == 0) gpio_direction_output(gpio43, 0); else pm8xxx_mpp_config( PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_LOW_CONFIG); #if defined(CONFIG_MACH_JACTIVE_ATT) if(system_rev < 10) gpio_direction_output(gpio33, 0); else gpio_direction_output(LCD_22V_EN, 0); #else #if defined(CONFIG_FB_MSM_ENABLE_LCD_EN2) if( system_rev >= 16 ) // rev0.6 + 10 { gpio_direction_output(LCD_22V_EN_2, 0); mdelay(10); } #endif gpio_direction_output(LCD_22V_EN, 0); #endif usleep(2000); /*1ms delay(minimum) required between VDD off and AVDD off*/ rc = regulator_set_optimum_mode(reg_L15, 100); if (rc < 0) { pr_err("set_optimum_mode L15 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(reg_L15); if (rc) { pr_err("disable reg_L15 failed, rc=%d\n", rc); return -ENODEV; } gpio_direction_output(gpio27, 0);/*LED_DRIVER(gpio27);*/ #if defined(CONFIG_MACH_JACTIVE_EUR) if( system_rev >= 15 ) // rev0.5 + 10 { msleep ( 10 ); rc = regulator_set_optimum_mode(reg_L16, 100); if (rc < 0) { pr_err("set_optimum_mode L16 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(reg_L16); if (rc) { pr_err("disable reg_L16 failed, rc=%d\n", rc); return -ENODEV; } } #elif defined(CONFIG_MACH_JACTIVE_ATT) if( system_rev >= 11 ) // rev0.3 + 8 { msleep ( 10 ); rc = regulator_set_optimum_mode(reg_L16, 100); if (rc < 0) { pr_err("set_optimum_mode L16 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(reg_L16); if (rc) { pr_err("disable reg_L16 failed, rc=%d\n", rc); return -ENODEV; } } #endif #if defined(CONFIG_MACH_JACTIVE_EUR) rc = regulator_set_optimum_mode(reg_LVS1, 100); if (rc < 0) { pr_err("set_optimum_mode LVS1 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(reg_LVS1); if (rc) { pr_err("disable reg_LVS1 failed, rc=%d\n", rc); return -ENODEV; } #elif defined(CONFIG_MACH_JACTIVE) if (system_rev >= 11) { rc = regulator_set_optimum_mode(reg_LVS1, 100); if (rc < 0) { pr_err("set_optimum_mode LVS1 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(reg_LVS1); if (rc) { pr_err("disable reg_LVS1 failed, rc=%d\n", rc); return -ENODEV; } } #endif msleep(20); } return rc; }
static int mipi_dsi_power_tft_request(void) { int rc = 0; #if defined(CONFIG_MACH_JACTIVE_ATT) if (system_rev < 10){ gpio33 = PM8921_GPIO_PM_TO_SYS(LCD_22V_EN); rc = gpio_request(gpio33, "led_dirver"); if (rc) { pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc); return -ENODEV; } rc = pm8xxx_gpio_config(gpio33, &gpio43_param); if (rc) { pr_err("gpio_config lcd_22v_en failed (3), rc=%d\n", rc); return -EINVAL; } } else{ pr_info("[lcd] request gpio lcd_22v_en\n"); rc = gpio_request(LCD_22V_EN, "lcd_22v_en"); if (rc) { gpio_free(LCD_22V_EN); rc = gpio_request(LCD_22V_EN, "lcd_22v_en"); if(rc){ pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc); return -ENODEV; } } pr_info("[lcd] configure LCD_22V_EN\n"); gpio_tlmm_config(GPIO_CFG(LCD_22V_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); } #else pr_info("[lcd] request gpio lcd_22v_en\n"); rc = gpio_request(LCD_22V_EN, "lcd_22v_en"); if (rc) { pr_err("request gpio lcd_22v_en failed, rc=%d\n", rc); return -ENODEV; } pr_info("[lcd] configure LCD_22V_EN\n"); gpio_tlmm_config(GPIO_CFG(LCD_22V_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #if defined(CONFIG_FB_MSM_ENABLE_LCD_EN2) if( system_rev >= 16 ) // rev0.6 + 10 { pr_info("[lcd] request gpio lcd_22v_en_2\n"); rc = gpio_request(LCD_22V_EN_2, "lcd_22v_en_2"); if (rc) { pr_err("request gpio lcd_22v_en_2 failed, rc=%d\n", rc); return -ENODEV; } pr_info("[lcd] configure LCD_22V_EN_2\n"); gpio_tlmm_config(GPIO_CFG(LCD_22V_EN_2, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); } #endif #endif if (system_rev == 0) { gpio43 = PM8921_GPIO_PM_TO_SYS( PMIC_GPIO_LCD_RST); rc = gpio_request(gpio43, "mlcd_rst"); if (rc) { pr_err("request gpio mlcd_rst failed, rc=%d\n", rc); return -ENODEV; } rc = pm8xxx_gpio_config(gpio43, &gpio43_param); if (rc) { pr_err("gpio_config mlcd_rst failed (3), rc=%d\n", rc); return -EINVAL; } } #if defined(CONFIG_MACH_JACTIVE_ATT) if (system_rev < 10) gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER_REV00); else gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER_REV10); #else gpio27 = PM8921_GPIO_PM_TO_SYS(PMIC_GPIO_LED_DRIVER); #endif rc = gpio_request(gpio27, "led_dirver"); if (rc) { pr_err("request gpio led_dirver failed, rc=%d\n", rc); return -ENODEV; } rc = pm8xxx_gpio_config(gpio27, &gpio43_param); if (rc) { pr_err("gpio_config led_dirver failed (3), rc=%d\n", rc); return -EINVAL; } #if !defined(CONFIG_MACH_JACTIVE_ATT) && !defined(CONFIG_MACH_JACTIVE_EUR) #if defined(CONFIG_MACH_JACTIVE_ATT) if(system_rev < 10) gpio_direction_output(gpio33, 0); else gpio_direction_output(LCD_22V_EN, 0); #else gpio_direction_output(LCD_22V_EN, 0); #endif if (system_rev == 0) gpio_direction_output(gpio43, 0); else pm8xxx_mpp_config( PM8921_MPP_PM_TO_SYS(MLCD_RST_MPP2), &MLCD_RESET_LOW_CONFIG); msleep(1000); #endif gpio_direction_output(gpio27, 0); return rc; }
static int __devinit hs_probe(struct platform_device *pdev) { int rc = 0,err; struct input_dev *ipdev; struct pm8xxx_mpp_config_data sky_handset_digital_adc = { .type = PM8XXX_MPP_TYPE_D_INPUT, .level = PM8058_MPP_DIG_LEVEL_S3, .control = PM8XXX_MPP_DIN_TO_INT, }; hs_dbg("hs_probe start!!!\n"); headset_init=0; //sky_hs_3p5pi_jack_ctrl.state=SKY_HS_JACK_STATE_INIT; hs = kzalloc(sizeof(struct msm_headset), GFP_KERNEL); if (!hs) return -ENOMEM; hspd = kzalloc(sizeof(struct msm_headset_platform_data), GFP_KERNEL); if (!hspd) return -ENOMEM; #if 0 hs->sdev.name = "h2w"; #else hs->sdev.name = "hw2"; #endif hs->sdev.print_name = msm_headset_print_name; rc = switch_dev_register(&hs->sdev); if (rc) goto err_switch_dev_register; ipdev = input_allocate_device(); if (!ipdev) { rc = -ENOMEM; goto err_switch_dev; } input_set_drvdata(ipdev, hs); hs->ipdev = ipdev; if (pdev->dev.platform_data) { hs->hs_pdata = pdev->dev.platform_data; hspd = pdev->dev.platform_data; } if (hs->hs_pdata->hs_name) ipdev->name = hs->hs_pdata->hs_name; else ipdev->name = DRIVER_NAME; mutex_init(&headset_adc_lock); INIT_DELAYED_WORK(&earjack_work,earjack_det_func); INIT_DELAYED_WORK(&remotekey_work,remotekey_det_func); wake_lock_init(&headset_wakelock, WAKE_LOCK_SUSPEND, "Headset_wakelock"); ipdev->id.vendor = 0x0001; ipdev->id.product = 1; ipdev->id.version = 1; input_set_capability(ipdev, EV_KEY, KEY_MEDIA); input_set_capability(ipdev, EV_KEY, KEY_VOLUMEUP); input_set_capability(ipdev, EV_KEY, KEY_VOLUMEDOWN); //input_set_capability(ipdev, EV_KEY, KEY_END); input_set_capability(ipdev, EV_SW, SW_HEADPHONE_INSERT); //input_set_capability(ipdev, EV_KEY, KEY_POWER); //input_set_capability(ipdev, EV_KEY, KEY_SEND); rc = input_register_device(ipdev); if (rc) { dev_err(&ipdev->dev, "hs_probe: input_register_device rc=%d\n", rc); goto err_reg_wakelock; } /* Enable runtime PM ops, start in ACTIVE mode */ //rc = pm_runtime_set_active(&pdev->dev); //if (rc < 0) // dev_dbg(&pdev->dev, "unable to set runtime pm state\n"); //pm_runtime_enable(&pdev->dev); platform_set_drvdata(pdev, hs); device_init_wakeup(&pdev->dev,1); hs_jack_l8 = regulator_get(NULL, "8058_l8"); if(IS_ERR(hs_jack_l8)) { printk("regulator l8 get error\n"); goto err_reg_input_dev; } // Added sysfs. (/sys/devices/platform/msm-handset/headset) rc = sysfs_create_group(&pdev->dev.kobj, &dev_attr_grp); if (rc) { dev_err(&ipdev->dev, "hs_probe: sysfs_create_group rc=%d\n", rc); goto err_reg_input_dev; } err = gpio_request(hspd->ear_det, "headset_det"); if(err) { printk("unable to request gpio headset_det err=%d\n",err); goto err_reg_input_dev; } err=gpio_direction_input(hspd->ear_det); if(err) { printk("Unable to set direction headset_det err=%d\n",err); goto err_reg_input_dev; } #if AT1_BDVER_GE(AT1_WS22) gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #else gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #endif //gpio_set_debounce(hspd->ear_det,5); //set_irq_wake(gpio_to_irq(hspd->ear_det),1); err=request_irq(gpio_to_irq(hspd->ear_det), Earjack_Det_handler, IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "earjack_det-irq", hs); if (err < 0) { printk("Couldn't acquire ear_det as request_irq()"); goto err_reg_input_dev; } irq_set_irq_wake(gpio_to_irq(hspd->ear_det),1); err = gpio_request(hspd->remote_det, "remote_det"); if(err) { printk("unable to request gpio remote_det err=%d\n",err); goto err_reg_input_dev; } #if AT1_BDVER_GE(AT1_WS22) err = pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(XOADC_MPP_3), &sky_handset_digital_adc); if (err < 0) printk("%s: pm8058_mpp_config_DIG ret=%d\n",__func__, err); /* err = pm8058_mpp_config_digital_in(PM8058_MPP_SYS_TO_PM(hspd->remote_det), PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT); err |= pm8058_mpp_config_bi_dir(PM8058_MPP_SYS_TO_PM(hspd->remote_det), PM8058_MPP_DIG_LEVEL_S3, PM_MPP_BI_PULLUP_OPEN); */ printk("mpp config %d mpp %d err=%d\n",hspd->remote_det, PM8058_MPP_SYS_TO_PM(hspd->remote_det),err); printk(" remote %d %d\n",gpio_to_irq(hspd->remote_det),PM8058_MPP_IRQ(PM8058_IRQ_BASE,PM8058_MPP_SYS_TO_PM(hspd->remote_det))); err=request_threaded_irq(gpio_to_irq(hspd->remote_det),NULL, Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs); #else err=gpio_direction_input(hspd->remote_det); if(err) { printk("Unable to set direction remote_det err=%d\n",err); goto err_reg_input_dev; } //gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); //gpio_set_debounce(hspd->remote_det,5); err=request_irq(gpio_to_irq(hspd->remote_det), Remotekey_Det_handler, IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs); #endif if (err < 0) { printk("Couldn't acquire remote_det as request_irq()"); goto err_reg_input_dev; } disable_irq(gpio_to_irq(hspd->remote_det)); headset_init=1; // headset init rc=gpio_get_value_cansleep(hspd->ear_det); if(rc==hspd->ear_det_active) { schedule_delayed_work(&earjack_work,msecs_to_jiffies(200)); //schedule_delayed_work(&earjack_work,200); } printk("hs_probe success!!!\n"); return 0; err_reg_input_dev: input_unregister_device(ipdev); err_reg_wakelock: wake_lock_destroy(&headset_wakelock); input_free_device(ipdev); err_switch_dev: switch_dev_unregister(&hs->sdev); err_switch_dev_register: kfree(hspd); kfree(hs); return rc; }
static void remotekey_detect_func(struct work_struct * test_remotekey_work) { int key_first=0; int key_second=0; // int key_third=0; struct pm8xxx_mpp_config_data pantech_presto_earjack_remote_adc = { .type = PM8XXX_MPP_TYPE_A_INPUT, .level = PM8XXX_MPP_AIN_AMUX_CH5, .control = PM8XXX_MPP_AOUT_CTRL_DISABLE, }; struct pm8xxx_mpp_config_data pantech_presto_earjack_digital_adc = { .type = PM8XXX_MPP_TYPE_D_INPUT, .level = PM8058_MPP_DIG_LEVEL_S3, .control = PM8XXX_MPP_DIN_TO_INT, }; dbg_func_in(); // car kit if(earjack->car_kit ){ if(EARJACK_INSERTED){ dbg("report KEY_MEDIA input from car_kit"); input_report_key(earjack->ipdev, KEY_MEDIA, earjack->remotekey_pressed); // car kit button down earjack->car_kit = 0; // reset car_kit flag if(REMOTEKEY_RELEASED) { earjack->remotekey_pressed = 0; input_report_key(earjack->ipdev, KEY_MEDIA, earjack->remotekey_pressed); // car kit button up } } input_sync(earjack->ipdev); earjack->car_kit = 0; // reset car_kit flag. enable_irq(gpio_to_irq(REMOTEKEY_DET)); wake_unlock(&remotekey_wake_lock); dbg_func_out(); return ; } // if current state: key not pressed if(!earjack->remotekey_pressed){ dbg("current state: remotekey not pressed, read adc value. \n"); pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(2), &pantech_presto_earjack_remote_adc); //pm8058_mpp_config_analog_input(XOADC_MPP_3,PM_MPP_AIN_AMUX_CH5, PM_MPP_AOUT_CTL_DISABLE); // read adc value twice key_first=adc_value_to_key(); key_second=adc_value_to_key(); // after 20ms (adc reading delay) pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(2), &pantech_presto_earjack_digital_adc); //pm8058_mpp_config_digital_in(XOADC_MPP_3,PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT); // is valid key && earjack inserted if( (key_first==key_second) && EARJACK_INSERTED){ earjack->remotekey_index = key_first; earjack->remotekey_pressed = 1; if (earjack->remotekey_index != 0 && !earjack->car_kit) { input_report_key(earjack->ipdev, remotekey_type[earjack->remotekey_index].key_index, earjack->remotekey_pressed); dbg("remote key: %s : %d->%d \n", remotekey_type[earjack->remotekey_index].key_name, !earjack->remotekey_pressed, earjack->remotekey_pressed); } else if (earjack->car_kit) { schedule_delayed_work(&remotekey_work, 20); // for car kit : delayed work after 200ms for __ TODO return; } // Defense code :key pressed but released during processing key. if(REMOTEKEY_RELEASED){ earjack->remotekey_pressed=0; if (earjack->remotekey_index != 0) input_report_key(earjack->ipdev, remotekey_type[earjack->remotekey_index].key_index, earjack->remotekey_pressed); dbg("remote key: %s : %d->%d \n", remotekey_type[earjack->remotekey_index].key_name, !earjack->remotekey_pressed, earjack->remotekey_pressed); } } // else, ignore key else { dbg("igrnore key.\n"); enable_irq(gpio_to_irq(REMOTEKEY_DET)); wake_unlock(&remotekey_wake_lock); dbg_func_out(); return ; } } // if current state : key pressed else { earjack->remotekey_pressed=0; if (earjack->remotekey_index != 0) input_report_key(earjack->ipdev, remotekey_type[earjack->remotekey_index].key_index, earjack->remotekey_pressed); dbg("remote key: %s : %d->%d \n", remotekey_type[earjack->remotekey_index].key_name, !earjack->remotekey_pressed, earjack->remotekey_pressed); } input_sync(earjack->ipdev); enable_irq(gpio_to_irq(REMOTEKEY_DET)); wake_unlock(&remotekey_wake_lock); dbg_func_out(); return; }
static int mipi_dsi_panel_power(int on) { static struct regulator *reg_lvs5, *reg_l2; int rc; PR_DISP_INFO("%s: on=%d\n", __func__, on); if (!dsi_power_on) { reg_lvs5 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi1_vddio"); if (IS_ERR_OR_NULL(reg_lvs5)) { pr_err("could not get 8921_lvs5, rc = %ld\n", PTR_ERR(reg_lvs5)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi1_pll_vdda"); if (IS_ERR_OR_NULL(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } gpio_tlmm_config(GPIO_CFG(LCD_RST, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); dsi_power_on = true; } if (on) { if (!first_init) { rc = regulator_enable(reg_lvs5); if (rc) { pr_err("enable lvs5 failed, rc=%d\n", rc); return -ENODEV; } msleep(200); rc = pm8xxx_mpp_config(LCM_P5V_EN_MPP_10, &MPP_ENABLE); if (rc < 0) { pr_err("enable lcd_5v+ failed, rc=%d\n", rc); return -ENODEV; } msleep(10); rc = pm8xxx_mpp_config(LCM_N5V_EN_MPP_9, &MPP_ENABLE); if (rc < 0) { pr_err("enable lcd_5v- failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l2, 100000); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } msm_xo_mode_vote(wa_xo, MSM_XO_MODE_ON); gpio_set_value(LCD_RST, 0); msleep(10); gpio_set_value(LCD_RST, 1); msm_xo_mode_vote(wa_xo, MSM_XO_MODE_OFF); } else { rc = regulator_enable(reg_lvs5); if (rc) { pr_err("enable lvs5 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l2, 100000); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } msm_xo_mode_vote(wa_xo, MSM_XO_MODE_ON); msleep(10); msm_xo_mode_vote(wa_xo, MSM_XO_MODE_OFF); } } else { rc = pm8xxx_mpp_config(BL_HW_EN_MPP_8, &MPP_DISABLE); if (rc < 0) { pr_err("disable bl_hw failed, rc=%d\n", rc); } gpio_set_value(LCD_RST, 0); msleep(10); rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = pm8xxx_mpp_config(LCM_N5V_EN_MPP_9, &MPP_DISABLE); if (rc < 0) { pr_err("disable lcd_5v- failed, rc=%d\n", rc); return -ENODEV; } msleep(10); rc = pm8xxx_mpp_config(LCM_P5V_EN_MPP_10, &MPP_DISABLE); if (rc < 0) { pr_err("disable lcd_5v- failed, rc=%d\n", rc); return -ENODEV; } msleep(100); rc = regulator_disable(reg_lvs5); if (rc) { pr_err("disable reg_lvs5 failed, rc=%d\n", rc); return -ENODEV; } } #ifdef CONFIG_HTC_PNPMGR if (on) set_screen_status(true); else set_screen_status(false); #endif return 0; }
static int Check_ADC_MPP(int *nValue) { int err=0,ret=0,result=0; void *h; struct adc_chan_result adc_chan_result; //long timeout=0; struct completion conv_complete_evt; struct pm8xxx_mpp_config_data sky_handset_analog_adc = { .type = PM8XXX_MPP_TYPE_A_INPUT, .level = PM8XXX_MPP_AIN_AMUX_CH5, .control = PM8XXX_MPP_AOUT_CTRL_DISABLE, }; mutex_lock(&headset_adc_lock); ret=gpio_get_value_cansleep(hspd->ear_det); if(ret!=hspd->ear_det_active) { printk("EARJACK_DET %d\n",ret); mutex_unlock(&headset_adc_lock); return -1; } #if AT1_BDVER_GE(AT1_WS22) if(hspd->curr_state == MSM_HEADSET) { Remote_Interrupt_Enable(0); msleep(1); } #endif //sys_gpio= PM8901_GPIO_PM_TO_SYS(mpp); //err=pm8058_mpp_config_analog_input(XOADC_MPP_3,PM_MPP_AIN_AMUX_CH5, PM_MPP_AOUT_CTL_DISABLE); err = pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(XOADC_MPP_3), &sky_handset_analog_adc); if(err) { printk("pm8058_mpp_config_analog_input() err=%d\n",err); mutex_unlock(&headset_adc_lock); return -1; } ret = adc_channel_open(CHANNEL_ADC_HDSET, &h); if(ret) { printk("couldn't open channel %d ret=%d\n",CHANNEL_ADC_HDSET,ret); mutex_unlock(&headset_adc_lock); return -1; } init_completion(&conv_complete_evt); ret = adc_channel_request_conv(h, &conv_complete_evt); if(ret) { printk("couldn't request convert channel %d ret=%d\n",CHANNEL_ADC_HDSET,ret); result=-2; goto check_adc_out; } wait_for_completion(&conv_complete_evt); /* timeout=wait_for_completion_timeout(&conv_complete_evt,msecs_to_jiffies(100)); if(timeout<=0) { printk("headset ADC timeout\n"); result=-3; goto check_adc_out; } */ ret = adc_channel_read_result(h, &adc_chan_result); if(ret) { printk("could't read result channel %d ret=%d\n",CHANNEL_ADC_HDSET,ret); result=-4; goto check_adc_out; } *nValue=(int)adc_chan_result.measurement; check_adc_out: ret = adc_channel_close(h); if(ret) { printk("could't close channel %d ret=%d\n",CHANNEL_ADC_HDSET,ret); mutex_unlock(&headset_adc_lock); return -1; } #if AT1_BDVER_GE(AT1_WS22) if(hspd->curr_state == MSM_HEADSET) { Remote_Interrupt_Enable(1); } #endif //printk("ADC value=%d, physical=%d\n",(int)adc_chan_result.measurement,adc_chan_result.physical); mutex_unlock(&headset_adc_lock); return result; }
static void earjack_detect_func( struct work_struct *test_earjack) { int err; struct pm8xxx_mpp_config_data pantech_presto_earjack_adc = { .type = PM8XXX_MPP_TYPE_D_INPUT, .level = PM8058_MPP_DIG_LEVEL_S3, .control = PM8XXX_MPP_DIN_TO_INT, }; dbg_func_in(); dbg("currnet earjack->type: "); switch(earjack->type){ case EARJACK_STATE_OFF : { dbg_without_label("EARJACK_STATE_OFF\n"); if(EARJACK_INSERTED){ earjack->type = EARJACK_STATE_CHECK; #if defined(CONFIG_MIC_BIAS_1_8V) #else err=regulator_is_enabled(hs_jack_l8); if(err<=0) err = regulator_enable(hs_jack_l8); #endif //defined(CONFIG_MACH_MSM8X60_PRESTO) pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(2), &pantech_presto_earjack_adc); //pm8058_mpp_config_digital_in(XOADC_MPP_3,PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT); schedule_delayed_work(&earjack_work, 5); //50ms // return without enable IRQ, wake_unlock. return; } break; } case EARJACK_STATE_CHECK : { dbg_without_label("EARJACK_STATE_CHECK\n"); if(EARJACK_INSERTED) { // 3pole if(!is_4pole_earjack()){ dbg("3pole headset inserted.\n"); earjack->type= EARJACK_STATE_ON_3POLE_CHECK; earjack->mic_on = 0; earjack->hs_on = 1; input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on); switch_set_state(&earjack->sdev, switch_state()); schedule_delayed_work(&earjack_work, 60); // check if 4pole 600ms // return without enable IRQ, wake_unlock. return; } //4pole else { dbg("4pole headset inserted.\n"); earjack->type= EARJACK_STATE_ON; err=request_threaded_irq(gpio_to_irq(REMOTEKEY_DET),NULL,Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", earjack); if(err) dbg("request_threaded_irq failed\n"); earjack->mic_on = 1; earjack->hs_on = 1; input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on); //TODO: NO USE? input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on); switch_set_state(&earjack->sdev, switch_state()); } } else // if EARJACK_RELEASED { earjack->type = EARJACK_STATE_OFF; dbg("earjack_type: -> EARJACK_STATE_OFF"); } break; // case EARJACK_STATE_CHECK } case EARJACK_STATE_ON_3POLE_CHECK : { // CHECKING IF 4POLE EARJACK IS INSERTIND? dbg_without_label("EARJACK_STATE_ON_3POLE_CHECK\n"); if(EARJACK_INSERTED){ earjack->type= EARJACK_STATE_ON; if(!is_4pole_earjack()){ dbg("3pole earjack insert.\n"); #if defined(CONFIG_MIC_BIAS_1_8V) #else err=regulator_is_enabled(hs_jack_l8); dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err); if(err>0) regulator_disable(hs_jack_l8); #endif //defined(CONFIG_MACH_MSM8X60_PRESTO) } else { dbg("4pole earjack insert.\n"); earjack->mic_on =1; input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on); switch_set_state(&earjack->sdev, switch_state()); err=request_threaded_irq(gpio_to_irq(REMOTEKEY_DET),NULL,Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", earjack); if(err) dbg("request_threaded_irq failed\n"); } } else{ #if defined(CONFIG_MIC_BIAS_1_8V) #else err=regulator_is_enabled(hs_jack_l8); dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err); if(err>0) regulator_disable(hs_jack_l8); #endif// defined(CONFIG_MACH_MSM8X60_PRESTO) earjack->type = EARJACK_STATE_OFF; earjack->hs_on=0; input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on); switch_set_state(&earjack->sdev, switch_state()); } break; } case EARJACK_STATE_ON: { dbg_without_label("EARJACK_STATE_ON\n"); if(EARJACK_RELEASED){ earjack->type = EARJACK_STATE_OFF; // if 4pole if (earjack->mic_on) { earjack->mic_on = 0; input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on); // free remote key irq and turn off mic power. free_irq(gpio_to_irq(REMOTEKEY_DET), earjack); #if defined(CONFIG_MIC_BIAS_1_8V) #else err=regulator_is_enabled(hs_jack_l8); dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err); if(err>0){ regulator_disable(hs_jack_l8); } #endif //defined(CONFIG_MACH_MSM8X60_PRESTO) // release remote key if pressed if(earjack->remotekey_pressed){ earjack->remotekey_pressed = 0; if (earjack->remotekey_index != 0) input_report_key(earjack->ipdev, remotekey_type[earjack->remotekey_index].key_index, earjack->remotekey_pressed); dbg("remote key: %s : %d->%d \n", remotekey_type[earjack->remotekey_index].key_name, !earjack->remotekey_pressed, earjack->remotekey_pressed); input_sync(earjack->ipdev); } dbg("earjack_release \n"); } earjack->hs_on = 0; input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on); switch_set_state(&earjack->sdev, switch_state()); } break; } default : dbg("earjack_detect_func default.\n"); } enable_irq_detect(); //enable_irq(gpio_to_irq(EARJACK_DET)); wake_unlock(&earjack_wake_lock); dbg_func_out(); return; }