diff --git a/include/linux/sde_io_util.h b/include/linux/sde_io_util.h index a4ead7e489..c759d45865 100644 --- a/include/linux/sde_io_util.h +++ b/include/linux/sde_io_util.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012, 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2012, 2017-2020, The Linux Foundation. All rights reserved. */ #ifndef __SDE_IO_UTIL_H__ @@ -89,8 +89,8 @@ void msm_dss_iounmap(struct dss_io_data *io_data); int msm_dss_enable_gpio(struct dss_gpio *in_gpio, int num_gpio, int enable); int msm_dss_gpio_enable(struct dss_gpio *in_gpio, int num_gpio, int enable); -int msm_dss_config_vreg(struct device *dev, struct dss_vreg *in_vreg, - int num_vreg, int config); +int msm_dss_get_vreg(struct device *dev, struct dss_vreg *in_vreg, + int num_vreg, int enable); int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable); int msm_dss_get_clk(struct device *dev, struct dss_clk *clk_arry, int num_clk); diff --git a/msm/dp/dp_power.c b/msm/dp/dp_power.c index 403d5cf69d..be8b54fc91 100644 --- a/msm/dp/dp_power.c +++ b/msm/dp/dp_power.c @@ -39,14 +39,14 @@ static int dp_power_regulator_init(struct dp_power_private *power) pdev = power->pdev; for (i = DP_CORE_PM; !rc && (i < DP_MAX_PM); i++) { - rc = msm_dss_config_vreg(&pdev->dev, + rc = msm_dss_get_vreg(&pdev->dev, parser->mp[i].vreg_config, parser->mp[i].num_vreg, 1); if (rc) { DP_ERR("failed to init vregs for %s\n", dp_parser_pm_name(i)); for (j = i - 1; j >= DP_CORE_PM; j--) { - msm_dss_config_vreg(&pdev->dev, + msm_dss_get_vreg(&pdev->dev, parser->mp[j].vreg_config, parser->mp[j].num_vreg, 0); } @@ -68,7 +68,7 @@ static void dp_power_regulator_deinit(struct dp_power_private *power) pdev = power->pdev; for (i = DP_CORE_PM; (i < DP_MAX_PM); i++) { - rc = msm_dss_config_vreg(&pdev->dev, + rc = msm_dss_get_vreg(&pdev->dev, parser->mp[i].vreg_config, parser->mp[i].num_vreg, 0); if (rc) diff --git a/msm/dsi/dsi_pwr.c b/msm/dsi/dsi_pwr.c index bcaefaf98a..b7e5ccccde 100644 --- a/msm/dsi/dsi_pwr.c +++ b/msm/dsi/dsi_pwr.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -179,15 +179,16 @@ static int dsi_pwr_enable_vregs(struct dsi_regulator_info *regs, bool enable) usleep_range((pre_off_ms * 1000), (pre_off_ms * 1000) + 10); - if (regs->vregs[i].off_min_voltage) - (void)regulator_set_voltage(regs->vregs[i].vreg, - regs->vregs[i].off_min_voltage, - regs->vregs[i].max_voltage); - (void)regulator_set_load(regs->vregs[i].vreg, regs->vregs[i].disable_load); (void)regulator_disable(regs->vregs[i].vreg); + num_of_v = regulator_count_voltages(vreg->vreg); + if (num_of_v > 0) + (void)regulator_set_voltage(regs->vregs[i].vreg, + regs->vregs[i].off_min_voltage, + regs->vregs[i].max_voltage); + if (post_off_ms) usleep_range((post_off_ms * 1000), (post_off_ms * 1000) + 10); diff --git a/msm/sde_io_util.c b/msm/sde_io_util.c index 32762311d2..088a6850da 100644 --- a/msm/sde_io_util.c +++ b/msm/sde_io_util.c @@ -129,17 +129,16 @@ void msm_dss_iounmap(struct dss_io_data *io_data) } /* msm_dss_iounmap */ EXPORT_SYMBOL(msm_dss_iounmap); -int msm_dss_config_vreg(struct device *dev, struct dss_vreg *in_vreg, - int num_vreg, int config) +int msm_dss_get_vreg(struct device *dev, struct dss_vreg *in_vreg, + int num_vreg, int enable) { int i = 0, rc = 0; struct dss_vreg *curr_vreg = NULL; - enum dss_vreg_type type; if (!in_vreg || !num_vreg) return rc; - if (config) { + if (enable) { for (i = 0; i < num_vreg; i++) { curr_vreg = &in_vreg[i]; curr_vreg->vreg = regulator_get(dev, @@ -152,33 +151,11 @@ int msm_dss_config_vreg(struct device *dev, struct dss_vreg *in_vreg, curr_vreg->vreg = NULL; goto vreg_get_fail; } - type = (regulator_count_voltages(curr_vreg->vreg) > 0) - ? DSS_REG_LDO : DSS_REG_VS; - if (type == DSS_REG_LDO) { - rc = regulator_set_voltage( - curr_vreg->vreg, - curr_vreg->min_voltage, - curr_vreg->max_voltage); - if (rc < 0) { - DEV_ERR("%pS->%s: %s set vltg fail\n", - __builtin_return_address(0), - __func__, - curr_vreg->vreg_name); - goto vreg_set_voltage_fail; - } - } } } else { for (i = num_vreg-1; i >= 0; i--) { curr_vreg = &in_vreg[i]; if (curr_vreg->vreg) { - type = (regulator_count_voltages( - curr_vreg->vreg) > 0) - ? DSS_REG_LDO : DSS_REG_VS; - if (type == DSS_REG_LDO) { - regulator_set_voltage(curr_vreg->vreg, - 0, curr_vreg->max_voltage); - } regulator_put(curr_vreg->vreg); curr_vreg->vreg = NULL; } @@ -186,24 +163,16 @@ int msm_dss_config_vreg(struct device *dev, struct dss_vreg *in_vreg, } return 0; -vreg_unconfig: -if (type == DSS_REG_LDO) - regulator_set_load(curr_vreg->vreg, 0); - -vreg_set_voltage_fail: - regulator_put(curr_vreg->vreg); - curr_vreg->vreg = NULL; - vreg_get_fail: for (i--; i >= 0; i--) { curr_vreg = &in_vreg[i]; - type = (regulator_count_voltages(curr_vreg->vreg) > 0) - ? DSS_REG_LDO : DSS_REG_VS; - goto vreg_unconfig; + regulator_set_load(curr_vreg->vreg, 0); + regulator_put(curr_vreg->vreg); + curr_vreg->vreg = NULL; } return rc; -} /* msm_dss_config_vreg */ -EXPORT_SYMBOL(msm_dss_config_vreg); +} /* msm_dss_get_vreg */ +EXPORT_SYMBOL(msm_dss_get_vreg); static bool msm_dss_is_hw_controlled(struct dss_vreg in_vreg) { @@ -255,6 +224,10 @@ int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable) in_vreg[i].vreg_name); goto vreg_set_opt_mode_fail; } + if (regulator_count_voltages(in_vreg[i].vreg) > 0) + regulator_set_voltage(in_vreg[i].vreg, + in_vreg[i].min_voltage, + in_vreg[i].max_voltage); rc = regulator_enable(in_vreg[i].vreg); if (in_vreg[i].post_on_sleep && need_sleep) usleep_range(in_vreg[i].post_on_sleep * 1000, @@ -277,6 +250,9 @@ int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable) regulator_set_load(in_vreg[i].vreg, in_vreg[i].disable_load); regulator_disable(in_vreg[i].vreg); + if (regulator_count_voltages(in_vreg[i].vreg) > 0) + regulator_set_voltage(in_vreg[i].vreg, 0, + in_vreg[i].max_voltage); if (in_vreg[i].post_off_sleep) usleep_range(in_vreg[i].post_off_sleep * 1000, (in_vreg[i].post_off_sleep * 1000) + 10); diff --git a/msm/sde_power_handle.c b/msm/sde_power_handle.c index 50124f9f7d..ff94796112 100644 --- a/msm/sde_power_handle.c +++ b/msm/sde_power_handle.c @@ -574,10 +574,10 @@ int sde_power_resource_init(struct platform_device *pdev, goto parse_vreg_err; } - rc = msm_dss_config_vreg(&pdev->dev, + rc = msm_dss_get_vreg(&pdev->dev, mp->vreg_config, mp->num_vreg, 1); if (rc) { - pr_err("vreg config failed rc=%d\n", rc); + pr_err("get config failed rc=%d\n", rc); goto vreg_err; } @@ -613,7 +613,7 @@ bus_err: clkset_err: msm_dss_put_clk(mp->clk_config, mp->num_clk); clkget_err: - msm_dss_config_vreg(&pdev->dev, mp->vreg_config, mp->num_vreg, 0); + msm_dss_get_vreg(&pdev->dev, mp->vreg_config, mp->num_vreg, 0); vreg_err: if (mp->vreg_config) devm_kfree(&pdev->dev, mp->vreg_config); @@ -653,7 +653,7 @@ void sde_power_resource_deinit(struct platform_device *pdev, msm_dss_put_clk(mp->clk_config, mp->num_clk); - msm_dss_config_vreg(&pdev->dev, mp->vreg_config, mp->num_vreg, 0); + msm_dss_get_vreg(&pdev->dev, mp->vreg_config, mp->num_vreg, 0); if (mp->clk_config) devm_kfree(&pdev->dev, mp->clk_config);