Commit d2a80cb5 authored by Cristian Ciocaltea's avatar Cristian Ciocaltea Committed by Heiko Stuebner

drm/rockchip: dw_hdmi: Simplify clock handling

Make use of devm_clk_get_optional_enabled() to replace devm_clk_get()
and clk_prepare_enable() for ref_clk and drop the now unnecessary calls
to clk_disable_unprepare().

Additionally, use devm_clk_get_optional() helper for grf_clk to replace
the open coding call to devm_clk_get() followed by the -ENOENT test.
Signed-off-by: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20240813-dw-hdmi-rockchip-cleanup-v1-2-b3e73b5f4fd6@collabora.com
parent 1b8f576c
...@@ -209,6 +209,7 @@ static const struct dw_hdmi_phy_config rockchip_phy_config[] = { ...@@ -209,6 +209,7 @@ static const struct dw_hdmi_phy_config rockchip_phy_config[] = {
static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi) static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
{ {
struct device_node *np = hdmi->dev->of_node; struct device_node *np = hdmi->dev->of_node;
int ret;
hdmi->regmap = syscon_regmap_lookup_by_phandle(np, "rockchip,grf"); hdmi->regmap = syscon_regmap_lookup_by_phandle(np, "rockchip,grf");
if (IS_ERR(hdmi->regmap)) { if (IS_ERR(hdmi->regmap)) {
...@@ -216,25 +217,23 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi) ...@@ -216,25 +217,23 @@ static int rockchip_hdmi_parse_dt(struct rockchip_hdmi *hdmi)
return PTR_ERR(hdmi->regmap); return PTR_ERR(hdmi->regmap);
} }
hdmi->ref_clk = devm_clk_get_optional(hdmi->dev, "ref"); hdmi->ref_clk = devm_clk_get_optional_enabled(hdmi->dev, "ref");
if (!hdmi->ref_clk) if (!hdmi->ref_clk)
hdmi->ref_clk = devm_clk_get_optional(hdmi->dev, "vpll"); hdmi->ref_clk = devm_clk_get_optional_enabled(hdmi->dev, "vpll");
if (PTR_ERR(hdmi->ref_clk) == -EPROBE_DEFER) { if (IS_ERR(hdmi->ref_clk)) {
return -EPROBE_DEFER; ret = PTR_ERR(hdmi->ref_clk);
} else if (IS_ERR(hdmi->ref_clk)) { if (ret != -EPROBE_DEFER)
drm_err(hdmi, "failed to get reference clock\n"); drm_err(hdmi, "failed to get reference clock\n");
return PTR_ERR(hdmi->ref_clk); return ret;
} }
hdmi->grf_clk = devm_clk_get(hdmi->dev, "grf"); hdmi->grf_clk = devm_clk_get_optional(hdmi->dev, "grf");
if (PTR_ERR(hdmi->grf_clk) == -ENOENT) { if (IS_ERR(hdmi->grf_clk)) {
hdmi->grf_clk = NULL; ret = PTR_ERR(hdmi->grf_clk);
} else if (PTR_ERR(hdmi->grf_clk) == -EPROBE_DEFER) { if (ret != -EPROBE_DEFER)
return -EPROBE_DEFER; drm_err(hdmi, "failed to get grf clock\n");
} else if (IS_ERR(hdmi->grf_clk)) { return ret;
drm_err(hdmi, "failed to get grf clock\n");
return PTR_ERR(hdmi->grf_clk);
} }
hdmi->avdd_0v9 = devm_regulator_get(hdmi->dev, "avdd-0v9"); hdmi->avdd_0v9 = devm_regulator_get(hdmi->dev, "avdd-0v9");
...@@ -615,12 +614,6 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, ...@@ -615,12 +614,6 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
goto err_avdd_1v8; goto err_avdd_1v8;
} }
ret = clk_prepare_enable(hdmi->ref_clk);
if (ret) {
drm_err(hdmi, "Failed to enable HDMI reference clock: %d\n", ret);
goto err_clk;
}
if (hdmi->chip_data == &rk3568_chip_data) { if (hdmi->chip_data == &rk3568_chip_data) {
regmap_write(hdmi->regmap, RK3568_GRF_VO_CON1, regmap_write(hdmi->regmap, RK3568_GRF_VO_CON1,
HIWORD_UPDATE(RK3568_HDMI_SDAIN_MSK | HIWORD_UPDATE(RK3568_HDMI_SDAIN_MSK |
...@@ -649,8 +642,6 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master, ...@@ -649,8 +642,6 @@ static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
err_bind: err_bind:
drm_encoder_cleanup(encoder); drm_encoder_cleanup(encoder);
clk_disable_unprepare(hdmi->ref_clk);
err_clk:
regulator_disable(hdmi->avdd_1v8); regulator_disable(hdmi->avdd_1v8);
err_avdd_1v8: err_avdd_1v8:
regulator_disable(hdmi->avdd_0v9); regulator_disable(hdmi->avdd_0v9);
...@@ -665,7 +656,6 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master, ...@@ -665,7 +656,6 @@ static void dw_hdmi_rockchip_unbind(struct device *dev, struct device *master,
dw_hdmi_unbind(hdmi->hdmi); dw_hdmi_unbind(hdmi->hdmi);
drm_encoder_cleanup(&hdmi->encoder.encoder); drm_encoder_cleanup(&hdmi->encoder.encoder);
clk_disable_unprepare(hdmi->ref_clk);
regulator_disable(hdmi->avdd_1v8); regulator_disable(hdmi->avdd_1v8);
regulator_disable(hdmi->avdd_0v9); regulator_disable(hdmi->avdd_0v9);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment