mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sandor Yu <Sandor.yu@nxp.com>
To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	andrzej.hajda@intel.com, narmstrong@baylibre.com,
	robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com,
	jonas@kwiboo.se, jernej.skrabec@gmail.com,
	hverkuil-cisco@xs4all.nl
Cc: Sandor.yu@nxp.com, shengjiu.wang@nxp.com, cai.huoqing@linux.dev,
	maxime@cerno.tech, harry.wentland@amd.com
Subject: [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function
Date: Fri,  8 Apr 2022 18:32:24 +0800	[thread overview]
Message-ID: <45739041a743cd435415ca53264678e57a653147.1649412256.git.Sandor.yu@nxp.com> (raw)
In-Reply-To: <cover.1649412256.git.Sandor.yu@nxp.com>

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>
---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
index c8f44bcb298a..ab176401b727 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi-cec.c
@@ -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)
@@ -306,11 +310,44 @@ static int dw_hdmi_cec_remove(struct platform_device *pdev)
 	return 0;
 }
 
+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 register */
+	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 register */
+	 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	= dw_hdmi_cec_remove,
 	.driver = {
 		.name = "dw-hdmi-cec",
+		.pm = &dw_hdmi_cec_pm,
 	},
 };
 module_platform_driver(dw_hdmi_cec_driver);
-- 
2.25.1


  reply	other threads:[~2022-04-08 10:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-08 10:32 [PATCH v2 0/5] DRM: Bridge: DW_HDMI: Add new features and bug fix Sandor Yu
2022-04-08 10:32 ` Sandor Yu [this message]
2022-04-08 13:41   ` [PATCH v2 1/5] drm: bridge: dw_hdmi: cec: Add cec suspend/resume function Neil Armstrong
2022-04-10 10:13     ` Jernej Škrabec
2022-04-11  7:42       ` Neil Armstrong
2022-04-11  7:47       ` [EXT] " Sandor Yu
2022-04-08 10:32 ` [PATCH v2 2/5] drm: bridge: dw_hdmi: default enable workaround to clear the overflow Sandor Yu
2022-04-08 12:20   ` Neil Armstrong
2022-04-10 10:20   ` Jernej Škrabec
2022-04-08 10:32 ` [PATCH v2 3/5] drm: bridge: dw_hdmi: Enable GCP only for Deep Color Sandor Yu
2022-04-08 12:40   ` Neil Armstrong
2022-04-11  9:24     ` [EXT] " Sandor Yu
2022-04-08 10:32 ` [PATCH v2 4/5] drm: bridge: dw_hdmi: add reset function for PHY GEN1 Sandor Yu
2022-04-08 12:22   ` Neil Armstrong
2022-04-10 10:14     ` Jernej Škrabec
2022-04-08 10:32 ` [PATCH v2 5/5] drm: bridge: dw_hdmi: Audio: Add General Parallel Audio (GPA) driver Sandor Yu
2022-04-08 12:51   ` Neil Armstrong
2022-04-11  8:52     ` [EXT] " Sandor Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45739041a743cd435415ca53264678e57a653147.1649412256.git.Sandor.yu@nxp.com \
    --to=sandor.yu@nxp.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=andrzej.hajda@intel.com \
    --cc=cai.huoqing@linux.dev \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime@cerno.tech \
    --cc=narmstrong@baylibre.com \
    --cc=robert.foss@linaro.org \
    --cc=shengjiu.wang@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®