Skip to contentSkip to conversation

mfd: axp20x: Add a 500ms delay at the end of axp20x_power_off

PATCH Superseded Hans de Goede 3 participants 3 messages Jun 5, 2016 – Jun 8, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: axp20x: Add a 500ms delay at the end of axp20x_power_off

The kernel expects the power_off function to not return, and if it does it panics. At 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.

---
 drivers/mfd/axp20x.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mfd/axp20x.c +4 -0
index 6364dab..fd80b09 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -677,6 +678,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)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 mfd: axp20x: Add a 500ms delay at the end of axp20x_power_off

Quoted 2 lines · Hans de Goede

The kernel expects the power_off function to not return, and if it does it panics. At a slight delay after the i2c write which turns off power

             ^^^ Add?

Otherwise,

Quoted 40 lines

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.

---
 drivers/mfd/axp20x.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mfd/axp20x.c +4 -1
index 6364dab..fd80b09 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -677,6 +678,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)
--

2.7.4

Applied
#2 lore raw

PATCH 1/1 mfd: axp20x: Add a 500ms delay at the end of axp20x_power_off

In reply to Hans de Goede
Quoted 10 lines · Hans de Goede

The kernel expects the power_off function to not return, and if it does it panics. At 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
Quoted 6 lines

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

---
 drivers/mfd/axp20x.c | 4 ++++
 1 file changed, 4 insertions(+)

Applied, thanks.

Quoted 22 lines
drivers/mfd/axp20x.c +4 -0
index 6364dab..fd80b09 100644
@@ -17,6 +17,7 @@
  */
 
 #include <linux/err.h>
+#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -677,6 +678,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)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog