From: Domenico Andreoli <domenico.andreoli@xxxxxxxxx> Proof of concept: max8907 as provider of reset hooks. Cc: Russell King <linux@xxxxxxxxxxxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Olof Johansson <olof@xxxxxxxxx> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx Signed-off-by: Domenico Andreoli <domenico.andreoli@xxxxxxxxx> --- drivers/mfd/Kconfig | 1 + drivers/mfd/max8907.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) Index: b/drivers/mfd/Kconfig =================================================================== --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -339,6 +339,7 @@ config MFD_MAX8907 tristate "Maxim Semiconductor MAX8907 PMIC Support" select MFD_CORE depends on I2C=y + select MACHINE_RESET select REGMAP_I2C select REGMAP_IRQ help Index: b/drivers/mfd/max8907.c =================================================================== --- a/drivers/mfd/max8907.c +++ b/drivers/mfd/max8907.c @@ -20,6 +20,7 @@ #include <linux/of_device.h> #include <linux/regmap.h> #include <linux/slab.h> +#include <linux/machine_reset.h> static struct mfd_cell max8907_cells[] = { { .name = "max8907-regulator", }, @@ -176,9 +177,9 @@ static const struct regmap_irq_chip max8 .num_irqs = ARRAY_SIZE(max8907_rtc_irqs), }; -static struct max8907 *max8907_pm_off; -static void max8907_power_off(void) +static void max8907_power_off(void *dev) { + struct max8907 *max8907_pm_off = dev; regmap_update_bits(max8907_pm_off->regmap_gen, MAX8907_REG_RESET_CNFG, MAX8907_MASK_POWER_OFF, MAX8907_MASK_POWER_OFF); } @@ -266,9 +267,11 @@ static int max8907_i2c_probe(struct i2c_ goto err_add_devices; } - if (pm_off && !pm_power_off) { - max8907_pm_off = max8907; - pm_power_off = max8907_power_off; + if (pm_off) { + struct reset_hook hook; + reset_hook_init(&hook); + hook.power_off = max8907_power_off; + set_machine_reset(RESET_POWER_OFF, &hook, max8907); } return 0; -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html