Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230721124415.1513223-1-Sandor.yu@nxp.com

authored by

Sandor Yu and committed by
Neil Armstrong
db1184e4 eae74888

+37
+37
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
··· 62 62 bool rx_done; 63 63 struct cec_notifier *notify; 64 64 int irq; 65 + 66 + u8 regs_polarity; 67 + u8 regs_mask; 68 + u8 regs_mute_stat0; 65 69 }; 66 70 67 71 static void dw_hdmi_write(struct dw_hdmi_cec *cec, u8 val, int offset) ··· 308 304 cec_unregister_adapter(cec->adap); 309 305 } 310 306 307 + static int __maybe_unused dw_hdmi_cec_resume(struct device *dev) 308 + { 309 + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); 310 + 311 + /* Restore logical address */ 312 + dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L); 313 + dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H); 314 + 315 + /* Restore interrupt status/mask registers */ 316 + dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY); 317 + dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK); 318 + dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0); 319 + 320 + return 0; 321 + } 322 + 323 + static int __maybe_unused dw_hdmi_cec_suspend(struct device *dev) 324 + { 325 + struct dw_hdmi_cec *cec = dev_get_drvdata(dev); 326 + 327 + /* store interrupt status/mask registers */ 328 + cec->regs_polarity = dw_hdmi_read(cec, HDMI_CEC_POLARITY); 329 + cec->regs_mask = dw_hdmi_read(cec, HDMI_CEC_MASK); 330 + cec->regs_mute_stat0 = dw_hdmi_read(cec, HDMI_IH_MUTE_CEC_STAT0); 331 + 332 + return 0; 333 + } 334 + 335 + static const struct dev_pm_ops dw_hdmi_cec_pm = { 336 + SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume) 337 + }; 338 + 311 339 static struct platform_driver dw_hdmi_cec_driver = { 312 340 .probe = dw_hdmi_cec_probe, 313 341 .remove_new = dw_hdmi_cec_remove, 314 342 .driver = { 315 343 .name = "dw-hdmi-cec", 344 + .pm = &dw_hdmi_cec_pm, 316 345 }, 317 346 }; 318 347 module_platform_driver(dw_hdmi_cec_driver);