Skip to contentSkip to conversation

Stop AXP from crashing when enabeling LDO3

PATCH New Olliver Schinagl 7 participants 19 messages Mar 1, 2017 – Apr 21, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Stop AXP from crashing when enabeling LDO3

Hi list,

When powering up an AXP209, the default value for LDO3 output is enabled. This works fine. However if for whatever reason, LDO3 is disabled, for example by OS during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen from Linux as well, u-boot disables LDO3 as a default value, the kernel enables it per its DTS, the kernel hangs as the PMIC gets shut down.

The root cause is that some boards have to high capacitance on the LDO3 output port causing inrush currents exceeding the maximum of the AXP209.

The fix is to turn on the LDO3 at the lowest possible voltage and then set the final voltage.

If the capacitance is really big (due to a connected device for example) the AXP209 also features VRC, or Voltage Rate Control, which allows the voltage ramp up to be even slower.

This patch series implements the above with a few tiny, cleanups I ran into underway.

The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

[0] https://groups.google.com/forum/m/#!topic/linux-sunxi/EDvEsbHHqQI

Olliver Schinagl (8):
sunxi: board: Print error after power initialization fails
sunxi: pmic_bus: Decrease boot time by not writing duplicate data
power: axp209: Use BIT() macro
power: axp209: Define the chip version mask
power: axp209: Reduce magic values by adding defines for LDO[234]
power: axp209: Add support for voltage rate control on LDO3
power: axp209: Limit inrush current for broken boards
arm: sunxi: Enable inrush quirk on Olimex OLinuXino-A20-Lime2

 arch/arm/mach-sunxi/pmic_bus.c        |  6 ++++
 board/sunxi/board.c                   | 14 ++++----
 configs/A20-OLinuXino-Lime2_defconfig |  1 +
 drivers/power/Kconfig                 | 42 ++++++++++++++++++++++
 drivers/power/axp209.c                | 61 ++++++++++++++++++++++++++------
 include/axp209.h                      | 66 ++++++++++++++++++++++++++---------
 6 files changed, 158 insertions(+), 32 deletions(-)
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/8 sunxi: board: Print error after power initialization fails

Currently during init, we enable all power, then enable the dram and after that check if there was an error during power-up.

This makes little sense, we should enable power and then check if power was brought up properly initializing other things.

This patch moves the DRAM init after the power failure check.

---
 board/sunxi/board.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
board/sunxi/board.c +8 -6
index 53656383d5..5467015860 100644
@@ -540,11 +540,6 @@ void sunxi_board_init(void)
 	power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
 #endif
 #endif
