mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 06:01:57 +00:00
drm/bridge: dw-hdmi: Simplify clock handling
Make use of devm_clk_get_enabled() to replace devm_clk_get() and clk_prepare_enable() for isfr and iahb clocks, and drop the now unnecessary calls to clk_disable_unprepare(). Similarly, use devm_clk_get_optional_enabled() helper for cec clock, which additionally allows to remove the -ENOENT test. Moreover, the clock related members of struct dw_hdmi are not required anymore, hence drop them. Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Reviewed-by: Robert Foss <rfoss@kernel.org> Signed-off-by: Robert Foss <rfoss@kernel.org> Link: https://patchwork.freedesktop.org/patch/msgid/20240813-dw-hdmi-simple-clk-v1-1-78d45cef02a9@collabora.com
This commit is contained in:
parent
fe828fbd87
commit
737ad37763
@ -138,9 +138,6 @@ struct dw_hdmi {
|
||||
struct platform_device *audio;
|
||||
struct platform_device *cec;
|
||||
struct device *dev;
|
||||
struct clk *isfr_clk;
|
||||
struct clk *iahb_clk;
|
||||
struct clk *cec_clk;
|
||||
struct dw_hdmi_i2c *i2c;
|
||||
|
||||
struct hdmi_data_info hdmi_data;
|
||||
@ -3326,6 +3323,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
||||
struct device_node *ddc_node;
|
||||
struct dw_hdmi_cec_data cec;
|
||||
struct dw_hdmi *hdmi;
|
||||
struct clk *clk;
|
||||
struct resource *iores = NULL;
|
||||
int irq;
|
||||
int ret;
|
||||
@ -3405,50 +3403,27 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
||||
hdmi->regm = plat_data->regm;
|
||||
}
|
||||
|
||||
hdmi->isfr_clk = devm_clk_get(hdmi->dev, "isfr");
|
||||
if (IS_ERR(hdmi->isfr_clk)) {
|
||||
ret = PTR_ERR(hdmi->isfr_clk);
|
||||
clk = devm_clk_get_enabled(hdmi->dev, "isfr");
|
||||
if (IS_ERR(clk)) {
|
||||
ret = PTR_ERR(clk);
|
||||
dev_err(hdmi->dev, "Unable to get HDMI isfr clk: %d\n", ret);
|
||||
goto err_res;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(hdmi->isfr_clk);
|
||||
if (ret) {
|
||||
dev_err(hdmi->dev, "Cannot enable HDMI isfr clock: %d\n", ret);
|
||||
clk = devm_clk_get_enabled(hdmi->dev, "iahb");
|
||||
if (IS_ERR(clk)) {
|
||||
ret = PTR_ERR(clk);
|
||||
dev_err(hdmi->dev, "Unable to get HDMI iahb clk: %d\n", ret);
|
||||
goto err_res;
|
||||
}
|
||||
|
||||
hdmi->iahb_clk = devm_clk_get(hdmi->dev, "iahb");
|
||||
if (IS_ERR(hdmi->iahb_clk)) {
|
||||
ret = PTR_ERR(hdmi->iahb_clk);
|
||||
dev_err(hdmi->dev, "Unable to get HDMI iahb clk: %d\n", ret);
|
||||
goto err_isfr;
|
||||
}
|
||||
|
||||
ret = clk_prepare_enable(hdmi->iahb_clk);
|
||||
if (ret) {
|
||||
dev_err(hdmi->dev, "Cannot enable HDMI iahb clock: %d\n", ret);
|
||||
goto err_isfr;
|
||||
}
|
||||
|
||||
hdmi->cec_clk = devm_clk_get(hdmi->dev, "cec");
|
||||
if (PTR_ERR(hdmi->cec_clk) == -ENOENT) {
|
||||
hdmi->cec_clk = NULL;
|
||||
} else if (IS_ERR(hdmi->cec_clk)) {
|
||||
ret = PTR_ERR(hdmi->cec_clk);
|
||||
clk = devm_clk_get_optional_enabled(hdmi->dev, "cec");
|
||||
if (IS_ERR(clk)) {
|
||||
ret = PTR_ERR(clk);
|
||||
if (ret != -EPROBE_DEFER)
|
||||
dev_err(hdmi->dev, "Cannot get HDMI cec clock: %d\n",
|
||||
ret);
|
||||
|
||||
hdmi->cec_clk = NULL;
|
||||
goto err_iahb;
|
||||
} else {
|
||||
ret = clk_prepare_enable(hdmi->cec_clk);
|
||||
if (ret) {
|
||||
dev_err(hdmi->dev, "Cannot enable HDMI cec clock: %d\n",
|
||||
ret);
|
||||
goto err_iahb;
|
||||
}
|
||||
goto err_res;
|
||||
}
|
||||
|
||||
/* Product and revision IDs */
|
||||
@ -3462,12 +3437,12 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
||||
dev_err(dev, "Unsupported HDMI controller (%04x:%02x:%02x)\n",
|
||||
hdmi->version, prod_id0, prod_id1);
|
||||
ret = -ENODEV;
|
||||
goto err_iahb;
|
||||
goto err_res;
|
||||
}
|
||||
|
||||
ret = dw_hdmi_detect_phy(hdmi);
|
||||
if (ret < 0)
|
||||
goto err_iahb;
|
||||
goto err_res;
|
||||
|
||||
dev_info(dev, "Detected HDMI TX controller v%x.%03x %s HDCP (%s)\n",
|
||||
hdmi->version >> 12, hdmi->version & 0xfff,
|
||||
@ -3479,14 +3454,14 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0) {
|
||||
ret = irq;
|
||||
goto err_iahb;
|
||||
goto err_res;
|
||||
}
|
||||
|
||||
ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq,
|
||||
dw_hdmi_irq, IRQF_SHARED,
|
||||
dev_name(dev), hdmi);
|
||||
if (ret)
|
||||
goto err_iahb;
|
||||
goto err_res;
|
||||
|
||||
/*
|
||||
* To prevent overflows in HDMI_IH_FC_STAT2, set the clk regenerator
|
||||
@ -3603,11 +3578,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
|
||||
|
||||
return hdmi;
|
||||
|
||||
err_iahb:
|
||||
clk_disable_unprepare(hdmi->iahb_clk);
|
||||
clk_disable_unprepare(hdmi->cec_clk);
|
||||
err_isfr:
|
||||
clk_disable_unprepare(hdmi->isfr_clk);
|
||||
err_res:
|
||||
i2c_put_adapter(hdmi->ddc);
|
||||
|
||||
@ -3627,10 +3597,6 @@ void dw_hdmi_remove(struct dw_hdmi *hdmi)
|
||||
/* Disable all interrupts */
|
||||
hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0);
|
||||
|
||||
clk_disable_unprepare(hdmi->iahb_clk);
|
||||
clk_disable_unprepare(hdmi->isfr_clk);
|
||||
clk_disable_unprepare(hdmi->cec_clk);
|
||||
|
||||
if (hdmi->i2c)
|
||||
i2c_del_adapter(&hdmi->i2c->adap);
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user