From: Marek Vasut <marex@nabladev.com>
To: linux-kernel@vger.kernel.org
Cc: Marek Vasut <marex@nabladev.com>, Lee Jones <lee@kernel.org>,
Pascal PAILLET-LME <p.paillet@st.com>,
Paul Cercueil <paul@crapouillou.net>,
Sean Nyekjaer <sean@geanix.com>,
kernel@dh-electronics.com
Subject: [PATCH] mfd: stpmic1: Attempt system shutdown twice in case PMIC is confused
Date: Fri, 9 Jan 2026 05:12:09 +0100 [thread overview]
Message-ID: <20260109041301.1344783-1-marex@nabladev.com> (raw)
Attempt to shut down again, in case the first attempt failed.
The STPMIC1 might get confused and the first regmap_update_bits()
returns with -ETIMEDOUT / -110 . If that or similar transient
failure occurs, try to shut down again. If the second attempt
fails, there is some bigger problem, report it to user.
Fixes: 6e9df38f359a ("mfd: stpmic1: Add PMIC poweroff via sys-off handler")
Signed-off-by: Marek Vasut <marex@nabladev.com>
---
Cc: Lee Jones <lee@kernel.org>
Cc: Pascal PAILLET-LME <p.paillet@st.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Sean Nyekjaer <sean@geanix.com>
Cc: kernel@dh-electronics.com
---
drivers/mfd/stpmic1.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c
index 081827bc05961..9ef4049d7db10 100644
--- a/drivers/mfd/stpmic1.c
+++ b/drivers/mfd/stpmic1.c
@@ -121,9 +121,23 @@ static const struct regmap_irq_chip stpmic1_regmap_irq_chip = {
static int stpmic1_power_off(struct sys_off_data *data)
{
struct stpmic1 *ddata = data->cb_data;
+ int ret;
+
+ ret = regmap_update_bits(ddata->regmap, MAIN_CR, SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF);
+ if (!ret)
+ return NOTIFY_DONE;
+
+ /*
+ * Attempt to shut down again, in case the first attempt failed.
+ * The STPMIC1 might get confused and the first regmap_update_bits()
+ * returns with -ETIMEDOUT / -110 . If that or similar transient
+ * failure occurs, try to shut down again. If the second attempt
+ * fails, there is some bigger problem, report it to user.
+ */
+ ret = regmap_update_bits(ddata->regmap, MAIN_CR, SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF);
+ if (ret)
+ dev_err(ddata->dev, "Failed to access PMIC I2C bus (%d)\n", ret);
- regmap_update_bits(ddata->regmap, MAIN_CR,
- SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF);
return NOTIFY_DONE;
}
--
2.51.0
next reply other threads:[~2026-01-09 4:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 4:12 Marek Vasut [this message]
2026-01-09 14:54 ` Sean Nyekjaer
2026-01-09 15:39 ` Marek Vasut
2026-01-13 12:33 ` Lee Jones
2026-01-15 17:40 ` Marek Vasut
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=20260109041301.1344783-1-marex@nabladev.com \
--to=marex@nabladev.com \
--cc=kernel@dh-electronics.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.paillet@st.com \
--cc=paul@crapouillou.net \
--cc=sean@geanix.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®