From: Clark Wang <xiaoning.wang@nxp.com> To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i3c: master: svc: fix i3c suspend/resume issue Date: Wed, 17 May 2023 11:30:28 +0800 [thread overview] Message-ID: <20230517033030.3068085-1-xiaoning.wang@nxp.com> (raw) When system suspends, if i3c module is powered down, register value will lose. Need to save the key registers before system suspend. So save these registers value in runtime pm suspend, and restore them if these register's value is different with the saved values when runtime pm resume. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> --- drivers/i3c/master/svc-i3c-master.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index e3f454123805..bca3a4352ad1 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -145,6 +145,11 @@ struct svc_i3c_xfer { struct svc_i3c_cmd cmds[]; }; +struct svc_i3c_regs_save { + u32 mconfig; + u32 mdynaddr; +}; + /** * struct svc_i3c_master - Silvaco I3C Master structure * @base: I3C master controller @@ -173,6 +178,7 @@ struct svc_i3c_master { struct i3c_master_controller base; struct device *dev; void __iomem *regs; + struct svc_i3c_regs_save saved_regs; u32 free_slots; u8 addrs[SVC_I3C_MAX_DEVS]; struct i3c_dev_desc *descs[SVC_I3C_MAX_DEVS]; @@ -1579,10 +1585,28 @@ static void svc_i3c_master_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } +static void svc_i3c_save_regs(struct svc_i3c_master *master) +{ + master->saved_regs.mconfig = readl(master->regs + SVC_I3C_MCONFIG); + master->saved_regs.mdynaddr = readl(master->regs + SVC_I3C_MDYNADDR); +} + +static void svc_i3c_restore_regs(struct svc_i3c_master *master) +{ + if (readl(master->regs + SVC_I3C_MDYNADDR) != + master->saved_regs.mdynaddr) { + writel(master->saved_regs.mconfig, + master->regs + SVC_I3C_MCONFIG); + writel(master->saved_regs.mdynaddr, + master->regs + SVC_I3C_MDYNADDR); + } +} + static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev) { struct svc_i3c_master *master = dev_get_drvdata(dev); + svc_i3c_save_regs(master); svc_i3c_master_unprepare_clks(master); pinctrl_pm_select_sleep_state(dev); @@ -1596,6 +1620,8 @@ static int __maybe_unused svc_i3c_runtime_resume(struct device *dev) pinctrl_pm_select_default_state(dev); svc_i3c_master_prepare_clks(master); + svc_i3c_restore_regs(master); + return 0; } -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Clark Wang <xiaoning.wang@nxp.com> To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i3c: master: svc: fix i3c suspend/resume issue Date: Wed, 17 May 2023 11:30:28 +0800 [thread overview] Message-ID: <20230517033030.3068085-1-xiaoning.wang@nxp.com> (raw) When system suspends, if i3c module is powered down, register value will lose. Need to save the key registers before system suspend. So save these registers value in runtime pm suspend, and restore them if these register's value is different with the saved values when runtime pm resume. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> --- drivers/i3c/master/svc-i3c-master.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index e3f454123805..bca3a4352ad1 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -145,6 +145,11 @@ struct svc_i3c_xfer { struct svc_i3c_cmd cmds[]; }; +struct svc_i3c_regs_save { + u32 mconfig; + u32 mdynaddr; +}; + /** * struct svc_i3c_master - Silvaco I3C Master structure * @base: I3C master controller @@ -173,6 +178,7 @@ struct svc_i3c_master { struct i3c_master_controller base; struct device *dev; void __iomem *regs; + struct svc_i3c_regs_save saved_regs; u32 free_slots; u8 addrs[SVC_I3C_MAX_DEVS]; struct i3c_dev_desc *descs[SVC_I3C_MAX_DEVS]; @@ -1579,10 +1585,28 @@ static void svc_i3c_master_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); } +static void svc_i3c_save_regs(struct svc_i3c_master *master) +{ + master->saved_regs.mconfig = readl(master->regs + SVC_I3C_MCONFIG); + master->saved_regs.mdynaddr = readl(master->regs + SVC_I3C_MDYNADDR); +} + +static void svc_i3c_restore_regs(struct svc_i3c_master *master) +{ + if (readl(master->regs + SVC_I3C_MDYNADDR) != + master->saved_regs.mdynaddr) { + writel(master->saved_regs.mconfig, + master->regs + SVC_I3C_MCONFIG); + writel(master->saved_regs.mdynaddr, + master->regs + SVC_I3C_MDYNADDR); + } +} + static int __maybe_unused svc_i3c_runtime_suspend(struct device *dev) { struct svc_i3c_master *master = dev_get_drvdata(dev); + svc_i3c_save_regs(master); svc_i3c_master_unprepare_clks(master); pinctrl_pm_select_sleep_state(dev); @@ -1596,6 +1620,8 @@ static int __maybe_unused svc_i3c_runtime_resume(struct device *dev) pinctrl_pm_select_default_state(dev); svc_i3c_master_prepare_clks(master); + svc_i3c_restore_regs(master); + return 0; } -- 2.34.1 -- linux-i3c mailing list linux-i3c@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-i3c
next reply other threads:[~2023-05-17 3:30 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-17 3:30 Clark Wang [this message] 2023-05-17 3:30 ` [PATCH] i3c: master: svc: fix i3c suspend/resume issue Clark Wang 2023-05-17 3:30 ` [PATCH] i3c: master: svc: fix cpu schedule in spin lock Clark Wang 2023-05-17 3:30 ` Clark Wang 2023-05-22 8:32 ` Miquel Raynal 2023-05-22 8:32 ` Miquel Raynal 2023-06-04 22:52 ` (subset) " Alexandre Belloni 2023-06-04 22:52 ` Alexandre Belloni 2023-05-17 3:30 ` [PATCH] i3c: master: svc: add NACK check after start byte sent Clark Wang 2023-05-17 3:30 ` Clark Wang 2023-05-22 8:33 ` Miquel Raynal 2023-05-22 8:33 ` Miquel Raynal 2023-05-22 8:31 ` [PATCH] i3c: master: svc: fix i3c suspend/resume issue Miquel Raynal 2023-05-22 8:31 ` Miquel Raynal 2023-06-04 22:52 ` (subset) " Alexandre Belloni 2023-06-04 22:52 ` Alexandre Belloni
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=20230517033030.3068085-1-xiaoning.wang@nxp.com \ --to=xiaoning.wang@nxp.com \ --cc=alexandre.belloni@bootlin.com \ --cc=conor.culhane@silvaco.com \ --cc=linux-i3c@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=miquel.raynal@bootlin.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.