-	printf("DRAM:");
-	ramsize = sunxi_dram_init();
-	printf(" %d MiB\n", (int)(ramsize >> 20));
-	if (!ramsize)
-		hang();
 
 	/*
 	 * Only clock up the CPU to full speed if we are reasonably
@@ -553,7 +548,14 @@ void sunxi_board_init(void)
 	if (!power_failed)
 		clock_set_pll1(CONFIG_SYS_CLK_FREQ);
 	else
-		printf("Failed to set core voltage! Can't set CPU frequency\n");
+		printf("Error setting up the power controller.\n \
+			CPU frequency not set.\n");
+
+	printf("DRAM:");
+	ramsize = sunxi_dram_init();
+	printf(" %d MiB\n", (int)(ramsize >> 20));
+	if (!ramsize)
+		hang();
 }
 #endif
 
Signature · 1 line
2.11.0
#2 lore raw

PATCH 1/8 sunxi: board: Print error after power initialization fails

01.03.2017, 20:52, "Olliver Schinagl" <[email protected]>:

Quoted 7 lines

Currently during init, we enable all power, then enable the dram and after that check if there was an error during power-up.

This makes little sense, we should enable power and then check if power was brought up properly initializing other things.

This patch moves the DRAM init after the power failure check.

Seems meaningful... at least some Pine64 wrongly set its DRAM voltage when booting.

Quoted 45 lines

---
 board/sunxi/board.c | 14 ++++++++------

 1 file changed, 8 insertions(+), 6 deletions(-)
board/sunxi/board.c +0 -5
index 53656383d5..5467015860 100644
@@ -540,11 +540,6 @@ void sunxi_board_init(void)
          power_failed |= axp_set_sw(IS_ENABLED(CONFIG_AXP_SW_ON));
  #endif
  #endif
- printf("DRAM:");
- ramsize = sunxi_dram_init();
- printf(" %d MiB\n", (int)(ramsize >> 20));
- if (!ramsize)
- hang();
 
          /*
           * Only clock up the CPU to full speed if we are reasonably
@@ -553,7 +548,14 @@ void sunxi_board_init(void)
          if (!power_failed)
                  clock_set_pll1(CONFIG_SYS_CLK_FREQ);

         else
- printf("Failed to set core voltage! Can't set CPU frequency\n");
+ printf("Error setting up the power controller.\n \
+ CPU frequency not set.\n");
+
+ printf("DRAM:");
+ ramsize = sunxi_dram_init();
+ printf(" %d MiB\n", (int)(ramsize >> 20));
+ if (!ramsize)
+ hang();
 }
 #endif

--
2.11.0

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.

#3 lore raw

PATCH 2/8 sunxi: pmic_bus: Decrease boot time by not writing duplicate data

In reply to Olliver Schinagl

When we set or clear a pmic_bus bit, we do a read-modify-write operation. We waste some time however, by writing back the exact same value that was already set in the chip. Let us thus only configure the chip if the data is different.

---
 arch/arm/mach-sunxi/pmic_bus.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-sunxi/pmic_bus.c +6 -0
index 7c57f02792..dc3d328c1b 100644
@@ -95,6 +95,9 @@ int pmic_bus_setbits(u8 reg, u8 bits)
 	if (ret)
 		return ret;
 
+	if (val & bits)
+		return 0;
+
 	val |= bits;
 	return pmic_bus_write(reg, val);
 }
@@ -108,6 +111,9 @@ int pmic_bus_clrbits(u8 reg, u8 bits)
 	if (ret)
 		return ret;
 
+	if (!(val & bits))
+		return 0;
+
 	val &= ~bits;
 	return pmic_bus_write(reg, val);
 }
Signature · 1 line
2.11.0
#4 lore raw

PATCH 3/8 power: axp209: Use BIT() macro

In reply to Olliver Schinagl

Use the standard BIT() macro to define BITS.

---
 include/axp209.h | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)
include/axp209.h +18 -16
index e1b22e3442..7803300328 100644
@@ -4,6 +4,8 @@
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
+#include <linux/bitops.h>
+
 enum axp209_reg {
 	AXP209_POWER_STATUS = 0x00,
 	AXP209_CHIP_VERSION = 0x03,
@@ -21,29 +23,29 @@ enum axp209_reg {
 	AXP209_SHUTDOWN = 0x32,
 };
 
-#define AXP209_POWER_STATUS_ON_BY_DC	(1 << 0)
-#define AXP209_POWER_STATUS_VBUS_USABLE	(1 << 4)
+#define AXP209_POWER_STATUS_ON_BY_DC	BIT(0)
+#define AXP209_POWER_STATUS_VBUS_USABLE	BIT(4)
 
-#define AXP209_OUTPUT_CTRL_EXTEN	(1 << 0)
-#define AXP209_OUTPUT_CTRL_DCDC3	(1 << 1)
-#define AXP209_OUTPUT_CTRL_LDO2		(1 << 2)
-#define AXP209_OUTPUT_CTRL_LDO4		(1 << 3)
-#define AXP209_OUTPUT_CTRL_DCDC2	(1 << 4)
-#define AXP209_OUTPUT_CTRL_LDO3		(1 << 6)
+#define AXP209_OUTPUT_CTRL_EXTEN	BIT(0)
+#define AXP209_OUTPUT_CTRL_DCDC3	BIT(1)
+#define AXP209_OUTPUT_CTRL_LDO2		BIT(2)
+#define AXP209_OUTPUT_CTRL_LDO4		BIT(3)
+#define AXP209_OUTPUT_CTRL_DCDC2	BIT(4)
+#define AXP209_OUTPUT_CTRL_LDO3		BIT(6)
 
-#define AXP209_IRQ5_PEK_UP		(1 << 6)
-#define AXP209_IRQ5_PEK_DOWN		(1 << 5)
+#define AXP209_IRQ5_PEK_UP		BIT(6)
+#define AXP209_IRQ5_PEK_DOWN		BIT(5)
 
-#define AXP209_POWEROFF			(1 << 7)
+#define AXP209_POWEROFF			BIT(7)
 
 /* For axp_gpio.c */
 #define AXP_POWER_STATUS		0x00
-#define AXP_POWER_STATUS_VBUS_PRESENT		(1 << 5)
+#define AXP_POWER_STATUS_VBUS_PRESENT	BIT(5)
 #define AXP_GPIO0_CTRL			0x90
 #define AXP_GPIO1_CTRL			0x92
 #define AXP_GPIO2_CTRL			0x93
-#define AXP_GPIO_CTRL_OUTPUT_LOW		0x00 /* Drive pin low */
-#define AXP_GPIO_CTRL_OUTPUT_HIGH		0x01 /* Drive pin high */
-#define AXP_GPIO_CTRL_INPUT			0x02 /* Input */
+#define AXP_GPIO_CTRL_OUTPUT_LOW	0x00 /* Drive pin low */
+#define AXP_GPIO_CTRL_OUTPUT_HIGH	0x01 /* Drive pin high */
+#define AXP_GPIO_CTRL_INPUT		0x02 /* Input */
 #define AXP_GPIO_STATE			0x94
