Message ID | 20240522-fd-hdmi-hpd-v2-6-c30bdb7c5c7e@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/msm/hdmi: rework and fix the HPD even generation | expand |
On 5/22/2024 3:50 AM, Dmitry Baryshkov wrote: > The last platform using legacy clock names for HDMI block (APQ8064) > switched to new clock names in 5.16. It's time to stop caring about old > DT, drop hand-coded helpers and switch to clk_bulk_* API. > > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Reviewed-by: Jessica Zhang <quic_jesszhan@quicinc.com> > --- > drivers/gpu/drm/msm/hdmi/hdmi.c | 15 +++++--------- > drivers/gpu/drm/msm/hdmi/hdmi.h | 2 +- > drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 39 +++++++++++++------------------------ > 3 files changed, 19 insertions(+), 37 deletions(-) > > diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c > index c14e009f38b1..7ec4ca3b7597 100644 > --- a/drivers/gpu/drm/msm/hdmi/hdmi.c > +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c > @@ -469,17 +469,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) > if (!hdmi->hpd_clks) > return -ENOMEM; > > - for (i = 0; i < config->hpd_clk_cnt; i++) { > - struct clk *clk; > + for (i = 0; i < config->hpd_clk_cnt; i++) > + hdmi->hpd_clks[i].id = config->hpd_clk_names[i]; > > - clk = msm_clk_get(pdev, config->hpd_clk_names[i]); > - if (IS_ERR(clk)) > - return dev_err_probe(dev, PTR_ERR(clk), > - "failed to get hpd clk: %s\n", > - config->hpd_clk_names[i]); > - > - hdmi->hpd_clks[i] = clk; > - } > + ret = devm_clk_bulk_get(&pdev->dev, config->hpd_clk_cnt, hdmi->hpd_clks); > + if (ret) > + return ret; > > hdmi->extp_clk = devm_clk_get_optional(&pdev->dev, "extp"); > if (IS_ERR(hdmi->extp_clk)) > diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h > index c0d60ed23b75..eeba85ffef09 100644 > --- a/drivers/gpu/drm/msm/hdmi/hdmi.h > +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h > @@ -50,7 +50,7 @@ struct hdmi { > > struct regulator_bulk_data *hpd_regs; > struct regulator_bulk_data *pwr_regs; > - struct clk **hpd_clks; > + struct clk_bulk_data *hpd_clks; > struct clk *extp_clk; > > struct gpio_desc *hpd_gpiod; > diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c > index 7ae69b14e953..36266aa626dc 100644 > --- a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c > +++ b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c > @@ -60,27 +60,6 @@ static void msm_hdmi_phy_reset(struct hdmi *hdmi) > } > } > > -static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) > -{ > - const struct hdmi_platform_config *config = hdmi->config; > - struct device *dev = &hdmi->pdev->dev; > - int i, ret; > - > - if (enable) { > - for (i = 0; i < config->hpd_clk_cnt; i++) { > - ret = clk_prepare_enable(hdmi->hpd_clks[i]); > - if (ret) { > - DRM_DEV_ERROR(dev, > - "failed to enable hpd clk: %s (%d)\n", > - config->hpd_clk_names[i], ret); > - } > - } > - } else { > - for (i = config->hpd_clk_cnt - 1; i >= 0; i--) > - clk_disable_unprepare(hdmi->hpd_clks[i]); > - } > -} > - > int msm_hdmi_hpd_enable(struct drm_bridge *bridge) > { > struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); > @@ -107,7 +86,9 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge) > gpiod_set_value_cansleep(hdmi->hpd_gpiod, 1); > > pm_runtime_get_sync(dev); > - enable_hpd_clocks(hdmi, true); > + ret = clk_bulk_prepare_enable(config->hpd_clk_cnt, hdmi->hpd_clks); > + if (ret) > + goto fail; > > msm_hdmi_set_mode(hdmi, false); > msm_hdmi_phy_reset(hdmi); > @@ -149,7 +130,7 @@ void msm_hdmi_hpd_disable(struct hdmi *hdmi) > > msm_hdmi_set_mode(hdmi, false); > > - enable_hpd_clocks(hdmi, false); > + clk_bulk_disable_unprepare(config->hpd_clk_cnt, hdmi->hpd_clks); > pm_runtime_put(dev); > > ret = pinctrl_pm_select_sleep_state(dev); > @@ -193,14 +174,20 @@ void msm_hdmi_hpd_irq(struct drm_bridge *bridge) > > static enum drm_connector_status detect_reg(struct hdmi *hdmi) > { > - uint32_t hpd_int_status; > + const struct hdmi_platform_config *config = hdmi->config; > + uint32_t hpd_int_status = 0; > + int ret; > > pm_runtime_get_sync(&hdmi->pdev->dev); > - enable_hpd_clocks(hdmi, true); > + ret = clk_bulk_prepare_enable(config->hpd_clk_cnt, hdmi->hpd_clks); > + if (ret) > + goto out; > > hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); > > - enable_hpd_clocks(hdmi, false); > + clk_bulk_disable_unprepare(config->hpd_clk_cnt, hdmi->hpd_clks); > + > +out: > pm_runtime_put(&hdmi->pdev->dev); > > return (hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED) ? > > -- > 2.39.2 >
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index c14e009f38b1..7ec4ca3b7597 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -469,17 +469,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) if (!hdmi->hpd_clks) return -ENOMEM; - for (i = 0; i < config->hpd_clk_cnt; i++) { - struct clk *clk; + for (i = 0; i < config->hpd_clk_cnt; i++) + hdmi->hpd_clks[i].id = config->hpd_clk_names[i]; - clk = msm_clk_get(pdev, config->hpd_clk_names[i]); - if (IS_ERR(clk)) - return dev_err_probe(dev, PTR_ERR(clk), - "failed to get hpd clk: %s\n", - config->hpd_clk_names[i]); - - hdmi->hpd_clks[i] = clk; - } + ret = devm_clk_bulk_get(&pdev->dev, config->hpd_clk_cnt, hdmi->hpd_clks); + if (ret) + return ret; hdmi->extp_clk = devm_clk_get_optional(&pdev->dev, "extp"); if (IS_ERR(hdmi->extp_clk)) diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.h b/drivers/gpu/drm/msm/hdmi/hdmi.h index c0d60ed23b75..eeba85ffef09 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.h +++ b/drivers/gpu/drm/msm/hdmi/hdmi.h @@ -50,7 +50,7 @@ struct hdmi { struct regulator_bulk_data *hpd_regs; struct regulator_bulk_data *pwr_regs; - struct clk **hpd_clks; + struct clk_bulk_data *hpd_clks; struct clk *extp_clk; struct gpio_desc *hpd_gpiod; diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c index 7ae69b14e953..36266aa626dc 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_hpd.c @@ -60,27 +60,6 @@ static void msm_hdmi_phy_reset(struct hdmi *hdmi) } } -static void enable_hpd_clocks(struct hdmi *hdmi, bool enable) -{ - const struct hdmi_platform_config *config = hdmi->config; - struct device *dev = &hdmi->pdev->dev; - int i, ret; - - if (enable) { - for (i = 0; i < config->hpd_clk_cnt; i++) { - ret = clk_prepare_enable(hdmi->hpd_clks[i]); - if (ret) { - DRM_DEV_ERROR(dev, - "failed to enable hpd clk: %s (%d)\n", - config->hpd_clk_names[i], ret); - } - } - } else { - for (i = config->hpd_clk_cnt - 1; i >= 0; i--) - clk_disable_unprepare(hdmi->hpd_clks[i]); - } -} - int msm_hdmi_hpd_enable(struct drm_bridge *bridge) { struct hdmi_bridge *hdmi_bridge = to_hdmi_bridge(bridge); @@ -107,7 +86,9 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge) gpiod_set_value_cansleep(hdmi->hpd_gpiod, 1); pm_runtime_get_sync(dev); - enable_hpd_clocks(hdmi, true); + ret = clk_bulk_prepare_enable(config->hpd_clk_cnt, hdmi->hpd_clks); + if (ret) + goto fail; msm_hdmi_set_mode(hdmi, false); msm_hdmi_phy_reset(hdmi); @@ -149,7 +130,7 @@ void msm_hdmi_hpd_disable(struct hdmi *hdmi) msm_hdmi_set_mode(hdmi, false); - enable_hpd_clocks(hdmi, false); + clk_bulk_disable_unprepare(config->hpd_clk_cnt, hdmi->hpd_clks); pm_runtime_put(dev); ret = pinctrl_pm_select_sleep_state(dev); @@ -193,14 +174,20 @@ void msm_hdmi_hpd_irq(struct drm_bridge *bridge) static enum drm_connector_status detect_reg(struct hdmi *hdmi) { - uint32_t hpd_int_status; + const struct hdmi_platform_config *config = hdmi->config; + uint32_t hpd_int_status = 0; + int ret; pm_runtime_get_sync(&hdmi->pdev->dev); - enable_hpd_clocks(hdmi, true); + ret = clk_bulk_prepare_enable(config->hpd_clk_cnt, hdmi->hpd_clks); + if (ret) + goto out; hpd_int_status = hdmi_read(hdmi, REG_HDMI_HPD_INT_STATUS); - enable_hpd_clocks(hdmi, false); + clk_bulk_disable_unprepare(config->hpd_clk_cnt, hdmi->hpd_clks); + +out: pm_runtime_put(&hdmi->pdev->dev); return (hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED) ?
The last platform using legacy clock names for HDMI block (APQ8064) switched to new clock names in 5.16. It's time to stop caring about old DT, drop hand-coded helpers and switch to clk_bulk_* API. Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> --- drivers/gpu/drm/msm/hdmi/hdmi.c | 15 +++++--------- drivers/gpu/drm/msm/hdmi/hdmi.h | 2 +- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 39 +++++++++++++------------------------ 3 files changed, 19 insertions(+), 37 deletions(-)