Skip to contentSkip to conversation

drm: bridge: dw_hdmi: Add cec suspend/resume functions

PATCH Applied Sandor Yu 3 participants 4 messages Jul 21, 2023 – Aug 3, 2023

Subsystems (3)
lore
Share & tools
lore

Sandor Yu

author
#0 lore raw

PATCH 1/1 drm: bridge: dw_hdmi: Add cec suspend/resume functions

CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +37 -0
index 9389ce526eb13..be21c11de1f2a 100644
@@ -62,6 +62,10 @@ struct dw_hdmi_cec {
 	bool rx_done;
 	struct cec_notifier *notify;
 	int irq;
+
+	u8 regs_polarity;
+	u8 regs_mask;
+	u8 regs_mute_stat0;
 };
 
 static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset)
@@ -304,11 +308,44 @@ static void dw_hdmi_cec_remove(struct platform_device *pdev)
 	cec_unregister_adapter(cec->adap);
 }
 
+static int __maybe_unused dw_hdmi_cec_resume(struct device *dev)
+{
+	struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
+
+	/* Restore logical address */
+	dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L);
+	dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H);
+
+	/* Restore interrupt status/mask registers */
+	dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY);
+	dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK);
+	dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0);
+
+	return 0;
+}
+
+static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev)
+{
+	struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
+
+	/* store interrupt status/mask registers */
+	 cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY);
+	 cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK);
+	 cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0);
+
+	return 0;
+}
+
+static const struct dev_pm_ops dw_hdmi_cec_pm = {
+	SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume)
+};
+
 static struct platform_driver dw_hdmi_cec_driver = {
 	.probe	= dw_hdmi_cec_probe,
 	.remove_new = dw_hdmi_cec_remove,
 	.driver = {
 		.name = "dw-hdmi-cec",
+		.pm = &dw_hdmi_cec_pm,
 	},
 };
 module_platform_driver(dw_hdmi_cec_driver);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 61 lines · Sandor Yu

CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.

---
  drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++
  1 file changed, 37 insertions(+)
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +35 -0
index 9389ce526eb13..be21c11de1f2a 100644
@@ -62,6 +62,10 @@ struct dw_hdmi_cec {
  	bool rx_done;
  	struct cec_notifier *notify;
  	int irq;
+
+	u8 regs_polarity;
+	u8 regs_mask;
+	u8 regs_mute_stat0;
  };
 
  static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset)
@@ -304,11 +308,44 @@ static void dw_hdmi_cec_remove(struct platform_device *pdev)
  	cec_unregister_adapter(cec->adap);
  }
 
+static int __maybe_unused dw_hdmi_cec_resume(struct device *dev)
+{
+	struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
+
+	/* Restore logical address */
+	dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L);
+	dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H);
+
+	/* Restore interrupt status/mask registers */
+	dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY);
+	dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK);
+	dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0);
+
+	return 0;
+}
+
+static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev)
+{
+	struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
+
+	/* store interrupt status/mask registers */
+	 cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY);
+	 cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK);
+	 cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0);
+
+	return 0;
+}
+
+static const struct dev_pm_ops dw_hdmi_cec_pm = {
+	SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume)
+};

drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c static void dw_hdmi_cec_remove(struct platform_device *pdev) · line 351

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c +2 -0
+
  static struct platform_driver dw_hdmi_cec_driver = {
  	.probe	= dw_hdmi_cec_probe,
  	.remove_new = dw_hdmi_cec_remove,
  	.driver = {
  		.name = "dw-hdmi-cec",
+		.pm = &dw_hdmi_cec_pm,
  	},
  };
  module_platform_driver(dw_hdmi_cec_driver);
maintainer Applied
#2 lore raw
In reply to Sandor Yu

Hi,

Quoted 8 lines · Sandor Yu

CEC interrupt status/mask and logical address registers
will be reset when device enter suspend.
It will cause cec fail to work after device resume.
Add CEC suspend/resume functions, reinitialize logical address registers and restore interrupt status/mask registers after resume.

[...]

Thanks, Applied to https://anongit.freedesktop.org/git/drm/drm-misc.git (drm-misc-next)

[1/1] drm: bridge: dw_hdmi: Add cec suspend/resume functions

      https://cgit.freedesktop.org/drm/drm-misc/commit/?id=db1184e410744a680f92ca21e5acd5ae54510db8
Signature · 1 line
Neil
#3 lore raw
In reply to Sandor Yu
kernel test robot noticed the following build warnings:

Hi Sandor,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on linus/master v6.5-rc4 next-20230803] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Sandor-Yu/drm-bridge-dw_hdmi-Add-cec-suspend-resume-functions/20230721-204732
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20230721124415.1513223-1-Sandor.yu%40nxp.com
patch subject: [PATCH] drm: bridge: dw_hdmi: Add cec suspend/resume functions
config: riscv-randconfig-m031-20230730 (https://download.01.org/0day-ci/archive/20230803/[email protected]/config)
compiler: riscv64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230803/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

smatch warnings:
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c:332 dw_hdmi_cec_suspend() warn: inconsistent indenting

vim +332 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c

326
327 static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev)
328 {
329 struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
330
331 /* store interrupt status/mask registers */

 > 332		 cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY);

333 cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK);
334 cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0);
335
336 return 0;
337 }
338

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki