Skip to contentSkip to conversation

omapdrm: hdmi4_cec: Fix CEC clock handling for PM

PATCH Superseded Tony Lindgren 3 participants 4 messages Mar 25, 2019 – Mar 26, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 omapdrm: hdmi4_cec: Fix CEC clock handling for PM

If CONFIG_OMAP4_DSS_HDMI_CEC is enabled in .config, deeper SoC idle states are blocked because the CEC clock gets always enabled on init.

Let's fix the issue by moving the CEC clock handling to happen later in hdmi_cec_adap_enable() as suggested by Hans Verkuil <[email protected]>. This way the CEC clock gets only enabled when needed. This can be tested by doing cec-ctl --playback to enable the CEC, and doing cec-ctl --clear to disable it.

Let's also fix the typo for "divider" in the comments while at it.

Fixes 8d7f934df8d8 ("omapdrm: hdmi4_cec: add OMAP4 HDMI CEC support")
Cc Hans Verkuil <[email protected]>
Cc Jyri Sarha <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +10 -6
@@ -169,12 +169,19 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int temp, err;
 
-	if (!enable) {
+	if (enable) {
+		/*
+		 * Initialize CEC clock divider: CEC needs 2MHz clock hence
+		 * set the divider to 24 to get 48/24=2MHz clock
+		 */
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
+	} else {
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_0, 0);
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_1, 0);
 		REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
 		hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
 		hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 		hdmi4_core_disable(core);
 		return 0;
 	}
@@ -333,11 +340,8 @@ int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core,
 		return ret;
 	core->wp = wp;
 
-	/*
-	 * Initialize CEC clock divider: CEC needs 2MHz clock hence
-	 * set the devider to 24 to get 48/24=2MHz clock
-	 */
-	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
+	/* Disable clock initially, hdmi_cec_adap_enable() manages it */
+	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 
 	ret = cec_register_adapter(core->adap, &pdev->dev);
 	if (ret < 0) {
Signature · 5 lines
2.21.0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

Hi Tony,

Thank you for the patch.

Quoted 9 lines · Tony Lindgren

If CONFIG_OMAP4_DSS_HDMI_CEC is enabled in .config, deeper SoC idle states are blocked because the CEC clock gets always enabled on init.

Let's fix the issue by moving the CEC clock handling to happen later in hdmi_cec_adap_enable() as suggested by Hans Verkuil <[email protected]>. This way the CEC clock gets only enabled when needed. This can be tested by doing cec-ctl --playback to enable the CEC, and doing cec-ctl --clear to disable it.

Quoted 8 lines

Let's also fix the typo for "divider" in the comments while at it.

Fixes 8d7f934df8d8 ("omapdrm: hdmi4_cec: add OMAP4 HDMI CEC support")
Cc Hans Verkuil <[email protected]>
Cc Jyri Sarha <[email protected]>
Cc Laurent Pinchart <[email protected]>
Quoted 42 lines
---
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +10 -6
@@ -169,12 +169,19 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int temp, err;
 
-	if (!enable) {
+	if (enable) {
+		/*
+		 * Initialize CEC clock divider: CEC needs 2MHz clock hence
+		 * set the divider to 24 to get 48/24=2MHz clock
+		 */
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
+	} else {
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_0, 0);
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_1, 0);
 		REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
 		hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
 		hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 		hdmi4_core_disable(core);
 		return 0;
 	}
@@ -333,11 +340,8 @@ int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core,
 		return ret;
 	core->wp = wp;
 
-	/*
-	 * Initialize CEC clock divider: CEC needs 2MHz clock hence
-	 * set the devider to 24 to get 48/24=2MHz clock
-	 */
-	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
+	/* Disable clock initially, hdmi_cec_adap_enable() manages it */
+	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 
 	ret = cec_register_adapter(core->adap, &pdev->dev);
 	if (ret < 0) {
Signature · 7 lines
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Tony Lindgren
Quoted 25 lines · Tony Lindgren

If CONFIG_OMAP4_DSS_HDMI_CEC is enabled in .config, deeper SoC idle states are blocked because the CEC clock gets always enabled on init.

Let's fix the issue by moving the CEC clock handling to happen later in hdmi_cec_adap_enable() as suggested by Hans Verkuil <[email protected]>. This way the CEC clock gets only enabled when needed. This can be tested by doing cec-ctl --playback to enable the CEC, and doing cec-ctl --clear to disable it.

Let's also fix the typo for "divider" in the comments while at it.

Fixes 8d7f934df8d8 ("omapdrm: hdmi4_cec: add OMAP4 HDMI CEC support")
Cc Hans Verkuil <[email protected]>
Cc Jyri Sarha <[email protected]>
Cc Laurent Pinchart <[email protected]>
---
 drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) · line 177

Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +6 -1
@@ -169,12 +169,19 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int temp, err;
 
-	if (!enable) {
+	if (enable) {
+		/*
+		 * Initialize CEC clock divider: CEC needs 2MHz clock hence
+		 * set the divider to 24 to get 48/24=2MHz clock
+		 */
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);

Please move this to after the 'if'. That's where all the other 'enable' code is.

Regards,

Hans

Quoted 15 lines
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +2 -0
+	} else {
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_0, 0);
 		hdmi_write_reg(core->base, HDMI_CEC_INT_ENABLE_1, 0);
 		REG_FLD_MOD(core->base, HDMI_CORE_SYS_INTR_UNMASK4, 0, 3, 3);
 		hdmi_wp_clear_irqenable(core->wp, HDMI_IRQ_CORE);
 		hdmi_wp_set_irqstatus(core->wp, HDMI_IRQ_CORE);
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 		hdmi4_core_disable(core);
 		return 0;
 	}
@@ -333,11 +340,8 @@ int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core,
 		return ret;
 	core->wp = wp;
 

drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c int hdmi4_cec_init(struct platform_device *pdev, struct hdmi_core_data *core, · line 347

Quoted 10 lines
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +2 -5
-	/*
-	 * Initialize CEC clock divider: CEC needs 2MHz clock hence
-	 * set the devider to 24 to get 48/24=2MHz clock
-	 */
-	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);
+	/* Disable clock initially, hdmi_cec_adap_enable() manages it */
+	REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0, 5, 0);
 
 	ret = cec_register_adapter(core->adap, &pdev->dev);
 	if (ret < 0) {

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw
Quoted 5 lines · Hans Verkuil
Quoted 4 lines · Tony Lindgren
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +0 -0
@@ -169,12 +169,19 @@ static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int temp, err;
 
Quoted 10 lines

drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable) · line 177

Quoted 7 lines
drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c +6 -1
-	if (!enable) {
+	if (enable) {
+		/*
+		 * Initialize CEC clock divider: CEC needs 2MHz clock hence
+		 * set the divider to 24 to get 48/24=2MHz clock
+		 */
+		REG_FLD_MOD(core->wp->base, HDMI_WP_CLK, 0x18, 5, 0);

Please move this to after the 'if'. That's where all the other 'enable' code is.

Oops yeah that's better, will post v2 shortly.

Regards,

Tony
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel