Skip to content

Commit 1b1305e

Browse files
smaeullag-linaro
authored andcommitted
mfd: axp20x: Switch to the sys-off handler API
This removes a layer of indirection through pm_power_off() and allows the PMIC handler to be used as a fallback when firmware power off fails. This happens on boards like the Clockwork DevTerm R-01 where OpenSBI does not know how to use the PMIC to power off the board. Move the check for AXP288 to avoid registering a dummy handler. Signed-off-by: Samuel Holland <[email protected]> [Lee: Removed superfluous new line] Signed-off-by: Lee Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 88a32c2 commit 1b1305e

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

drivers/mfd/axp20x.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <linux/mfd/core.h>
2424
#include <linux/module.h>
2525
#include <linux/of_device.h>
26-
#include <linux/pm_runtime.h>
26+
#include <linux/reboot.h>
2727
#include <linux/regmap.h>
2828
#include <linux/regulator/consumer.h>
2929

@@ -825,17 +825,16 @@ static const struct mfd_cell axp813_cells[] = {
825825
},
826826
};
827827

828-
static struct axp20x_dev *axp20x_pm_power_off;
829-
static void axp20x_power_off(void)
828+
static int axp20x_power_off(struct sys_off_data *data)
830829
{
831-
if (axp20x_pm_power_off->variant == AXP288_ID)
832-
return;
830+
struct axp20x_dev *axp20x = data->cb_data;
833831

834-
regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
835-
AXP20X_OFF);
832+
regmap_write(axp20x->regmap, AXP20X_OFF_CTRL, AXP20X_OFF);
836833

837834
/* Give capacitors etc. time to drain to avoid kernel panic msg. */
838835
mdelay(500);
836+
837+
return NOTIFY_DONE;
839838
}
840839

841840
int axp20x_match_device(struct axp20x_dev *axp20x)
@@ -1002,10 +1001,11 @@ int axp20x_device_probe(struct axp20x_dev *axp20x)
10021001
return ret;
10031002
}
10041003

1005-
if (!pm_power_off) {
1006-
axp20x_pm_power_off = axp20x;
1007-
pm_power_off = axp20x_power_off;
1008-
}
1004+
if (axp20x->variant != AXP288_ID)
1005+
devm_register_sys_off_handler(axp20x->dev,
1006+
SYS_OFF_MODE_POWER_OFF,
1007+
SYS_OFF_PRIO_DEFAULT,
1008+
axp20x_power_off, axp20x);
10091009

10101010
dev_info(axp20x->dev, "AXP20X driver loaded\n");
10111011

@@ -1015,11 +1015,6 @@ EXPORT_SYMBOL(axp20x_device_probe);
10151015

10161016
void axp20x_device_remove(struct axp20x_dev *axp20x)
10171017
{
1018-
if (axp20x == axp20x_pm_power_off) {
1019-
axp20x_pm_power_off = NULL;
1020-
pm_power_off = NULL;
1021-
}
1022-
10231018
mfd_remove_devices(axp20x->dev);
10241019
regmap_del_irq_chip(axp20x->irq, axp20x->regmap_irqc);
10251020
}

0 commit comments

Comments
 (0)