[PATCH] sunxi: set PIO voltage to hardware-detected value on startup on H6

22 views
Skip to first unread message

Icenowy Zheng

unread,
Apr 24, 2019, 1:44:33 AM4/24/19
to Jagan Teki, Maxime Ripard, Chen-Yu Tsai, u-b...@lists.denx.de, linux...@googlegroups.com, Icenowy Zheng
The Allwinner H6 SoC has a register to set the PIO banks' voltage. When
it mismatches the real voltage supplied to the VCC to the PIO supply,
the PIO will work improperly.

The PIO controller also has a register that contains the status of each
VCC rail of the PIO supplies, and it has the same definition with the
configuration register. so we can just copy the content of this register
to the configuration register at startup, to ensure the configuration is
correct at startup stage.

Signed-off-by: Icenowy Zheng <ice...@aosc.io>
---
arch/arm/include/asm/arch-sunxi/gpio.h | 3 +++
arch/arm/mach-sunxi/board.c | 9 +++++++++
2 files changed, 12 insertions(+)

diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h
index 40a3f845d0..a646ea6a3c 100644
--- a/arch/arm/include/asm/arch-sunxi/gpio.h
+++ b/arch/arm/include/asm/arch-sunxi/gpio.h
@@ -73,6 +73,9 @@ struct sunxi_gpio_reg {
struct sunxi_gpio_int gpio_int;
};

+#define SUN50I_H6_GPIO_POW_MOD_SEL 0x340
+#define SUN50I_H6_GPIO_POW_MOD_VAL 0x348
+
#define BANK_TO_GPIO(bank) (((bank) < SUNXI_GPIO_L) ? \
&((struct sunxi_gpio_reg *)SUNXI_PIO_BASE)->gpio_bank[bank] : \
&((struct sunxi_gpio_reg *)SUNXI_R_PIO_BASE)->gpio_bank[(bank) - SUNXI_GPIO_L])
diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index c6dd7b8e54..bd3b5d8303 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -65,6 +65,7 @@ struct mm_region *mem_map = sunxi_mem_map;

static int gpio_init(void)
{
+ __maybe__unused uint val;
#if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
#if defined(CONFIG_MACH_SUN4I) || \
defined(CONFIG_MACH_SUN7I) || \
@@ -139,6 +140,14 @@ static int gpio_init(void)
#error Unsupported console port number. Please fix pin mux settings in board.c
#endif

+#ifdef CONFIG_MACH_SUN50I_H6
+ /* Update PIO power bias configuration by copy hardware detected value */
+ val = readl(SUNXI_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_VAL);
+ writel(val, SUNXI_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_SEL);
+ val = readl(SUNXI_R_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_VAL);
+ writel(val, SUNXI_R_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_SEL);
+#endif
+
return 0;
}

--
2.18.1

Icenowy Zheng

unread,
Apr 24, 2019, 1:59:01 AM4/24/19
to Jagan Teki, Maxime Ripard, Chen-Yu Tsai, u-b...@lists.denx.de, linux...@googlegroups.com
在 2019-04-24三的 13:44 +0800,Icenowy Zheng写道:
Sorry for the extra _ here. Should be __maybe_unused.

Ondřej Jirman

unread,
Oct 25, 2019, 8:59:20 AM10/25/19
to Icenowy Zheng, Jagan Teki, Maxime Ripard, Chen-Yu Tsai, u-b...@lists.denx.de, linux...@googlegroups.com
Hi,
Does this really run after regulators are turned on? If not, how will the SoC
detect voltages correctly?

regards,
o.

> {
> + __maybe__unused uint val;
> #if CONFIG_CONS_INDEX == 1 && defined(CONFIG_UART0_PORT_F)
> #if defined(CONFIG_MACH_SUN4I) || \
> defined(CONFIG_MACH_SUN7I) || \
> @@ -139,6 +140,14 @@ static int gpio_init(void)
> #error Unsupported console port number. Please fix pin mux settings in board.c
> #endif
>
> +#ifdef CONFIG_MACH_SUN50I_H6
> + /* Update PIO power bias configuration by copy hardware detected value */
> + val = readl(SUNXI_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_VAL);
> + writel(val, SUNXI_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_SEL);
> + val = readl(SUNXI_R_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_VAL);
> + writel(val, SUNXI_R_PIO_BASE + SUN50I_H6_GPIO_POW_MOD_SEL);
> +#endif
> +
> return 0;
> }
>
> --
> 2.18.1
>
> _______________________________________________
> U-Boot mailing list
> U-B...@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
Reply all
Reply to author
Forward
0 new messages