===================================================================
@@ -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
===================================================================
@@ -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;