Skip to content

Commit

Permalink
mfd: axp20x: Add a 500ms delay at the end of axp20x_power_off
Browse files Browse the repository at this point in the history
The kernel expects the power_off function to not return, and if it does
it panics. Add a slight delay after the i2c write which turns off power
through the PMIC, to give capacitors etc. some time to drain.

Without this the kernel lives on long enough after the poweroff to
print the following on the serial console on my Mele A1000G quad:

[  248.583588] reboot: Power down
[  248.600490] Kernel pa

With the delay the start of printing "Kernel panic" is gone.

Signed-off-by: Hans de Goede <[email protected]>
Acked-by: Chen-Yu Tsai <[email protected]>
Signed-off-by: Lee Jones <[email protected]>
  • Loading branch information
jwrdegoede authored and Lee Jones committed Jun 29, 2016
1 parent 2be5975 commit 179dc63
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/mfd/axp20x.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include <linux/err.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
Expand Down Expand Up @@ -667,6 +668,9 @@ static void axp20x_power_off(void)

regmap_write(axp20x_pm_power_off->regmap, AXP20X_OFF_CTRL,
AXP20X_OFF);

/* Give capacitors etc. time to drain to avoid kernel panic msg. */
msleep(500);
}

int axp20x_match_device(struct axp20x_dev *axp20x)
Expand Down

0 comments on commit 179dc63

Please sign in to comment.