1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

drm/msm/hdmi: use bulk regulator API

Switch to using bulk regulator API instead of hand coding loops.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
Link: https://lore.kernel.org/r/20211015001100.4193241-1-dmitry.baryshkov@linaro.org
Signed-off-by: Rob Clark <robdclark@chromium.org>
This commit is contained in:
Dmitry Baryshkov 2021-10-15 03:10:59 +03:00 committed by Rob Clark
parent 89e56d5ed1
commit 31b3b1f5e3
5 changed files with 40 additions and 77 deletions

View file

@ -152,21 +152,15 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto fail;
} }
for (i = 0; i < config->hpd_reg_cnt; i++) { for (i = 0; i < config->hpd_reg_cnt; i++)
struct regulator *reg; hdmi->hpd_regs[i].supply = config->hpd_reg_names[i];
reg = devm_regulator_get(&pdev->dev, ret = devm_regulator_bulk_get(&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs);
config->hpd_reg_names[i]); if (ret) {
if (IS_ERR(reg)) { DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %d\n", ret);
ret = PTR_ERR(reg);
DRM_DEV_ERROR(&pdev->dev, "failed to get hpd regulator: %s (%d)\n",
config->hpd_reg_names[i], ret);
goto fail; goto fail;
} }
hdmi->hpd_regs[i] = reg;
}
hdmi->pwr_regs = devm_kcalloc(&pdev->dev, hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
config->pwr_reg_cnt, config->pwr_reg_cnt,
sizeof(hdmi->pwr_regs[0]), sizeof(hdmi->pwr_regs[0]),
@ -175,21 +169,13 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
ret = -ENOMEM; ret = -ENOMEM;
goto fail; goto fail;
} }
for (i = 0; i < config->pwr_reg_cnt; i++) {
struct regulator *reg;
reg = devm_regulator_get(&pdev->dev, ret = devm_regulator_bulk_get(&pdev->dev, config->pwr_reg_cnt, hdmi->pwr_regs);
config->pwr_reg_names[i]); if (ret) {
if (IS_ERR(reg)) { DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %d\n", ret);
ret = PTR_ERR(reg);
DRM_DEV_ERROR(&pdev->dev, "failed to get pwr regulator: %s (%d)\n",
config->pwr_reg_names[i], ret);
goto fail; goto fail;
} }
hdmi->pwr_regs[i] = reg;
}
hdmi->hpd_clks = devm_kcalloc(&pdev->dev, hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
config->hpd_clk_cnt, config->hpd_clk_cnt,
sizeof(hdmi->hpd_clks[0]), sizeof(hdmi->hpd_clks[0]),

View file

@ -56,8 +56,8 @@ struct hdmi {
void __iomem *qfprom_mmio; void __iomem *qfprom_mmio;
phys_addr_t mmio_phy_addr; phys_addr_t mmio_phy_addr;
struct regulator **hpd_regs; struct regulator_bulk_data *hpd_regs;
struct regulator **pwr_regs; struct regulator_bulk_data *pwr_regs;
struct clk **hpd_clks; struct clk **hpd_clks;
struct clk **pwr_clks; struct clk **pwr_clks;
@ -163,7 +163,7 @@ struct hdmi_phy {
void __iomem *mmio; void __iomem *mmio;
struct hdmi_phy_cfg *cfg; struct hdmi_phy_cfg *cfg;
const struct hdmi_phy_funcs *funcs; const struct hdmi_phy_funcs *funcs;
struct regulator **regs; struct regulator_bulk_data *regs;
struct clk **clks; struct clk **clks;
}; };

View file

@ -28,13 +28,9 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)
pm_runtime_get_sync(&hdmi->pdev->dev); pm_runtime_get_sync(&hdmi->pdev->dev);
for (i = 0; i < config->pwr_reg_cnt; i++) { ret = regulator_bulk_enable(config->pwr_reg_cnt, hdmi->pwr_regs);
ret = regulator_enable(hdmi->pwr_regs[i]); if (ret)
if (ret) { DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %d\n", ret);
DRM_DEV_ERROR(dev->dev, "failed to enable pwr regulator: %s (%d)\n",
config->pwr_reg_names[i], ret);
}
}
if (config->pwr_clk_cnt > 0) { if (config->pwr_clk_cnt > 0) {
DBG("pixclock: %lu", hdmi->pixclock); DBG("pixclock: %lu", hdmi->pixclock);
@ -70,13 +66,9 @@ static void power_off(struct drm_bridge *bridge)
for (i = 0; i < config->pwr_clk_cnt; i++) for (i = 0; i < config->pwr_clk_cnt; i++)
clk_disable_unprepare(hdmi->pwr_clks[i]); clk_disable_unprepare(hdmi->pwr_clks[i]);
for (i = 0; i < config->pwr_reg_cnt; i++) { ret = regulator_bulk_disable(config->pwr_reg_cnt, hdmi->pwr_regs);
ret = regulator_disable(hdmi->pwr_regs[i]); if (ret)
if (ret) { DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %d\n", ret);
DRM_DEV_ERROR(dev->dev, "failed to disable pwr regulator: %s (%d)\n",
config->pwr_reg_names[i], ret);
}
}
pm_runtime_put_autosuspend(&hdmi->pdev->dev); pm_runtime_put_autosuspend(&hdmi->pdev->dev);
} }

