Skip to contentSkip to conversation

sunxi: axp2xx: disable ldoio0/1 at boot

PATCH New Hans de Goede 2 participants 3 messages Sep 12, 2016 X-powers multifunction PMIC device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sunxi: axp2xx: disable ldoio0/1 at boot

When cold-booting the ldoio0/1 regulators are always off / the gpios are always at tristate. But when re-booting from android these are sometimes on. Disable them at axp_init time (iow as early as possible) to remove this difference between a cold boot and a reboot.

---
 drivers/power/axp209.c | 10 +++++++++-
 drivers/power/axp221.c |  9 ++++++++-
 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/power/axp209.c +9 -1
index fc162a1..998e114 100644
@@ -167,7 +167,15 @@ int axp_init(void)
 			return rc;
 	}
 
-	return 0;
+	/*
+	 * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting
+	 * from android these are sometimes on.
+	 */
+	rc |= pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT);
+	rc |= pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT);
+	rc |= pmic_bus_write(AXP_GPIO2_CTRL, AXP_GPIO_CTRL_INPUT);
+
+	return rc;
 }
 
 int do_poweroff(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
drivers/power/axp221.c +8 -1
index 727ab09..0d14211 100644
@@ -223,7 +223,14 @@ int axp_init(void)
 	if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17))
 		return -ENODEV;
 
-	return 0;
+	/*
+	 * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting
+	 * from android these are sometimes on.
+	 */
+	ret |= pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT);
+	ret |= pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT);
+
+	return ret;
 }
 
 int axp_get_sid(unsigned int *sid)
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/1 sunxi: axp2xx: disable ldoio0/1 at boot

Quoted 11 lines · Hans de Goede
(quoted diff) +0 -0
@@ -223,7 +223,14 @@ int axp_init(void)
 > ?	if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17))
 > ?		return -ENODEV;

?

drivers/power/axp221.c int axp_init(void) · line 231

Quoted 7 lines
drivers/power/axp221.c +6 -1
-	return 0;
+	/*
+	?* Turn off LDOIO regulators / tri-state GPIO pins, when rebooting
+	?* from android these are sometimes on.
+	?*/
+	ret |= pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT);
+	ret |= pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT);

If ret values are errno's (as the context suggests by containing -ENODEV) then or-ing them together could result in corruption from combining two distinct errno values.

Ian.

#2 lore raw

PATCH 1/1 sunxi: axp2xx: disable ldoio0/1 at boot

Hi,

Quoted 5 lines · Ian Campbell
Quoted 4 lines · Hans de Goede
(quoted diff) +0 -0
@@ -223,7 +223,14 @@ int axp_init(void)
 >  	if (!(axp_chip_id == 0x6 || axp_chip_id == 0x7 || axp_chip_id == 0x17))
 >  		return -ENODEV;
 
Quoted 11 lines
Quoted 7 lines
(quoted diff) +0 -0
 > -	return 0;

drivers/power/axp221.c int axp_init(void) · line 231

Quoted 6 lines
drivers/power/axp221.c +6 -0
+	/*
+	 * Turn off LDOIO regulators / tri-state GPIO pins, when rebooting
+	 * from android these are sometimes on.
+	 */
+	ret |= pmic_bus_write(AXP_GPIO0_CTRL, AXP_GPIO_CTRL_INPUT);
+	ret |= pmic_bus_write(AXP_GPIO1_CTRL, AXP_GPIO_CTRL_INPUT);

If ret values are errno's (as the context suggests by containing -ENODEV) then or-ing them together could result in corruption from combining two distinct errno values.

True, v2 coming up ...

Regards,

Hans