All of lore.kernel.org
 help / color / mirror / Atom feed
From: <shumingf@realtek.com>
To: <broonie@kernel.org>, <lgirdwood@gmail.com>
Cc: <linux-sound@vger.kernel.org>, <lars@metafoo.de>,
	<flove@realtek.com>, <oder_chiou@realtek.com>,
	<jack.yu@realtek.com>, <derek.fang@realtek.com>,
	<ckeepax@opensource.cirrus.com>,
	Shuming Fan <shumingf@realtek.com>
Subject: [PATCH] ASoC: SDCA: restore the settings if power is lost during suspend
Date: Wed, 8 Apr 2026 16:56:07 +0800	[thread overview]
Message-ID: <20260408085607.3813488-1-shumingf@realtek.com> (raw)

From: Shuming Fan <shumingf@realtek.com>

We should restore the MIPI-defined registers when the device is attached.
If a function status interrupt occurs, the device will trigger an interrupt to reload the settings.

Signed-off-by: Shuming Fan <shumingf@realtek.com>
---
 sound/soc/sdca/sdca_class.c      |  4 ++++
 sound/soc/sdca/sdca_interrupts.c | 10 +++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sdca/sdca_class.c b/sound/soc/sdca/sdca_class.c
index 7af4e5d1b347..d1feaa57eae7 100644
--- a/sound/soc/sdca/sdca_class.c
+++ b/sound/soc/sdca/sdca_class.c
@@ -49,6 +49,10 @@ static int class_sdw_update_status(struct sdw_slave *sdw, enum sdw_slave_status
 		drv->attached = true;
 
 		complete(&drv->device_attach);
+
+		/* resync the MIPI-defined registers if the device loses power */
+		regcache_mark_dirty(drv->dev_regmap);
+		regcache_sync(drv->dev_regmap);
 		break;
 	case SDW_SLAVE_UNATTACHED:
 		dev_dbg(drv->dev, "device detach\n");
diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c
index 1838dabcdf60..ee69486e6b68 100644
--- a/sound/soc/sdca/sdca_interrupts.c
+++ b/sound/soc/sdca/sdca_interrupts.c
@@ -24,6 +24,7 @@
 #include <sound/sdca_interrupts.h>
 #include <sound/sdca_jack.h>
 #include <sound/sdca_ump.h>
+#include <sound/sdca_regmap.h>
 #include <sound/soc-component.h>
 #include <sound/soc.h>
 
@@ -121,7 +122,14 @@ static irqreturn_t function_status_handler(int irq, void *data)
 
 		switch (mask) {
 		case SDCA_CTL_ENTITY_0_FUNCTION_NEEDS_INITIALIZATION:
-			//FIXME: Add init writes
+			dev_info(dev, "%s function needs initialisation\n", interrupt->function->desc->name);
+			ret = sdca_regmap_write_init(dev, interrupt->device_regmap,
+					     interrupt->function);
+			if (ret)
+				return ret;
+			/* resync the function registers */
+			regcache_mark_dirty(interrupt->function_regmap);
+			regcache_sync(interrupt->function_regmap);
 			break;
 		case SDCA_CTL_ENTITY_0_FUNCTION_FAULT:
 			dev_err(dev, "function fault\n");
-- 
2.53.0


             reply	other threads:[~2026-04-08  8:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08  8:56 shumingf [this message]
2026-04-08  9:21 ` [PATCH] ASoC: SDCA: restore the settings if power is lost during suspend Charles Keepax
2026-04-08  9:40   ` Shuming [范書銘]
2026-04-08  9:43     ` Charles Keepax
2026-04-08  9:58     ` Richard Fitzgerald

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=20260408085607.3813488-1-shumingf@realtek.com \
    --to=shumingf@realtek.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=derek.fang@realtek.com \
    --cc=flove@realtek.com \
    --cc=jack.yu@realtek.com \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=oder_chiou@realtek.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 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.