]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
drm: bridge: dw_hdmi: Add cec suspend/resume functions
authorSandor Yu <Sandor.yu@nxp.com>
Fri, 21 Jul 2023 12:44:15 +0000 (20:44 +0800)
committerNeil Armstrong <neil.armstrong@linaro.org>
Thu, 3 Aug 2023 08:28:43 +0000 (10:28 +0200)
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
drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c

index 9389ce526eb132d68e6b5096e7e4143983d1d97c..be21c11de1f2a135c8cce534e9cea85b4af3b613 100644 (file)
@@ -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);