-#define AXP_GPIO_STATE_OFFSET			4
+#define AXP_GPIO_STATE_OFFSET		4
Signature · 1 line
2.11.0
#5 lore raw

PATCH 4/8 power: axp209: Define the chip version mask

In reply to Olliver Schinagl

Use a define for the chip version mask on the axp209.

---
 drivers/power/axp209.c | 5 +----
 include/axp209.h       | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/power/axp209.c +1 -4
index 731b75e50a..d496f675a1 100644
@@ -154,10 +154,7 @@ int axp_init(void)
 	if (rc)
 		return rc;
 
-	/* Low 4 bits is chip version */
-	ver &= 0x0f;
-
-	if (ver != 0x1)
+	if ((ver & AXP209_CHIP_VERSION_MASK) != 0x1)
 		return -1;
 
 	/* Mask all interrupts */
include/axp209.h +2 -0
index 7803300328..51d2e88dd2 100644
@@ -26,6 +26,8 @@ enum axp209_reg {
 #define AXP209_POWER_STATUS_ON_BY_DC	BIT(0)
 #define AXP209_POWER_STATUS_VBUS_USABLE	BIT(4)
 
+#define AXP209_CHIP_VERSION_MASK	0x0f
+
 #define AXP209_OUTPUT_CTRL_EXTEN	BIT(0)
 #define AXP209_OUTPUT_CTRL_DCDC3	BIT(1)
 #define AXP209_OUTPUT_CTRL_LDO2		BIT(2)
Signature · 1 line
2.11.0
#6 lore raw

PATCH 4/8 power: axp209: Define the chip version mask

Hi Olliver,

Quoted 1 line · Olliver Schinagl

Use a define for the chip version mask on the axp209.

I missed this patch...Could you resend the patch with other patches? (on latest u-boot version.)

There is conflict.

Best Regards,
Jaehoon Chung

Quoted 37 lines
---
 drivers/power/axp209.c | 5 +----
 include/axp209.h       | 2 ++
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/power/axp209.c +1 -4
index 731b75e50a..d496f675a1 100644
@@ -154,10 +154,7 @@ int axp_init(void)
 	if (rc)
 		return rc;
 
-	/* Low 4 bits is chip version */
-	ver &= 0x0f;
-
-	if (ver != 0x1)
+	if ((ver & AXP209_CHIP_VERSION_MASK) != 0x1)
 		return -1;
 
 	/* Mask all interrupts */
include/axp209.h +2 -0
index 7803300328..51d2e88dd2 100644
@@ -26,6 +26,8 @@ enum axp209_reg {
 #define AXP209_POWER_STATUS_ON_BY_DC	BIT(0)
 #define AXP209_POWER_STATUS_VBUS_USABLE	BIT(4)
 
+#define AXP209_CHIP_VERSION_MASK	0x0f
+
 #define AXP209_OUTPUT_CTRL_EXTEN	BIT(0)
 #define AXP209_OUTPUT_CTRL_DCDC3	BIT(1)
 #define AXP209_OUTPUT_CTRL_LDO2		BIT(2)
#7 lore raw

PATCH 5/8 power: axp209: Reduce magic values by adding defines for LDO[234]

In reply to Olliver Schinagl

The AXP209 has a few 'magisc-ish' values that are better served with clear defines.

---
 drivers/power/axp209.c | 10 ++++------
 include/axp209.h       | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 6 deletions(-)
drivers/power/axp209.c +4 -6
index d496f675a1..a5d38cdf76 100644
@@ -82,8 +82,7 @@ int axp_set_aldo2(unsigned int mvolt)
 	if (rc)
 		return rc;
 
-	/* LDO2 configuration is in upper 4 bits */
-	reg = (reg & 0x0f) | (cfg << 4);
+	reg |= AXP209_LDO24_LDO2_SET(reg, cfg);
 	rc = pmic_bus_write(AXP209_LDO24_VOLTAGE, reg);
 	if (rc)
 		return rc;
@@ -101,9 +100,9 @@ int axp_set_aldo3(unsigned int mvolt)
 					AXP209_OUTPUT_CTRL_LDO3);
 
 	if (mvolt == -1)
-		cfg = 0x80;	/* determined by LDO3IN pin */
+		cfg = AXP209_LDO3_VOLTAGE_FROM_LDO3IN;
 	else
-		cfg = axp209_mvolt_to_cfg(mvolt, 700, 3500, 25);
+		cfg = AXP209_LDO3_VOLTAGE_SET(axp209_mvolt_to_cfg(mvolt, 700, 3500, 25));
 
 	rc = pmic_bus_write(AXP209_LDO3_VOLTAGE, cfg);
 	if (rc)
@@ -132,8 +131,7 @@ int axp_set_aldo4(unsigned int mvolt)
 	if (rc)
 		return rc;
 
-	/* LDO4 configuration is in lower 4 bits */
-	reg = (reg & 0xf0) | (cfg << 0);
+	reg |= AXP209_LDO24_LDO4_SET(reg, cfg);
 	rc = pmic_bus_write(AXP209_LDO24_VOLTAGE, reg);
 	if (rc)
 		return rc;
include/axp209.h +14 -0
index 51d2e88dd2..e4210eca00 100644
@@ -35,6 +35,20 @@ enum axp209_reg {
 #define AXP209_OUTPUT_CTRL_DCDC2	BIT(4)
 #define AXP209_OUTPUT_CTRL_LDO3		BIT(6)
 
+#define AXP209_LDO24_LDO2_MASK		0xf0
+#define AXP209_LDO24_LDO4_MASK		0x0f
+#define AXP209_LDO24_LDO2_SET(reg, cfg)	\
+	(((reg) & ~AXP209_LDO24_LDO2_MASK) | \
+	(((cfg) << 4) & AXP209_LDO24_LDO2_MASK))
+#define AXP209_LDO24_LDO4_SET(reg, cfg)	\
+	(((reg) & ~AXP209_LDO24_LDO4_MASK) | \
+	(((cfg) << 0) & AXP209_LDO24_LDO4_MASK))
+
+
+#define AXP209_LDO3_VOLTAGE_FROM_LDO3IN	BIT(7)
+#define AXP209_LDO3_VOLTAGE_MASK	0x7f
+#define AXP209_LDO3_VOLTAGE_SET(x)	((x) & AXP209_LDO3_VOLTAGE_MASK)
+
 #define AXP209_IRQ5_PEK_UP		BIT(6)
 #define AXP209_IRQ5_PEK_DOWN		BIT(5)
 
Signature · 1 line
2.11.0
#8 lore raw

PATCH 6/8 power: axp209: Add support for voltage rate control on LDO3

In reply to Olliver Schinagl

The AXP209 has voltage rate control, or can set a slew rate, for LDO3. This allows for the power to gradually rise to the desired voltage, instead of spiking up quickly. Reason to have this can be to reduce the inrush currents for example.

There are 3 slopes to choose from, the default, 'none' is a voltage rise of 0.0167 V/uS, a 1.6 mV/uS and a 0.8 mV/uS voltage rise.

---
 drivers/power/Kconfig  | 33 +++++++++++++++++++++++++++++++++
 drivers/power/axp209.c | 24 ++++++++++++++++++++++++
 include/axp209.h       | 16 ++++++++++++++++
 3 files changed, 73 insertions(+)
drivers/power/Kconfig +33 -0
index f2c5629be2..3f10f84a89 100644
@@ -188,6 +188,39 @@ config AXP_ALDO3_VOLT
 	On A83T / H8 boards aldo3 is AVCC, VCC-PL, and VCC-LED, and should be
 	3.0V.
 
+choice
+	prompt "axp pmic (a)ldo3 voltage rate control"
+	depends on AXP209_POWER && (AXP_ALDO3_VOLT != 0)
+	default AXP_ALDO3_VOLT_SLOPE_NONE
+	---help---
+	The AXP can slowly ramp up voltage to reduce the inrush current when
+	changing voltages.
+	Note, this does not apply when enabeling/disableing LDO3. See
+	"axp pmic (a)ldo3 inrush quirk" below to enable a slew rate to limit
+	inrush current on broken board designs.
+
+config AXP_ALDO3_VOLT_SLOPE_NONE
+	bool "No voltage slope"
+	---help---
+	Tries to reach the next voltage setting near instantaneous. Measurements
+	indicate that this is about 0.0167 V/uS.
+
+config AXP_ALDO3_VOLT_SLOPE_16
+	bool "1.6 mV per uS"
+	---help---
+	Increases the voltage by 1.6 mV per uS until the final voltage has
+	been reached. Note that the scaling is in 25 mV steps however and thus
+	the slew rate is 25 mV/31.250 uS in reality.
+
+config AXP_ALDO3_VOLT_SLOPE_08
+	bool "0.8 mV per uS"
+	---help---
+	Increases the voltage by 0.8 mV per uS until the final voltage has
+	been reached. Note that the scaling is in 25 mV steps however and thus
+	the slew rate is 25 mV/15.625 uS in reality. This is the slowest rate.
+
+endchoice
+
 config AXP_ALDO4_VOLT
 	int "axp pmic (a)ldo4 voltage"
 	depends on AXP209_POWER
drivers/power/axp209.c +24 -0
index a5d38cdf76..8f9269cb40 100644
@@ -10,6 +10,16 @@
 #include <asm/arch/pmic_bus.h>
 #include <axp_pmic.h>
 
+#ifdef CONFIG_AXP_ALDO3_VOLT_SLOPE_08
+#  define AXP209_VRC_SLOPE AXP209_VRC_LDO3_800uV_uS
+#endif
+#ifdef CONFIG_AXP_ALDO3_VOLT_SLOPE_16
+#  define AXP209_VRC_SLOPE AXP209_VRC_LDO3_1600uV_uS
+#endif
+#if defined CONFIG_AXP_ALDO3_VOLT_SLOPE_NONE || !defined AXP209_VRC_SLOPE
+#  define AXP209_VRC_SLOPE 0x00
+#endif
+
 static u8 axp209_mvolt_to_cfg(int mvolt, int min, int max, int div)
 {
 	if (mvolt < min)
@@ -99,6 +109,20 @@ int axp_set_aldo3(unsigned int mvolt)
 		return pmic_bus_clrbits(AXP209_OUTPUT_CTRL,
 					AXP209_OUTPUT_CTRL_LDO3);
 
+	/*
+	 * Some boards have trouble reaching the target voltage without causing
+	 * great inrush currents. To prevent this, boards can enable a certain
+	 * slope to ramp up voltage. Note, this only works when changing an
+	 * already active power rail. When toggling power on, the AXP ramps up
+	 * [email protected] V/uS.
+	 */
+	rc = pmic_bus_read(AXP209_VRC_DCDC2_LDO3, &cfg);
+	cfg = AXP209_VRC_LDO3_SLOPE_SET(cfg, AXP209_VRC_SLOPE);
+	rc |= pmic_bus_write(AXP209_VRC_DCDC2_LDO3, cfg);
+
+	if (rc)
+		return rc;
+
 	if (mvolt == -1)
 		cfg = AXP209_LDO3_VOLTAGE_FROM_LDO3IN;
 	else
include/axp209.h +16 -0
index e4210eca00..62be93b806 100644
@@ -11,6 +11,7 @@ enum axp209_reg {
 	AXP209_CHIP_VERSION = 0x03,
 	AXP209_OUTPUT_CTRL = 0x12,
 	AXP209_DCDC2_VOLTAGE = 0x23,
+	AXP209_VRC_DCDC2_LDO3 = 0x25,
 	AXP209_DCDC3_VOLTAGE = 0x27,
 	AXP209_LDO24_VOLTAGE = 0x28,
 	AXP209_LDO3_VOLTAGE = 0x29,
@@ -35,6 +36,21 @@ enum axp209_reg {
 #define AXP209_OUTPUT_CTRL_DCDC2	BIT(4)
 #define AXP209_OUTPUT_CTRL_LDO3		BIT(6)
 
+#define AXP209_VRC_LDO3_EN		BIT(3)
+#define AXP209_VRC_DCDC2_EN		BIT(2)
+#define AXP209_VRC_LDO3_800uV_uS	(BIT(1) | AXP209_VRC_LDO3_EN)
+#define AXP209_VRC_LDO3_1600uV_uS	AXP209_VRC_LDO3_EN
+#define AXP209_VRC_DCDC2_800uV_uS	(BIT(0) | AXP209_VRC_DCDC2_EN)
+#define AXP209_VRC_DCDC2_1600uV_uS	AXP209_VRC_DCDC2_EN
+#define AXP209_VRC_LDO3_MASK		0xa
+#define AXP209_VRC_DCDC2_MASK		0x5
+#define AXP209_VRC_DCDC2_SLOPE_SET(reg, cfg) \
+	(((reg) & ~AXP209_VRC_DCDC2_MASK) | \
+	((cfg) & AXP209_VRC_DCDC2_MASK))
+#define AXP209_VRC_LDO3_SLOPE_SET(reg, cfg) \
+	(((reg) & ~AXP209_VRC_LDO3_MASK) | \
+	((cfg) & AXP209_VRC_LDO3_MASK))
+
 #define AXP209_LDO24_LDO2_MASK		0xf0
 #define AXP209_LDO24_LDO4_MASK		0x0f
 #define AXP209_LDO24_LDO2_SET(reg, cfg)	\
Signature · 1 line
2.11.0
#9 lore raw

PATCH 6/8 power: axp209: Add support for voltage rate control on LDO3

Hi Oliver,

2017-03-01 13:52 GMT+01:00 Olliver Schinagl <[email protected]>:

include/axp209.h enum axp209_reg { · line 42

Quoted 5 lines
include/axp209.h +4 -0
+#define AXP209_VRC_LDO3_EN             BIT(3)
+#define AXP209_VRC_DCDC2_EN            BIT(2)
+#define AXP209_VRC_LDO3_800uV_uS       (BIT(1) | AXP209_VRC_LDO3_EN)
+#define AXP209_VRC_LDO3_1600uV_uS      AXP209_VRC_LDO3_EN

Does that mean that the description of the LDO3/DCDC2 VRC control on the linux-sunxi wiki [1] and the PDF datasheet [2] are wrong? They say that VRC for LDO3 is enabled if the bit is 0, disabled when the bit is 1. And that the default value is enabled.

[1]
http://linux-sunxi.org/AXP209#REG_25H:_DC-DC2.2FLDO3_dynamic_voltage_scaling_parameter_settings
[2] http://dl.linux-sunxi.org/AXP/AXP209_Datasheet_v1.0en.pdf

Cheers,

Marcus

#10 lore raw

PATCH 6/8 power: axp209: Add support for voltage rate control on LDO3

Hey Marcus,

Quoted 11 lines · Marcus Weseloh

Hi Oliver,

2017-03-01 13:52 GMT+01:00 Olliver Schinagl <[email protected] <mailto:[email protected]>>:

    +#define AXP209_VRC_LDO3_EN             BIT(3)
    +#define AXP209_VRC_DCDC2_EN            BIT(2)
    +#define AXP209_VRC_LDO3_800uV_uS       (BIT(1) | AXP209_VRC_LDO3_EN)
    +#define AXP209_VRC_LDO3_1600uV_uS      AXP209_VRC_LDO3_EN
Quoted 4 lines

Does that mean that the description of the LDO3/DCDC2 VRC control on the linux-sunxi wiki [1] and the PDF datasheet [2] are wrong? They say that VRC for LDO3 is enabled if the bit is 0, disabled when the bit is 1. And that the default value is enabled.

Yes you are correct (and well spotted) that the datasheet is wrong. It took us some time to figure out why it wasn't working :)

I thought I updated the wiki, but I must have done it incorrectly. I will fix it immediatly.

olliver

Quoted 8 lines

[1]
http://linux-sunxi.org/AXP209#REG_25H:_DC-DC2.2FLDO3_dynamic_voltage_scaling_parameter_settings
[2] http://dl.linux-sunxi.org/AXP/AXP209_Datasheet_v1.0en.pdf

Cheers,

Marcus

#11 lore raw

PATCH 6/8 power: axp209: Add support for voltage rate control on LDO3

Quoted 21 lines · Olliver Schinagl

Hey Marcus,

Quoted 12 lines · Marcus Weseloh

Hi Oliver,

2017-03-01 13:52 GMT+01:00 Olliver Schinagl <[email protected] <mailto:[email protected]>>:

    +#define AXP209_VRC_LDO3_EN             BIT(3)
    +#define AXP209_VRC_DCDC2_EN            BIT(2)
    +#define AXP209_VRC_LDO3_800uV_uS       (BIT(1) | AXP209_VRC_LDO3_EN)
    +#define AXP209_VRC_LDO3_1600uV_uS      AXP209_VRC_LDO3_EN
Quoted 4 lines

Does that mean that the description of the LDO3/DCDC2 VRC control on the linux-sunxi wiki [1] and the PDF datasheet [2] are wrong? They say that VRC for LDO3 is enabled if the bit is 0, disabled when the bit is 1. And that the default value is enabled.

Quoted 5 lines

Yes you are correct (and well spotted) that the datasheet is wrong. It took us some time to figure out why it wasn't working :)

I thought I updated the wiki, but I must have done it incorrectly. I will fix it immediatly.

Please also leave a note there saying the datasheet is wrong.

Thanks
ChenYu

Quoted 14 lines

olliver

Quoted 9 lines

[1]

http://linux-sunxi.org/AXP209#REG_25H:_DC-DC2.2FLDO3_dynamic_voltage_scaling_parameter_settings
[2] http://dl.linux-sunxi.org/AXP/AXP209_Datasheet_v1.0en.pdf

Cheers,

Marcus

#12 lore raw

PATCH 7/8 power: axp209: Limit inrush current for broken boards

In reply to Olliver Schinagl

Some boards feature a capacitance on LDO3's output that is to large, causing inrush currents which as a result, shut down the AXP209. This has been reported before, without knowing the actual cause.

A fix appeared to be done with commit 0e6e34ac8db ("sunxi: Olimex A20
boards: Enable LDO3 and LDO4 regulators").

The description there is a bit misleading, the kernel does not hang during AXP209 initialization, the PMIC shuts down, causing voltages to drop and thus the whole system to freeze.

While the AXP209 does have the ability to ramp up the voltage slowly, to reduce these inrush currents, the voltage rate control (VRC) however is not applicable when switching on the LDO3 output. Only when going from an enabled lower voltage setting, to a higher voltage setting is the VRC in effect.

To work around this problem, we set LDO3 to the lowest possible setting of 0.7 V if it was not yet enabled, and then let the VRC (if enabled) do its thing. It should be noted, that for some undocumented reason, there is a short delay needed between setting the LDO3 voltage register and enabling the power. One would expect that this delay ought to be just after enabling the output power at 0.7 V, but this did not work.

---
 drivers/power/Kconfig  |  9 +++++++++
 drivers/power/axp209.c | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+)
drivers/power/Kconfig +9 -0
index 3f10f84a89..644f206b4d 100644
@@ -221,6 +221,15 @@ config AXP_ALDO3_VOLT_SLOPE_08
 
 endchoice
 
+config AXP_ALDO3_INRUSH_QUIRK
+	bool "axp pmic (a)ldo3 inrush quirk"
+	depends on AXP209_POWER
+	default n
+	---help---
+	The reference design denotes a value of 4.7 uF for the output capacitor
+	of LDO3. Some boards have to higher capacitance than that which causes
+	an inrush current and causes an AXP209 shutdown.
+
 config AXP_ALDO4_VOLT
 	int "axp pmic (a)ldo4 voltage"
 	depends on AXP209_POWER
drivers/power/axp209.c +22 -0
index 8f9269cb40..2121b88e0c 100644
@@ -123,6 +123,28 @@ int axp_set_aldo3(unsigned int mvolt)
 	if (rc)
 		return rc;
 
+	/*
+	 * On some boards, LDO3 has a to big capacitor installed. When
+	 * turning on LDO3, this causes the AXP209 to shutdown on
+	 * voltages over 1.9 volt. As a work around, we enable LDO3
+	 * first with the lowest possible voltage. If this still causes
+	 * high inrush currents, the voltage slope should be increased.
+	 */
+#ifdef CONFIG_AXP_ALDO3_INRUSH_QUIRK
+	rc = pmic_bus_read(AXP209_OUTPUT_CTRL, &cfg);
+	if (rc)
+		return rc;
+
+	if (!(cfg & AXP209_OUTPUT_CTRL_LDO3)) {
+		rc = pmic_bus_write(AXP209_LDO3_VOLTAGE, 0x0); /* 0.7 Volt */
+		mdelay(1);
+		rc |= pmic_bus_setbits(AXP209_OUTPUT_CTRL, AXP209_OUTPUT_CTRL_LDO3);
+
+		if (rc)
+			return rc;
+	}
+#endif
+
 	if (mvolt == -1)
 		cfg = AXP209_LDO3_VOLTAGE_FROM_LDO3IN;
 	else
Signature · 1 line
2.11.0
#13 lore raw

PATCH 8/8 arm: sunxi: Enable inrush quirk on Olimex OLinuXino-A20-Lime2

In reply to Olliver Schinagl

The lime2 features a too large capacitor on the LDO3 output, which causes the PMIC to shutdown when enabling power. To be able to still boot up however, we must gradually enable power on LDO3 for this board.

---
 configs/A20-OLinuXino-Lime2_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/A20-OLinuXino-Lime2_defconfig +1 -0
index 8fd7c64e77..72bb8beb2e 100644
@@ -19,6 +19,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_DFU_RAM=y
 CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_ETH_DESIGNWARE=y
+CONFIG_AXP_ALDO3_INRUSH_QUIRK=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
Signature · 1 line
2.11.0
#14 lore raw

cover Stop AXP from crashing when enabeling LDO3

In reply to Olliver Schinagl

Hi Oliver,

Quoted 19 lines · Olliver Schinagl

Hi list,

When powering up an AXP209, the default value for LDO3 output is enabled. This works fine. However if for whatever reason, LDO3 is disabled, for example by OS during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen from Linux as well, u-boot disables LDO3 as a default value, the kernel enables it per its DTS, the kernel hangs as the PMIC gets shut down.

The root cause is that some boards have to high capacitance on the LDO3 output port causing inrush currents exceeding the maximum of the AXP209.

The fix is to turn on the LDO3 at the lowest possible voltage and then set the final voltage.

If the capacitance is really big (due to a connected device for example) the AXP209 also features VRC, or Voltage Rate Control, which allows the voltage ramp up to be even slower.

Quoted 5 lines

This patch series implements the above with a few tiny, cleanups I ran into underway.

The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

If you don't CC the proper maintainers, no one is going to pick the patches.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170301/18cdc5f1/attachment.sig>
#15 lore raw

cover Stop AXP from crashing when enabeling LDO3

Hey Maxime,

Quoted 22 lines · Maxime Ripard

Hi Oliver,

Quoted 19 lines · Olliver Schinagl

Hi list,

When powering up an AXP209, the default value for LDO3 output is enabled. This works fine. However if for whatever reason, LDO3 is disabled, for example by OS during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen from Linux as well, u-boot disables LDO3 as a default value, the kernel enables it per its DTS, the kernel hangs as the PMIC gets shut down.

The root cause is that some boards have to high capacitance on the LDO3 output port causing inrush currents exceeding the maximum of the AXP209.

The fix is to turn on the LDO3 at the lowest possible voltage and then set the final voltage.

If the capacitance is really big (due to a connected device for example) the AXP209 also features VRC, or Voltage Rate Control, which allows the voltage ramp up to be even slower.

Quoted 7 lines
Quoted 5 lines

This patch series implements the above with a few tiny, cleanups I ran into underway.

The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

If you don't CC the proper maintainers, no one is going to pick the patches.

who did I miss? I did use the get_maintainers script, and added you explicitly.

There is no sunxi custodian anymore, it is orphaned.

Quoted 3 lines

Maxime

#16 lore raw

01.03.2017, 21:45, "Olliver Schinagl" <[email protected]>:

Quoted 31 lines

Hey Maxime,

Quoted 28 lines · Maxime Ripard

 Hi Oliver,

Quoted 24 lines · Olliver Schinagl

 Hi list,

 When powering up an AXP209, the default value for LDO3 output is enabled. This works fine. However if for whatever reason, LDO3 is disabled, for example by OS during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen from Linux as well, u-boot disables LDO3 as a default value, the kernel enables it per its DTS, the kernel hangs as the PMIC gets shut down.

 The root cause is that some boards have to high capacitance on the LDO3 output port causing inrush currents exceeding the maximum of the AXP209.

 The fix is to turn on the LDO3 at the lowest possible voltage and then set the final voltage.

 If the capacitance is really big (due to a connected device for example) the AXP209 also features VRC, or Voltage Rate Control, which allows the voltage ramp up to be even slower.

 This patch series implements the above with a few tiny, cleanups I ran into underway.

 The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

Quoted 6 lines
Quoted 1 line

 If you don't CC the proper maintainers, no one is going to pick the patches.

who did I miss? I did use the get_maintainers script, and added you explicitly.

There is no sunxi custodian anymore, it is orphaned.

Currently maintainers are Maxime Ripard and Jegan Teki.

Quoted 7 lines
Quoted 2 lines

 Maxime

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe at googlegroups.com. For more options, visit https://groups.google.com/d/optout.

#17 lore raw

cover Stop AXP from crashing when enabeling LDO3

In reply to Maxime Ripard

Hey Maxime, Jagan,

Quoted 22 lines · Maxime Ripard

Hi Oliver,

Quoted 19 lines · Olliver Schinagl

Hi list,

When powering up an AXP209, the default value for LDO3 output is enabled. This works fine. However if for whatever reason, LDO3 is disabled, for example by OS during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen from Linux as well, u-boot disables LDO3 as a default value, the kernel enables it per its DTS, the kernel hangs as the PMIC gets shut down.

The root cause is that some boards have to high capacitance on the LDO3 output port causing inrush currents exceeding the maximum of the AXP209.

The fix is to turn on the LDO3 at the lowest possible voltage and then set the final voltage.

If the capacitance is really big (due to a connected device for example) the AXP209 also features VRC, or Voltage Rate Control, which allows the voltage ramp up to be even slower.

Quoted 7 lines
Quoted 5 lines

This patch series implements the above with a few tiny, cleanups I ran into underway.

The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

If you don't CC the proper maintainers, no one is going to pick the patches.

Appologies, I did check the u-boot page, where sunxi is still listed as orphaned and the AXP stuff does not show up with the sunxi maintainers.

@Jagan, do you wish for me to resend the series, or can you see them via the linux-sunxi list?

Olliver

Quoted 3 lines

Maxime

#18 lore raw

cover Stop AXP from crashing when enabeling LDO3

Hey Jagan,

FYI,

I used the wrong e-mail address, I think it is still listed in some of the u-boot sources.

Olliver

Quoted 54 lines · Olliver Schinagl

Hey Maxime, Jagan,

Quoted 34 lines · Maxime Ripard

Hi Oliver,

Quoted 31 lines · Olliver Schinagl

Hi list,

When powering up an AXP209, the default value for LDO3 output is enabled. This
works fine. However if for whatever reason, LDO3 is disabled, for example by OS
during reboot and u-boot enables LDO3 again, the PMIC shutsdown (without setting an interrupt) causing the board to hang. This behavior has been seen
from Linux as well, u-boot disables LDO3 as a default value, the kernel enables
it per its DTS, the kernel hangs as the PMIC gets shut down.

The root cause is that some boards have to high capacitance on the LDO3 output
port causing inrush currents exceeding the maximum of the AXP209.

The fix is to turn on the LDO3 at the lowest possible voltage and then set the
final voltage.

If the capacitance is really big (due to a connected device for example) the
AXP209 also features VRC, or Voltage Rate Control, which allows the voltage
ramp up to be even slower.

This patch series implements the above with a few tiny, cleanups I ran into
underway.

Quoted 5 lines
Quoted 2 lines

The initial discussion with some scope screenshots can be found in the linux-sunxi mailing list [0].

If you don't CC the proper maintainers, no one is going to pick the patches.

Appologies, I did check the u-boot page, where sunxi is still listed as orphaned and the AXP stuff does not show up with the sunxi maintainers.

@Jagan, do you wish for me to resend the series, or can you see them via the linux-sunxi list?

Olliver

Quoted 3 lines

Maxime