mfd: tps65219: Add support for soft shutdown via sys-off API
Subsystems (2)
PATCH RESEND v3 1/1 mfd: tps65219: Add support for soft shutdown via sys-off API
Use new API for power-off mode support:
sys-off API allows support of shutdown handler and restart handler.
Shutdown was not supported before that enhancement. This is required for platform that are not using PSCI.
Test:
- restart:
# reboot Default is cold reset: # cat /sys/kernel/reboot/mode Switch boot mode to warm reset: # echo warm > /sys/kernel/reboot/mode - power-off: # halt
Tested on AM62-LP-SK board.
---
Notes:
Change-log v3 to v2
v2: Link: https://lore.kernel.org/lkml/[email protected]/
Lee Jones Review:
nits: rm not needed line wraps and restore a cr deleted not related with the patch.
Change-log v2 to v1
v1: Link: https://lore.kernel.org/all/[email protected]/
Andrew Davis Review:
- Use new helpers devm_register_restart_handler and devm_register_power_off_handler Vignesh Raghavendra:
- Fix typo on board name in commit message
drivers/mfd/tps65219.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
drivers/mfd/tps65219.c +28 -10
@@ -25,13 +25,21 @@ static int tps65219_cold_reset(struct tps65219 *tps) TPS65219_MFP_COLD_RESET_I2C_CTRL_MASK); } -static int tps65219_restart (struct notifier_block *this, -unsigned long reboot_mode,void *cmd) +static int tps65219_soft_shutdown (struct tps65219 *tps) { -struct tps65219 *tps; +return regmap_update_bits (tps->regmap,TPS65219_REG_MFP_CTRL , +TPS65219_MFP_I2C_OFF_REQ_MASK , +TPS65219_MFP_I2C_OFF_REQ_MASK ); +} - tps = container_of(this, struct tps65219, nb); +static int tps65219_power_off_handler (struct sys_off_data *data) +{ +tps65219_soft_shutdown (data->cb_data); +return NOTIFY_DONE ; +} +static int tps65219_restart (struct tps65219 *tps,unsigned long reboot_mode) +{if (reboot_mode ==REBOOT_WARM )tps65219_warm_reset (tps);else
@@ -40,10 +48,11 @@ static int tps65219_restart(struct notifier_block *this,return NOTIFY_DONE ; } -static struct notifier_block pmic_rst_restart_nb = { - .notifier_call = tps65219_restart, - .priority =200 , -}; +static int tps65219_restart_handler (struct sys_off_data *data) +{ +tps65219_restart (data->cb_data, data->mode); +return NOTIFY_DONE ; +}static const struct resource tps65219_pwrbutton_resources[] = {DEFINE_RES_IRQ_NAMED (TPS65219_INT_PB_FALLING_EDGE_DETECT ,"falling" ),
@@ -269,13 +278,22 @@ static int tps65219_probe(struct i2c_client *client) } } - tps->nb = pmic_rst_restart_nb; - ret =register_restart_handler (&tps->nb); + ret =devm_register_restart_handler (tps->dev, + tps65219_restart_handler, + tps); +if (ret) {dev_err (tps->dev,"cannot register restart handler, %d\n" , ret);return ret; } + ret =devm_register_power_off_handler (tps->dev, + tps65219_power_off_handler, + tps); +if (ret) { +dev_err (tps->dev,"failed to register power-off handler: %d\n" , ret); +return ret; + }return 0 ; }
Signature · 1 line
2.34.1
Quoted 39 lines · Jerome Neanne
Use new API for power-off mode support:
sys-off API allows support of shutdown handler and restart handler.
Shutdown was not supported before that enhancement. This is required for platform that are not using PSCI.
Test:
- restart:# reboot Default is cold reset: # cat /sys/kernel/reboot/mode Switch boot mode to warm reset: # echo warm > /sys/kernel/reboot/mode - power-off: # haltTested on AM62-LP-SK board.
Signed-off-by Jerome Neanne <[email protected]>Suggested-by Andrew Davis <[email protected]>Reviewed-by Andrew Davis <[email protected]>---
Notes:
Change-log v3 to v2
v2: Link: https://lore.kernel.org/lkml/[email protected]/
Lee Jones Review:
nits: rm not needed line wraps and restore a cr deleted not related with the patch.Change-log v2 to v1
v1: Link: https://lore.kernel.org/all/[email protected]/
Andrew Davis Review:
- Use new helpersdevm_register_restart_handleranddevm_register_power_off_handlerVignesh Raghavendra:
- Fix typo on board name in commit message
Quoted 2 lines
drivers/mfd/tps65219.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-)
Applied, thanks
Signature · 1 line
Lee Jones [李琼斯]
Hi Jerome,
Quoted 54 lines · Jerome Neanne
Use new API for power-off mode support:
sys-off API allows support of shutdown handler and restart handler.
Shutdown was not supported before that enhancement. This is required for platform that are not using PSCI.
Test:
- restart:# reboot Default is cold reset: # cat /sys/kernel/reboot/mode Switch boot mode to warm reset: # echo warm > /sys/kernel/reboot/mode - power-off: # haltTested on AM62-LP-SK board.
Signed-off-by Jerome Neanne <[email protected]>Suggested-by Andrew Davis <[email protected]>Reviewed-by Andrew Davis <[email protected]>---
Notes:
Change-log v3 to v2
v2: Link: https://lore.kernel.org/lkml/[email protected]/
Lee Jones Review:
nits: rm not needed line wraps and restore a cr deleted not related with the patch.
Change-log v2 to v1
v1: Link: https://lore.kernel.org/all/[email protected]/
Andrew Davis Review:
- Use new helpersdevm_register_restart_handleranddevm_register_power_off_handlerVignesh Raghavendra:
- Fix typo on board name in commit messagedrivers/mfd/tps65219.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)drivers/mfd/tps65219.c +0
-0@@ -25,13 +25,21 @@ static int tps65219_cold_reset(struct tps65219 *tps) TPS65219_MFP_COLD_RESET_I2C_CTRL_MASK); }drivers/mfd/tps65219.c +1
-2-static int tps65219_restart (struct notifier_block *this, - unsigned long reboot_mode, void *cmd) +static int tps65219_soft_shutdown (struct tps65219 *tps){
drivers/mfd/tps65219.c static int tps65219_cold_reset(struct tps65219 *tps) · line 32
Quoted 4 lines
drivers/mfd/tps65219.c +3
-1-struct tps65219 *tps; +return regmap_update_bits (tps->regmap,TPS65219_REG_MFP_CTRL , + TPS65219_MFP_I2C_OFF_REQ_MASK, + TPS65219_MFP_I2C_OFF_REQ_MASK);
I suppose this is I2C access and is therefore a [potentially] sleeping call? Could this be an issue, see below...
Quoted 45 lines
+}
drivers/mfd/tps65219.c +5
-1- tps = container_of(this, struct tps65219, nb); +static int tps65219_power_off_handler (struct sys_off_data *data) +{ +tps65219_soft_shutdown (data->cb_data); +return NOTIFY_DONE ; +}drivers/mfd/tps65219.c +2
-0+static int tps65219_restart (struct tps65219 *tps,unsigned long reboot_mode) +{if (
reboot_mode==REBOOT_WARM)tps65219_warm_reset(tps); elsedrivers/mfd/tps65219.c +0
-0@@ -40,10 +48,11 @@ static int tps65219_restart(struct notifier_block *this, return NOTIFY_DONE; }drivers/mfd/tps65219.c +5
-4-static struct notifier_block pmic_rst_restart_nb = { - .notifier_call = tps65219_restart, - .priority =200 , -}; +static int tps65219_restart_handler (struct sys_off_data *data) +{ +tps65219_restart (data->cb_data, data->mode); +return NOTIFY_DONE ; +}
static const struct resource tps65219_pwrbutton_resources[] = {DEFINE_RES_IRQ_NAMED(TPS65219_INT_PB_FALLING_EDGE_DETECT, "falling"),drivers/mfd/tps65219.c +0
-0@@ -269,13 +278,22 @@ static int tps65219_probe(struct i2c_client *client) } }drivers/mfd/tps65219.c +4
-2- tps->nb = pmic_rst_restart_nb; - ret =register_restart_handler (&tps->nb); + ret =devm_register_restart_handler (tps->dev, + tps65219_restart_handler, + tps); +if (ret) {
dev_err(tps->dev, "cannot register restart handler, %d\n", ret); return ret;
}
drivers/mfd/tps65219.c static int tps65219_probe(struct i2c_client *client) · line 292
Quoted 3 lines
drivers/mfd/tps65219.c +3
-0+ ret =devm_register_power_off_handler (tps->dev, + tps65219_power_off_handler, + tps);
... while this translates to
return devm_register_sys_off_handler(dev,
SYS_OFF_MODE_POWER_OFF,
... might this be an issue?
enum sys_off_mode {
[]
/**
* @SYS_OFF_MODE_POWER_OFF:
*
* Handlers power-off system. Handlers are disallowed to sleep.
*/
SYS_OFF_MODE_POWER_OFF,Quoted 6 lines
drivers/mfd/tps65219.c +4
-0+if (ret) { +dev_err (tps->dev,"failed to register power-off handler: %d\n" , ret); +return ret; + }return 0;
}
Signature · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com
Hello all,
and sorry for spam,
Quoted 53 lines · Alexander Sverdlin
Quoted 53 lines
Use new API for power-off mode support:
sys-off API allows support of shutdown handler and restart handler.
Shutdown was not supported before that enhancement. This is required for platform that are not using PSCI.
Test:
- restart:# reboot Default is cold reset: # cat /sys/kernel/reboot/mode Switch boot mode to warm reset: # echo warm > /sys/kernel/reboot/mode - power-off: # haltTested on AM62-LP-SK board.
Signed-off-by Jerome Neanne <[email protected]>Suggested-by Andrew Davis <[email protected]>Reviewed-by Andrew Davis <[email protected]>---
Notes:
Change-log v3 to v2
v2: Link: https://lore.kernel.org/lkml/[email protected]/
Lee Jones Review:
nits: rm not needed line wraps and restore a cr deleted not related with the patch.
Change-log v2 to v1
v1: Link: https://lore.kernel.org/all/[email protected]/
Andrew Davis Review:
- Use new helpersdevm_register_restart_handleranddevm_register_power_off_handlerVignesh Raghavendra:
- Fix typo on board name in commit messagedrivers/mfd/tps65219.c | 38 ++++++++++++++++++++++++++++----------
1 file changed, 28 insertions(+), 10 deletions(-)drivers/mfd/tps65219.c +0
-0@@ -25,13 +25,21 @@ static int tps65219_cold_reset(struct tps65219 *tps) TPS65219_MFP_COLD_RESET_I2C_CTRL_MASK); }drivers/mfd/tps65219.c +1
-2-static int tps65219_restart (struct notifier_block *this, - unsigned long reboot_mode, void *cmd) +static int tps65219_soft_shutdown (struct tps65219 *tps)
Quoted 8 lines
drivers/mfd/tps65219.c static int tps65219_cold_reset(struct tps65219 *tps) · line 32
Quoted 5 lines
{
drivers/mfd/tps65219.c +3
-1-struct tps65219 *tps; +return regmap_update_bits (tps->regmap,TPS65219_REG_MFP_CTRL , + TPS65219_MFP_I2C_OFF_REQ_MASK, + TPS65219_MFP_I2C_OFF_REQ_MASK);I suppose this is I2C access and is therefore a [potentially] sleeping call? Could this be an issue, see below...
I totally missed master_xfer_atomic = omap_i2c_xfer_polling in i2c-omap.c! No issues here, I'm sorry!
Quoted 72 lines
Quoted 45 lines
+}
drivers/mfd/tps65219.c +5
-1- tps = container_of(this, struct tps65219, nb); +static int tps65219_power_off_handler (struct sys_off_data *data) +{ +tps65219_soft_shutdown (data->cb_data); +return NOTIFY_DONE ; +}drivers/mfd/tps65219.c +2
-0+static int tps65219_restart (struct tps65219 *tps,unsigned long reboot_mode) +{if (
reboot_mode==REBOOT_WARM)tps65219_warm_reset(tps); elsedrivers/mfd/tps65219.c +0
-0@@ -40,10 +48,11 @@ static int tps65219_restart(struct notifier_block *this, return NOTIFY_DONE; }drivers/mfd/tps65219.c +5
-4-static struct notifier_block pmic_rst_restart_nb = { - .notifier_call = tps65219_restart, - .priority =200 , -}; +static int tps65219_restart_handler (struct sys_off_data *data) +{ +tps65219_restart (data->cb_data, data->mode); +return NOTIFY_DONE ; +}
static const struct resource tps65219_pwrbutton_resources[] = {DEFINE_RES_IRQ_NAMED(TPS65219_INT_PB_FALLING_EDGE_DETECT, "falling"),drivers/mfd/tps65219.c +0
-0@@ -269,13 +278,22 @@ static int tps65219_probe(struct i2c_client *client) } }drivers/mfd/tps65219.c +4
-2- tps->nb = pmic_rst_restart_nb; - ret =register_restart_handler (&tps->nb); + ret =devm_register_restart_handler (tps->dev, + tps65219_restart_handler, + tps); +if (ret) {
dev_err(tps->dev, "cannot register restart handler, %d\n", ret); return ret;
}drivers/mfd/tps65219.c static int tps65219_probe(struct i2c_client *client) · line 292
Quoted 3 lines
drivers/mfd/tps65219.c +3
-0+ ret =devm_register_power_off_handler (tps->dev, + tps65219_power_off_handler, + tps);... while this translates to
return devm_register_sys_off_handler(dev,
SYS_OFF_MODE_POWER_OFF,
... might this be an issue?enum
sys_off_mode{[]
/** * @SYS_OFF_MODE_POWER_OFF: * * Handlers power-off system. Handlers are disallowed to sleep. */ SYS_OFF_MODE_POWER_OFF,Quoted 6 lines
drivers/mfd/tps65219.c +4
-0+if (ret) { +dev_err (tps->dev,"failed to register power-off handler: %d\n" , ret); +return ret; + }return 0;
}
Signature · 3 lines
Alexander Sverdlin Siemens AG www.siemens.com