Skip to contentSkip to conversation

drm: bridge: synopsys/dw-hdmi: Enable cec clock

PATCH Superseded Pierre-Hugues Husson 3 participants 5 messages Oct 26, 2017 – Nov 24, 2017

Subsystems (5)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm: bridge: synopsys/dw-hdmi: Enable cec clock

The documentation already mentions "cec" optional clock, but currently the driver doesn't enable it.

Changes:
v3:
- Drop useless braces

v2:
- Separate ENOENT errors from others
- Propagate other errors (especially -EPROBE_DEFER)

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +25 -0
index bf14214fa464..d82b9747a979 100644
@@ -138,6 +138,7 @@ struct dw_hdmi {
 	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;
@@ -2382,6 +2383,26 @@ __dw_hdmi_probe(struct platform_device *pdev,
 		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);
+		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;
+		}
+	}
+
 	/* Product and revision IDs */
 	hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8)
 		      | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0);
@@ -2518,6 +2539,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
 		cec_notifier_put(hdmi->cec_notifier);
 
 	clk_disable_unprepare(hdmi->iahb_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 err_isfr:
 	clk_disable_unprepare(hdmi->isfr_clk);
 err_res:
@@ -2541,6 +2564,8 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
 
 	clk_disable_unprepare(hdmi->iahb_clk);
 	clk_disable_unprepare(hdmi->isfr_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 
 	if (hdmi->i2c)
 		i2c_del_adapter(&hdmi->i2c->adap);
Signature · 1 line
2.14.2
#1 lore raw

I didn't see this merged for 4.15, is it too late to include this? All other changes needed to get CEC to work on rk3288 and rk3399 are all merged.

Regards,

Hans

Quoted 74 lines · Pierre-Hugues Husson

The documentation already mentions "cec" optional clock, but currently the driver doesn't enable it.

Changes:
v3:
- Drop useless braces

v2:
- Separate ENOENT errors from others
- Propagate other errors (especially -EPROBE_DEFER)

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +25 -0
index bf14214fa464..d82b9747a979 100644
@@ -138,6 +138,7 @@ struct dw_hdmi {
 	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;
@@ -2382,6 +2383,26 @@ __dw_hdmi_probe(struct platform_device *pdev,
 		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);
+		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;
+		}
+	}
+
 	/* Product and revision IDs */
 	hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8)
 		      | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0);
@@ -2518,6 +2539,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
 		cec_notifier_put(hdmi->cec_notifier);
 
 	clk_disable_unprepare(hdmi->iahb_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 err_isfr:
 	clk_disable_unprepare(hdmi->isfr_clk);
 err_res:
@@ -2541,6 +2564,8 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
 
 	clk_disable_unprepare(hdmi->iahb_clk);
 	clk_disable_unprepare(hdmi->isfr_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 
 	if (hdmi->i2c)
 		i2c_del_adapter(&hdmi->i2c->adap);
#2 lore raw

Hi,

Quoted 2 lines · Hans Verkuil

I didn't see this merged for 4.15, is it too late to include this? All other changes needed to get CEC to work on rk3288 and rk3399 are all merged.

Sorry for the late reply. I was out last week.

Dave recently sent the second pull request for 4.15, so I think it would be hard to get it in the merge window now. We could target it for the 4.15-rcs since it is preventing the feature from working. Is it possible to rephrase the commit message a bit so that it's clear that we need it for CEC to work?

Thanks,
Archit

Quoted 81 lines

Regards,

Hans

Quoted 74 lines · Pierre-Hugues Husson

The documentation already mentions "cec" optional clock, but currently the driver doesn't enable it.

Changes:
v3:
- Drop useless braces

v2:
- Separate ENOENT errors from others
- Propagate other errors (especially -EPROBE_DEFER)

---
  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +25 -0
index bf14214fa464..d82b9747a979 100644
@@ -138,6 +138,7 @@ struct dw_hdmi {
  	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;
@@ -2382,6 +2383,26 @@ __dw_hdmi_probe(struct platform_device *pdev,
  		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);
+		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;
+		}
+	}
+
  	/* Product and revision IDs */
  	hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8)
  		      | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0);
