static int nt35565_vreg_power(int on) { int rc = 0; if (!vreg_lcd_vci) { vreg_lcd_vci = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vci"); if (IS_ERR(vreg_lcd_vci)) { pr_err("could not get dsi_vci, rc = %ld\n", PTR_ERR(vreg_lcd_vci)); return -ENODEV; } } if (!vreg_lcd_vddio) { vreg_lcd_vddio = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vddio"); if (IS_ERR(vreg_lcd_vddio)) { pr_err("%s: Unable to get dsi_vddio\n", __func__); vreg_lcd_vddio = NULL; goto out_put; } } if (on) { rc = regulator_set_voltage(vreg_lcd_vci, 2850000, 2850000); if (rc) { pr_err("%s:%d unable to set dsi_vci voltage to 2.8V\n", __func__, rc); goto out_put_all; } rc = regulator_enable(vreg_lcd_vci); if (rc) { pr_err("%s: Enable regulator dsi_vci failed\n", __func__); goto out_put_all; } rc = regulator_set_voltage(vreg_lcd_vddio, 1800000, 1800000); if (rc) { pr_err("%s:%d unable to set dsi_vddio voltage to 1.8V\n", __func__, rc); goto out_disable; } rc = regulator_enable(vreg_lcd_vddio); if (rc) { pr_err("%s: Enable regulator dsi_vddio failed\n", __func__); goto out_disable; } rc = lcd_gpio_setup(on); if (rc) { pr_err("gpio setup failed , rc=%d\n", rc); goto out_disable_all; } msleep(LCD_VREG_ON_WAIT_MS); gpio_set_value_cansleep(gpio_lcd_reset, 1); msleep(LCD_RESET_WAIT_MS); gpio_set_value_cansleep(gpio_lcd_reset, 0); msleep(LCD_RESET_WAIT_MS); gpio_set_value_cansleep(gpio_lcd_reset, 1); msleep(LCD_RESET_H_WAIT_MS_NT35565); } else { gpio_set_value_cansleep(gpio_lcd_reset, 0); rc = lcd_gpio_setup(on); if (rc) { pr_err("gpio setup failed , rc=%d\n", rc); return -EINVAL; } rc = regulator_disable(vreg_lcd_vci); if (rc) pr_warning("%s: '%s' regulator disable failed, rc=%d\n", __func__, "dsi_vci", rc); rc = regulator_disable(vreg_lcd_vddio); if (rc) pr_warning("%s: '%s' regulator disable failed, rc=%d\n", __func__, "dsi_vddio", rc); } return 0; out_disable_all: regulator_disable(vreg_lcd_vddio); out_disable: regulator_disable(vreg_lcd_vci); out_put_all: regulator_put(vreg_lcd_vddio); vreg_lcd_vddio = NULL; out_put: regulator_put(vreg_lcd_vci); vreg_lcd_vci = NULL; return rc; }
static int mipi_dsi_panel_plf_power(int on) { int rc = 0; pr_debug("%s: power_on=%d\n", __func__, on); rc = mipi_dsi_panel_plf_init(); if (on) { pr_debug("%s: Power On\n", __func__); rc = regulator_enable(reg_l11); /* Enable dsi1_avdd */ if (rc) { pr_err("%s: enable reg_l11 failed, rc=%d\n", __func__, rc); goto disable_none; } rc = regulator_set_optimum_mode(reg_l29, 1000); if (rc < 0) { pr_err("%s: set_optimum_mode l29 failed, rc=%d\n", __func__, rc); goto disable_l11; } rc = regulator_enable(reg_l29); /* Enable dsi1_vddio */ if (rc) { pr_err("%s: enable reg_l29 failed, rc=%d\n", __func__, rc); goto disable_l11; } usleep_range(11000, 12000); /* Spec says > 10 ms */ rc = regulator_set_optimum_mode(reg_l2, 135000); if (rc < 0) { pr_err("%s: set_optimum_mode l2 failed, rc=%d\n", __func__, rc); goto disable_l29_l11; } rc = regulator_enable(reg_l2); /* Enable dsi-vdda */ if (rc) { pr_err("%s: enable l2 failed, rc=%d\n", __func__, rc); goto disable_l29_l11; } mipi_dsi_panel_plf_reset(0); /* Reset LOW */ usleep_range(6000, 7000); /* Spec says > 5 ms */ mipi_dsi_panel_plf_reset(1); /* Reset HIGH */ usleep_range(11000, 12000); /* Spec says > 10 ms */ /* Enable VSP/VSN */ gpio_set_value_cansleep(lcd_dcdc_en_gpio, 1); usleep_range(11000, 12000); /* Spec says > 10 ms */ } else { pr_debug("%s: Power Off\n", __func__); /* Disable VSP/VSN */ gpio_set_value_cansleep(lcd_dcdc_en_gpio, 0); msleep(20); /* Spec says > 20 ms) */ gpio_set_value_cansleep(lcd_reset_gpio, 0); /* Pull RESET Low */ rc = regulator_disable(reg_l2); /* Disable dsi-vdda */ if (rc) pr_err("%s: disable l2 failed, rc=%d\n", __func__, rc); rc = regulator_disable(reg_l29); /* Disable dsi1_vddio */ if (rc) pr_err("%s: disable l29 failed, rc=%d\n", __func__, rc); rc = regulator_disable(reg_l11); /* Disable dsi1_avdd */ if (rc) pr_err("%s: disable l11 failed, rc=%d\n", __func__, rc); } return 0; disable_l29_l11: rc = regulator_disable(reg_l29); if (rc) pr_err("%s: disable l29 failed, rc=%d\n", __func__, rc); disable_l11: rc = regulator_disable(reg_l11); if (rc) pr_err("disable reg_l11 failed, rc=%d\n", rc); disable_none: return rc; }
static void mipi_dsi_panel_pwm_cfg(void) { int rc; static int mipi_dsi_panel_gpio_configured; static struct pm_gpio pwm_enable = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 1, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_VPH, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_NORMAL, .inv_int_pol = 0, .disable_pin = 0, }; static struct pm_gpio pwm_mode = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_S4, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_2, .inv_int_pol = 0, .disable_pin = 0, }; if (mipi_dsi_panel_gpio_configured == 0) { /* pm8xxx: gpio-21, Backlight Enable */ rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(21), &pwm_enable); if (rc != 0) pr_err("%s: pwm_enabled failed\n", __func__); /* pm8xxx: gpio-24, Bl: Off, PWM mode */ rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(24), &pwm_mode); if (rc != 0) pr_err("%s: pwm_mode failed\n", __func__); mipi_dsi_panel_gpio_configured++; } } /** * LiQUID panel on/off * * @param on * * @return int */ static int mipi_dsi_liquid_panel_power(int on) { static struct regulator *reg_l2, *reg_ext_3p3v; static int gpio21, gpio24, gpio43; int rc; mipi_dsi_panel_pwm_cfg(); pr_debug("%s: on=%d\n", __func__, on); gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */ gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/ gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */ if (!dsi_power_on) { reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(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; } reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev, "vdd_lvds_3p3v"); if (IS_ERR(reg_ext_3p3v)) { pr_err("could not get reg_ext_3p3v, rc = %ld\n", PTR_ERR(reg_ext_3p3v)); return -ENODEV; } rc = gpio_request(gpio21, "disp_pwr_en_n"); if (rc) { pr_err("request gpio 21 failed, rc=%d\n", rc); return -ENODEV; } rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } rc = gpio_request(gpio24, "disp_backlight_pwm"); if (rc) { pr_err("request gpio 24 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { 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; } rc = regulator_enable(reg_ext_3p3v); if (rc) { pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } /* set reset pin before power enable */ gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */ gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */ msleep(20); gpio_set_value_cansleep(gpio43, 1); /* disp enable */ msleep(20); gpio_set_value_cansleep(gpio43, 0); /* disp enable */ msleep(20); gpio_set_value_cansleep(gpio43, 1); /* disp enable */ msleep(20); } else { gpio_set_value_cansleep(gpio43, 0); gpio_set_value_cansleep(gpio21, 1); rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_ext_3p3v); if (rc) { pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } } return 0; } static int mipi_dsi_cdp_panel_power(int on) { static struct regulator *reg_l8, *reg_l23, *reg_l2; static int gpio43; int rc; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdc"); if (IS_ERR(reg_l8)) { pr_err("could not get 8921_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vddio"); if (IS_ERR(reg_l23)) { pr_err("could not get 8921_l23, rc = %ld\n", PTR_ERR(reg_l23)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 2800000, 3000000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l23, 1800000, 1800000); if (rc) { pr_err("set_voltage l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } gpio43 = PM8921_GPIO_PM_TO_SYS(43); rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100000); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } 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_l8); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l23); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } gpio_set_value_cansleep(gpio43, 1); } else { rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l23); if (rc) { pr_err("disable reg_l23 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } gpio_set_value_cansleep(gpio43, 0); } return 0; } static int mipi_dsi_panel_power(int on) { int ret; pr_debug("%s: on=%d\n", __func__, on); if (machine_is_msm8960_liquid()) ret = mipi_dsi_liquid_panel_power(on); else ret = mipi_dsi_cdp_panel_power(on); return ret; } #elif defined(CONFIG_FB_MSM_MIPI_LGIT_LH470WX1_VIDEO_HD_PT) int mipi_dsi_panel_power(int on) { static struct regulator *reg_l8, *reg_l2, *reg_lvs6; static int gpio20; int rc; struct pm_gpio gpio20_param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 1, .pull = PM_GPIO_PULL_NO, .vin_sel = 2, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_PAIRED, .inv_int_pol = 0, .disable_pin = 0, }; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdc"); if (IS_ERR(reg_l8)) { pr_err("could not get 8921_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_lvs6 = regulator_get(&msm_mipi_dsi1_device.dev, "8921_lvs6"); if (IS_ERR(reg_lvs6)) { pr_err("could not get 8921_lvs6, rc = %ld\n", PTR_ERR(reg_lvs6)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 3000000, 3000000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } gpio20 = PM8921_GPIO_PM_TO_SYS(20); rc = gpio_request(gpio20, "disp_rst_n"); if (rc) { pr_err("request gpio 20 failed, rc=%d\n", rc); return -ENODEV; } rc = pm8xxx_gpio_config(gpio20, &gpio20_param); if (rc) { pr_err("gpio_config 20 failed (4), rc=%d\n", rc); return -EINVAL; } dsi_power_on = true; } if (on) { rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_lvs6, 100000); if (rc < 0) { pr_err("set_optimum_mode lvs6 failed, rc=%d\n", rc); return -EINVAL; } 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_lvs6); if (rc) { pr_err("enable lvs6 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_enable(reg_l8); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } mdelay(5); } else { gpio_set_value_cansleep(gpio20, 0); rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_lvs6); if (rc) { pr_err("disable reg_lvs6 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_lvs6, 100); if (rc < 0) { pr_err("set_optimum_mode lvs6 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } } return 0; } #elif defined(CONFIG_FB_MSM_MIPI_LGIT_VIDEO_HD_PT) static int mipi_dsi_panel_power(int on) { static struct regulator *reg_l8, *reg_l2, *reg_lvs6; static int gpio43; int rc; struct pm_gpio gpio43_param = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = 2, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_PAIRED, .inv_int_pol = 0, .disable_pin = 0, }; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "8921_l8"); if (IS_ERR(reg_l8)) { pr_err("could not get 8921_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_lvs6 = regulator_get(&msm_mipi_dsi1_device.dev, "8921_lvs6"); if (IS_ERR(reg_lvs6)) { pr_err("could not get 8921_lvs6, rc = %ld\n", PTR_ERR(reg_lvs6)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 3000000, 3000000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } gpio43 = PM8921_GPIO_PM_TO_SYS(43); rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { //gpio_set_value_cansleep(gpio43, 0); rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } 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_l8); // dsi_vci if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); // 100us rc = regulator_enable(reg_lvs6); if (rc) { pr_err("enable lvs6 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } printk(KERN_INFO " %s : reset start.", __func__); // LCD RESET HIGH mdelay(2); gpio43_param.pull = PM_GPIO_PULL_NO; rc = pm8xxx_gpio_config(gpio43, &gpio43_param); if (rc) { pr_err("gpio_config 43 failed (1), rc=%d\n", rc); return -EINVAL; } gpio43_param.pull = PM_GPIO_PULL_UP_30; rc = pm8xxx_gpio_config(gpio43, &gpio43_param); if (rc) { pr_err("gpio_config 43 failed (2), rc=%d\n", rc); return -EINVAL; } gpio43_param.pull = PM_GPIO_PULL_NO; rc = pm8xxx_gpio_config(gpio43, &gpio43_param); if (rc) { pr_err("gpio_config 43 failed (3), rc=%d\n", rc); return -EINVAL; } gpio43_param.pull = PM_GPIO_PULL_UP_30; rc = pm8xxx_gpio_config(gpio43, &gpio43_param); if (rc) { pr_err("gpio_config 43 failed (4), rc=%d\n", rc); return -EINVAL; } gpio_set_value_cansleep(gpio43, 1); mdelay(11); } else { gpio_set_value_cansleep(gpio43, 0); udelay(100); rc = regulator_disable(reg_lvs6); if (rc) { pr_err("disable reg_lvs6 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_disable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } } return 0; } #else static int mipi_dsi_panel_power(int on) { int ret; pr_debug("%s: on=%d\n", __func__, on); if (machine_is_msm8960_liquid()) ret = mipi_dsi_liquid_panel_power(on); else ret = mipi_dsi_cdp_panel_power(on); return ret; } #endif static struct mipi_dsi_platform_data mipi_dsi_pdata = { .vsync_gpio = MDP_VSYNC_GPIO, .dsi_power_save = mipi_dsi_panel_power, .splash_is_enabled = mipi_dsi_splash_is_enabled, }; #ifdef CONFIG_LGE_LCD_TUNING static int tuning_read_porch(unsigned long tmp) { int size = ARRAY_SIZE(porch_value)*4; printk(KERN_INFO "read_porch_value\n"); if (copy_to_user((uint32_t *)tmp, porch_value, size)) { printk(KERN_ERR "read_file : error of copy_to_user_buff\n"); return -EFAULT; } return 0; } static int tuning_write_porch(unsigned long tmp) { u32 *buf; int size = ARRAY_SIZE(porch_value)*4; printk(KERN_INFO "write porch file\n"); buf = kmalloc(size, GFP_KERNEL); if (copy_from_user(buf, (u32 *)tmp, size)) { printk(KERN_ERR "write_file : error of copy_from_user\n"); return -EFAULT; } memcpy(porch_value, buf, size); kfree(buf); return 0; }
static int jdi25x16_cmd_power_off( struct mdfld_dsi_config *dsi_config) { struct mdfld_dsi_pkg_sender *sender = mdfld_dsi_get_pkg_sender(dsi_config); int err; int i; PSB_DEBUG_ENTRY("\n"); if (!sender) { DRM_ERROR("Failed to get DSI packet sender\n"); return -EINVAL; } for (i = 0; i < 2; i++) { if (i == 0) sender->work_for_slave_panel = false; else sender->work_for_slave_panel = true; mdelay(20); err = mdfld_dsi_send_gen_short_hs(sender, access_protect, 0, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set MCAP\n", __func__, __LINE__); goto power_off_err; } err = mdfld_dsi_send_gen_long_hs(sender, jdi25x16_set_normal_mode, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Mode\n", __func__, __LINE__); goto power_off_err; } err = mdfld_dsi_send_gen_short_hs(sender, access_protect, 3, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set MCAP\n", __func__, __LINE__); goto power_off_err; } } for (i = 0; i < 2; i++) { if (i == 0) sender->work_for_slave_panel = false; else sender->work_for_slave_panel = true; /* Set Display off */ err = mdfld_dsi_send_mcs_short_hs(sender, set_display_off, 0, 0, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Display On\n", __func__, __LINE__); goto power_off_err; } msleep(20); /* Sleep In */ err = mdfld_dsi_send_mcs_short_hs(sender, enter_sleep_mode, 0, 0, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Exit Sleep Mode\n", __func__, __LINE__); goto power_off_err; } msleep(80); } gpio_set_value_cansleep(bias_en_gpio, 0); msleep(10); for (i = 0; i < 2; i++) { if (i == 0) sender->work_for_slave_panel = false; else sender->work_for_slave_panel = true; err = mdfld_dsi_send_gen_short_hs(sender, access_protect, 0, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set MCAP\n", __func__, __LINE__); goto power_off_err; } err = mdfld_dsi_send_gen_short_hs(sender, low_power_mode, 1, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set MCAP\n", __func__, __LINE__); goto power_off_err; } } sender->work_for_slave_panel = false; return 0; power_off_err: sender->work_for_slave_panel = false; err = -EIO; return err; }
static int devkit8000_panel_enable_lcd(struct omap_dss_device *dssdev) { if (gpio_is_valid(dssdev->reset_gpio)) gpio_set_value_cansleep(dssdev->reset_gpio, 1); return 0; }
static int mipi_dsi_panel_msm_power(int on) { int rc = 0; uint32_t lcdc_reset_cfg; /* I2C-controlled GPIO Expander -init of the GPIOs very late */ if (unlikely(!dsi_gpio_initialized)) { pmapp_disp_backlight_init(); rc = gpio_request(GPIO_DISPLAY_PWR_EN, "gpio_disp_pwr"); if (rc < 0) { pr_err("failed to request gpio_disp_pwr\n"); return rc; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, 1); if (rc < 0) { pr_err("failed to enable display pwr\n"); goto fail_gpio1; } rc = gpio_request(GPIO_BACKLIGHT_EN, "gpio_bkl_en"); if (rc < 0) { pr_err("failed to request gpio_bkl_en\n"); goto fail_gpio1; } rc = gpio_direction_output(GPIO_BACKLIGHT_EN, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); goto fail_gpio2; } } rc = regulator_bulk_get(NULL, ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not get regulators: %d\n", __func__, rc); goto fail_gpio2; } rc = regulator_bulk_set_voltage(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) { pr_err("%s: could not set voltages: %d\n", __func__, rc); goto fail_vreg; } if (pmapp_disp_backlight_set_brightness(100)) pr_err("backlight set brightness failed\n"); dsi_gpio_initialized = 1; } if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, on); gpio_set_value_cansleep(GPIO_BACKLIGHT_EN, on); } else if (machine_is_msm7x27a_ffa() || machine_is_msm7625a_ffa() || machine_is_msm8625_ffa()) { if (on) { /* This line drives an active low pin on FFA */ rc = gpio_direction_output(GPIO_DISPLAY_PWR_EN, !on); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } else { gpio_set_value_cansleep(GPIO_DISPLAY_PWR_EN, !on); rc = gpio_direction_input(GPIO_DISPLAY_PWR_EN); if (rc < 0) pr_err("failed to set direction for " "display pwr\n"); } } if (on) { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 0); if (machine_is_msm7x27a_surf() || machine_is_msm7625a_surf() || machine_is_msm8625_surf()) { lcdc_reset_cfg = readl_relaxed(lcdc_reset_ptr); rmb(); lcdc_reset_cfg &= ~1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); msleep(20); wmb(); lcdc_reset_cfg |= 1; writel_relaxed(lcdc_reset_cfg, lcdc_reset_ptr); msleep(20); } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 0); msleep(20); gpio_set_value_cansleep(GPIO_LCDC_BRDG_RESET_N, 1); msleep(20); } } else { gpio_set_value_cansleep(GPIO_LCDC_BRDG_PD, 1); } rc = on ? regulator_bulk_enable(ARRAY_SIZE(regs_dsi), regs_dsi) : regulator_bulk_disable(ARRAY_SIZE(regs_dsi), regs_dsi); if (rc) pr_err("%s: could not %sable regulators: %d\n", __func__, on ? "en" : "dis", rc); return rc; fail_vreg: regulator_bulk_free(ARRAY_SIZE(regs_dsi), regs_dsi); fail_gpio2: gpio_free(GPIO_BACKLIGHT_EN); fail_gpio1: gpio_free(GPIO_DISPLAY_PWR_EN); dsi_gpio_initialized = 0; return rc; }
static int mipi_truly_set_bl(int on) { gpio_set_value_cansleep(QRD_GPIO_BACKLIGHT_EN, !!on); return 1; }
int msm_sensor_config(struct msm_sensor_ctrl_t *s_ctrl, void __user *argp) { struct sensorb_cfg_data *cdata = (struct sensorb_cfg_data *)argp; long rc = 0; int i = 0; mutex_lock(s_ctrl->msm_sensor_mutex); //CDBG("%s:%d %s cfgtype = %d\n", __func__, __LINE__, // s_ctrl->sensordata->sensor_name, cdata->cfgtype); switch (cdata->cfgtype) { case CFG_GET_SENSOR_INFO: memcpy(cdata->cfg.sensor_info.sensor_name, s_ctrl->sensordata->sensor_name, sizeof(cdata->cfg.sensor_info.sensor_name)); cdata->cfg.sensor_info.session_id = s_ctrl->sensordata->sensor_info->session_id; for (i = 0; i < SUB_MODULE_MAX; i++) cdata->cfg.sensor_info.subdev_id[i] = s_ctrl->sensordata->sensor_info->subdev_id[i]; cdata->cfg.sensor_info.is_mount_angle_valid = s_ctrl->sensordata->sensor_info->is_mount_angle_valid; cdata->cfg.sensor_info.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; cdata->cfg.sensor_info.position = s_ctrl->sensordata->sensor_info->position; cdata->cfg.sensor_info.modes_supported = s_ctrl->sensordata->sensor_info->modes_supported; CDBG("%s:%d sensor name %s\n", __func__, __LINE__, cdata->cfg.sensor_info.sensor_name); CDBG("%s:%d session id %d\n", __func__, __LINE__, cdata->cfg.sensor_info.session_id); for (i = 0; i < SUB_MODULE_MAX; i++) CDBG("%s:%d subdev_id[%d] %d\n", __func__, __LINE__, i, cdata->cfg.sensor_info.subdev_id[i]); CDBG("%s:%d mount angle valid %d value %d\n", __func__, __LINE__, cdata->cfg.sensor_info.is_mount_angle_valid, cdata->cfg.sensor_info.sensor_mount_angle); break; case CFG_GET_SENSOR_INIT_PARAMS: cdata->cfg.sensor_init_params.modes_supported = s_ctrl->sensordata->sensor_info->modes_supported; cdata->cfg.sensor_init_params.position = s_ctrl->sensordata->sensor_info->position; cdata->cfg.sensor_init_params.sensor_mount_angle = s_ctrl->sensordata->sensor_info->sensor_mount_angle; CDBG("%s:%d init params mode %d pos %d mount %d\n", __func__, __LINE__, cdata->cfg.sensor_init_params.modes_supported, cdata->cfg.sensor_init_params.position, cdata->cfg.sensor_init_params.sensor_mount_angle); break; case CFG_SET_SLAVE_INFO: { struct msm_camera_sensor_slave_info sensor_slave_info; struct msm_camera_power_ctrl_t *p_ctrl; uint16_t size; int s_index = 0; if (copy_from_user(&sensor_slave_info, (void *)cdata->cfg.setting, sizeof(sensor_slave_info))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } /* Update sensor slave address */ if (sensor_slave_info.slave_addr) { s_ctrl->sensor_i2c_client->cci_client->sid = sensor_slave_info.slave_addr >> 1; } /* Update sensor address type */ s_ctrl->sensor_i2c_client->addr_type = sensor_slave_info.addr_type; p_ctrl = &s_ctrl->sensordata->power_info; /* Update power up sequence */ size = sensor_slave_info.power_setting_array.size; if (p_ctrl->power_setting_size < size) { struct msm_sensor_power_setting *tmp; tmp = kmalloc(sizeof(*tmp) * size, GFP_KERNEL); if (!tmp) { pr_err("%s: failed to alloc mem\n", __func__); rc = -ENOMEM; break; } kfree(p_ctrl->power_setting); p_ctrl->power_setting = tmp; } p_ctrl->power_setting_size = size; rc = copy_from_user(p_ctrl->power_setting, (void *) sensor_slave_info.power_setting_array.power_setting, size * sizeof(struct msm_sensor_power_setting)); if (rc) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(sensor_slave_info.power_setting_array. power_setting); rc = -EFAULT; break; } CDBG("%s sensor id %x\n", __func__, sensor_slave_info.slave_addr); CDBG("%s sensor addr type %d\n", __func__, sensor_slave_info.addr_type); CDBG("%s sensor reg %x\n", __func__, sensor_slave_info.sensor_id_info.sensor_id_reg_addr); CDBG("%s sensor id %x\n", __func__, sensor_slave_info.sensor_id_info.sensor_id); for (s_index = 0; s_index < p_ctrl->power_setting_size; s_index++) { CDBG("%s i %d power up setting %d %d %ld %d\n", __func__, s_index, p_ctrl->power_setting[s_index].seq_type, p_ctrl->power_setting[s_index].seq_val, p_ctrl->power_setting[s_index].config_val, p_ctrl->power_setting[s_index].delay); } /* Update power down sequence */ if (!sensor_slave_info.power_setting_array.power_down_setting || 0 == size) { pr_err("%s: Missing dedicated power down sequence\n", __func__); break; } size = sensor_slave_info.power_setting_array.size_down; if (p_ctrl->power_down_setting_size < size) { struct msm_sensor_power_setting *tmp; tmp = kmalloc(sizeof(*tmp) * size, GFP_KERNEL); if (!tmp) { pr_err("%s: failed to alloc mem\n", __func__); rc = -ENOMEM; break; } kfree(p_ctrl->power_down_setting); p_ctrl->power_down_setting = tmp; } p_ctrl->power_down_setting_size = size; rc = copy_from_user(p_ctrl->power_down_setting, (void *) sensor_slave_info.power_setting_array. power_down_setting, size * sizeof(struct msm_sensor_power_setting)); if (rc) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(sensor_slave_info.power_setting_array. power_down_setting); rc = -EFAULT; break; } for (s_index = 0; s_index < p_ctrl->power_down_setting_size; s_index++) { CDBG("%s i %d power DOWN setting %d %d %ld %d\n", __func__, s_index, p_ctrl->power_down_setting[s_index].seq_type, p_ctrl->power_down_setting[s_index].seq_val, p_ctrl->power_down_setting[s_index].config_val, p_ctrl->power_down_setting[s_index].delay); } break; } case CFG_WRITE_I2C_ARRAY: { struct msm_camera_i2c_reg_setting conf_array; struct msm_camera_i2c_reg_array *reg_setting = NULL; if (s_ctrl->sensor_state != MSM_SENSOR_POWER_UP) { pr_err("%s:%d failed: invalid state %d\n", __func__, __LINE__, s_ctrl->sensor_state); rc = -EFAULT; break; } if (copy_from_user(&conf_array, (void *)cdata->cfg.setting, sizeof(struct msm_camera_i2c_reg_setting))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } if (!conf_array.size) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } reg_setting = kzalloc(conf_array.size * (sizeof(struct msm_camera_i2c_reg_array)), GFP_KERNEL); if (!reg_setting) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -ENOMEM; break; } if (copy_from_user(reg_setting, (void *)conf_array.reg_setting, conf_array.size * sizeof(struct msm_camera_i2c_reg_array))) { pr_err("%s:%d failed\n", __func__, __LINE__); kfree(reg_setting); rc = -EFAULT; break; } conf_array.reg_setting = reg_setting; rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write_table( s_ctrl->sensor_i2c_client, &conf_array); kfree(reg_setting); /* LGE_CHANGE_S, To avoid VCM power down after change camera mode(normal <-> panorama), 2015-03-09, [email protected] */ #if defined(CONFIG_MACH_MSM8226_E8WIFI) || defined(CONFIG_MACH_MSM8226_E9WIFI) || defined(CONFIG_MACH_MSM8226_E9WIFIN) if (s_ctrl->sensor_state == MSM_SENSOR_POWER_UP && gpio_get_value_cansleep(0) == 0) { gpio_set_value_cansleep(0,GPIO_OUT_HIGH); pr_err("%s:%d sangwoo25.park gpio 0 is %d\n", __func__, __LINE__,gpio_get_value_cansleep(0)); } #endif /* LGE_CHANGE_E, To avoid VCM power down after change camera mode(normal <-> panorama), 2015-03-09, [email protected] */ break; } /*LGE_CHANGE, add bank register for imx219, 2014-02-19, [email protected]*/ case CFG_READ_I2C_ARRAY_LG:{ struct msm_camera_i2c_reg_setting reg_setting; uint16_t local_data = 0; uint16_t read_bank_addr = 0; if (copy_from_user(®_setting, (void *)cdata->cfg.setting, sizeof(struct msm_camera_i2c_reg_setting))) { pr_err("%s:%d bank failed\n", __func__, __LINE__); rc = -EFAULT; break; } read_bank_addr = reg_setting.reg_setting->reg_addr; // pr_err("%s:CFG_Bank_READ_I2C:", __func__); // pr_err("reg_addr=0x%x, reg_data=0x%x\n", reg_setting.reg_setting->reg_addr, reg_setting.reg_setting->reg_data); rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_read( s_ctrl->sensor_i2c_client, read_bank_addr, &local_data, reg_setting.data_type); if (rc < 0) { pr_err("%s:%d: error read bank\n", __func__, __LINE__); break; } // pr_err("[B2MINI] %s bank %d\n", __func__, local_data); if (copy_to_user((void *)reg_setting.value, &local_data, sizeof(uint16_t))) { pr_err("%s:%d bank copy failed\n", __func__, __LINE__); rc = -EFAULT; break; } break; } /*LGE_CHANGE, add bank register for imx219, 2014-02-19, [email protected]*/ case CFG_SLAVE_READ_I2C: { struct msm_camera_i2c_read_config read_config; uint16_t local_data = 0; uint16_t orig_slave_addr = 0, read_slave_addr = 0; if (copy_from_user(&read_config, (void *)cdata->cfg.setting, sizeof(struct msm_camera_i2c_read_config))) { pr_err("%s:%d failed\n", __func__, __LINE__); rc = -EFAULT; break; } read_slave_addr = read_config.slave_addr; CDBG("%s:CFG_SLAVE_READ_I2C:", __func__); CDBG("%s:slave_addr=0x%x reg_addr=0x%x, data_type=%d\n", __func__, read_config.slave_addr, read_config.reg_addr, read_config.data_type); if (s_ctrl->sensor_i2c_client->cci_client) { orig_slave_addr = s_ctrl->sensor_i2c_client->cci_client->sid; s_ctrl->sensor_i2c_client->cci_client->sid = read_slave_addr >> 1; } else if (s_ctrl->sensor_i2c_client->client) {
static int mipi_dsi_panel_c8681_power(int on) { int rc = 0; printk("%s: on = %d\n", __func__, on); rc = gpio_request(GPIO_C8681_LCD_RESET_N, "c8680_lcdc_reset_n"); if (rc < 0) { pr_err("failed to request c8680 lcd reset_n\n"); return rc; } rc = gpio_tlmm_config(GPIO_CFG(GPIO_C8681_LCD_RESET_N, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { pr_err("Failed to enable LCD reset\n"); gpio_free(GPIO_LCDC_BRDG_RESET_N); return rc; } rc = gpio_direction_output(GPIO_C8681_LCD_RESET_N, 1); if (rc < 0) { pr_err("Failed to set reset invalid\n"); return rc; } if (on) { gpio_set_value_cansleep(GPIO_C8681_LCD_RESET_N, 1); udelay(20); gpio_set_value_cansleep(GPIO_C8681_LCD_RESET_N, 0); udelay(20); gpio_set_value_cansleep(GPIO_C8681_LCD_RESET_N, 1); } else { rc = gpio_direction_output(GPIO_C8681_LCD_RESET_N, 0); if (rc < 0) { pr_err("Failed to set reset invalid\n"); return rc; } } gpio_free(GPIO_C8681_LCD_RESET_N); rc = gpio_request(GPIO_C8681_LCD_MODESEL, "c8681_lcd_cmd_pin"); if (rc < 0) { pr_err("failed to request c8681 lcd cmd pin\n"); return rc; } rc = gpio_tlmm_config(GPIO_CFG(GPIO_C8681_LCD_MODESEL, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { pr_err("Failed to enable c8681 lcd cmd pin\n"); gpio_free(GPIO_C8681_LCD_MODESEL); return rc; } rc = gpio_direction_output(GPIO_C8681_LCD_MODESEL, 1); if (rc < 0) { pr_err("Failed to set reset invalid\n"); return rc; } gpio_free(GPIO_C8681_LCD_MODESEL); return rc; }
static int lvds_panel_power(int on) { static struct regulator *reg_lvs7, *reg_l2, *reg_ext_3p3v; static int gpio36, gpio26, mpp3; int rc; pr_debug("%s: on=%d\n", __func__, on); if (!lvds_power_on) { reg_lvs7 = regulator_get(&msm_lvds_device.dev, "lvds_vdda"); if (IS_ERR_OR_NULL(reg_lvs7)) { pr_err("could not get 8921_lvs7, rc = %ld\n", PTR_ERR(reg_lvs7)); return -ENODEV; } reg_l2 = regulator_get(&msm_lvds_device.dev, "lvds_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; } reg_ext_3p3v = regulator_get(&msm_lvds_device.dev, "lvds_vccs_3p3v"); if (IS_ERR_OR_NULL(reg_ext_3p3v)) { pr_err("could not get reg_ext_3p3v, rc = %ld\n", PTR_ERR(reg_ext_3p3v)); return -ENODEV; } gpio26 = PM8921_GPIO_PM_TO_SYS(26); rc = gpio_request(gpio26, "pwm_backlight_ctrl"); if (rc) { pr_err("request gpio 26 failed, rc=%d\n", rc); return -ENODEV; } gpio36 = PM8921_GPIO_PM_TO_SYS(36); /* lcd1_pwr_en_n */ rc = gpio_request(gpio36, "lcd1_pwr_en_n"); if (rc) { pr_err("request gpio 36 failed, rc=%d\n", rc); return -ENODEV; } mpp3 = PM8921_MPP_PM_TO_SYS(3); rc = gpio_request(mpp3, "backlight_en"); if (rc) { pr_err("request mpp3 failed, rc=%d\n", rc); return -ENODEV; } lvds_power_on = true; } if (on) { rc = regulator_enable(reg_lvs7); if (rc) { pr_err("enable lvs7 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; } rc = regulator_enable(reg_ext_3p3v); if (rc) { pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } gpio_set_value_cansleep(gpio36, 0); gpio_set_value_cansleep(mpp3, 1); } else { gpio_set_value_cansleep(mpp3, 0); gpio_set_value_cansleep(gpio36, 1); rc = regulator_disable(reg_lvs7); if (rc) { pr_err("disable reg_lvs7 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_ext_3p3v); if (rc) { pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } } return 0; }
static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, unsigned int rate) { struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); int ret; sigmadsp_reset(adau1701->sigmadsp); if (clkdiv != ADAU1707_CLKDIV_UNSET && gpio_is_valid(adau1701->gpio_pll_mode[0]) && gpio_is_valid(adau1701->gpio_pll_mode[1])) { switch (clkdiv) { case 64: gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 0); gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 0); break; case 256: gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 0); gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 1); break; case 384: gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 1); gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 0); break; case 0: /* fallback */ case 512: gpio_set_value_cansleep(adau1701->gpio_pll_mode[0], 1); gpio_set_value_cansleep(adau1701->gpio_pll_mode[1], 1); break; } } adau1701->pll_clkdiv = clkdiv; if (gpio_is_valid(adau1701->gpio_nreset)) { gpio_set_value_cansleep(adau1701->gpio_nreset, 0); /* minimum reset time is 20ns */ udelay(1); gpio_set_value_cansleep(adau1701->gpio_nreset, 1); /* power-up time may be as long as 85ms */ mdelay(85); } /* * Postpone the firmware download to a point in time when we * know the correct PLL setup */ if (clkdiv != ADAU1707_CLKDIV_UNSET) { ret = sigmadsp_setup(adau1701->sigmadsp, rate); if (ret) { dev_warn(codec->dev, "Failed to load firmware\n"); return ret; } } regmap_write(adau1701->regmap, ADAU1701_DACSET, ADAU1701_DACSET_DACINIT); regmap_write(adau1701->regmap, ADAU1701_DSPCTRL, ADAU1701_DSPCTRL_CR); regcache_mark_dirty(adau1701->regmap); regcache_sync(adau1701->regmap); return 0; }
static int bt_set_gpio(int on) { int rc = 0; struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; #if defined (CONFIG_ARIMA_BT_DBG_INFO) if (on) { printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), on, %d \n", on); } else { printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), off, %d \n", on); } #endif if (on) { if (machine_is_msm7627a_evb() || machine_is_msm8625_qrd7()) { //+ murphy 2011.09.19 #if 1 //re-configure GPIO setting in case AMSS part is not executed okay printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), on = %d, if cond exec \n", on); rc = gpio_tlmm_config(GPIO_CFG(gpio_bt_sys_rest_en, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { printk(KERN_INFO "[BT_DBG] - GPIO 12 enable fail \n"); } else { printk(KERN_INFO "[BT_DBG] - GPIO 12 enable OK \n"); } gpio_set_value(gpio_bt_sys_rest_en, 1); #endif //- murphy 2011.09.19 } else { rc = gpio_direction_output(gpio_bt_sys_rest_en, 1); } #if defined (CONFIG_ARIMA_BT_DBG_INFO) printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), msleep(%d) \n", 150); #endif msleep(150); //murphy 2011.11.07 } else { if (!marimba_get_fm_status(&config) && !marimba_get_bt_status(&config)) { if (machine_is_msm7627a_evb() || machine_is_msm8625_qrd7()) { gpio_set_value(gpio_bt_sys_rest_en, 0); rc = gpio_tlmm_config(GPIO_CFG( gpio_bt_sys_rest_en, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE); } else { gpio_set_value_cansleep(gpio_bt_sys_rest_en, 0); rc = gpio_direction_input(gpio_bt_sys_rest_en); } //+ murphy 2012.08.14 //Fixed for BT CTS failed case - test_enableDisable //restore back to original sleep time to avoid unvisitable side effect at 2012.10.22 msleep(100); //msleep(75); //- murphy 2012.08.14 } } if (rc) pr_err("%s: BT sys_reset_en GPIO : Error", __func__); return rc; }
static void insert_headset(struct hsd_info *hi) { int earjack_type; HSD_DBG("insert_headset"); // set irq to wake up in sleep mode irq_set_irq_wake(hi->irq_key, 1); //LGE_CHANGE_S 20130710 ilda.jung[Audio] Disable not using GPIO #if !defined(CONFIG_MACH_APQ8064_AWIFI) // set high to an external LDO for mic bias if (hi->set_headset_mic_bias) { hi->set_headset_mic_bias(TRUE); } else if( hi->external_ldo_mic_bias > 0 ) { gpio_cansleep(hi->external_ldo_mic_bias) ? gpio_set_value_cansleep(hi->external_ldo_mic_bias, 1) : gpio_set_value(hi->external_ldo_mic_bias, 1); } #endif //LGE_CHANGE_E20130710 ilda.jung[Audio] Disable not using GPIO // set mode pin high gpio_direction_output(hi->gpio_mode, 1); msleep(25); /* check if 3-pole or 4-pole * 1. read gpio_swd * 2. check if 3-pole or 4-pole * 3-1. NOT regiter irq with gpio_swd if 3-pole. complete. * 3-2. regiter irq with gpio_swd if 4-pole * 4. read MPP1 and decide a pressed key when interrupt occurs */ /* 1. read gpio_swd */ if( gpio_cansleep(hi->gpio_swd) ) earjack_type = gpio_get_value_cansleep(hi->gpio_swd); else earjack_type = gpio_get_value(hi->gpio_swd); /* 2. check if 3-pole or 4-pole */ if ( earjack_type == HEADSET_POLE_4 ) {// high HSD_DBG("======= 4 polarity earjack ======="); atomic_set(&hi->is_3_pole_or_not, HEADSET_POLE_4); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, HEADSET_WITH_MIC); mutex_unlock(&hi->mutex_lock); if (!atomic_read(&hi->irq_key_enabled)) { unsigned long irq_flags; HSD_DBG("irq_key_enabled = enable"); local_irq_save(irq_flags); enable_irq(hi->irq_key); local_irq_restore(irq_flags); atomic_set(&hi->irq_key_enabled, TRUE); } // set mode pin high #if 1 //gpio_direction_output(hi->gpio_mode, 1); #else gpio_tlmm_config( // GPIOMUX_FUNC_GPIO GPIO_CFG(hi->gpio_mode, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, 0xf), GPIO_CFG_ENABLE); #endif input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1); input_sync(hi->input); } else {// low HSD_DBG("********** 3 polarity earjack **********"); atomic_set(&hi->is_3_pole_or_not, HEADSET_POLE_3); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, HEADSET_NO_MIC); mutex_unlock(&hi->mutex_lock); irq_set_irq_wake(hi->irq_key, 0); //LGE_CHANGE_S 20130710 ilda.jung[Audio] Disable not using GPIO #if !defined(CONFIG_MACH_APQ8064_AWIFI) // set low to an external LDO for mic bias if (hi->set_headset_mic_bias) { hi->set_headset_mic_bias(FALSE); } else if( hi->external_ldo_mic_bias > 0 ) { gpio_cansleep(hi->external_ldo_mic_bias) ? gpio_set_value_cansleep(hi->external_ldo_mic_bias, 0) : gpio_set_value(hi->external_ldo_mic_bias, 0); } #endif //LGE_CHANGE_E 20130710 ilda.jung[Audio] Disable not using GPIO // set mode pin high-z #if 1 gpio_direction_input(hi->gpio_mode); #else gpio_tlmm_config( // GPIOMUX_FUNC_GPIO GPIO_CFG(hi->gpio_mode, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); #endif input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); } }
static int bcm2079x_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret, iIrq; struct bcm2079x_platform_data *platform_data; struct bcm2079x_dev *bcm2079x_dev; #ifdef DEBUG_BCM2079X_I2C_IRQ char tmp[5] = {0x10, 0x20, 0x00, 0x01, 0x00}; #endif platform_data = client->dev.platform_data; dev_info(&client->dev, "%s, probing bcm2079x driver flags = %x\n", __func__, client->flags); if (platform_data == NULL) { dev_err(&client->dev, "nfc probe fail\n"); return -ENODEV; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "need I2C_FUNC_I2C\n"); return -ENODEV; } ret = gpio_request(platform_data->irq_gpio, "nfc_int"); if (ret) return -ENODEV; gpio_direction_input(platform_data->irq_gpio); ret = gpio_request(platform_data->en_gpio, "nfc_en"); if (ret) goto err_en; gpio_direction_output(platform_data->en_gpio, 0); ret = gpio_request(platform_data->wake_gpio, "nfc_wake"); if (ret) goto err_firm; gpio_direction_output(platform_data->wake_gpio, 0); #ifdef CONFIG_NFC_PMIC_CLK ret = gpio_request(platform_data->clk_req_gpio, "nfc_clk_req"); if (ret) goto err_clk_req; gpio_direction_input(platform_data->clk_req_gpio); #endif #ifdef DEBUG_BCM2079X_I2C_IRQ msleep(100); gpio_set_value_cansleep(platform_data->en_gpio, 1); msleep(100); #else gpio_set_value_cansleep(platform_data->en_gpio, 0); #endif gpio_set_value_cansleep(platform_data->wake_gpio, 1); bcm2079x_dev = kzalloc(sizeof(*bcm2079x_dev), GFP_KERNEL); if (bcm2079x_dev == NULL) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto err_exit; } #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->nfc_clock = msm_xo_get(MSM_XO_TCXO_A1, "nfc"); if (IS_ERR(bcm2079x_dev->nfc_clock)) { ret = PTR_ERR(bcm2079x_dev->nfc_clock); printk(KERN_ERR "%s: Couldn't get TCXO_A1 vote for NFC (%d)\n", __func__, ret); ret = -ENODEV; goto err_get_clock; } bcm2079x_dev->clock_state = false; #endif bcm2079x_dev->wake_gpio = platform_data->wake_gpio; bcm2079x_dev->irq_gpio = platform_data->irq_gpio; bcm2079x_dev->en_gpio = platform_data->en_gpio; bcm2079x_dev->client = client; #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->clk_req_gpio = platform_data->clk_req_gpio; bcm2079x_dev->clk_req_irq = platform_data->clk_req_irq; #endif /* init mutex and queues */ init_waitqueue_head(&bcm2079x_dev->read_wq); mutex_init(&bcm2079x_dev->read_mutex); spin_lock_init(&bcm2079x_dev->irq_enabled_lock); bcm2079x_dev->bcm2079x_device.minor = MISC_DYNAMIC_MINOR; bcm2079x_dev->bcm2079x_device.name = "bcm2079x"; bcm2079x_dev->bcm2079x_device.fops = &bcm2079x_dev_fops; ret = misc_register(&bcm2079x_dev->bcm2079x_device); if (ret) { dev_err(&client->dev, "misc_register failed\n"); goto err_misc_register; } /* wake lock init */ wake_lock_init(&bcm2079x_dev->nfc_wake_lock, WAKE_LOCK_SUSPEND, "nfc_wake_lock"); #ifdef CONFIG_NFC_PMIC_CLK bcm2079x_dev->wq_clock = create_singlethread_workqueue("nfc_wq"); if (!bcm2079x_dev->wq_clock) { ret = -ENOMEM; pr_err("%s: could not create workqueue\n", __func__); goto err_create_workqueue; } INIT_WORK(&bcm2079x_dev->work_nfc_clock, nfc_work_func_clock); ret = request_irq(bcm2079x_dev->clk_req_irq, bcm2079x_dev_clk_req_irq_handler, IRQF_SHARED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING , "bcm2079x_clk_req", bcm2079x_dev); if (ret) { dev_err(&client->dev, "request_irq(clk_req) failed\n"); goto err_request_irq_failed; } enable_irq_wake(bcm2079x_dev->clk_req_irq); #endif /* request irq. the irq is set whenever the chip has data available * for reading. it is cleared when all data has been read. */ iIrq = gpio_to_irq(client->irq); client->irq = iIrq; dev_info(&client->dev, "requesting IRQ %d with IRQF_NO_SUSPEND\n", iIrq); ret = request_irq(iIrq, bcm2079x_dev_irq_handler, IRQF_TRIGGER_RISING|IRQF_NO_SUSPEND, client->name, bcm2079x_dev); if (ret) { dev_err(&client->dev, "request_irq failed\n"); goto err_request_irq_failed; } i2c_set_clientdata(client, bcm2079x_dev); #ifndef DEBUG_BCM2079X_I2C_IRQ bcm2079x_dev->irq_enabled = false; disable_irq_nosync(bcm2079x_dev->client->irq); #else /* NCI reset test */ ret = i2c_master_send(bcm2079x_dev->client, tmp, sizeof(tmp)); if (ret != 5) pr_err("%s, i2c write error, NCI rest cmd err = %d\n", __func__, ret); else pr_info("%s, i2c write success!!! ret = %d\n", __func__, ret); #endif dev_info(&client->dev, "%s, probing bcm2079x driver exited successfully\n", __func__); return 0; err_request_irq_failed: #ifdef CONFIG_NFC_PMIC_CLK err_create_workqueue: #endif wake_lock_destroy(&bcm2079x_dev->nfc_wake_lock); misc_deregister(&bcm2079x_dev->bcm2079x_device); err_misc_register: mutex_destroy(&bcm2079x_dev->read_mutex); #ifdef CONFIG_NFC_PMIC_CLK msm_xo_put(bcm2079x_dev->nfc_clock); err_get_clock: #endif kfree(bcm2079x_dev); err_exit: #ifdef CONFIG_NFC_PMIC_CLK gpio_free(platform_data->clk_req_gpio); err_clk_req: #endif gpio_free(platform_data->wake_gpio); err_firm: gpio_free(platform_data->en_gpio); err_en: gpio_free(platform_data->irq_gpio); return ret; }
int32_t gc0339_power_down(struct msm_sensor_ctrl_t *s_ctrl) { int32_t index = 0; struct msm_sensor_power_setting_array *power_setting_array = NULL; struct msm_sensor_power_setting *power_setting = NULL; struct msm_camera_sensor_board_info *data = s_ctrl->sensordata; struct msm_camera_power_ctrl_t *power_info = &data->power_info; struct msm_camera_gpio_conf *gpio_conf = power_info->gpio_conf; CDBG("%s:%d\n", __func__, __LINE__); power_setting_array = &s_ctrl->power_setting_array; if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) { s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util( s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE); } s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write( s_ctrl->sensor_i2c_client, 0xfc, 0x01, MSM_CAMERA_I2C_BYTE_DATA); for (index = (power_setting_array->size - 1); index >= 0; index--) { CDBG("%s index %d\n", __func__, index); power_setting = &power_setting_array->power_setting[index]; CDBG("%s type %d\n", __func__, power_setting->seq_type); switch (power_setting->seq_type) { case SENSOR_CLK: msm_cam_clk_enable(power_info->dev, &power_info->clk_info[0], (struct clk **)&power_setting->data[0], power_info->clk_info_size, 0); break; case SENSOR_GPIO: if (power_setting->seq_val >= SENSOR_GPIO_MAX || !gpio_conf->gpio_num_info) { pr_err("%s gpio index %d >= max %d\n", __func__, power_setting->seq_val, SENSOR_GPIO_MAX); continue; } if (gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val]) gpio_set_value_cansleep( gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val], GPIOF_OUT_INIT_LOW); break; case SENSOR_VREG: if (power_setting->seq_val >= CAM_VREG_MAX) { pr_err("%s vreg index %d >= max %d\n", __func__, power_setting->seq_val, SENSOR_GPIO_MAX); continue; } msm_camera_config_single_vreg(power_info->dev, &power_info->cam_vreg[power_setting->seq_val], (struct regulator **)&power_setting->data[0], 0); break; default: pr_err("%s error power seq type %d\n", __func__, power_setting->seq_type); break; } if (power_setting->delay > 20) { msleep(power_setting->delay); } else if (power_setting->delay) { usleep_range(power_setting->delay * 1000, (power_setting->delay * 1000) + 1000); } } msm_camera_request_gpio_table( gpio_conf->cam_gpio_req_tbl, gpio_conf->cam_gpio_req_tbl_size, 0); CDBG("%s exit\n", __func__); return 0; }
static void mipi_dsi_panel_pwm_cfg(void) { int rc; static int mipi_dsi_panel_gpio_configured; static struct pm_gpio pwm_enable = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 1, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_VPH, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_NORMAL, .inv_int_pol = 0, .disable_pin = 0, }; static struct pm_gpio pwm_mode = { .direction = PM_GPIO_DIR_OUT, .output_buffer = PM_GPIO_OUT_BUF_CMOS, .output_value = 0, .pull = PM_GPIO_PULL_NO, .vin_sel = PM_GPIO_VIN_S4, .out_strength = PM_GPIO_STRENGTH_HIGH, .function = PM_GPIO_FUNC_2, .inv_int_pol = 0, .disable_pin = 0, }; if (mipi_dsi_panel_gpio_configured == 0) { /* pm8xxx: gpio-21, Backlight Enable */ rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(21), &pwm_enable); if (rc != 0) pr_err("%s: pwm_enabled failed\n", __func__); /* pm8xxx: gpio-24, Bl: Off, PWM mode */ rc = pm8xxx_gpio_config(PM8921_GPIO_PM_TO_SYS(24), &pwm_mode); if (rc != 0) pr_err("%s: pwm_mode failed\n", __func__); mipi_dsi_panel_gpio_configured++; } } #endif /* CONFIG_MACH_LGE */ static bool dsi_power_on; #ifndef CONFIG_MACH_LGE /** * LiQUID panel on/off * * @param on * * @return int */ static int mipi_dsi_liquid_panel_power(int on) { static struct regulator *reg_l2, *reg_ext_3p3v; static int gpio21, gpio24, gpio43; int rc; mipi_dsi_panel_pwm_cfg(); pr_debug("%s: on=%d\n", __func__, on); gpio21 = PM8921_GPIO_PM_TO_SYS(21); /* disp power enable_n */ gpio43 = PM8921_GPIO_PM_TO_SYS(43); /* Displays Enable (rst_n)*/ gpio24 = PM8921_GPIO_PM_TO_SYS(24); /* Backlight PWM */ if (!dsi_power_on) { reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(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; } reg_ext_3p3v = regulator_get(&msm_mipi_dsi1_device.dev, "vdd_lvds_3p3v"); if (IS_ERR(reg_ext_3p3v)) { pr_err("could not get reg_ext_3p3v, rc = %ld\n", PTR_ERR(reg_ext_3p3v)); return -ENODEV; } rc = gpio_request(gpio21, "disp_pwr_en_n"); if (rc) { pr_err("request gpio 21 failed, rc=%d\n", rc); return -ENODEV; } rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } rc = gpio_request(gpio24, "disp_backlight_pwm"); if (rc) { pr_err("request gpio 24 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { 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; } rc = regulator_enable(reg_ext_3p3v); if (rc) { pr_err("enable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } /* set reset pin before power enable */ gpio_set_value_cansleep(gpio43, 0); /* disp disable (resx=0) */ gpio_set_value_cansleep(gpio21, 0); /* disp power enable_n */ msleep(20); gpio_set_value_cansleep(gpio43, 1); /* disp enable */ msleep(20); gpio_set_value_cansleep(gpio43, 0); /* disp enable */ msleep(20); gpio_set_value_cansleep(gpio43, 1); /* disp enable */ msleep(20); } else { gpio_set_value_cansleep(gpio43, 0); gpio_set_value_cansleep(gpio21, 1); rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_ext_3p3v); if (rc) { pr_err("disable reg_ext_3p3v failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } } return 0; } static int mipi_dsi_cdp_panel_power(int on) { static struct regulator *reg_l8, *reg_l23, *reg_l2; static int gpio43; int rc; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdc"); if (IS_ERR(reg_l8)) { pr_err("could not get 8921_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_l23 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vddio"); if (IS_ERR(reg_l23)) { pr_err("could not get 8921_l23, rc = %ld\n", PTR_ERR(reg_l23)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 2800000, 3000000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l23, 1800000, 1800000); if (rc) { pr_err("set_voltage l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } gpio43 = PM8921_GPIO_PM_TO_SYS(43); rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100000); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } 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_l8); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l23); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } gpio_set_value_cansleep(gpio43, 1); } else { rc = regulator_disable(reg_l2); if (rc) { pr_err("disable reg_l2 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l23); if (rc) { pr_err("disable reg_l23 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l23, 100); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } gpio_set_value_cansleep(gpio43, 0); } return 0; } #endif /* CONFIG_MACH_LGE */ static char mipi_dsi_splash_is_enabled(void); #ifndef CONFIG_MACH_LGE static int mipi_dsi_panel_power(int on) { int ret; pr_debug("%s: on=%d\n", __func__, on); if (machine_is_msm8960_liquid()) ret = mipi_dsi_liquid_panel_power(on); else ret = mipi_dsi_cdp_panel_power(on); return ret; } #else static int mipi_dsi_panel_power(int on) { static struct regulator *reg_l8, *reg_l2, *reg_lvs6; static int gpio43 = PM8921_GPIO_PM_TO_SYS(43); int rc; pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdc"); if (IS_ERR(reg_l8)) { pr_err("could not get 8921_l8, rc = %ld\n", PTR_ERR(reg_l8)); return -ENODEV; } reg_lvs6 = regulator_get(&msm_mipi_dsi1_device.dev, "8921_lvs6"); if (IS_ERR(reg_lvs6)) { pr_err("could not get 8921_lvs6, rc = %ld\n", PTR_ERR(reg_lvs6)); return -ENODEV; } reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vdda"); if (IS_ERR(reg_l2)) { pr_err("could not get 8921_l2, rc = %ld\n", PTR_ERR(reg_l2)); return -ENODEV; } rc = regulator_set_voltage(reg_l8, 2800000, 2800000); if (rc) { pr_err("set_voltage l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_voltage(reg_l2, 1200000, 1200000); if (rc) { pr_err("set_voltage l2 failed, rc=%d\n", rc); return -EINVAL; } /* VREG_2P8_LCD_VCI enable - [email protected] */ rc = gpio_request(LCD_VCI_EN_GPIO, "LCD_VCI_EN_GPIO"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "LCD_VCI_EN_GPIO", LCD_VCI_EN_GPIO, rc); } gpio_tlmm_config(GPIO_CFG(LCD_VCI_EN_GPIO, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); rc = gpio_request(gpio43, "disp_rst_n"); if (rc) { pr_err("request gpio 43 failed, rc=%d\n", rc); return -ENODEV; } dsi_power_on = true; } if (on) { rc = regulator_set_optimum_mode(reg_l8, 100000); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } 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_l8); if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_enable(reg_lvs6); if (rc) { pr_err("enable lvs6 failed, rc=%d\n", rc); return -ENODEV; } rc = gpio_direction_output(LCD_VCI_EN_GPIO, 1); mdelay(1); rc = regulator_enable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } } else { rc = regulator_disable(reg_l8); if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_lvs6); if (rc) { pr_err("disable reg_lvs6 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_l2); if (rc) { pr_err("enable l2 failed, rc=%d\n", rc); return -ENODEV; } /* LCD Reset LOW */ gpio_direction_output(gpio43, 0); /* LCD VCI EN LOW */ rc = gpio_direction_output(LCD_VCI_EN_GPIO, 0); rc = regulator_set_optimum_mode(reg_l8, 100); if (rc < 0) { pr_err("set_optimum_mode l8 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_set_optimum_mode(reg_l2, 100); if (rc < 0) { pr_err("set_optimum_mode l2 failed, rc=%d\n", rc); return -EINVAL; } } return 0; } #endif /* CONFIG_MACH_LGE */ static struct mipi_dsi_platform_data mipi_dsi_pdata = { .vsync_gpio = MDP_VSYNC_GPIO, .dsi_power_save = mipi_dsi_panel_power, .splash_is_enabled = mipi_dsi_splash_is_enabled, }; #ifdef CONFIG_MSM_BUS_SCALING static struct msm_bus_vectors mdp_init_vectors[] = { { .src = MSM_BUS_MASTER_MDP_PORT0, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, };
static int geomagnetic_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct geomagnetic_data *data = NULL; struct input_dev *input_data = NULL, *input_raw = NULL; int rt, sysfs_created = 0, sysfs_raw_created = 0; int data_registered = 0, raw_registered = 0, i; struct yas_mag_filter filter; YLOGE(("[HSS] geomagnetic_probe\n")); i2c_set_clientdata(client, NULL); data = kzalloc(sizeof(struct geomagnetic_data), GFP_KERNEL); if (data == NULL) { rt = -ENOMEM; goto err; } data->threshold = YAS_DEFAULT_MAGCALIB_THRESHOLD; for (i = 0; i < 3; i++) { data->distortion[i] = YAS_DEFAULT_MAGCALIB_DISTORTION; } data->shape = 0; atomic_set(&data->enable, 0); for (i = 0; i < 3; i++) { atomic_set(&data->last_data[i], 0); } atomic_set(&data->last_status, 0); INIT_DELAYED_WORK(&data->work, geomagnetic_input_work_func); init_MUTEX(&data->driver_lock); init_MUTEX(&data->multi_lock); input_data = input_allocate_device(); if (input_data == NULL) { rt = -ENOMEM; YLOGE(("geomagnetic_probe: Failed to allocate input_data device\n")); goto err; } input_data->name = GEOMAGNETIC_INPUT_NAME; input_data->id.bustype = BUS_I2C; set_bit(EV_ABS, input_data->evbit); input_set_capability(input_data, EV_ABS, ABS_X); input_set_capability(input_data, EV_ABS, ABS_Y); input_set_capability(input_data, EV_ABS, ABS_Z); input_set_capability(input_data, EV_ABS, ABS_STATUS); input_set_capability(input_data, EV_ABS, ABS_WAKE); input_data->dev.parent = &client->dev; rt = input_register_device(input_data); if (rt) { YLOGE(("geomagnetic_probe: Unable to register input_data device: %s\n", input_data->name)); goto err; } data_registered = 1; rt = sysfs_create_group(&input_data->dev.kobj, &geomagnetic_attribute_group); if (rt) { YLOGE(("geomagnetic_probe: sysfs_create_group failed[%s]\n", input_data->name)); goto err; } sysfs_created = 1; input_raw = input_allocate_device(); if (input_raw == NULL) { rt = -ENOMEM; YLOGE(("geomagnetic_probe: Failed to allocate input_raw device\n")); goto err; } input_raw->name = GEOMAGNETIC_INPUT_RAW_NAME; input_raw->id.bustype = BUS_I2C; set_bit(EV_ABS, input_raw->evbit); input_set_capability(input_raw, EV_ABS, ABS_X); input_set_capability(input_raw, EV_ABS, ABS_Y); input_set_capability(input_raw, EV_ABS, ABS_Z); input_set_capability(input_raw, EV_ABS, ABS_RAW_DISTORTION); input_set_capability(input_raw, EV_ABS, ABS_RAW_THRESHOLD); input_set_capability(input_raw, EV_ABS, ABS_RAW_SHAPE); input_set_capability(input_raw, EV_ABS, ABS_RAW_REPORT); input_raw->dev.parent = &client->dev; rt = input_register_device(input_raw); if (rt) { YLOGE(("geomagnetic_probe: Unable to register input_raw device: %s\n", input_raw->name)); goto err; } raw_registered = 1; rt = sysfs_create_group(&input_raw->dev.kobj, &geomagnetic_raw_attribute_group); if (rt) { YLOGE(("geomagnetic_probe: sysfs_create_group failed[%s]\n", input_data->name)); goto err; } sysfs_raw_created = 1; this_client = client; data->input_raw = input_raw; data->input_data = input_data; input_set_drvdata(input_data, data); input_set_drvdata(input_raw, data); i2c_set_clientdata(client, data); // [Hss] gpio_set_value_cansleep(180, 0); printk(KERN_ERR "Compass I: RST LOW\n"); udelay(120); gpio_set_value_cansleep(180, 1); printk(KERN_ERR "Compass I: RST HIGH\n"); if ((rt = yas_mag_driver_init(&hwdep_driver)) < 0) { YLOGE(("yas_mag_driver_init failed[%d]\n", rt)); goto err; } if (hwdep_driver.init != NULL) { if ((rt = hwdep_driver.init()) < 0) { YLOGE(("hwdep_driver.init() failed[%d]\n", rt)); goto err; } } if (hwdep_driver.set_position != NULL) { if (hwdep_driver.set_position(YAS_CDRV_YAS529_POSITION) < 0) { YLOGE(("hwdep_driver.set_position() failed[%d]\n", rt)); goto err; } } if (hwdep_driver.get_offset != NULL) { if (hwdep_driver.get_offset(&data->driver_offset) < 0) { YLOGE(("hwdep_driver get_driver_state failed\n")); goto err; } } if (hwdep_driver.get_delay != NULL) { data->delay = hwdep_driver.get_delay(); } if (hwdep_driver.set_filter_enable != NULL) { /* default to enable */ if (hwdep_driver.set_filter_enable(1) == 0) { data->filter_enable = 1; } } if (hwdep_driver.get_filter != NULL) { if (hwdep_driver.get_filter(&filter) < 0) { YLOGE(("hwdep_driver get_filter failed\n")); goto err; } data->filter_len = filter.len; for (i = 0; i < 3; i++) { data->filter_noise[i] = filter.noise[i]; } data->filter_threshold = filter.threshold; } return 0; err: if (data != NULL) { if (input_raw != NULL) { if (sysfs_raw_created) { sysfs_remove_group(&input_raw->dev.kobj, &geomagnetic_raw_attribute_group); } if (raw_registered) { input_unregister_device(input_raw); } else { input_free_device(input_raw); } } if (input_data != NULL) { if (sysfs_created) { sysfs_remove_group(&input_data->dev.kobj, &geomagnetic_attribute_group); } if (data_registered) { input_unregister_device(input_data); } else { input_free_device(input_data); } } kfree(data); } return rt; }
int msm_camera_request_gpio_table(struct msm_camera_sensor_info *sinfo, int gpio_en) { int rc = 0; struct msm_camera_gpio_conf *gpio_conf = sinfo->sensor_platform_info->gpio_conf; #ifdef CONFIG_PANTECH_CAMERA if (gpio_conf->cam_gpio_common_tbl == NULL) { #else if (gpio_conf->cam_gpio_req_tbl == NULL || gpio_conf->cam_gpio_common_tbl == NULL) { #endif pr_err("%s: NULL camera gpio table\n", __func__); return -EFAULT; } if (gpio_en) { if (gpio_conf->cam_gpiomux_conf_tbl != NULL) { msm_gpiomux_install( (struct msm_gpiomux_config *)gpio_conf-> cam_gpiomux_conf_tbl, gpio_conf->cam_gpiomux_conf_tbl_size); } rc = gpio_request_array(gpio_conf->cam_gpio_common_tbl, gpio_conf->cam_gpio_common_tbl_size); if (rc < 0) { pr_err("%s common gpio request failed\n", __func__); return rc; } #ifndef CONFIG_PANTECH_CAMERA rc = gpio_request_array(gpio_conf->cam_gpio_req_tbl, gpio_conf->cam_gpio_req_tbl_size); if (rc < 0) { pr_err("%s camera gpio request failed\n", __func__); gpio_free_array(gpio_conf->cam_gpio_common_tbl, gpio_conf->cam_gpio_common_tbl_size); return rc; } #endif } else { #ifndef CONFIG_PANTECH_CAMERA gpio_free_array(gpio_conf->cam_gpio_req_tbl, gpio_conf->cam_gpio_req_tbl_size); #endif gpio_free_array(gpio_conf->cam_gpio_common_tbl, gpio_conf->cam_gpio_common_tbl_size); } return rc; } int msm_camera_config_gpio_table(struct msm_camera_sensor_info *sinfo, int gpio_en) { struct msm_camera_gpio_conf *gpio_conf = sinfo->sensor_platform_info->gpio_conf; int rc = 0, i; if (gpio_en) { for (i = 0; i < gpio_conf->cam_gpio_set_tbl_size; i++) { gpio_set_value_cansleep( gpio_conf->cam_gpio_set_tbl[i].gpio, gpio_conf->cam_gpio_set_tbl[i].flags); usleep_range(gpio_conf->cam_gpio_set_tbl[i].delay, gpio_conf->cam_gpio_set_tbl[i].delay + 1000); } } else { for (i = gpio_conf->cam_gpio_set_tbl_size - 1; i >= 0; i--) { if (gpio_conf->cam_gpio_set_tbl[i].flags) gpio_set_value_cansleep( gpio_conf->cam_gpio_set_tbl[i].gpio, GPIOF_OUT_INIT_LOW); } } return rc; }
static int mipi_dsi_panel_qrd3_power(int on) { int rc = 0; if (!qrd3_dsi_gpio_initialized) { pmapp_disp_backlight_init(); rc = gpio_request(GPIO_QRD3_LCD_BACKLIGHT_EN, "qrd3_gpio_bkl_en"); if (rc < 0) return rc; qrd3_dsi_gpio_initialized = 1; if (mdp_pdata.cont_splash_enabled) { rc = gpio_tlmm_config(GPIO_CFG( GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n"); return rc; } rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN); return rc; } /*Configure LCD Bridge reset*/ rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE); if (rc < 0) { pr_err("Failed to enable LCD Bridge reset enable\n"); return rc; } // } temporary fix error by DPI rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1); if (rc < 0) { pr_err("Failed GPIO bridge Reset\n"); gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N); return rc; } return 0; } } if (on) { rc = gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE); if (rc < 0) { pr_err("failed QRD3 GPIO_BACKLIGHT_EN tlmm config\n"); return rc; } rc = gpio_direction_output(GPIO_QRD3_LCD_BACKLIGHT_EN, 1); if (rc < 0) { pr_err("failed to enable backlight\n"); gpio_free(GPIO_QRD3_LCD_BACKLIGHT_EN); return rc; } /*Toggle Backlight GPIO*/ gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1); udelay(190); gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 0); udelay(286); gpio_set_value_cansleep(GPIO_QRD3_LCD_BACKLIGHT_EN, 1); /* 1 wire mode starts from this low to high transition */ udelay(50); /*Enable EXT_2.85 and 1.8 regulators*/ rc = regulator_enable(gpio_reg_2p85v); if (rc < 0) pr_err("%s: reg enable failed\n", __func__); rc = regulator_enable(gpio_reg_1p8v); if (rc < 0) pr_err("%s: reg enable failed\n", __func__); /*Configure LCD Bridge reset*/ rc = gpio_tlmm_config(qrd3_mipi_dsi_gpio[0], GPIO_CFG_ENABLE); if (rc < 0) { pr_err("Failed to enable LCD Bridge reset enable\n"); return rc; } rc = gpio_direction_output(GPIO_QRD3_LCD_BRDG_RESET_N, 1); if (rc < 0) { pr_err("Failed GPIO bridge Reset\n"); gpio_free(GPIO_QRD3_LCD_BRDG_RESET_N); return rc; } /*Toggle Bridge Reset GPIO*/ msleep(20); gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 0); msleep(20); gpio_set_value_cansleep(GPIO_QRD3_LCD_BRDG_RESET_N, 1); msleep(20); } else { gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BACKLIGHT_EN, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_DISABLE); gpio_tlmm_config(GPIO_CFG(GPIO_QRD3_LCD_BRDG_RESET_N, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE); rc = regulator_disable(gpio_reg_2p85v); if (rc < 0) pr_err("%s: reg disable failed\n", __func__); rc = regulator_disable(gpio_reg_1p8v); if (rc < 0) pr_err("%s: reg disable failed\n", __func__); } return rc; }
int msm_camera_flash_external( struct msm_camera_sensor_flash_external *external, unsigned led_state) { int rc = 0; #if defined CONFIG_MSM_CAMERA_FLASH_SC628A switch (led_state) { case MSM_CAMERA_LED_INIT: if (!sc628a_client) { rc = i2c_add_driver(&sc628a_i2c_driver); if (rc < 0 || sc628a_client == NULL) { rc = -ENOTSUPP; CDBG("I2C add driver failed"); return rc; } } #if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE) if (external->expander_info && !sx150x_client) { struct i2c_adapter *adapter = i2c_get_adapter(external->expander_info->bus_id); if (adapter) sx150x_client = i2c_new_device(adapter, external->expander_info->board_info); if (!sx150x_client || !adapter) { rc = -ENOTSUPP; i2c_del_driver(&sc628a_i2c_driver); sc628a_client = NULL; return rc; } } #endif rc = gpio_request(external->led_en, "sc628a"); if (!rc) { gpio_direction_output(external->led_en, 1); } else { goto err1; } rc = gpio_request(external->led_flash_en, "sc628a"); if (!rc) { gpio_direction_output(external->led_flash_en, 1); break; } gpio_set_value_cansleep(external->led_en, 0); gpio_free(external->led_en); err1: i2c_del_driver(&sc628a_i2c_driver); sc628a_client = NULL; break; case MSM_CAMERA_LED_RELEASE: if (sc628a_client) { gpio_set_value_cansleep(external->led_en, 0); gpio_free(external->led_en); gpio_set_value_cansleep(external->led_flash_en, 0); gpio_free(external->led_flash_en); } #if defined(CONFIG_GPIO_SX150X) || defined(CONFIG_GPIO_SX150X_MODULE) if (external->expander_info && sx150x_client) { i2c_unregister_device(sx150x_client); sx150x_client = NULL; } #endif break; case MSM_CAMERA_LED_OFF: rc = sc628a_i2c_write_b_flash(0x02, 0x0); if (sc628a_client) { gpio_set_value_cansleep(external->led_en, 0); gpio_set_value_cansleep(external->led_flash_en, 0); } break; case MSM_CAMERA_LED_LOW: if (sc628a_client) { gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); usleep_range(2000, 3000); } rc = sc628a_i2c_write_b_flash(0x02, 0x06); break; case MSM_CAMERA_LED_HIGH: if (sc628a_client) { gpio_set_value_cansleep(external->led_en, 1); gpio_set_value_cansleep(external->led_flash_en, 1); usleep_range(2000, 3000); } rc = sc628a_i2c_write_b_flash(0x02, 0x49); break; default: rc = -EFAULT; break; } #endif return rc; }
static void s5k4e5yx_poweroff_af(void) { gpio_set_value_cansleep(s5k4e5yx_msm_actuator_info->vcm_pwd, 0); gpio_free(s5k4e5yx_msm_actuator_info->vcm_pwd); }
int arizona_dev_init(struct arizona *arizona) { struct device *dev = arizona->dev; const char *type_name; unsigned int reg, val; int (*apply_patch)(struct arizona *) = NULL; int ret, i; dev_set_drvdata(arizona->dev, arizona); mutex_init(&arizona->clk_lock); if (dev_get_platdata(arizona->dev)) memcpy(&arizona->pdata, dev_get_platdata(arizona->dev), sizeof(arizona->pdata)); else arizona_of_get_core_pdata(arizona); regcache_cache_only(arizona->regmap, true); switch (arizona->type) { case WM5102: case WM5110: case WM8997: for (i = 0; i < ARRAY_SIZE(wm5102_core_supplies); i++) arizona->core_supplies[i].supply = wm5102_core_supplies[i]; arizona->num_core_supplies = ARRAY_SIZE(wm5102_core_supplies); break; default: dev_err(arizona->dev, "Unknown device type %d\n", arizona->type); return -EINVAL; } /* Mark DCVDD as external, LDO1 driver will clear if internal */ arizona->external_dcvdd = true; ret = mfd_add_devices(arizona->dev, -1, early_devs, ARRAY_SIZE(early_devs), NULL, 0, NULL); if (ret != 0) { dev_err(dev, "Failed to add early children: %d\n", ret); return ret; } ret = devm_regulator_bulk_get(dev, arizona->num_core_supplies, arizona->core_supplies); if (ret != 0) { dev_err(dev, "Failed to request core supplies: %d\n", ret); goto err_early; } /** * Don't use devres here because the only device we have to get * against is the MFD device and DCVDD will likely be supplied by * one of its children. Meaning that the regulator will be * destroyed by the time devres calls regulator put. */ arizona->dcvdd = regulator_get(arizona->dev, "DCVDD"); if (IS_ERR(arizona->dcvdd)) { ret = PTR_ERR(arizona->dcvdd); dev_err(dev, "Failed to request DCVDD: %d\n", ret); goto err_early; } if (arizona->pdata.reset) { /* Start out with /RESET low to put the chip into reset */ ret = gpio_request_one(arizona->pdata.reset, GPIOF_DIR_OUT | GPIOF_INIT_LOW, "arizona /RESET"); if (ret != 0) { dev_err(dev, "Failed to request /RESET: %d\n", ret); goto err_dcvdd; } } ret = regulator_bulk_enable(arizona->num_core_supplies, arizona->core_supplies); if (ret != 0) { dev_err(dev, "Failed to enable core supplies: %d\n", ret); goto err_dcvdd; } ret = regulator_enable(arizona->dcvdd); if (ret != 0) { dev_err(dev, "Failed to enable DCVDD: %d\n", ret); goto err_enable; } if (arizona->pdata.reset) { gpio_set_value_cansleep(arizona->pdata.reset, 1); msleep(1); } regcache_cache_only(arizona->regmap, false); /* Verify that this is a chip we know about */ ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, ®); if (ret != 0) { dev_err(dev, "Failed to read ID register: %d\n", ret); goto err_reset; } switch (reg) { case 0x5102: case 0x5110: case 0x8997: break; default: dev_err(arizona->dev, "Unknown device ID: %x\n", reg); goto err_reset; } /* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) { regcache_mark_dirty(arizona->regmap); ret = regmap_write(arizona->regmap, ARIZONA_SOFTWARE_RESET, 0); if (ret != 0) { dev_err(dev, "Failed to reset device: %d\n", ret); goto err_reset; } msleep(1); ret = regcache_sync(arizona->regmap); if (ret != 0) { dev_err(dev, "Failed to sync device: %d\n", ret); goto err_reset; } } /* Ensure device startup is complete */ switch (arizona->type) { case WM5102: ret = regmap_read(arizona->regmap, 0x19, &val); if (ret != 0) dev_err(dev, "Failed to check write sequencer state: %d\n", ret); else if (val & 0x01) break; /* Fall through */ default: ret = arizona_wait_for_boot(arizona); if (ret != 0) { dev_err(arizona->dev, "Device failed initial boot: %d\n", ret); goto err_reset; } break; } /* Read the device ID information & do device specific stuff */ ret = regmap_read(arizona->regmap, ARIZONA_SOFTWARE_RESET, ®); if (ret != 0) { dev_err(dev, "Failed to read ID register: %d\n", ret); goto err_reset; } ret = regmap_read(arizona->regmap, ARIZONA_DEVICE_REVISION, &arizona->rev); if (ret != 0) { dev_err(dev, "Failed to read revision register: %d\n", ret); goto err_reset; } arizona->rev &= ARIZONA_DEVICE_REVISION_MASK; switch (reg) { #ifdef CONFIG_MFD_WM5102 case 0x5102: type_name = "WM5102"; if (arizona->type != WM5102) { dev_err(arizona->dev, "WM5102 registered as %d\n", arizona->type); arizona->type = WM5102; } apply_patch = wm5102_patch; arizona->rev &= 0x7; break; #endif #ifdef CONFIG_MFD_WM5110 case 0x5110: type_name = "WM5110"; if (arizona->type != WM5110) { dev_err(arizona->dev, "WM5110 registered as %d\n", arizona->type); arizona->type = WM5110; } apply_patch = wm5110_patch; break; #endif #ifdef CONFIG_MFD_WM8997 case 0x8997: type_name = "WM8997"; if (arizona->type != WM8997) { dev_err(arizona->dev, "WM8997 registered as %d\n", arizona->type); arizona->type = WM8997; } apply_patch = wm8997_patch; break; #endif default: dev_err(arizona->dev, "Unknown device ID %x\n", reg); goto err_reset; } dev_info(dev, "%s revision %c\n", type_name, arizona->rev + 'A'); if (apply_patch) { ret = apply_patch(arizona); if (ret != 0) { dev_err(arizona->dev, "Failed to apply patch: %d\n", ret); goto err_reset; } switch (arizona->type) { case WM5102: ret = arizona_apply_hardware_patch(arizona); if (ret != 0) { dev_err(arizona->dev, "Failed to apply hardware patch: %d\n", ret); goto err_reset; } break; default: break; } } for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) { if (!arizona->pdata.gpio_defaults[i]) continue; regmap_write(arizona->regmap, ARIZONA_GPIO1_CTRL + i, arizona->pdata.gpio_defaults[i]); } pm_runtime_set_autosuspend_delay(arizona->dev, 100); pm_runtime_use_autosuspend(arizona->dev); pm_runtime_enable(arizona->dev); /* Chip default */ if (!arizona->pdata.clk32k_src) arizona->pdata.clk32k_src = ARIZONA_32KZ_MCLK2; switch (arizona->pdata.clk32k_src) { case ARIZONA_32KZ_MCLK1: case ARIZONA_32KZ_MCLK2: regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, ARIZONA_CLK_32K_SRC_MASK, arizona->pdata.clk32k_src - 1); arizona_clk32k_enable(arizona); break; case ARIZONA_32KZ_NONE: regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1, ARIZONA_CLK_32K_SRC_MASK, 2); break; default: dev_err(arizona->dev, "Invalid 32kHz clock source: %d\n", arizona->pdata.clk32k_src); ret = -EINVAL; goto err_reset; } for (i = 0; i < ARIZONA_MAX_MICBIAS; i++) { if (!arizona->pdata.micbias[i].mV && !arizona->pdata.micbias[i].bypass) continue; /* Apply default for bypass mode */ if (!arizona->pdata.micbias[i].mV) arizona->pdata.micbias[i].mV = 2800; val = (arizona->pdata.micbias[i].mV - 1500) / 100; val <<= ARIZONA_MICB1_LVL_SHIFT; if (arizona->pdata.micbias[i].ext_cap) val |= ARIZONA_MICB1_EXT_CAP; if (arizona->pdata.micbias[i].discharge) val |= ARIZONA_MICB1_DISCH; if (arizona->pdata.micbias[i].soft_start) val |= ARIZONA_MICB1_RATE; if (arizona->pdata.micbias[i].bypass) val |= ARIZONA_MICB1_BYPASS; regmap_update_bits(arizona->regmap, ARIZONA_MIC_BIAS_CTRL_1 + i, ARIZONA_MICB1_LVL_MASK | ARIZONA_MICB1_DISCH | ARIZONA_MICB1_BYPASS | ARIZONA_MICB1_RATE, val); } for (i = 0; i < ARIZONA_MAX_INPUT; i++) { /* Default for both is 0 so noop with defaults */ val = arizona->pdata.dmic_ref[i] << ARIZONA_IN1_DMIC_SUP_SHIFT; val |= arizona->pdata.inmode[i] << ARIZONA_IN1_MODE_SHIFT; regmap_update_bits(arizona->regmap, ARIZONA_IN1L_CONTROL + (i * 8), ARIZONA_IN1_DMIC_SUP_MASK | ARIZONA_IN1_MODE_MASK, val); } for (i = 0; i < ARIZONA_MAX_OUTPUT; i++) { /* Default is 0 so noop with defaults */ if (arizona->pdata.out_mono[i]) val = ARIZONA_OUT1_MONO; else val = 0; regmap_update_bits(arizona->regmap, ARIZONA_OUTPUT_PATH_CONFIG_1L + (i * 8), ARIZONA_OUT1_MONO, val); } for (i = 0; i < ARIZONA_MAX_PDM_SPK; i++) { if (arizona->pdata.spk_mute[i]) regmap_update_bits(arizona->regmap, ARIZONA_PDM_SPK1_CTRL_1 + (i * 2), ARIZONA_SPK1_MUTE_ENDIAN_MASK | ARIZONA_SPK1_MUTE_SEQ1_MASK, arizona->pdata.spk_mute[i]); if (arizona->pdata.spk_fmt[i]) regmap_update_bits(arizona->regmap, ARIZONA_PDM_SPK1_CTRL_2 + (i * 2), ARIZONA_SPK1_FMT_MASK, arizona->pdata.spk_fmt[i]); } /* Set up for interrupts */ ret = arizona_irq_init(arizona); if (ret != 0) goto err_reset; arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", arizona_clkgen_err, arizona); arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked", arizona_overclocked, arizona); arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", arizona_underclocked, arizona); switch (arizona->type) { case WM5102: ret = mfd_add_devices(arizona->dev, -1, wm5102_devs, ARRAY_SIZE(wm5102_devs), NULL, 0, NULL); break; case WM5110: ret = mfd_add_devices(arizona->dev, -1, wm5110_devs, ARRAY_SIZE(wm5110_devs), NULL, 0, NULL); break; case WM8997: ret = mfd_add_devices(arizona->dev, -1, wm8997_devs, ARRAY_SIZE(wm8997_devs), NULL, 0, NULL); break; } if (ret != 0) { dev_err(arizona->dev, "Failed to add subdevices: %d\n", ret); goto err_irq; } #ifdef CONFIG_PM_RUNTIME regulator_disable(arizona->dcvdd); #endif return 0; err_irq: arizona_irq_exit(arizona); err_reset: if (arizona->pdata.reset) { gpio_set_value_cansleep(arizona->pdata.reset, 0); gpio_free(arizona->pdata.reset); } regulator_disable(arizona->dcvdd); err_enable: regulator_bulk_disable(arizona->num_core_supplies, arizona->core_supplies); err_dcvdd: regulator_put(arizona->dcvdd); err_early: mfd_remove_devices(dev); return ret; }
static int mipi_dsi_panel_power(int on) { static struct regulator *reg_lvs5, *reg_l2; static int gpio36, gpio37; 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; } gpio36 = PM8921_GPIO_PM_TO_SYS(V_LCM_N5V_EN); rc = gpio_request(gpio36, "lcd_5v-"); if (rc) { pr_err("request lcd_5v- failed, rc=%d\n", rc); return -ENODEV; } gpio37 = PM8921_GPIO_PM_TO_SYS(V_LCM_P5V_EN); rc = gpio_request(gpio37, "lcd_5v+"); if (rc) { pr_err("request lcd_5v+ failed, rc=%d\n", rc); return -ENODEV; } 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); gpio_set_value_cansleep(gpio37, 1); msleep(10); gpio_set_value_cansleep(gpio36, 1); 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 { gpio_tlmm_config(GPIO_CFG(BL_HW_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE); gpio_set_value(BL_HW_EN, 0); 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; } gpio_set_value_cansleep(gpio36, 0); msleep(10); gpio_set_value_cansleep(gpio37, 0); msleep(100); rc = regulator_disable(reg_lvs5); if (rc) { pr_err("disable reg_lvs5 failed, rc=%d\n", rc); return -ENODEV; } } return 0; }
static void insert_headset(struct work_struct *work) { struct delayed_work *dwork = container_of(work, struct delayed_work, work); struct hsd_info *hi = container_of(dwork, struct hsd_info, work_for_insert); int earjack_type; int value = gpio_get_value_cansleep(hi->gpio_detect); if(value != EARJACK_INSERTED) { HSD_ERR("insert_headset but actually Fake inserted state!!\n"); return; } else { // mutex_lock(&hi->mutex_lock); // switch_set_state(&hi->sdev, LGE_HEADSET); // mutex_unlock(&hi->mutex_lock); } HSD_DBG("insert_headset"); if (hi->set_headset_mic_bias) hi->set_headset_mic_bias(TRUE); gpio_set_value_cansleep(hi->gpio_mic_en, 1); msleep(hi->latency_for_detection); // 75 -> 10 ms earjack_type = gpio_get_value_cansleep(hi->gpio_jpole); if (earjack_type == EARJACK_TYPE_3_POLE) { HSD_DBG("3 polarity earjack"); if (hi->set_headset_mic_bias) hi->set_headset_mic_bias(FALSE); atomic_set(&hi->is_3_pole_or_not, 1); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET_NO_MIC); mutex_unlock(&hi->mutex_lock); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); } else { HSD_DBG("4 polarity earjack"); atomic_set(&hi->is_3_pole_or_not, 0); cancel_delayed_work_sync(&(hi->work_for_key_det_enable)); queue_delayed_work(local_fsa8008_workqueue, &(hi->work_for_key_det_enable), FSA8008_KEY_EN_DELAY_MS ); mutex_lock(&hi->mutex_lock); switch_set_state(&hi->sdev, LGE_HEADSET); mutex_unlock(&hi->mutex_lock); input_report_switch(hi->input, SW_HEADPHONE_INSERT, 1); input_sync(hi->input); // 2012-07-01, [email protected] - to prevent a lost uevent of earjack inserted input_report_switch(hi->input, SW_MICROPHONE_INSERT, 1); input_sync(hi->input); } }
static void devkit8000_panel_disable_lcd(struct omap_dss_device *dssdev) { if (gpio_is_valid(dssdev->reset_gpio)) gpio_set_value_cansleep(dssdev->reset_gpio, 0); }
static int sharp5_cmd_power_off(struct mdfld_dsi_config *dsi_config) { struct mdfld_dsi_pkg_sender *sender = mdfld_dsi_get_pkg_sender(dsi_config); int err; PSB_DEBUG_ENTRY("\n"); if (!sender) { DRM_ERROR("Failed to get DSI packet sender\n"); return -EINVAL; } err = mdfld_dsi_send_mcs_short_hs(sender, set_display_off, 0, 0, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Display Off\n", __func__, __LINE__); goto power_off_err; } usleep_range(20000, 20100); err = mdfld_dsi_send_mcs_short_hs(sender, set_tear_off, 0, 0, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Tear Off\n", __func__, __LINE__); goto power_off_err; } err = mdfld_dsi_send_mcs_short_hs(sender, enter_sleep_mode, 0, 0, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Enter Sleep Mode\n", __func__, __LINE__); goto power_off_err; } msleep(60); err = mdfld_dsi_send_gen_short_hs(sender, access_protect, 4, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Access Protect\n", __func__, __LINE__); goto power_off_err; } err = mdfld_dsi_send_gen_short_hs(sender, low_power_mode, 1, 2, MDFLD_DSI_SEND_PACKAGE); if (err) { DRM_ERROR("%s: %d: Set Low Power Mode\n", __func__, __LINE__); goto power_off_err; } if (bias_en_gpio) gpio_set_value_cansleep(bias_en_gpio, 0); usleep_range(1000, 1500); return 0; power_off_err: err = -EIO; return err; }
static int hdmi_gpio_config(int on) { int rc = 0; static int prev_on; int pmic_gpio14 = PM8921_GPIO_PM_TO_SYS(14); if (on == prev_on) return 0; if (on) { rc = gpio_request(HDMI_DDC_CLK_GPIO, "HDMI_DDC_CLK"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_DDC_CLK", HDMI_DDC_CLK_GPIO, rc); goto error1; } rc = gpio_request(HDMI_DDC_DATA_GPIO, "HDMI_DDC_DATA"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_DDC_DATA", HDMI_DDC_DATA_GPIO, rc); goto error2; } rc = gpio_request(HDMI_HPD_GPIO, "HDMI_HPD"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_HPD", HDMI_HPD_GPIO, rc); goto error3; } if (machine_is_apq8064_liquid()) { rc = gpio_request(pmic_gpio14, "PMIC_HDMI_MUX_SEL"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "PMIC_HDMI_MUX_SEL", 14, rc); goto error4; } gpio_set_value_cansleep(pmic_gpio14, 0); } pr_debug("%s(on): success\n", __func__); } else { gpio_free(HDMI_DDC_CLK_GPIO); gpio_free(HDMI_DDC_DATA_GPIO); gpio_free(HDMI_HPD_GPIO); if (machine_is_apq8064_liquid()) { gpio_set_value_cansleep(pmic_gpio14, 1); gpio_free(pmic_gpio14); } pr_debug("%s(off): success\n", __func__); } prev_on = on; return 0; error4: gpio_free(HDMI_HPD_GPIO); error3: gpio_free(HDMI_DDC_DATA_GPIO); error2: gpio_free(HDMI_DDC_CLK_GPIO); error1: return rc; }
int32_t gc0339_power_up(struct msm_sensor_ctrl_t *s_ctrl) { int32_t rc = 0, index = 0; struct msm_sensor_power_setting_array *power_setting_array = NULL; struct msm_sensor_power_setting *power_setting = NULL; struct msm_camera_sensor_board_info *data = s_ctrl->sensordata; struct msm_camera_power_ctrl_t *power_info = &data->power_info; struct msm_camera_gpio_conf *gpio_conf = power_info->gpio_conf; CDBG("%s:%d\n", __func__, __LINE__); power_setting_array = &s_ctrl->power_setting_array; if (gpio_conf->cam_gpiomux_conf_tbl != NULL) { pr_err("%s:%d mux install\n", __func__, __LINE__); msm_gpiomux_install( (struct msm_gpiomux_config *) gpio_conf->cam_gpiomux_conf_tbl, gpio_conf->cam_gpiomux_conf_tbl_size); } rc = msm_camera_request_gpio_table( gpio_conf->cam_gpio_req_tbl, gpio_conf->cam_gpio_req_tbl_size, 1); if (rc < 0) { pr_err("%s: request gpio failed\n", __func__); return rc; } for (index = 0; index < power_setting_array->size; index++) { CDBG("%s index %d\n", __func__, index); power_setting = &power_setting_array->power_setting[index]; CDBG("%s type %d\n", __func__, power_setting->seq_type); switch (power_setting->seq_type) { case SENSOR_CLK: if (power_setting->seq_val >= power_info->clk_info_size) { pr_err("%s clk index %d >= max %d\n", __func__, power_setting->seq_val, power_info->clk_info_size); goto power_up_failed; } if (power_setting->config_val) power_info->clk_info[power_setting->seq_val]. clk_rate = power_setting->config_val; rc = msm_cam_clk_enable(power_info->dev, &power_info->clk_info[0], (struct clk **)&power_setting->data[0], power_info->clk_info_size, 1); if (rc < 0) { pr_err("%s: clk enable failed\n", __func__); goto power_up_failed; } break; case SENSOR_GPIO: if (power_setting->seq_val >= SENSOR_GPIO_MAX || !gpio_conf->gpio_num_info) { pr_err("%s gpio index %d >= max %d\n", __func__, power_setting->seq_val, SENSOR_GPIO_MAX); goto power_up_failed; } pr_debug("%s:%d gpio set val %d\n", __func__, __LINE__, gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val]); if (gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val]) gpio_set_value_cansleep( gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val], power_setting->config_val); break; case SENSOR_VREG: if (power_setting->seq_val >= CAM_VREG_MAX) { pr_err("%s vreg index %d >= max %d\n", __func__, power_setting->seq_val, SENSOR_GPIO_MAX); goto power_up_failed; } msm_camera_config_single_vreg(power_info->dev, &power_info->cam_vreg[power_setting->seq_val], (struct regulator **)&power_setting->data[0], 1); break; default: pr_err("%s error power seq type %d\n", __func__, power_setting->seq_type); break; } if (power_setting->delay > 20) { msleep(power_setting->delay); } else if (power_setting->delay) { usleep_range(power_setting->delay * 1000, (power_setting->delay * 1000) + 1000); } } if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) { rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util( s_ctrl->sensor_i2c_client, MSM_CCI_INIT); if (rc < 0) { pr_err("%s cci_init failed\n", __func__); goto power_up_failed; } } s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write( s_ctrl->sensor_i2c_client, 0xfc, 0x10, MSM_CAMERA_I2C_BYTE_DATA); if (s_ctrl->func_tbl->sensor_match_id) rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl); else rc = msm_sensor_match_id(s_ctrl); if (rc < 0) { pr_err("%s:%d match id failed rc %d\n", __func__, __LINE__, rc); goto power_up_failed; } CDBG("%s exit\n", __func__); return 0; power_up_failed: pr_err("%s:%d failed\n", __func__, __LINE__); if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) { s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util( s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE); } for (index--; index >= 0; index--) { CDBG("%s index %d\n", __func__, index); power_setting = &power_setting_array->power_setting[index]; CDBG("%s type %d\n", __func__, power_setting->seq_type); switch (power_setting->seq_type) { case SENSOR_CLK: msm_cam_clk_enable(power_info->dev, &power_info->clk_info[0], (struct clk **)&power_setting->data[0], power_info->clk_info_size, 0); break; case SENSOR_GPIO: if (gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val]) gpio_set_value_cansleep( gpio_conf->gpio_num_info->gpio_num [power_setting->seq_val], GPIOF_OUT_INIT_LOW); break; case SENSOR_VREG: msm_camera_config_single_vreg(power_info->dev, &power_info->cam_vreg[power_setting->seq_val], (struct regulator **)&power_setting->data[0], 0); break; default: pr_err("%s error power seq type %d\n", __func__, power_setting->seq_type); break; } if (power_setting->delay > 20) { msleep(power_setting->delay); } else if (power_setting->delay) { usleep_range(power_setting->delay * 1000, (power_setting->delay * 1000) + 1000); } } msm_camera_request_gpio_table( gpio_conf->cam_gpio_req_tbl, gpio_conf->cam_gpio_req_tbl_size, 0); return rc; }
static int gpio_config(struct hdmi *hdmi, bool on) { struct drm_device *dev = hdmi->dev; const struct hdmi_platform_config *config = hdmi->config; int ret; if (on) { ret = gpio_request(config->ddc_clk_gpio, "HDMI_DDC_CLK"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_DDC_CLK", config->ddc_clk_gpio, ret); goto error1; } gpio_set_value_cansleep(config->ddc_clk_gpio, 1); ret = gpio_request(config->ddc_data_gpio, "HDMI_DDC_DATA"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_DDC_DATA", config->ddc_data_gpio, ret); goto error2; } gpio_set_value_cansleep(config->ddc_data_gpio, 1); ret = gpio_request(config->hpd_gpio, "HDMI_HPD"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_HPD", config->hpd_gpio, ret); goto error3; } gpio_direction_input(config->hpd_gpio); gpio_set_value_cansleep(config->hpd_gpio, 1); if (config->mux_en_gpio != -1) { ret = gpio_request(config->mux_en_gpio, "HDMI_MUX_EN"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_MUX_EN", config->mux_en_gpio, ret); goto error4; } gpio_set_value_cansleep(config->mux_en_gpio, 1); } if (config->mux_sel_gpio != -1) { ret = gpio_request(config->mux_sel_gpio, "HDMI_MUX_SEL"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_MUX_SEL", config->mux_sel_gpio, ret); goto error5; } gpio_set_value_cansleep(config->mux_sel_gpio, 0); } if (config->mux_lpm_gpio != -1) { ret = gpio_request(config->mux_lpm_gpio, "HDMI_MUX_LPM"); if (ret) { dev_err(dev->dev, "'%s'(%d) gpio_request failed: %d\n", "HDMI_MUX_LPM", config->mux_lpm_gpio, ret); goto error6; } gpio_set_value_cansleep(config->mux_lpm_gpio, 1); } DBG("gpio on"); } else { gpio_free(config->ddc_clk_gpio); gpio_free(config->ddc_data_gpio); gpio_free(config->hpd_gpio); if (config->mux_en_gpio != -1) { gpio_set_value_cansleep(config->mux_en_gpio, 0); gpio_free(config->mux_en_gpio); } if (config->mux_sel_gpio != -1) { gpio_set_value_cansleep(config->mux_sel_gpio, 1); gpio_free(config->mux_sel_gpio); } if (config->mux_lpm_gpio != -1) { gpio_set_value_cansleep(config->mux_lpm_gpio, 0); gpio_free(config->mux_lpm_gpio); } DBG("gpio off"); } return 0; error6: if (config->mux_sel_gpio != -1) gpio_free(config->mux_sel_gpio); error5: if (config->mux_en_gpio != -1) gpio_free(config->mux_en_gpio); error4: gpio_free(config->hpd_gpio); error3: gpio_free(config->ddc_data_gpio); error2: gpio_free(config->ddc_clk_gpio); error1: return ret; }
static void mipi_renesas_set_backlight(struct msm_fb_data_type *mfd) { #ifdef SKY_LCD_SINGLE_WIRE_LB_CON int cnt, bl_level; unsigned long flags; PRINT("mipi_renesas_set_backlight bl_level = %d \n", mfd->bl_level); #ifdef CONFIG_F_SKYDISP_SKIP_BLSET_WITH_EFS_ERASE mfd->bl_set_first_skip =0; #endif #ifdef CONFIG_F_SKYDISP_SILENT_BOOT if(is_silent_boot_mode_n_bl_off == 1) { printk(KERN_ERR"DONOT set backlight because this time is silentboot mode.\n"); return; } #endif if (prev_bl_level != mfd->bl_level) { bl_level=mfd->bl_level; if (bl_level == 0) { gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_LOW_VALUE); udelay(300); // Disable hold time gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_HIGH_VALUE); mdelay(5); first_enable = 0; } else { if (prev_bl_level == 0) { mdelay(100); gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_HIGH_VALUE); mdelay(5); gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_HIGH_VALUE); if (first_enable == 0) { first_enable = 1; local_save_flags(flags); local_irq_disable(); udelay(10); // T_EN mdelay(3); // T_SS local_irq_restore(flags); } else { udelay(300); // Turn on time } } if (prev_bl_level < bl_level) { cnt = LCD_BL_MAX - bl_level; cnt += prev_bl_level; } else { cnt = prev_bl_level - bl_level; } while (cnt) { local_save_flags(flags); local_irq_disable(); gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_LOW_VALUE); udelay(3);//DELAY_3NS();//udelay(3); // Turn off time gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_HIGH_VALUE); local_irq_restore(flags); udelay(10); // Turn on time cnt--; } } prev_bl_level = bl_level; } #else //SKY_LCD_SINGLE_WIRE_LB_CON int bl_level; //PRINT("mipi_renesas_set_backlight prev_bl_level=%d, bl_level=%d\n", prev_bl_level, mfd->bl_level); #ifdef CONFIG_F_SKYDISP_SILENT_BOOT if(is_silent_boot_mode_n_bl_off == 1) { printk(KERN_ERR"DONOT set backlight because this time is silentboot mode.\n"); return; } #endif #ifdef FEATURE_RENESAS_BL_CTRL_CHG bl_level=mfd->bl_level; cabc_data_val[2] = bl_table[bl_level]; //PRINT("mipi_renesas_set_backlight cabcData[1] =%d cabc_data_val[2] = %d\n",cabc_data_val[1],cabc_data_val[2]); if (bl_level == 0) { if(gpio_get_value_cansleep(gpio_lcd_bl_en)){ gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_LOW_VALUE); gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_LOW_VALUE); } } else { if(!gpio_get_value_cansleep(gpio_lcd_bl_en)){ gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_HIGH_VALUE); gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_HIGH_VALUE); } mutex_lock(&renesas_state.lcd_mutex); mipi_set_tx_power_mode(0); #ifdef FEATURE_RENESAS_CABC_BUG_FIX mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_cabc_bugfix_NOP_set_cmds, ARRAY_SIZE(renesas_cabc_bugfix_NOP_set_cmds)); #endif mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_cabc_bl_set_cmds, ARRAY_SIZE(renesas_cabc_bl_set_cmds)); mipi_set_tx_power_mode(1); mutex_unlock(&renesas_state.lcd_mutex); } #elif defined(FEATURE_RENESAS_BL_ON_DEBUG) bl_level=mfd->bl_level; cabc_data_val[2] = bl_table[bl_level]; PRINT("mipi_renesas_set_backlight cabcData[1] =%d cabc_data_val[2] = %d\n",cabc_data_val[1],cabc_data_val[2]); mutex_lock(&renesas_state.lcd_mutex); mipi_set_tx_power_mode(0); msleep(1); mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_cabc_bl_set_cmds, ARRAY_SIZE(renesas_cabc_bl_set_cmds)); mipi_set_tx_power_mode(1); mutex_unlock(&renesas_state.lcd_mutex); #else if (prev_bl_level != mfd->bl_level) { bl_level=mfd->bl_level; cabc_data_val[2] = bl_table[bl_level]; //PRINT("mipi_renesas_set_backlight cabcData[1] =%d cabc_data_val[2] = %d\n",cabc_data_val[1],cabc_data_val[2]); if (bl_level == 0) { gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_LOW_VALUE); udelay(300); // Disable hold time gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_LOW_VALUE); mdelay(5); first_enable = 0; } else { if (first_enable == 0) { gpio_set_value_cansleep(gpio_lcd_bl_en, GPIO_HIGH_VALUE); gpio_set_value_cansleep(gpio_lcd_bl_ctl, GPIO_HIGH_VALUE); first_enable = 1; } mutex_lock(&renesas_state.lcd_mutex); mipi_set_tx_power_mode(0); #ifdef FEATURE_RENESAS_CABC_BUG_FIX if(prev_bl_level == 0) { mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_cabc_bugfix_NOP_set_cmds, ARRAY_SIZE(renesas_cabc_bugfix_NOP_set_cmds)); } #endif mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_cabc_bl_set_cmds, ARRAY_SIZE(renesas_cabc_bl_set_cmds)); mipi_set_tx_power_mode(1); mutex_unlock(&renesas_state.lcd_mutex); } prev_bl_level = mfd->bl_level; } #endif // FEATURE_RENESAS_BL_CTRL_CHG #endif //SKY_LCD_SINGLE_WIRE_LB_CON }