Skip to content

Commit db1184e

Browse files
sandordevsuperna9999
authored andcommitted
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 <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent eae7488 commit db1184e

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ struct dw_hdmi_cec {
6262
bool rx_done;
6363
struct cec_notifier *notify;
6464
int irq;
65+
66+
u8 regs_polarity;
67+
u8 regs_mask;
68+
u8 regs_mute_stat0;
6569
};
6670

6771
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)
304308
cec_unregister_adapter(cec->adap);
305309
}
306310

311+
static int __maybe_unused dw_hdmi_cec_resume(struct device *dev)
312+
{
313+
struct dw_hdmi_cec *cec = dev_get_drvdata(dev);
314+
315+
/* Restore logical address */
316+
dw_hdmi_write(cec, cec->addresses & 255, HDMI_CEC_ADDR_L);
317+
dw_hdmi_write(cec, cec->addresses >> 8, HDMI_CEC_ADDR_H);
318+
319+
/* Restore interrupt status/mask registers */
320+
dw_hdmi_write(cec, cec->regs_polarity, HDMI_CEC_POLARITY);
321+
dw_hdmi_write(cec, cec->regs_mask, HDMI_CEC_MASK);
322+
dw_hdmi_write(cec, cec->regs_mute_stat0, HDMI_IH_MUTE_CEC_STAT0);
323+
324+
return 0;
325+
}
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+
339+
static const struct dev_pm_ops dw_hdmi_cec_pm = {
340+
SET_SYSTEM_SLEEP_PM_OPS(dw_hdmi_cec_suspend, dw_hdmi_cec_resume)
341+
};
342+
307343
static struct platform_driver dw_hdmi_cec_driver = {
308344
.probe = dw_hdmi_cec_probe,
309345
.remove_new = dw_hdmi_cec_remove,
310346
.driver = {
311347
.name = "dw-hdmi-cec",
348+
.pm = &dw_hdmi_cec_pm,
312349
},
313350
};
314351
module_platform_driver(dw_hdmi_cec_driver);

0 commit comments

Comments
 (0)