/* * Disable vdda and set uA */ static int mdss_edp_regulator_off(struct mdss_edp_drv_pdata *edp_drv) { int ret; ret = regulator_disable(edp_drv->vdda_vreg); if (ret) { pr_err("%s: Failed to disable vdda_vreg regulator.\n", __func__); return ret; } ret = regulator_set_optimum_mode(edp_drv->vdda_vreg, VDDA_UA_OFF_LOAD); if (ret < 0) { pr_err("%s: vdda_vreg set regulator mode failed.\n", __func__); return ret; } return 0; }
static int msm_sata_vreg_put_disable(struct device *dev, struct regulator *reg, const char *name, int max_uV) { int ret; if (!reg) return 0; ret = regulator_disable(reg); if (ret) { dev_err(dev, "Regulator: %s disable failed err=%d\n", name, ret); goto err; } if (regulator_count_voltages(reg) > 0) { ret = regulator_set_voltage(reg, 0, max_uV); if (ret < 0) { dev_err(dev, "Regulator: %s set voltage to 0 failed, err=%d\n", name, ret); goto err; } ret = regulator_set_optimum_mode(reg, 0); if (ret < 0) { dev_err(dev, "Regulator: %s set optimum mode(uA_load = 0) failed, err=%d\n", name, ret); goto err; } else { /* * regulator_set_optimum_mode() can return non zero * value even for success case. */ ret = 0; } } err: devm_regulator_put(reg); return ret; }
static int power_rail_on_stage(struct mmi_disp_reg_lst *reg_lst) { int i, rc = 0; struct mmi_disp_reg *reg; struct mmi_disp_gpio_config *en; pr_debug("%s is called\n", __func__); for (i = 0; i < reg_lst->num_disp_regs; i++) { reg = ®_lst->disp_reg[i]; en = ®->en_gpio; if (reg->reg_id[0] != '\0' && !IS_ERR_OR_NULL(reg->handle)) { rc = regulator_set_optimum_mode(reg->handle, 100000); if (rc < 0) { pr_err("%s: failed to set_optimum for %s." \ "rc=%d\n", __func__, reg->reg_id, rc); rc = -EINVAL; goto end; } else { pr_debug("%s: set set_optimum for %s(100000)\n", __func__, reg->reg_id); rc = 0; } } /* * If reg has enable gpio line, or it doesn't gpio en because * it is shared with other reg then it can be enable now */ if (!IS_ERR_OR_NULL(reg->handle)) { if ((en->num >= 0) || (reg->shared_gpio_en == 1)) { rc = panel_reg_enable(reg, 1); if (rc) goto end; } } } end: return rc; }
static int camera_sensor_power_enable(char *power, unsigned volt, struct regulator **sensor_power) { int rc; if (power == NULL) return -ENODEV; *sensor_power = regulator_get(NULL, power); if (IS_ERR(*sensor_power)) { pr_err("[CAM] %s: Unable to get %s\n", __func__, power); return -ENODEV; } if (strcmp(power, "8038_l17") == 0) { regulator_set_optimum_mode(*sensor_power, 10000); } if (volt != 1800000) { rc = regulator_set_voltage(*sensor_power, volt, volt); if (rc < 0) { pr_err("[CAM] %s: unable to set %s voltage to %d rc:%d\n", __func__, power, volt, rc); regulator_put(*sensor_power); *sensor_power = NULL; return -ENODEV; } } rc = regulator_enable(*sensor_power); if (rc < 0) { pr_err("[CAM] %s: Enable regulator %s failed\n", __func__, power); regulator_put(*sensor_power); *sensor_power = NULL; return -ENODEV; } return rc; }
static int power_rail_off_unstage(struct mmi_disp_reg_lst *reg_lst) { int i, rc = 0; struct mmi_disp_reg *reg; struct mmi_disp_gpio_config *en; pr_debug("%s is called\n", __func__); /* this is disable then it disables in reversed order */ for (i = reg_lst->num_disp_regs - 1; i >= 0; i--) { reg = ®_lst->disp_reg[i]; en = ®->en_gpio; /* If reg has en gpio line, then it can be disable now */ if (!IS_ERR_OR_NULL(reg->handle)) { if ((en->num >= 0) || (reg->shared_gpio_en == 1)) { rc = panel_reg_enable(reg, 0); if (rc) goto end; } } if (reg->reg_id[0] != '\0' && !IS_ERR_OR_NULL(reg->handle)) { rc = regulator_set_optimum_mode(reg->handle, 100); if (rc < 0) { pr_err("%s: failed to set_optimum for %s." \ "rc=%d\n", __func__, reg->reg_id, rc); rc = -EINVAL; goto end; } else { pr_debug("%s: set set_optimum for %s(100)\n", __func__, reg->reg_id); rc = 0; } } } end: return rc; }
int ufs_qcom_phy_cfg_vreg(struct phy *phy, struct ufs_qcom_phy_vreg *vreg, bool on) { int ret = 0; struct regulator *reg = vreg->reg; const char *name = vreg->name; int min_uV; int uA_load; struct ufs_qcom_phy *ufs_qcom_phy = get_ufs_qcom_phy(phy); struct device *dev = ufs_qcom_phy->dev; BUG_ON(!vreg); if (regulator_count_voltages(reg) > 0) { min_uV = on ? vreg->min_uV : 0; ret = regulator_set_voltage(reg, min_uV, vreg->max_uV); if (ret) { dev_err(dev, "%s: %s set voltage failed, err=%d\n", __func__, name, ret); goto out; } uA_load = on ? vreg->max_uA : 0; ret = regulator_set_optimum_mode(reg, uA_load); if (ret >= 0) { /* * regulator_set_optimum_mode() returns new regulator * mode upon success. */ ret = 0; } else { dev_err(dev, "%s: %s set optimum mode(uA_load=%d) failed, err=%d\n", __func__, name, uA_load, ret); goto out; } } out: return ret; }
static int pil_q6v4_power_up(struct device *dev) { int err; struct q6v4_data *drv = dev_get_drvdata(dev); err = regulator_set_voltage(drv->vreg, 1050000, 1050000); if (err) { dev_err(dev, "Failed to set regulator's voltage.\n"); return err; } err = regulator_set_optimum_mode(drv->vreg, 100000); if (err < 0) { dev_err(dev, "Failed to set regulator's mode.\n"); return err; } err = regulator_enable(drv->vreg); if (err) { dev_err(dev, "Failed to enable regulator.\n"); return err; } drv->vreg_enabled = true; return 0; }
static int ts_set_l17(int on) { int rc = -EINVAL; static struct regulator *vreg_l17; vreg_l17 = regulator_get(NULL, "8921_l17"); /* 3P0_L17_TOUCH */ if (IS_ERR(vreg_l17)) { pr_err("%s: regulator get of touch_3p0 failed (%ld)\n" , __func__, PTR_ERR(vreg_l17)); rc = PTR_ERR(vreg_l17); return rc; } rc = regulator_set_voltage(vreg_l17, MELFAS_VD33_MIN_UV, MELFAS_VD33_MAX_UV); if (on) { rc = regulator_set_optimum_mode(vreg_l17, MELFAS_VD33_CURR_UA); rc = regulator_enable(vreg_l17); } else { rc = regulator_disable(vreg_l17); } return rc; }
static int smsc_hub_remove(struct platform_device *pdev) { const struct smsc_hub_platform_data *pdata; pdata = pdev->dev.platform_data; if (smsc_hub->client) { i2c_unregister_device(smsc_hub->client); smsc_hub->client = NULL; i2c_del_driver(&hsic_hub_driver); } pm_runtime_disable(&pdev->dev); msm_xo_put(smsc_hub->xo_handle); regulator_disable(smsc_hub->hsic_hub_reg); regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, 0); regulator_set_voltage(smsc_hub->hsic_hub_reg, 0, HSIC_HUB_VDD_VOL_MIN); gpio_free(pdata->hub_reset); regulator_put(smsc_hub->hsic_hub_reg); kfree(smsc_hub); return 0; }
/** * usb_device_phy_en() - for enabling the 5V to usb gadget * @enable: to enabling the Phy for device. * * This function used to set the voltage for USB gadget mode. */ static void usb_device_phy_en(int enable) { int volt = 0; int ret = -1; if (phy_enable_stat == enable) return; if (enable == USB_ENABLE) { wake_lock(&ab8500_musb_wakelock); ux500_pins_enable(usb_gpio_pins); clk_enable(sysclock); phy_enable_stat = USB_ENABLE; regulator_enable(musb_vape_supply); regulator_enable(musb_smps2_supply); /* Set Vintcore12 LDO to 1.3V */ ret = regulator_set_voltage(musb_vintcore_supply, 1300000, 1350000); if (ret < 0) printk(KERN_ERR "Failed to set the Vintcore" " to 1.3V, ret=%d\n", ret); ret = regulator_set_optimum_mode(musb_vintcore_supply, 28000); if (ret < 0) printk(KERN_ERR "Failed to set optimum mode" " (ret=%d)\n", ret); regulator_enable(musb_vintcore_supply); volt = regulator_get_voltage(musb_vintcore_supply); if ((volt != 1300000) && (volt != 1350000)) printk(KERN_ERR "Vintcore is not" " set to 1.3V" " volt=%d\n", volt); #ifdef CONFIG_PM stm_musb_context(USB_ENABLE); #endif /* Workaround for USB performance issue. */ schedule_delayed_work_on(0, &work_usb_workaround, msecs_to_jiffies(USB_PROBE_DELAY)); prcmu_qos_update_requirement(PRCMU_QOS_APE_OPP, DEVICE_NAME, 100); abx500_set_register_interruptible(device, AB8500_USB, AB8500_USB_PHY_CTRL_REG, AB8500_USB_DEVICE_ENABLE); } else { /* enable == USB_DISABLE */ /* * Workaround: Sometimes the DISCONNECT interrupt is * not generated in musb_core. Force a disconnect if * necessary before we power down the PHY. */ stm_musb_force_disconnect(); if (boot_time_flag) boot_time_flag = USB_DISABLE; /* * Workaround for bug31952 in ABB cut2.0. Write 0x1 * before disabling the PHY. */ abx500_set_register_interruptible(device, AB8500_USB, AB8500_USB_PHY_CTRL_REG, AB8500_USB_DEVICE_ENABLE); udelay(200); abx500_set_register_interruptible(device, AB8500_USB, AB8500_USB_PHY_CTRL_REG, AB8500_USB_DEVICE_DISABLE); prcmu_qos_update_requirement(PRCMU_QOS_APE_OPP, DEVICE_NAME, 50); /* Workaround for USB performance issue. */ cancel_delayed_work_sync(&work_usb_workaround); prcmu_qos_update_requirement(PRCMU_QOS_ARM_OPP, "usb", 25); prcmu_release_usb_wakeup_state(); phy_enable_stat = USB_DISABLE; regulator_disable(musb_vape_supply); regulator_disable(musb_smps2_supply); regulator_disable(musb_vintcore_supply); regulator_set_optimum_mode(musb_vintcore_supply, 0); /* Set Vintcore12 LDO to 0V to 1.35V */ ret = regulator_set_voltage(musb_vintcore_supply, 0000000, 1350000); if (ret < 0) printk(KERN_ERR "Failed to set the Vintcore" " to 0V to 1.35V," " ret=%d\n", ret); clk_disable(sysclock); #ifdef CONFIG_PM stm_musb_context(USB_DISABLE); #endif ux500_pins_disable(usb_gpio_pins); wake_unlock(&ab8500_musb_wakelock); } }
static int mipi_dsi_panel_power(int on) { static struct regulator *v_lcm, *v_lcmio, *v_dsivdd; static bool bPanelPowerOn = false; int rc; char *lcm_str = "8921_l11"; char *lcmio_str = "8921_lvs5"; char *dsivdd_str = "8921_l2"; printk(KERN_ERR "[DISP] %s +++\n", __func__); /* To avoid system crash in shutdown for non-panel case */ if (panel_type == PANEL_ID_NONE) return -ENODEV; printk(KERN_INFO "%s: state : %d\n", __func__, on); if (!dsi_power_on) { v_lcm = regulator_get(&msm_mipi_dsi1_device.dev, lcm_str); if (IS_ERR_OR_NULL(v_lcm)) { printk(KERN_ERR "could not get %s, rc = %ld\n", lcm_str, PTR_ERR(v_lcm)); return -ENODEV; } v_lcmio = regulator_get(&msm_mipi_dsi1_device.dev, lcmio_str); if (IS_ERR_OR_NULL(v_lcmio)) { printk(KERN_ERR "could not get %s, rc = %ld\n", lcmio_str, PTR_ERR(v_lcmio)); return -ENODEV; } v_dsivdd = regulator_get(&msm_mipi_dsi1_device.dev, dsivdd_str); if (IS_ERR_OR_NULL(v_dsivdd)) { printk(KERN_ERR "could not get %s, rc = %ld\n", dsivdd_str, PTR_ERR(v_dsivdd)); return -ENODEV; } rc = regulator_set_voltage(v_lcm, 3000000, 3000000); if (rc) { printk(KERN_ERR "%s#%d: set_voltage %s failed, rc=%d\n", __func__, __LINE__, lcm_str, rc); return -EINVAL; } rc = regulator_set_voltage(v_dsivdd, 1200000, 1200000); if (rc) { printk(KERN_ERR "%s#%d: set_voltage %s failed, rc=%d\n", __func__, __LINE__, dsivdd_str, rc); return -EINVAL; } rc = gpio_request(FIGHTER_LCD_RSTz, "LCM_RST_N"); if (rc) { printk(KERN_ERR "%s:LCM gpio %d request failed, rc=%d\n", __func__, FIGHTER_LCD_RSTz, rc); return -EINVAL; } dsi_power_on = true; } if (on) { printk(KERN_INFO "%s: on\n", __func__); rc = regulator_set_optimum_mode(v_lcm, 100000); if (rc < 0) { printk(KERN_ERR "set_optimum_mode %s failed, rc=%d\n", lcm_str, rc); return -EINVAL; } rc = regulator_set_optimum_mode(v_dsivdd, 100000); if (rc < 0) { printk(KERN_ERR "set_optimum_mode %s failed, rc=%d\n", dsivdd_str, rc); return -EINVAL; } if (isOrise()) { rc = regulator_enable(v_lcmio); if (rc) { printk(KERN_ERR "enable regulator %s failed, rc=%d\n", lcmio_str, rc); return -ENODEV; } } else { rc = regulator_enable(v_lcm); if (rc) { printk(KERN_ERR "enable regulator %s failed, rc=%d\n", lcm_str, rc); return -ENODEV; } } rc = regulator_enable(v_dsivdd); if (rc) { printk(KERN_ERR "enable regulator %s failed, rc=%d\n", dsivdd_str, rc); return -ENODEV; } if (isOrise()) { rc = regulator_enable(v_lcm); if (rc) { printk(KERN_ERR "enable regulator %s failed, rc=%d\n", lcm_str, rc); return -ENODEV; } } else { rc = regulator_enable(v_lcmio); if (rc) { printk(KERN_ERR "enable regulator %s failed, rc=%d\n", lcmio_str, rc); return -ENODEV; } } if (!mipi_lcd_on) { if (isOrise()) hr_msleep(1); else hr_msleep(10); gpio_set_value(FIGHTER_LCD_RSTz, 1); if (isOrise()) hr_msleep(10); else hr_msleep(5); gpio_set_value(FIGHTER_LCD_RSTz, 0); if (isOrise()) hr_msleep(10); else hr_msleep(30); gpio_set_value(FIGHTER_LCD_RSTz, 1); } if (isOrise()) hr_msleep(10); else hr_msleep(30); bPanelPowerOn = true; } else { printk(KERN_INFO "%s: off\n", __func__); if (!bPanelPowerOn) return 0; if (isOrise()) hr_msleep(120); gpio_set_value(FIGHTER_LCD_RSTz, 0); if (isOrise()) hr_msleep(120); else hr_msleep(5); if (isOrise()) { if (regulator_disable(v_lcm)) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, lcm_str); return -EINVAL; } } else { if (regulator_disable(v_lcmio)) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, lcmio_str); return -EINVAL; } hr_msleep(5); } if (regulator_disable(v_dsivdd)) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, dsivdd_str); return -EINVAL; } if (isOrise()) { if (regulator_disable(v_lcmio)) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, lcmio_str); return -EINVAL; } } else { if (regulator_disable(v_lcm)) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, lcm_str); return -EINVAL; } } rc = regulator_set_optimum_mode(v_dsivdd, 100); if (rc < 0) { printk(KERN_ERR "%s: Unable to enable the regulator: %s\n", __func__, dsivdd_str); return -EINVAL; } bPanelPowerOn = false; } return 0; }
int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, int num_vreg, enum msm_camera_vreg_name_t *vreg_seq, int num_vreg_seq, struct regulator **reg_ptr, int config) { int i = 0, j = 0; int rc = 0; struct camera_vreg_t *curr_vreg; if (num_vreg_seq > num_vreg) { pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__); return -EINVAL; } if (!num_vreg_seq) num_vreg_seq = num_vreg; if (config) { for (i = 0; i < num_vreg_seq; i++) { if (vreg_seq) { j = vreg_seq[i]; if (j >= num_vreg) continue; } else j = i; curr_vreg = &cam_vreg[j]; reg_ptr[j] = regulator_get(dev, curr_vreg->reg_name); if (IS_ERR(reg_ptr[j])) { pr_err("%s: %s get failed\n", __func__, curr_vreg->reg_name); reg_ptr[j] = NULL; goto vreg_get_fail; } if (regulator_count_voltages(reg_ptr[j]) > 0) { rc = regulator_set_voltage( reg_ptr[j], curr_vreg->min_voltage, curr_vreg->max_voltage); if (rc < 0) { pr_err("%s: %s set voltage failed\n", __func__, curr_vreg->reg_name); goto vreg_set_voltage_fail; } if (curr_vreg->op_mode >= 0) { rc = regulator_set_optimum_mode( reg_ptr[j], curr_vreg->op_mode); if (rc < 0) { pr_err( "%s:%s set optimum mode fail\n", __func__, curr_vreg->reg_name); goto vreg_set_opt_mode_fail; } } } } } else { for (i = num_vreg_seq-1; i >= 0; i--) { if (vreg_seq) { j = vreg_seq[i]; if (j >= num_vreg) continue; } else j = i; curr_vreg = &cam_vreg[j]; if (reg_ptr[j]) { if (regulator_count_voltages(reg_ptr[j]) > 0) { if (curr_vreg->op_mode >= 0) { regulator_set_optimum_mode( reg_ptr[j], 0); } regulator_set_voltage( reg_ptr[j], 0, curr_vreg-> max_voltage); } regulator_put(reg_ptr[j]); reg_ptr[j] = NULL; } } } return 0; vreg_unconfig: if (regulator_count_voltages(reg_ptr[j]) > 0) regulator_set_optimum_mode(reg_ptr[j], 0); vreg_set_opt_mode_fail: if (regulator_count_voltages(reg_ptr[j]) > 0) regulator_set_voltage(reg_ptr[j], 0, curr_vreg->max_voltage); vreg_set_voltage_fail: regulator_put(reg_ptr[j]); reg_ptr[j] = NULL; vreg_get_fail: for (i--; i >= 0; i--) { if (vreg_seq) { j = vreg_seq[i]; if (j >= num_vreg) continue; } else j = i; curr_vreg = &cam_vreg[j]; goto vreg_unconfig; } return -ENODEV; }
int msm_camera_config_single_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, struct regulator **reg_ptr, int config) { int rc = 0; const char *vreg_name = NULL; if (!dev || !cam_vreg || !reg_ptr) { pr_err("%s: get failed NULL parameter\n", __func__); goto vreg_get_fail; } if (cam_vreg->type == VREG_TYPE_CUSTOM) { if (cam_vreg->custom_vreg_name == NULL) { pr_err("%s : can't find sub reg name", __func__); goto vreg_get_fail; } vreg_name = cam_vreg->custom_vreg_name; } else { if (cam_vreg->reg_name == NULL) { pr_err("%s : can't find reg name", __func__); goto vreg_get_fail; } vreg_name = cam_vreg->reg_name; } if (config) { CDBG("%s enable %s\n", __func__, vreg_name); *reg_ptr = regulator_get(dev, vreg_name); if (IS_ERR(*reg_ptr)) { pr_err("%s: %s get failed\n", __func__, vreg_name); *reg_ptr = NULL; goto vreg_get_fail; } if (regulator_count_voltages(*reg_ptr) > 0) { CDBG("%s: voltage min=%d, max=%d\n", __func__, cam_vreg->min_voltage, cam_vreg->max_voltage); rc = regulator_set_voltage( *reg_ptr, cam_vreg->min_voltage, cam_vreg->max_voltage); if (rc < 0) { pr_err("%s: %s set voltage failed\n", __func__, vreg_name); goto vreg_set_voltage_fail; } if (cam_vreg->op_mode >= 0) { rc = regulator_set_optimum_mode(*reg_ptr, cam_vreg->op_mode); if (rc < 0) { pr_err( "%s: %s set optimum mode failed\n", __func__, vreg_name); goto vreg_set_opt_mode_fail; } } } rc = regulator_enable(*reg_ptr); if (rc < 0) { pr_err("%s: %s regulator_enable failed\n", __func__, vreg_name); goto vreg_unconfig; } } else { CDBG("%s disable %s\n", __func__, vreg_name); if (*reg_ptr) { CDBG("%s disable %s\n", __func__, vreg_name); regulator_disable(*reg_ptr); if (regulator_count_voltages(*reg_ptr) > 0) { if (cam_vreg->op_mode >= 0) regulator_set_optimum_mode(*reg_ptr, 0); regulator_set_voltage( *reg_ptr, 0, cam_vreg->max_voltage); } regulator_put(*reg_ptr); *reg_ptr = NULL; } else { pr_err("%s can't disable %s\n", __func__, vreg_name); } } return 0; vreg_unconfig: if (regulator_count_voltages(*reg_ptr) > 0) regulator_set_optimum_mode(*reg_ptr, 0); vreg_set_opt_mode_fail: if (regulator_count_voltages(*reg_ptr) > 0) regulator_set_voltage(*reg_ptr, 0, cam_vreg->max_voltage); vreg_set_voltage_fail: regulator_put(*reg_ptr); *reg_ptr = NULL; vreg_get_fail: return -ENODEV; }
int32_t iu091_sensor_power_up(struct msm_sensor_ctrl_t *s_ctrl) { int32_t rc = 0; struct msm_camera_sensor_info *data = s_ctrl->sensordata; IU091_LOG_INF("START\n"); if (cam_vdig == NULL) { cam_vdig = regulator_get(&s_ctrl->sensor_i2c_client->client->dev, "cam_vdig"); if (IS_ERR(cam_vdig)) { IU091_LOG_ERR("VREG CAM VDIG get failed\n"); cam_vdig = NULL; iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_set_voltage(cam_vdig, CAM_VDIG_MINUV, CAM_VDIG_MAXUV)) { IU091_LOG_ERR("VREG CAM VDIG set voltage failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_set_optimum_mode(cam_vdig, CAM_VDIG_LOAD_UA) < 0) { IU091_LOG_ERR("VREG CAM VDIG set optimum mode failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_enable(cam_vdig)) { IU091_LOG_ERR("VREG CAM VDIG enable failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } } IU091_LOG_DBG("cam_vdig:%d [ON/OFF]",regulator_is_enabled(cam_vdig)); IU091_LOG_DBG("cam_vdig:%d [V]",regulator_get_voltage(cam_vdig)); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_VREG_L12); mdelay(IU091_WAIT_PWON_VREG_L12); camera_iu091_pm_vdig = true; rc = pm8xxx_gpio_config(IU091_PMGPIO_CAM_V_EN2, &iu091_cam_v_en_on); if (rc) { IU091_LOG_ERR("IU091_PMGPIO_CAM_V_EN2(%d) Error, rc = %d\n", IU091_PMGPIO_CAM_V_EN2, rc); iu091_sensor_power_down(s_ctrl); return -EFAULT; } IU091_LOG_DBG("PMGPIO[26]:ON\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_V_EN2); mdelay(IU091_WAIT_PWON_V_EN2); camera_iu091_pmgpio_26 = true; rc = pm8xxx_gpio_config(IU091_PMGPIO_CAM_V_EN1, &iu091_cam_v_en_on); if (rc) { IU091_LOG_ERR("IU091_PMGPIO_CAM_V_EN1(%d) Error, rc = %d\n", IU091_PMGPIO_CAM_V_EN1, rc); iu091_sensor_power_down(s_ctrl); return -EFAULT; } IU091_LOG_DBG("PMGPIO[13]:ON\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_V_EN1); mdelay(IU091_WAIT_PWON_V_EN1); camera_iu091_pmgpio_13 = true; if (cam_vana == NULL) { cam_vana = regulator_get(&s_ctrl->sensor_i2c_client->client->dev, "cam_vana"); if (IS_ERR(cam_vana)) { IU091_LOG_ERR("VREG CAM VANA get failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_set_voltage(cam_vana, CAM_VANA_MINUV, CAM_VANA_MAXUV)) { IU091_LOG_ERR("VREG CAM VANA set voltage failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_set_optimum_mode(cam_vana, CAM_VANA_LOAD_UA) < 0) { IU091_LOG_ERR("VREG CAM VANA set optimum mode failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (regulator_enable(cam_vana)) { IU091_LOG_ERR("VREG CAM VANA enable failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } } IU091_LOG_DBG("cam_vana:%d [ON/OFF]",regulator_is_enabled(cam_vana)); IU091_LOG_DBG("cam_vana:%d [V]",regulator_get_voltage(cam_vana)); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_VREG_L11); mdelay(IU091_WAIT_PWON_VREG_L11); camera_iu091_pm_vana = true; rc = pm8xxx_gpio_config(IU091_PMGPIO_CAM_RST_N, &iu091_cam_v_en_on); if (rc) { IU091_LOG_DBG("IU091_PMGPIO_CAM_RST_N(%d) Error, rc = %d\n", IU091_PMGPIO_CAM_RST_N, rc); iu091_sensor_power_down(s_ctrl); return -EFAULT; } IU091_LOG_DBG("PMGPIO[28]:ON\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_RST_N); mdelay(IU091_WAIT_PWON_RST_N); camera_iu091_pmgpio_28 = true; rc = msm_camera_request_gpio_table(data, 1); if (rc < 0) { IU091_LOG_ERR("request gpio failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } if (s_ctrl->clk_rate != 0) iu091_cam_clk_info->clk_rate = s_ctrl->clk_rate; rc = msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->dev, iu091_cam_clk_info, s_ctrl->cam_clk, ARRAY_SIZE(iu091_cam_clk_info), 1); if (rc < 0) { IU091_LOG_ERR("clk enable failed\n"); iu091_sensor_power_down(s_ctrl); return -EFAULT; } IU091_LOG_DBG("MCLK ENABLE\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWON_MCLK); mdelay(IU091_WAIT_PWON_MCLK); camera_iu091_mclk = true; if (data->sensor_platform_info->i2c_conf && data->sensor_platform_info->i2c_conf->use_i2c_mux){ msm_sensor_enable_i2c_mux(data->sensor_platform_info->i2c_conf); IU091_LOG_DBG("msm_sensor_enable_i2c_mux()\n"); } camera_iu091_i2c = true; IU091_LOG_INF("END\n"); return rc; }
int32_t iu091_sensor_power_down(struct msm_sensor_ctrl_t *s_ctrl) { struct msm_camera_sensor_info *data = s_ctrl->sensordata; IU091_LOG_INF("START\n"); if(camera_iu091_i2c) { if (data->sensor_platform_info->i2c_conf && data->sensor_platform_info->i2c_conf->use_i2c_mux) { msm_sensor_disable_i2c_mux( data->sensor_platform_info->i2c_conf); IU091_LOG_DBG("msm_sensor_disable_i2c_mux()\n"); } IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_I2C_STOP); mdelay(IU091_WAIT_PWOFF_I2C_STOP); camera_iu091_i2c = false; } if(camera_iu091_mclk) { msm_cam_clk_enable(&s_ctrl->sensor_i2c_client->client->dev, iu091_cam_clk_info, s_ctrl->cam_clk, ARRAY_SIZE(iu091_cam_clk_info), 0); msm_camera_request_gpio_table(data, 0); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_MCLK); mdelay(IU091_WAIT_PWOFF_MCLK); camera_iu091_mclk = false; } if(camera_iu091_pmgpio_28) { pm8xxx_gpio_config(IU091_PMGPIO_CAM_RST_N, &iu091_cam_v_en_off); IU091_LOG_DBG("PMGPIO[28]:OFF\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_RST_N); mdelay(IU091_WAIT_PWOFF_RST_N); camera_iu091_pmgpio_28 = false; } if(camera_iu091_pm_vana) { if (cam_vana){ regulator_set_optimum_mode(cam_vana, 0); regulator_set_voltage(cam_vana, 0, CAM_VANA_MAXUV); regulator_disable(cam_vana); regulator_put(cam_vana); IU091_LOG_DBG("cam_vana:%d [ON/OFF]",regulator_is_enabled(cam_vana)); IU091_LOG_DBG("cam_vana:%d [V]",regulator_get_voltage(cam_vana)); cam_vana = NULL; } IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_VREG_L11); mdelay(IU091_WAIT_PWOFF_VREG_L11); camera_iu091_pm_vana = false; } if(camera_iu091_pmgpio_13) { pm8xxx_gpio_config(IU091_PMGPIO_CAM_V_EN1, &iu091_cam_v_en_off); IU091_LOG_DBG("PMGPIO[13]:OFF\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_V_EN1); mdelay(IU091_WAIT_PWOFF_V_EN1); camera_iu091_pmgpio_13 = false; } if(camera_iu091_pmgpio_26) { pm8xxx_gpio_config(IU091_PMGPIO_CAM_V_EN2, &iu091_cam_v_en_off); IU091_LOG_DBG("PMGPIO[26]:OFF\n"); IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_V_EN2); mdelay(IU091_WAIT_PWOFF_V_EN2); camera_iu091_pmgpio_26 = false; } if(camera_iu091_pm_vdig) { if (cam_vdig) { regulator_set_voltage(cam_vdig, 0, CAM_VDIG_MAXUV); regulator_set_optimum_mode(cam_vdig, 0); regulator_disable(cam_vdig); regulator_put(cam_vdig); IU091_LOG_DBG("cam_vdig:%d [ON/OFF]",regulator_is_enabled(cam_vdig)); IU091_LOG_DBG("cam_vdig:%d [V]",regulator_get_voltage(cam_vdig)); cam_vdig = NULL; } IU091_LOG_DBG("wait %d[ms]\n",IU091_WAIT_PWOFF_VREG_L12); mdelay(IU091_WAIT_PWOFF_VREG_L12); camera_iu091_pm_vdig = false; } IU091_LOG_INF("END\n"); return 0; }
static int hdmi_core_power(int on, int show) { static struct regulator *reg_8921_l23, *reg_8921_s4; static int prev_on; int rc; if (on == prev_on) return 0; /* TBD: PM8921 regulator instead of 8901 */ if (!reg_8921_l23) { reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd"); if (IS_ERR(reg_8921_l23)) { pr_err("could not get reg_8921_l23, rc = %ld\n", PTR_ERR(reg_8921_l23)); return -ENODEV; } rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000); if (rc) { pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc); return -EINVAL; } } if (!reg_8921_s4) { reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc"); if (IS_ERR(reg_8921_s4)) { pr_err("could not get reg_8921_s4, rc = %ld\n", PTR_ERR(reg_8921_s4)); return -ENODEV; } rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000); if (rc) { pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc); return -EINVAL; } } if (on) { rc = regulator_set_optimum_mode(reg_8921_l23, 100000); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_8921_l23); if (rc) { pr_err("'%s' regulator enable failed, rc=%d\n", "hdmi_avdd", rc); return rc; } rc = regulator_enable(reg_8921_s4); if (rc) { pr_err("'%s' regulator enable failed, rc=%d\n", "hdmi_vcc", rc); return rc; } rc = gpio_request(100, "HDMI_DDC_CLK"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_DDC_CLK", 100, rc); goto error1; } rc = gpio_request(101, "HDMI_DDC_DATA"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_DDC_DATA", 101, rc); goto error2; } rc = gpio_request(102, "HDMI_HPD"); if (rc) { pr_err("'%s'(%d) gpio_request failed, rc=%d\n", "HDMI_HPD", 102, rc); goto error3; } pr_debug("%s(on): success\n", __func__); } else { gpio_free(100); gpio_free(101); gpio_free(102); rc = regulator_disable(reg_8921_l23); if (rc) { pr_err("disable reg_8921_l23 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_8921_s4); if (rc) { pr_err("disable reg_8921_s4 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_8921_l23, 100); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } pr_debug("%s(off): success\n", __func__); } prev_on = on; return 0; error3: gpio_free(101); error2: gpio_free(100); error1: regulator_disable(reg_8921_l23); regulator_disable(reg_8921_s4); return rc; }
static int pil_mss_loadable_init(struct modem_data *drv, struct platform_device *pdev) { struct q6v5_data *q6; struct pil_desc *q6_desc; struct resource *res; struct property *prop; int ret; q6 = pil_q6v5_init(pdev); if (IS_ERR(q6)) return PTR_ERR(q6); drv->q6 = q6; drv->xo = q6->xo; q6_desc = &q6->desc; q6_desc->owner = THIS_MODULE; q6_desc->proxy_timeout = PROXY_TIMEOUT_MS; q6_desc->ops = &pil_msa_mss_ops; q6->self_auth = of_property_read_bool(pdev->dev.of_node, "qcom,pil-self-auth"); if (q6->self_auth) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rmb_base"); q6->rmb_base = devm_request_and_ioremap(&pdev->dev, res); if (!q6->rmb_base) return -ENOMEM; drv->rmb_base = q6->rmb_base; q6_desc->ops = &pil_msa_mss_ops_selfauth; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "restart_reg"); if (!res) { res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "restart_reg_sec"); q6->restart_reg_sec = true; } q6->restart_reg = devm_request_and_ioremap(&pdev->dev, res); if (!q6->restart_reg) return -ENOMEM; q6->vreg = NULL; prop = of_find_property(pdev->dev.of_node, "vdd_mss-supply", NULL); if (prop) { q6->vreg = devm_regulator_get(&pdev->dev, "vdd_mss"); if (IS_ERR(q6->vreg)) return PTR_ERR(q6->vreg); ret = regulator_set_voltage(q6->vreg, VDD_MSS_UV, MAX_VDD_MSS_UV); if (ret) dev_err(&pdev->dev, "Failed to set vreg voltage.\n"); ret = regulator_set_optimum_mode(q6->vreg, 100000); if (ret < 0) { dev_err(&pdev->dev, "Failed to set vreg mode.\n"); return ret; } } q6->vreg_mx = devm_regulator_get(&pdev->dev, "vdd_mx"); if (IS_ERR(q6->vreg_mx)) return PTR_ERR(q6->vreg_mx); prop = of_find_property(pdev->dev.of_node, "vdd_mx-uV", NULL); if (!prop) { dev_err(&pdev->dev, "Missing vdd_mx-uV property\n"); return -EINVAL; } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cxrail_bhs_reg"); if (res) q6->cxrail_bhs = devm_ioremap(&pdev->dev, res->start, resource_size(res)); q6->ahb_clk = devm_clk_get(&pdev->dev, "iface_clk"); if (IS_ERR(q6->ahb_clk)) return PTR_ERR(q6->ahb_clk); q6->axi_clk = devm_clk_get(&pdev->dev, "bus_clk"); if (IS_ERR(q6->axi_clk)) return PTR_ERR(q6->axi_clk); q6->rom_clk = devm_clk_get(&pdev->dev, "mem_clk"); if (IS_ERR(q6->rom_clk)) return PTR_ERR(q6->rom_clk); /* Optional. */ if (of_property_match_string(pdev->dev.of_node, "qcom,active-clock-names", "gpll0_mss_clk") >= 0) q6->gpll0_mss_clk = devm_clk_get(&pdev->dev, "gpll0_mss_clk"); ret = pil_desc_init(q6_desc); return ret; }
static int reg_set_optimum_mode_check(struct regulator *reg, int load_uA) { return (regulator_count_voltages(reg) > 0) ? regulator_set_optimum_mode(reg, load_uA) : 0; }
static int vreg_setup(struct fpc1145_data *fpc1145, const char *name, bool enable) { size_t i; int rc; struct regulator *vreg; struct device *dev = fpc1145->dev; for (i = 0; i < ARRAY_SIZE(fpc1145->vreg); i++) { const char *n = vreg_conf[i].name; if (!strncmp(n, name, strlen(n))) goto found; } dev_err(dev, "Regulator %s not found\n", name); return -EINVAL; found: vreg = fpc1145->vreg[i]; if (enable) { if (!vreg) { vreg = regulator_get(dev, name); if (IS_ERR(vreg)) { dev_err(dev, "Unable to get %s\n", name); return PTR_ERR(vreg); } } if (regulator_count_voltages(vreg) > 0) { rc = regulator_set_voltage(vreg, vreg_conf[i].vmin, vreg_conf[i].vmax); if (rc) { dev_err(dev, "Unable to set voltage on %s, %d\n", name, rc); goto err_exit; } } rc = regulator_set_optimum_mode(vreg, vreg_conf[i].ua_load); if (rc < 0) { dev_err(dev, "Unable to set current on %s, %d\n", name, rc); goto err_exit; } rc = regulator_enable(vreg); if (rc) { dev_err(dev, "error enabling %s: %d\n", name, rc); err_exit: regulator_put(vreg); vreg = NULL; } fpc1145->vreg[i] = vreg; } else { if (vreg) { if (regulator_is_enabled(vreg)) { regulator_disable(vreg); dev_dbg(dev, "disabled %s\n", name); } regulator_put(vreg); fpc1145->vreg[i] = NULL; } rc = 0; } 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; }
/* Update voltage level given the current votes. */ static int update_vdd(struct clk_vdd_class *vdd_class) { int level, rc = 0, i, ignore; struct regulator **r = vdd_class->regulator; int *uv = vdd_class->vdd_uv; int *ua = vdd_class->vdd_ua; int n_reg = vdd_class->num_regulators; int cur_lvl = vdd_class->cur_level; int max_lvl = vdd_class->num_levels - 1; int cur_base = cur_lvl * n_reg; int new_base; /* aggregate votes */ for (level = max_lvl; level > 0; level--) if (vdd_class->level_votes[level]) break; if (level == cur_lvl) return 0; max_lvl = max_lvl * n_reg; new_base = level * n_reg; for (i = 0; i < vdd_class->num_regulators; i++) { rc = regulator_set_voltage(r[i], uv[new_base + i], uv[max_lvl + i]); if (rc) goto set_voltage_fail; if (ua) { rc = regulator_set_optimum_mode(r[i], ua[new_base + i]); rc = rc > 0 ? 0 : rc; if (rc) goto set_mode_fail; } if (cur_lvl == 0 || cur_lvl == vdd_class->num_levels) rc = regulator_enable(r[i]); else if (level == 0) rc = regulator_disable(r[i]); if (rc) goto enable_disable_fail; } if (vdd_class->set_vdd && !vdd_class->num_regulators) rc = vdd_class->set_vdd(vdd_class, level); if (!rc) vdd_class->cur_level = level; return rc; enable_disable_fail: /* * set_optimum_mode could use voltage to derive mode. Restore * previous voltage setting for r[i] first. */ if (ua) { regulator_set_voltage(r[i], uv[cur_base + i], uv[max_lvl + i]); regulator_set_optimum_mode(r[i], ua[cur_base + i]); } set_mode_fail: regulator_set_voltage(r[i], uv[cur_base + i], uv[max_lvl + i]); set_voltage_fail: for (i--; i >= 0; i--) { regulator_set_voltage(r[i], uv[cur_base + i], uv[max_lvl + i]); if (ua) regulator_set_optimum_mode(r[i], ua[cur_base + i]); if (cur_lvl == 0 || cur_lvl == vdd_class->num_levels) regulator_disable(r[i]); else if (level == 0) ignore = regulator_enable(r[i]); } return rc; }
/* CONFIG_N bit in SP_ILOCK register has to be cleared for new * values in registers to be effective after writing to * other registers. */ hsic_hub_clear_bits(client, SMSC3503_SP_ILOCK, CONFIG_N); return 0; } static int i2c_hsic_hub_remove(struct i2c_client *client) { return 0; } static const struct i2c_device_id hsic_hub_id[] = { {"i2c_hsic_hub", 0}, {} }; MODULE_DEVICE_TABLE(i2c, hsichub_id); static struct i2c_driver hsic_hub_driver = { .driver = { .name = "i2c_hsic_hub", }, .probe = i2c_hsic_hub_probe, .remove = i2c_hsic_hub_remove, .id_table = hsic_hub_id, }; #define HSIC_HUB_VDD_VOL_MIN 1650000 /* uV */ #define HSIC_HUB_VDD_VOL_MAX 1950000 /* uV */ #define HSIC_HUB_VDD_LOAD 36000 /* uA */ static int __devinit smsc_hub_probe(struct platform_device *pdev) { int ret = 0; const struct smsc_hub_platform_data *pdata; struct i2c_adapter *i2c_adap; struct i2c_board_info i2c_info; if (!pdev->dev.platform_data) { dev_err(&pdev->dev, "No platform data\n"); return -ENODEV; } pdata = pdev->dev.platform_data; if (!pdata->hub_reset) return -EINVAL; smsc_hub = kzalloc(sizeof(*smsc_hub), GFP_KERNEL); if (!smsc_hub) return -ENOMEM; smsc_hub->hsic_hub_reg = regulator_get(&pdev->dev, "EXT_HUB_VDDIO"); if (IS_ERR(smsc_hub->hsic_hub_reg)) { dev_err(&pdev->dev, "unable to get ext hub vddcx\n"); ret = PTR_ERR(smsc_hub->hsic_hub_reg); goto free_mem; } ret = gpio_request(pdata->hub_reset, "HSIC_HUB_RESET_GPIO"); if (ret < 0) { dev_err(&pdev->dev, "gpio request failed for GPIO%d\n", pdata->hub_reset); goto gpio_req_fail; } ret = regulator_set_voltage(smsc_hub->hsic_hub_reg, HSIC_HUB_VDD_VOL_MIN, HSIC_HUB_VDD_VOL_MAX); if (ret) { dev_err(&pdev->dev, "unable to set the voltage" "for hsic hub reg\n"); goto reg_set_voltage_fail; } ret = regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, HSIC_HUB_VDD_LOAD); if (ret < 0) { dev_err(&pdev->dev, "Unable to set optimum mode of regulator:" "VDDCX\n"); goto reg_optimum_mode_fail; } ret = regulator_enable(smsc_hub->hsic_hub_reg); if (ret) { dev_err(&pdev->dev, "unable to enable ext hub vddcx\n"); goto reg_enable_fail; } smsc_hub->xo_handle = msm_xo_get(MSM_XO_TCXO_D1, "hsic_hub"); if (IS_ERR(smsc_hub->xo_handle)) { dev_err(&pdev->dev, "not able to get the handle" "for TCXO D1 buffer\n"); goto disable_regulator; } ret = msm_xo_mode_vote(smsc_hub->xo_handle, MSM_XO_MODE_ON); if (ret) { dev_err(&pdev->dev, "failed to vote for TCXO" "D1 buffer\n"); goto xo_vote_fail; } gpio_direction_output(pdata->hub_reset, 0); /* Hub reset should be asserted for minimum 2microsec * before deasserting. */ udelay(5); gpio_direction_output(pdata->hub_reset, 1); ret = i2c_add_driver(&hsic_hub_driver); if (ret < 0) { dev_err(&pdev->dev, "failed to add I2C hsic_hub_driver\n"); goto i2c_add_fail; } usleep_range(10000, 12000); i2c_adap = i2c_get_adapter(SMSC_GSBI_I2C_BUS_ID); if (!i2c_adap) { dev_err(&pdev->dev, "failed to get i2c adapter\n"); i2c_del_driver(&hsic_hub_driver); goto i2c_add_fail; } memset(&i2c_info, 0, sizeof(struct i2c_board_info)); strlcpy(i2c_info.type, "i2c_hsic_hub", I2C_NAME_SIZE); smsc_hub->client = i2c_new_probed_device(i2c_adap, &i2c_info, normal_i2c, NULL); i2c_put_adapter(i2c_adap); if (!smsc_hub->client) dev_err(&pdev->dev, "failed to connect to smsc_hub" "through I2C\n"); i2c_add_fail: pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); return 0; xo_vote_fail: msm_xo_put(smsc_hub->xo_handle); disable_regulator: regulator_disable(smsc_hub->hsic_hub_reg); reg_enable_fail: regulator_set_optimum_mode(smsc_hub->hsic_hub_reg, 0); reg_optimum_mode_fail: regulator_set_voltage(smsc_hub->hsic_hub_reg, 0, HSIC_HUB_VDD_VOL_MIN); reg_set_voltage_fail: gpio_free(pdata->hub_reset); gpio_req_fail: regulator_put(smsc_hub->hsic_hub_reg); free_mem: kfree(smsc_hub); return ret; }
int msm_camera_config_vreg(struct device *dev, struct camera_vreg_t *cam_vreg, int num_vreg, struct regulator **reg_ptr, int config) { int i = 0; int rc = 0; struct camera_vreg_t *curr_vreg; if (config) { for (i = 0; i < num_vreg; i++) { curr_vreg = &cam_vreg[i]; reg_ptr[i] = regulator_get(dev, curr_vreg->reg_name); if (IS_ERR(reg_ptr[i])) { pr_err("%s: %s get failed\n", __func__, curr_vreg->reg_name); reg_ptr[i] = NULL; goto vreg_get_fail; } if (curr_vreg->type == REG_LDO) { rc = regulator_set_voltage( reg_ptr[i], curr_vreg->min_voltage, curr_vreg->max_voltage); if (rc < 0) { pr_err("%s: %s set voltage failed\n", __func__, curr_vreg->reg_name); goto vreg_set_voltage_fail; } if (curr_vreg->op_mode >= 0) { rc = regulator_set_optimum_mode( reg_ptr[i], curr_vreg->op_mode); if (rc < 0) { pr_err( "%s: %s set optimum mode failed\n", __func__, curr_vreg->reg_name); goto vreg_set_opt_mode_fail; } } } } } else { for (i = num_vreg-1; i >= 0; i--) { curr_vreg = &cam_vreg[i]; if (reg_ptr[i]) { if (curr_vreg->type == REG_LDO) { if (curr_vreg->op_mode >= 0) { regulator_set_optimum_mode( reg_ptr[i], 0); } regulator_set_voltage( reg_ptr[i], 0, curr_vreg-> max_voltage); } regulator_put(reg_ptr[i]); reg_ptr[i] = NULL; } } } return 0; vreg_unconfig: if (curr_vreg->type == REG_LDO) regulator_set_optimum_mode(reg_ptr[i], 0); vreg_set_opt_mode_fail: if (curr_vreg->type == REG_LDO) regulator_set_voltage(reg_ptr[i], 0, curr_vreg->max_voltage); vreg_set_voltage_fail: regulator_put(reg_ptr[i]); reg_ptr[i] = NULL; vreg_get_fail: for (i--; i >= 0; i--) { curr_vreg = &cam_vreg[i]; goto vreg_unconfig; } return -ENODEV; }
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 hdmi_core_power(int on, int show) { static struct regulator *reg_8921_l23, *reg_8921_s4; static int prev_on; int rc; if (on == prev_on) return 0; /* TBD: PM8921 regulator instead of 8901 */ if (!reg_8921_l23) { reg_8921_l23 = regulator_get(&hdmi_msm_device.dev, "hdmi_avdd"); if (IS_ERR(reg_8921_l23)) { pr_err("could not get reg_8921_l23, rc = %ld\n", PTR_ERR(reg_8921_l23)); return -ENODEV; } rc = regulator_set_voltage(reg_8921_l23, 1800000, 1800000); if (rc) { pr_err("set_voltage failed for 8921_l23, rc=%d\n", rc); return -EINVAL; } } if (!reg_8921_s4) { reg_8921_s4 = regulator_get(&hdmi_msm_device.dev, "hdmi_vcc"); if (IS_ERR(reg_8921_s4)) { pr_err("could not get reg_8921_s4, rc = %ld\n", PTR_ERR(reg_8921_s4)); return -ENODEV; } rc = regulator_set_voltage(reg_8921_s4, 1800000, 1800000); if (rc) { pr_err("set_voltage failed for 8921_s4, rc=%d\n", rc); return -EINVAL; } } if (on) { rc = regulator_set_optimum_mode(reg_8921_l23, 100000); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } rc = regulator_enable(reg_8921_l23); if (rc) { pr_err("'%s' regulator enable failed, rc=%d\n", "hdmi_avdd", rc); return rc; } rc = regulator_enable(reg_8921_s4); if (rc) { pr_err("'%s' regulator enable failed, rc=%d\n", "hdmi_vcc", rc); return rc; } pr_debug("%s(on): success\n", __func__); } else { rc = regulator_disable(reg_8921_l23); if (rc) { pr_err("disable reg_8921_l23 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_disable(reg_8921_s4); if (rc) { pr_err("disable reg_8921_s4 failed, rc=%d\n", rc); return -ENODEV; } rc = regulator_set_optimum_mode(reg_8921_l23, 100); if (rc < 0) { pr_err("set_optimum_mode l23 failed, rc=%d\n", rc); return -EINVAL; } pr_debug("%s(off): success\n", __func__); } prev_on = on; return 0; }
static int __devinit pil_q6v4_driver_probe(struct platform_device *pdev) { const struct pil_q6v4_pdata *pdata = pdev->dev.platform_data; struct q6v4_data *drv; struct resource *res; struct pil_desc *desc; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -EINVAL; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; platform_set_drvdata(pdev, drv); drv->base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!drv->base) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 1); if (res) { drv->modem_base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); if (!drv->modem_base) return -ENOMEM; } desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); if (!desc) return -ENOMEM; drv->pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); if (IS_ERR(drv->pll_supply)) { drv->pll_supply = NULL; } else { ret = regulator_set_voltage(drv->pll_supply, 1800000, 1800000); if (ret) { dev_err(&pdev->dev, "failed to set pll voltage\n"); return ret; } ret = regulator_set_optimum_mode(drv->pll_supply, 100000); if (ret < 0) { dev_err(&pdev->dev, "failed to set pll optimum mode\n"); return ret; } } desc->name = pdata->name; desc->depends_on = pdata->depends; desc->dev = &pdev->dev; desc->owner = THIS_MODULE; desc->proxy_timeout = 10000; if (pas_supported(pdata->pas_id) > 0) { desc->ops = &pil_q6v4_ops_trusted; dev_info(&pdev->dev, "using secure boot\n"); } else { desc->ops = &pil_q6v4_ops; dev_info(&pdev->dev, "using non-secure boot\n"); } drv->vreg = devm_regulator_get(&pdev->dev, "core_vdd"); if (IS_ERR(drv->vreg)) return PTR_ERR(drv->vreg); ret = regulator_set_optimum_mode(drv->vreg, 100000); if (ret < 0) { dev_err(&pdev->dev, "Failed to set regulator's mode.\n"); return ret; } drv->xo = devm_clk_get(&pdev->dev, "xo"); if (IS_ERR(drv->xo)) return PTR_ERR(drv->xo); if (pdata->xo1_id) { drv->xo1 = msm_xo_get(pdata->xo1_id, pdata->name); if (IS_ERR(drv->xo1)) return PTR_ERR(drv->xo1); } if (pdata->xo2_id) { drv->xo2 = msm_xo_get(pdata->xo2_id, pdata->name); if (IS_ERR(drv->xo2)) { msm_xo_put(drv->xo1); return PTR_ERR(drv->xo2); } } drv->pil = msm_pil_register(desc); if (IS_ERR(drv->pil)) { msm_xo_put(drv->xo2); msm_xo_put(drv->xo1); return PTR_ERR(drv->pil); } return 0; }
static int mipi_dsi_panel_power(int on) { static struct regulator *reg_l8, *reg_l2, *reg_lvs6, *ext_dsv_load; static int gpio42; int rc; struct pm_gpio gpio42_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, }; printk(KERN_INFO"%s: mipi lcd function started status = %d \n", __func__, on); pr_debug("%s: state : %d\n", __func__, on); if (!dsi_power_on) { gpio42 = PM8921_GPIO_PM_TO_SYS(42); rc = gpio_request(gpio42, "disp_rst_n"); if (rc) { pr_err("request gpio 42 failed, rc=%d\n", rc); return -ENODEV; } if (lge_get_board_revno() > HW_REV_C) { ext_dsv_load = regulator_get(NULL, "ext_dsv_load"); if (IS_ERR(ext_dsv_load)) { pr_err("could not get ext_dsv_load, rc = %ld\n", PTR_ERR(ext_dsv_load)); return -ENODEV; } } reg_l8 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi_vci"); 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, "dsi_iovcc"); 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; } dsi_power_on = true; } if (on) { if (lge_get_board_revno() > HW_REV_C) { rc = regulator_enable(ext_dsv_load); if (rc) { pr_err("enable ext_dsv_load failed, rc=%d\n", rc); return -ENODEV; } } 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; } #if defined(CONFIG_FB_MSM_MIPI_LGIT_VIDEO_WXGA_PT) rc = regulator_enable(reg_l8); // dsi_vci if (rc) { pr_err("enable l8 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_enable(reg_lvs6); // IOVCC if (rc) { pr_err("enable lvs6 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); #endif rc = regulator_enable(reg_l2); // DSI 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); gpio42_param.output_value = 1; rc = pm8xxx_gpio_config(gpio42,&gpio42_param); if (rc) { pr_err("gpio_config 42 failed (3), rc=%d\n", rc); return -EINVAL; } mdelay(5); } else { /* LCD RESET LOW */ gpio42_param.output_value = 0; rc = pm8xxx_gpio_config(gpio42,&gpio42_param); if (rc) { pr_err("gpio_config 42 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); #if defined(CONFIG_FB_MSM_MIPI_LGIT_VIDEO_WXGA_PT) rc = regulator_disable(reg_lvs6); // IOVCC if (rc) { pr_err("disable lvs6 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); rc = regulator_disable(reg_l8); //VCI if (rc) { pr_err("disable reg_l8 failed, rc=%d\n", rc); return -ENODEV; } udelay(100); #endif rc = regulator_disable(reg_l2); //DSI if (rc) { pr_err("disable reg_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; } if (lge_get_board_revno() > HW_REV_C) { rc = regulator_disable(ext_dsv_load); if (rc) { pr_err("disable ext_dsv_load failed, rc=%d\n", rc); return -ENODEV; } } } return 0; } static char mipi_dsi_splash_is_enabled(void) { return mdp_pdata.cont_splash_enabled; } static struct mipi_dsi_platform_data mipi_dsi_pdata = { .dsi_power_save = mipi_dsi_panel_power, .splash_is_enabled = mipi_dsi_splash_is_enabled, }; static struct msm_bus_vectors dtv_bus_init_vectors[] = { { .src = MSM_BUS_MASTER_MDP_PORT0, .dst = MSM_BUS_SLAVE_EBI_CH0, .ab = 0, .ib = 0, }, };
static int mipi_dsi_cdp_panel_power(int on) { static struct regulator *reg_l8, *reg_l23, *reg_l2; /* Control backlight GPIO (24) directly when using PM8917 */ #ifndef CONFIG_FB_MSM_MIPI_WARPLTE_OTM_VIDEO_WVGA_PT_PANEL int gpio24 = PM8917_GPIO_PM_TO_SYS(24); #endif int rc; printk("lizhiye, %s: state : %d, dsi_power_on = %d\n", __func__, on, dsi_power_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 8038_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 8038_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 8038_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; } rc = gpio_request(DISP_RST_GPIO, "disp_rst_n"); if (rc) { pr_err("request gpio DISP_RST_GPIO failed, rc=%d\n", rc); gpio_free(DISP_RST_GPIO); return -ENODEV; } #ifdef CONFIG_FB_MSM_MIPI_WARPLTE_OTM_VIDEO_WVGA_PT_PANEL rc = gpio_request(DISP_BACKLIGHT_GPIO, "disp_rst_n"); if (rc) { pr_err("lizhiye, request gpio DISP_BACKLIGHT_GPIO failed, rc=%d\n", rc); gpio_free(DISP_BACKLIGHT_GPIO); return -ENODEV; } #endif rc = gpio_request(DISP_3D_2D_MODE, "disp_3d_2d"); if (rc) { pr_err("request gpio DISP_3D_2D_MODE failed, rc=%d\n", rc); gpio_free(DISP_3D_2D_MODE); return -ENODEV; } rc = gpio_direction_output(DISP_3D_2D_MODE, 0); if (rc) { pr_err("gpio_direction_output failed for %d gpio rc=%d\n", DISP_3D_2D_MODE, rc); return -ENODEV; } #ifndef CONFIG_FB_MSM_MIPI_WARPLTE_OTM_VIDEO_WVGA_PT_PANEL if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) { rc = gpio_request(gpio24, "disp_bl"); if (rc) { pr_err("request for gpio 24 failed, rc=%d\n", rc); return -ENODEV; } gpio_set_value_cansleep(gpio24, 0); novatek_pdata.gpio_set_backlight = pm8917_gpio_set_backlight; } #endif 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; } usleep(10000); #if 0 gpio_set_value(DISP_RST_GPIO, 1); usleep(10); gpio_set_value(DISP_RST_GPIO, 0); usleep(20); gpio_set_value(DISP_RST_GPIO, 1); #endif gpio_set_value(DISP_3D_2D_MODE, 1); usleep(20); #ifndef CONFIG_FB_MSM_MIPI_WARPLTE_OTM_VIDEO_WVGA_PT_PANEL if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) gpio_set_value_cansleep(gpio24, 1); #endif } else { gpio_set_value(DISP_RST_GPIO, 0); 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(DISP_3D_2D_MODE, 0); usleep(20); #ifndef CONFIG_FB_MSM_MIPI_WARPLTE_OTM_VIDEO_WVGA_PT_PANEL if (socinfo_get_pmic_model() == PMIC_MODEL_PM8917) gpio_set_value_cansleep(gpio24, 0); #endif } return 0; }
static int __devinit pil_riva_probe(struct platform_device *pdev) { struct riva_data *drv; struct resource *res; struct pil_desc *desc; int ret; drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); if (!drv) return -ENOMEM; platform_set_drvdata(pdev, drv); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); drv->base = devm_request_and_ioremap(&pdev->dev, res); if (!drv->base) return -ENOMEM; res = platform_get_resource(pdev, IORESOURCE_MEM, 1); drv->cbase = devm_request_and_ioremap(&pdev->dev, res); if (!drv->cbase) return -ENOMEM; drv->pll_supply = devm_regulator_get(&pdev->dev, "pll_vdd"); if (IS_ERR(drv->pll_supply)) { dev_err(&pdev->dev, "failed to get pll supply\n"); return PTR_ERR(drv->pll_supply); } if (regulator_count_voltages(drv->pll_supply) > 0) { ret = regulator_set_voltage(drv->pll_supply, 1800000, 1800000); if (ret) { dev_err(&pdev->dev, "failed to set pll supply voltage\n"); return ret; } ret = regulator_set_optimum_mode(drv->pll_supply, 100000); if (ret < 0) { dev_err(&pdev->dev, "failed to set pll supply optimum mode\n"); return ret; } } drv->irq = platform_get_irq(pdev, 0); if (drv->irq < 0) return drv->irq; drv->xo = devm_clk_get(&pdev->dev, "cxo"); if (IS_ERR(drv->xo)) return PTR_ERR(drv->xo); desc = &drv->pil_desc; desc->name = "wcnss"; desc->dev = &pdev->dev; desc->owner = THIS_MODULE; desc->proxy_timeout = 10000; if (pas_supported(PAS_WCNSS) > 0) { desc->ops = &pil_riva_ops_trusted; dev_info(&pdev->dev, "using secure boot\n"); } else { desc->ops = &pil_riva_ops; dev_info(&pdev->dev, "using non-secure boot\n"); } ret = pil_desc_init(desc); ret = smsm_state_cb_register(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, drv); if (ret < 0) goto err_smsm; drv->subsys_desc.name = "wcnss"; drv->subsys_desc.dev = &pdev->dev; drv->subsys_desc.owner = THIS_MODULE; drv->subsys_desc.start = riva_start; drv->subsys_desc.stop = riva_stop; drv->subsys_desc.shutdown = riva_shutdown; drv->subsys_desc.powerup = riva_powerup; drv->subsys_desc.ramdump = riva_ramdump; drv->subsys_desc.crash_shutdown = riva_crash_shutdown; INIT_DELAYED_WORK(&drv->cancel_work, riva_post_bootup); drv->ramdump_dev = create_ramdump_device("riva", &pdev->dev); if (!drv->ramdump_dev) { ret = -ENOMEM; goto err_ramdump; } drv->subsys = subsys_register(&drv->subsys_desc); if (IS_ERR(drv->subsys)) { ret = PTR_ERR(drv->subsys); goto err_subsys; } scm_pas_init(MSM_BUS_MASTER_SPS); ret = devm_request_irq(&pdev->dev, drv->irq, riva_wdog_bite_irq_hdlr, IRQF_TRIGGER_RISING, "riva_wdog", drv); if (ret < 0) goto err; return 0; err: subsys_unregister(drv->subsys); err_subsys: destroy_ramdump_device(drv->ramdump_dev); err_ramdump: smsm_state_cb_deregister(SMSM_WCNSS_STATE, SMSM_RESET, smsm_state_cb_hdlr, drv); err_smsm: pil_desc_release(desc); return ret; }
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++; } } static bool dsi_power_on; /** * 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 char mipi_dsi_splash_is_enabled(void); 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; } 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, }, };