View file

@ -146,17 +146,14 @@ int msm_hdmi_hpd_enable(struct drm_connector *connector)
const struct hdmi_platform_config *config = hdmi->config; const struct hdmi_platform_config *config = hdmi->config;
struct device *dev = &hdmi->pdev->dev; struct device *dev = &hdmi->pdev->dev;
uint32_t hpd_ctrl; uint32_t hpd_ctrl;
int i, ret; int ret;
unsigned long flags; unsigned long flags;
for (i = 0; i < config->hpd_reg_cnt; i++) { ret = regulator_bulk_enable(config->hpd_reg_cnt, hdmi->hpd_regs);
ret = regulator_enable(hdmi->hpd_regs[i]);
if (ret) { if (ret) {
DRM_DEV_ERROR(dev, "failed to enable hpd regulator: %s (%d)\n", DRM_DEV_ERROR(dev, "failed to enable hpd regulators: %d\n", ret);
config->hpd_reg_names[i], ret);
goto fail; goto fail;
} }
}
ret = pinctrl_pm_select_default_state(dev); ret = pinctrl_pm_select_default_state(dev);
if (ret) { if (ret) {
@ -207,7 +204,7 @@ static void hdp_disable(struct hdmi_connector *hdmi_connector)
struct hdmi *hdmi = hdmi_connector->hdmi; struct hdmi *hdmi = hdmi_connector->hdmi;
const struct hdmi_platform_config *config = hdmi->config; const struct hdmi_platform_config *config = hdmi->config;
struct device *dev = &hdmi->pdev->dev; struct device *dev = &hdmi->pdev->dev;
int i, ret = 0; int ret;
/* Disable HPD interrupt */ /* Disable HPD interrupt */
hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0); hdmi_write(hdmi, REG_HDMI_HPD_INT_CTRL, 0);
@ -225,12 +222,9 @@ static void hdp_disable(struct hdmi_connector *hdmi_connector)
if (ret) if (ret)
dev_warn(dev, "pinctrl state chg failed: %d\n", ret); dev_warn(dev, "pinctrl state chg failed: %d\n", ret);
for (i = 0; i < config->hpd_reg_cnt; i++) { ret = regulator_bulk_disable(config->hpd_reg_cnt, hdmi->hpd_regs);
ret = regulator_disable(hdmi->hpd_regs[i]);
if (ret) if (ret)
dev_warn(dev, "failed to disable hpd regulator: %s (%d)\n", dev_warn(dev, "failed to disable hpd regulator: %d\n", ret);
config->hpd_reg_names[i], ret);
}
} }
static void static void

View file

@ -23,24 +23,17 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy)
if (!phy->clks) if (!phy->clks)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < cfg->num_regs; i++) { for (i = 0; i < cfg->num_regs; i++)
struct regulator *reg; phy->regs[i].supply = cfg->reg_names[i];
reg = devm_regulator_get(dev, cfg->reg_names[i]); ret = devm_regulator_bulk_get(dev, cfg->num_regs, phy->regs);
if (IS_ERR(reg)) { if (ret) {
ret = PTR_ERR(reg); if (ret != -EPROBE_DEFER)
if (ret != -EPROBE_DEFER) { DRM_DEV_ERROR(dev, "failed to get phy regulators: %d\n", ret);
DRM_DEV_ERROR(dev,
"failed to get phy regulator: %s (%d)\n",
cfg->reg_names[i], ret);
}
return ret; return ret;
} }
phy->regs[i] = reg;
}
for (i = 0; i < cfg->num_clks; i++) { for (i = 0; i < cfg->num_clks; i++) {
struct clk *clk; struct clk *clk;
@ -66,11 +59,10 @@ int msm_hdmi_phy_resource_enable(struct hdmi_phy *phy)
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
for (i = 0; i < cfg->num_regs; i++) { ret = regulator_bulk_enable(cfg->num_regs, phy->regs);
ret = regulator_enable(phy->regs[i]); if (ret) {
if (ret) DRM_DEV_ERROR(dev, "failed to enable regulators: (%d)\n", ret);
DRM_DEV_ERROR(dev, "failed to enable regulator: %s (%d)\n", return ret;
cfg->reg_names[i], ret);
} }
for (i = 0; i < cfg->num_clks; i++) { for (i = 0; i < cfg->num_clks; i++) {
@ -92,8 +84,7 @@ void msm_hdmi_phy_resource_disable(struct hdmi_phy *phy)
for (i = cfg->num_clks - 1; i >= 0; i--) for (i = cfg->num_clks - 1; i >= 0; i--)
clk_disable_unprepare(phy->clks[i]); clk_disable_unprepare(phy->clks[i]);
for (i = cfg->num_regs - 1; i >= 0; i--) regulator_bulk_disable(cfg->num_regs, phy->regs);
regulator_disable(phy->regs[i]);
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
} }