@@ -2518,6 +2539,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
  		cec_notifier_put(hdmi->cec_notifier);
 
  	clk_disable_unprepare(hdmi->iahb_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
  err_isfr:
  	clk_disable_unprepare(hdmi->isfr_clk);
  err_res:
@@ -2541,6 +2564,8 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
 
  	clk_disable_unprepare(hdmi->iahb_clk);
  	clk_disable_unprepare(hdmi->isfr_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 
  	if (hdmi->i2c)
  		i2c_del_adapter(&hdmi->i2c->adap);
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#3 lore raw
Quoted 6 lines · Archit Taneja

Hi,

Quoted 2 lines · Hans Verkuil

I didn't see this merged for 4.15, is it too late to include this? All other changes needed to get CEC to work on rk3288 and rk3399 are all merged.

Quoted 6 lines

Sorry for the late reply. I was out last week.

Dave recently sent the second pull request for 4.15, so I think it would be hard to get it in the merge window now. We could target it for the 4.15-rcs since it is preventing the feature from working. Is it possible to rephrase the commit message a bit so that it's clear that we need it for CEC to work?

While it is not my patch I would propose something like this:

"Support the "cec" optional clock. The documentation already mentions "cec" optional clock and it is used by several boards, but currently the driver doesn't enable it, thus preventing cec from working on those boards.

And even worse: a /dev/cecX device will appear for those boards, but it won't be functioning without configuring this clock."

I hadn't realized that last sentence until I started thinking about it, but this patch is really needed.

Regards,

Hans

Quoted 86 lines

Thanks,
Archit

Quoted 81 lines

Regards,

Hans

Quoted 74 lines · Pierre-Hugues Husson

The documentation already mentions "cec" optional clock, but currently the driver doesn't enable it.

Changes:
v3:
- Drop useless braces

v2:
- Separate ENOENT errors from others
- Propagate other errors (especially -EPROBE_DEFER)

---
  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 25 +++++++++++++++++++++++++
  1 file changed, 25 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +25 -0
index bf14214fa464..d82b9747a979 100644
@@ -138,6 +138,7 @@ struct dw_hdmi {
  	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;
@@ -2382,6 +2383,26 @@ __dw_hdmi_probe(struct platform_device *pdev,
  		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);
+		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;
+		}
+	}
+
  	/* Product and revision IDs */
  	hdmi->version = (hdmi_readb(hdmi, HDMI_DESIGN_ID) << 8)
  		      | (hdmi_readb(hdmi, HDMI_REVISION_ID) << 0);
@@ -2518,6 +2539,8 @@ __dw_hdmi_probe(struct platform_device *pdev,
  		cec_notifier_put(hdmi->cec_notifier);
 
  	clk_disable_unprepare(hdmi->iahb_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
  err_isfr:
  	clk_disable_unprepare(hdmi->isfr_clk);
  err_res:
@@ -2541,6 +2564,8 @@ static void __dw_hdmi_remove(struct dw_hdmi *hdmi)
 
  	clk_disable_unprepare(hdmi->iahb_clk);
  	clk_disable_unprepare(hdmi->isfr_clk);
+	if (hdmi->cec_clk)
+		clk_disable_unprepare(hdmi->cec_clk);
 
  	if (hdmi->i2c)
  		i2c_del_adapter(&hdmi->i2c->adap);
#4 lore raw

Hi,

Quoted 17 lines
Quoted 10 lines · Hans Verkuil
Quoted 2 lines

I didn't see this merged for 4.15, is it too late to include this? All other changes needed to get CEC to work on rk3288 and rk3399 are all merged.

Sorry for the late reply. I was out last week.

Dave recently sent the second pull request for 4.15, so I think it would be hard to get it in the merge window now. We could target it for the 4.15-rcs since it is preventing the feature from working. Is it possible to rephrase the commit message a bit so that it's clear that we need it for CEC to work?

While it is not my patch I would propose something like this:

"Support the "cec" optional clock. The documentation already mentions "cec" optional clock and it is used by several boards, but currently the driver doesn't enable it, thus preventing cec from working on those boards.

Quoted 5 lines

And even worse: a /dev/cecX device will appear for those boards, but it won't be functioning without configuring this clock."

I hadn't realized that last sentence until I started thinking about it, but this patch is really needed.

This change looks good to me.

Archit, I can send this as a new version of the patch tomorrow if you need it.

Regards,