From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Lee Jones <lee@kernel.org>,
Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
mfd@lists.linux.dev
Subject: [PATCH v5 5/5] mfd: max8907: Add restart handler
Date: Sun, 15 Nov 2026 11:01:47 +0200 [thread overview]
Message-ID: <20261115090147.95337-6-clamor95@gmail.com> (raw)
In-Reply-To: <20261115090147.95337-1-clamor95@gmail.com>
Add restart handler to reset hardware properly on system reboot.
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
drivers/mfd/max8907.c | 17 +++++++++++++++++
include/linux/mfd/max8907.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/drivers/mfd/max8907.c b/drivers/mfd/max8907.c
index 8412dab2133e3..b57c497334ea6 100644
--- a/drivers/mfd/max8907.c
+++ b/drivers/mfd/max8907.c
@@ -187,6 +187,19 @@ static int max8907_power_off(struct sys_off_data *data)
return NOTIFY_DONE;
}
+static int max8907_restart(struct sys_off_data *data)
+{
+ struct max8907 *max8907 = data->cb_data;
+ int ret;
+
+ ret = regmap_update_bits(max8907->regmap_gen, MAX8907_REG_RESET_CNFG,
+ MAX8907_MASK_SOFT_RESET, MAX8907_MASK_SOFT_RESET);
+ if (ret)
+ dev_err(max8907->dev, "failed to reset the device!\n");
+
+ return NOTIFY_DONE;
+}
+
static int max8907_i2c_probe(struct i2c_client *i2c)
{
struct device *dev = &i2c->dev;
@@ -246,6 +259,10 @@ static int max8907_i2c_probe(struct i2c_client *i2c)
ret = devm_register_power_off_handler(dev, max8907_power_off, max8907);
if (ret)
return dev_err_probe(dev, ret, "failed to register power-off handler\n");
+
+ ret = devm_register_restart_handler(dev, max8907_restart, max8907);
+ if (ret)
+ return dev_err_probe(dev, ret, "failed to register restart handler\n");
}
return 0;
diff --git a/include/linux/mfd/max8907.h b/include/linux/mfd/max8907.h
index e222250f0cc1e..025874e5f8808 100644
--- a/include/linux/mfd/max8907.h
+++ b/include/linux/mfd/max8907.h
@@ -164,6 +164,7 @@
#define MAX8907_MASK_OUT5V_VINEN 0x10
#define MAX8907_MASK_OUT5V_ENSRC 0x0E
#define MAX8907_MASK_OUT5V_EN 0x01
+#define MAX8907_MASK_SOFT_RESET 0x20
#define MAX8907_MASK_POWER_OFF 0x40
/* Regulator IDs */
--
2.53.0
prev parent reply other threads:[~2026-11-15 9:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 9:01 [PATCH v5 0/5] mfd: max8907: Schema, pdata and poweroff Svyatoslav Ryhel
2026-11-15 9:01 ` [PATCH v5 1/5] regulator: dt-bindings: maxim,max8907: Convert to DT schema Svyatoslav Ryhel
2026-11-15 9:01 ` [PATCH v5 2/5] mfd: max8907: Remove platform_data based probing Svyatoslav Ryhel
2026-11-15 9:01 ` [PATCH v5 3/5] mfd: max8907: Switch to resource-managed versions of helpers Svyatoslav Ryhel
2026-11-15 9:01 ` [PATCH v5 4/5] mfd: max8907: Convert to use device managed poweroff handler Svyatoslav Ryhel
2026-11-15 9:01 ` Svyatoslav Ryhel [this message]
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=20261115090147.95337-6-clamor95@gmail.com \
--to=clamor95@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
/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®