diff options
author | Sean Nyekjaer <sean@geanix.com> | 2023-06-02 08:24:26 +0200 |
---|---|---|
committer | Lee Jones <lee@kernel.org> | 2023-06-15 09:19:39 +0100 |
commit | 6e9df38f359a26431609320bd38ea9a81bb4d63d (patch) | |
tree | 95999d147150ada0318b66fcd3e35e545f6ee20c /drivers/mfd/stpmic1.c | |
parent | 48b4371b98676e8db3f72e4355af7707103d9c07 (diff) | |
download | linux-stable-6e9df38f359a26431609320bd38ea9a81bb4d63d.tar.gz linux-stable-6e9df38f359a26431609320bd38ea9a81bb4d63d.tar.bz2 linux-stable-6e9df38f359a26431609320bd38ea9a81bb4d63d.zip |
mfd: stpmic1: Add PMIC poweroff via sys-off handler
Use devm_register_sys_off_handler() that allows to register multiple
power-off handlers.
This will allow boards using the stpmic1 to power-off.
Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230602062426.3947116-2-sean@geanix.com
Diffstat (limited to 'drivers/mfd/stpmic1.c')
-rw-r--r-- | drivers/mfd/stpmic1.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/mfd/stpmic1.c b/drivers/mfd/stpmic1.c index a79dfb9923d7..3cc7492f828f 100644 --- a/drivers/mfd/stpmic1.c +++ b/drivers/mfd/stpmic1.c @@ -7,6 +7,7 @@ #include <linux/mfd/core.h> #include <linux/mfd/stpmic1.h> #include <linux/module.h> +#include <linux/reboot.h> #include <linux/of.h> #include <linux/of_irq.h> #include <linux/of_platform.h> @@ -117,6 +118,16 @@ static const struct regmap_irq_chip stpmic1_regmap_irq_chip = { .num_irqs = ARRAY_SIZE(stpmic1_irqs), }; +static int stpmic1_power_off(struct sys_off_data *data) +{ + struct stpmic1 *ddata = data->cb_data; + + regmap_update_bits(ddata->regmap, MAIN_CR, + SOFTWARE_SWITCH_OFF, SOFTWARE_SWITCH_OFF); + + return NOTIFY_DONE; +} + static int stpmic1_probe(struct i2c_client *i2c) { struct stpmic1 *ddata; @@ -159,6 +170,16 @@ static int stpmic1_probe(struct i2c_client *i2c) return ret; } + ret = devm_register_sys_off_handler(ddata->dev, + SYS_OFF_MODE_POWER_OFF, + SYS_OFF_PRIO_DEFAULT, + stpmic1_power_off, + ddata); + if (ret) { + dev_err(ddata->dev, "failed to register sys-off handler: %d\n", ret); + return ret; + } + return devm_of_platform_populate(dev); } |