From e1121f9a970a2d0e770532a5849eb749d8bbe8a3 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Fri, 18 Mar 2016 19:24:48 -0700 Subject: rn5t567: register ARM reset callback Use the PMIC repower capabilities to reboot the module. Register arm_pm_restart to trigger a cold reboot using the PMIC. Signed-off-by: Stefan Agner --- drivers/mfd/rn5t567.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/mfd/rn5t567.c b/drivers/mfd/rn5t567.c index f0a47ab52239..4209f1a51545 100644 --- a/drivers/mfd/rn5t567.c +++ b/drivers/mfd/rn5t567.c @@ -19,6 +19,8 @@ #include #include +#include + static const struct mfd_cell rn5t618_cells[] = { { .name = "rn5t618-regulator" }, { .name = "rn5t618-wdt" }, @@ -53,16 +55,28 @@ static const struct regmap_config rn5t618_regmap_config = { static struct rn5t618 *rn5t618_pm_power_off; -static void rn5t618_power_off(void) +static void rn5t618_trigger_poweroff_sequence(bool repower) { /* disable automatic repower-on */ regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_REPCNT, - RN5T618_REPCNT_REPWRON, 0); + RN5T618_REPCNT_REPWRON, repower); /* start power-off sequence */ regmap_update_bits(rn5t618_pm_power_off->regmap, RN5T618_SLPCNT, RN5T618_SLPCNT_SWPWROFF, RN5T618_SLPCNT_SWPWROFF); } +static void rn5t618_power_off(void) +{ + rn5t618_trigger_poweroff_sequence(false); +} + +static void rn5t618_restart(enum reboot_mode reboot_mode, const char *cmd) +{ + rn5t618_trigger_poweroff_sequence(true); + + pr_info("Unable to restart system\n"); +} + static int rn5t618_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -90,10 +104,12 @@ static int rn5t618_i2c_probe(struct i2c_client *i2c, return ret; } - if (!pm_power_off && of_device_is_compatible(np, "ricoh,rn5t618")) { - rn5t618_pm_power_off = priv; + rn5t618_pm_power_off = priv; + if (!pm_power_off && of_device_is_compatible(np, "ricoh,rn5t618")) pm_power_off = rn5t618_power_off; - } + + if (of_device_is_compatible(np, "ricoh,rn5t567")) + arm_pm_restart = rn5t618_restart; dev_err(&i2c->dev, "probe finished ok: %d\n", ret); -- cgit v1.2.3