Skip to contentSkip to conversation

sunxi: add OrangePi Zero 3 board support

PATCH In review Andre Przywara 4 participants 16 messages Dec 4, 2023 – Dec 9, 2023

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

v2 cover sunxi: add OrangePi Zero 3 board support

A small update for the OrangePi Zero 3 support series. This fixes USB support, and upgrades the DRAM clock to 792, for better stability (as the other DRAM parameters were tailored to that frequency). I added the tags on the way.
Please test!

=================
The OrangePi Zero 3 is a small development board featuring the Allwinner H618 SoC. Compared to its predecessor OrangePi Zero 2, the new board uses LPDDR4 DRAM instead of DDR3 DRAM, and an X-Powers AXP313 PMIC instead of the AXP305.
U-Boot gained support for both LPDDR4 DRAM and the new PMIC just recently, so add a user for those features by adding a defconfig for the new board.
To make this work, patch 1/3 introduces support for zBIT SPI NOR flash chip, and patch 2/3 removes the default AXP305 PMIC selection when compiling for H616 SoCs.
Patch 3/3 then adds the defconfig. The DT was already synced from the Linux kernel repo a few weeks ago.

Cheers,
Andre

Changelog v1 .. v2:
- add tags
- set DRAM clock to 792 MHz (from the default 720 MHz)
- fix USB support by supplying USB VBUS enable GPIO

Andre Przywara (3):
mtd: spi-nor: Add support for zBIT ZB25VQ128
sunxi: H616: remove default AXP305 selection
sunxi: H616: Add OrangePi Zero 3 board support

 arch/arm/dts/Makefile            |  1 +
 board/sunxi/MAINTAINERS          |  5 +++++
 configs/orangepi_zero2_defconfig |  1 +
 configs/orangepi_zero3_defconfig | 32 ++++++++++++++++++++++++++++++++
 configs/x96_mate_defconfig       |  1 +
 drivers/mtd/spi/Kconfig          |  5 +++++
 drivers/mtd/spi/spi-nor-ids.c    |  5 +++++
 drivers/power/Kconfig            |  1 -
 8 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 configs/orangepi_zero3_defconfig
Signature · 1 line
2.35.8
#1 lore raw

PATCH v2 1/3 mtd: spi-nor: Add support for zBIT ZB25VQ128

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

---
 drivers/mtd/spi/Kconfig       | 5 +++++
 drivers/mtd/spi/spi-nor-ids.c | 5 +++++
 2 files changed, 10 insertions(+)
drivers/mtd/spi/Kconfig +5 -0
index 732b0760452..abed392c28d 100644
@@ -224,6 +224,11 @@ config SPI_FLASH_XTX
 	  Add support for various XTX (XTX Technology Limited)
 	  SPI flash chips (XT25xxx).
 
+config SPI_FLASH_ZBIT
+	bool "ZBIT SPI flash support"
+	help
+	  Add support for Zbit Semiconductor Inc. SPI flash chips (ZB25xxx).
+
 endif
 
 config SPI_FLASH_USE_4K_SECTORS
drivers/mtd/spi/spi-nor-ids.c +5 -0
index 3cb132dcffc..f86e7ff8e58 100644
@@ -571,6 +571,11 @@ const struct flash_info spi_nor_ids[] = {
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("xt25w01g", 0x0b651B, 0, 64 * 1024, 2048,
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+#endif
+#ifdef CONFIG_SPI_FLASH_ZBIT
+	/* Zbit Semiconductor Inc. */
+	{ INFO("zb25vq128", 0x5e4018, 0, 64 * 1024, 256,
+	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 #endif
 	{ },
 };
Signature · 1 line
2.35.8
#2 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this via the sunxi tree, as this blocks some board support patches.

IIUC Linux gave up on adding rather generic entries up for each and every SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

Cheers,
Andre

Quoted 38 lines
---
 drivers/mtd/spi/Kconfig       | 5 +++++
 drivers/mtd/spi/spi-nor-ids.c | 5 +++++
 2 files changed, 10 insertions(+)
drivers/mtd/spi/Kconfig +5 -0
index 732b0760452..abed392c28d 100644
@@ -224,6 +224,11 @@ config SPI_FLASH_XTX
 	  Add support for various XTX (XTX Technology Limited)
 	  SPI flash chips (XT25xxx).
 
+config SPI_FLASH_ZBIT
+	bool "ZBIT SPI flash support"
+	help
+	  Add support for Zbit Semiconductor Inc. SPI flash chips (ZB25xxx).
+
 endif
 
 config SPI_FLASH_USE_4K_SECTORS
drivers/mtd/spi/spi-nor-ids.c +5 -0
index 3cb132dcffc..f86e7ff8e58 100644
@@ -571,6 +571,11 @@ const struct flash_info spi_nor_ids[] = {
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
 	{ INFO("xt25w01g", 0x0b651B, 0, 64 * 1024, 2048,
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
+#endif
+#ifdef CONFIG_SPI_FLASH_ZBIT
+	/* Zbit Semiconductor Inc. */
+	{ INFO("zb25vq128", 0x5e4018, 0, 64 * 1024, 256,
+	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 #endif
 	{ },
 };
Reviewed-by
#3 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Hello Andre,

Quoted 6 lines · Andre Przywara
Quoted 2 lines · On Mon, 4 Dec 2023 00:59:52 +0000 Andre Przywara <[email protected]>…

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this via the sunxi tree, as this blocks some board support patches.

The patch looks perfectly fine to me. Thus,

Quoted 4 lines

IIUC Linux gave up on adding rather generic entries up for each and every SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

I think it would be good to employ the same approach, to make it easier to support more chips and more boards in the future. Also, at least a few already existing chip definitions could be dropped, after testing, of course. Simplifying the things is almost always a good choice.

As visible in [1] and [2], the Linux kernel no longer accepts entries for the chips that can be detected automatically and don't require some specific fixes.

[1] https://lore.kernel.org/linux-mtd/[email protected]/T/#t
[2] https://lore.kernel.org/linux-mtd/[email protected]/

Quoted 40 lines
Quoted 40 lines
---
 drivers/mtd/spi/Kconfig       | 5 +++++
 drivers/mtd/spi/spi-nor-ids.c | 5 +++++
 2 files changed, 10 insertions(+)
drivers/mtd/spi/Kconfig +5 -0
index 732b0760452..abed392c28d 100644
@@ -224,6 +224,11 @@ config SPI_FLASH_XTX
 	  Add support for various XTX (XTX Technology Limited)
 	  SPI flash chips (XT25xxx).
 
+config SPI_FLASH_ZBIT
+	bool "ZBIT SPI flash support"
+	help
+	  Add support for Zbit Semiconductor Inc. SPI flash chips (ZB25xxx).
+
 endif
 
 config SPI_FLASH_USE_4K_SECTORS
drivers/mtd/spi/spi-nor-ids.c +5 -0
index 3cb132dcffc..f86e7ff8e58 100644
@@ -571,6 +571,11 @@ const struct flash_info spi_nor_ids[] = {
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 
 SPI_NOR_4B_OPCODES) },
 	{ INFO("xt25w01g", 0x0b651B, 0, 64 * 1024, 2048,
 	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 
 SPI_NOR_4B_OPCODES) },
+#endif
+#ifdef CONFIG_SPI_FLASH_ZBIT
+	/* Zbit Semiconductor Inc. */
+	{ INFO("zb25vq128", 0x5e4018, 0, 64 * 1024, 256,
+	       SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) },
 #endif

{ },
};

#4 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

In reply to Andre Przywara
Quoted 8 lines · Andre Przywara

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

Quoted 7 lines

does anyone have any objections against this patch? I wanted to take this via the sunxi tree, as this blocks some board support patches.

IIUC Linux gave up on adding rather generic entries up for each and every SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

Signature · 1 line
Tom
#5 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 12 lines · Tom Rini
Quoted 11 lines · Andre Przywara

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this via the sunxi tree, as this blocks some board support patches.

Quoted 7 lines
Quoted 4 lines

IIUC Linux gave up on adding rather generic entries up for each and every SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

In general, yes, but we'd also need to consume a bit more space with the additional auto-detection logic.

#6 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 20 lines · Dragan Simic
Quoted 19 lines · Tom Rini
Quoted 17 lines · Andre Przywara

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

Quoted 5 lines
Quoted 2 lines

And we could then start trimming the table we do have as well, to reclaim space?

In general, yes, but we'd also need to consume a bit more space with the additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 24 lines · Tom Rini
Quoted 23 lines · Dragan Simic
Quoted 21 lines · Tom Rini
Quoted 12 lines · Andre Przywara

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

Quoted 5 lines

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

Quoted 7 lines
Quoted 2 lines

In general, yes, but we'd also need to consume a bit more space with the additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Sounds like a plan to me and I'm willing to work on that. Though, I think we'll inevitably end up with increasing the resulting image sizes a bit, but that might be an acceptable trade-off for making supporting more SPI chips and more new boards much easier in the future.

#8 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 34 lines · Dragan Simic
Quoted 24 lines · Tom Rini
Quoted 23 lines · Dragan Simic
Quoted 21 lines · Tom Rini
Quoted 12 lines · Andre Przywara

On Mon, 4 Dec 2023 00:59:52 +0000
Andre Przywara <[email protected]> wrote:

Hi,

Quoted 2 lines

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

Quoted 5 lines

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

Quoted 8 lines
Quoted 3 lines

In general, yes, but we'd also need to consume a bit more space with the
additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Quoted 4 lines

Sounds like a plan to me and I'm willing to work on that. Though, I think we'll inevitably end up with increasing the resulting image sizes a bit, but that might be an acceptable trade-off for making supporting more SPI chips and more new boards much easier in the future.

Yeah, this is where we need to go overall long term if nothing else.

Signature · 1 line
Tom
#9 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 32 lines · Tom Rini
Quoted 31 lines · Dragan Simic
Quoted 29 lines · Tom Rini
Quoted 17 lines · Dragan Simic
Quoted 16 lines · Tom Rini
Quoted 14 lines · Andre Przywara
Quoted 2 lines · On Mon, 4 Dec 2023 00:59:52 +0000 Andre Przywara <[email protected]>…

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

Quoted 6 lines
Quoted 2 lines

And we could then start trimming the table we do have as well, to reclaim space?

In general, yes, but we'd also need to consume a bit more space with the
additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Quoted 6 lines
Quoted 4 lines

Sounds like a plan to me and I'm willing to work on that. Though, I think we'll inevitably end up with increasing the resulting image sizes a bit, but that might be an acceptable trade-off for making supporting more SPI chips and more new boards much easier in the future.

Yeah, this is where we need to go overall long term if nothing else.

I agree, it would make the things a bit easier. I'll see to start working on it next week.

#10 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 41 lines · Dragan Simic
Quoted 40 lines · Tom Rini
Quoted 38 lines · Dragan Simic
Quoted 21 lines · Tom Rini
Quoted 20 lines · Dragan Simic
Quoted 18 lines · Tom Rini
Quoted 9 lines · Andre Przywara
Quoted 2 lines · On Mon, 4 Dec 2023 00:59:52 +0000 Andre Przywara <[email protected]>…

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

Quoted 5 lines

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

Quoted 8 lines
Quoted 3 lines

In general, yes, but we'd also need to consume a bit more space with the
additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Sounds like a plan to me and I'm willing to work on that. Though, I think
we'll inevitably end up with increasing the resulting image sizes a bit, but
that might be an acceptable trade-off for making supporting more SPI chips
and more new boards much easier in the future.

Quoted 4 lines
Quoted 1 line

Yeah, this is where we need to go overall long term if nothing else.

I agree, it would make the things a bit easier. I'll see to start working on it next week.

Thanks!

Signature · 1 line
Tom
#11 lore raw

Re: [PATCH v2 1/3] mtd: spi-nor: Add support for zBIT ZB25VQ128

Quoted 39 lines · Tom Rini
Quoted 38 lines · Dragan Simic
Quoted 37 lines · Tom Rini
Quoted 35 lines · Dragan Simic
Quoted 21 lines · Tom Rini
Quoted 20 lines · Dragan Simic
Quoted 18 lines · Tom Rini
Quoted 9 lines · Andre Przywara
Quoted 2 lines · On Mon, 4 Dec 2023 00:59:52 +0000 Andre Przywara <[email protected]>…

Add support for the zBIT ZB25VQ128 (128M-bit) SPI NOR flash memory chip, as used on the Xunlong Orange Pi Zero 3 board.

does anyone have any objections against this patch? I wanted to take this
via the sunxi tree, as this blocks some board support patches.

Quoted 5 lines

IIUC Linux gave up on adding rather generic entries up for each and every
SPI NOR chip, if there is nothing special about them:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=773bbe1044
Should we follow suit here?

And we could then start trimming the table we do have as well, to reclaim space?

Quoted 8 lines
Quoted 3 lines

In general, yes, but we'd also need to consume a bit more space with the
additional auto-detection logic.

Maybe part one of the series is backport that logic, part two is remove all the easy to remove tables? Or at least a number of them so the series is a wash and then a targeted series of drop-an-entry and cc the person that added it so they can run-time verify it's still fine?

Sounds like a plan to me and I'm willing to work on that. Though, I think we'll inevitably end up with increasing the resulting image sizes a bit, but that might be an acceptable trade-off for making supporting more SPI chips and more new boards much easier in the future.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Yeah, this is where we need to go overall long term if nothing else.

I agree, it would make the things a bit easier. I'll see to start working on it next week.

Thanks!

Thank you for agreeing with this new approach.

#12 lore raw

PATCH v2 2/3 sunxi: H616: remove default AXP305 selection

In reply to Andre Przywara

The original H616 devices released about three years ago were typically paired with an X-Powers AXP305 PMIC. Newer devices uses the smaller AXP313, and there seem to be far more systems with this PMIC around now.

Remove the default AXP305 selection for the H616 SoC from the Kconfig, and move the PMIC selection into the board defconfig files instead.

---
 configs/orangepi_zero2_defconfig | 1 +
 configs/x96_mate_defconfig       | 1 +
 drivers/power/Kconfig            | 1 -
 3 files changed, 2 insertions(+), 1 deletion(-)
configs/orangepi_zero2_defconfig +1 -0
index 50009e823cb..98aed846f1f 100644
@@ -20,6 +20,7 @@ CONFIG_SYS_I2C_SPEED=400000
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_PHY_REALTEK=y
 CONFIG_SUN8I_EMAC=y
+CONFIG_AXP305_POWER=y
 CONFIG_SPI=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
configs/x96_mate_defconfig +1 -0
index 318951e19c2..e805e0952b3 100644
@@ -18,6 +18,7 @@ CONFIG_SPL_SYS_I2C_LEGACY=y
 CONFIG_SYS_I2C_MVTWSI=y
 CONFIG_SYS_I2C_SLAVE=0x7f
 CONFIG_SYS_I2C_SPEED=400000
+CONFIG_AXP305_POWER=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_OHCI_HCD=y
drivers/power/Kconfig +0 -1
index 2395720c99c..33b8bc1214d 100644
@@ -56,7 +56,6 @@ choice
 	depends on ARCH_SUNXI
 	default AXP209_POWER if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
 	default AXP221_POWER if MACH_SUN6I || MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_R40
-	default AXP305_POWER if MACH_SUN50I_H616
 	default AXP818_POWER if MACH_SUN8I_A83T
 	default SUNXI_NO_PMIC if MACH_SUNXI_H3_H5 || MACH_SUN50I || MACH_SUN8I_V3S
 
Signature · 1 line
2.35.8
#13 lore raw

PATCH v2 3/3 sunxi: H616: Add OrangePi Zero 3 board support

In reply to Andre Przywara

The OrangePi Zero 3 is a small development board featuring the Allwinner H618 SoC, shipping with up to 4GB of DRAM, Gigabit Ethernet, a micro-HDMI connector and two USB sockets.
The board uses LPDDR4 DRAM and an X-Powers AXP313a PMIC, support for which was recently added to U-Boot.

Add a defconfig file selecting the right drivers and DRAM options. Since the .dts file was synced from the Linux kernel repo already, we just need to add one line to the Makefile to actually build the .dtb.

The DRAM parameters were derived from the values found in the BSP DRAM drivers on the SPI NOR flash.

---
 arch/arm/dts/Makefile            |  1 +
 board/sunxi/MAINTAINERS          |  5 +++++
 configs/orangepi_zero3_defconfig | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 38 insertions(+)
 create mode 100644 configs/orangepi_zero3_defconfig
arch/arm/dts/Makefile +1 -0
index 1be08c5fdc2..5fc888680b3 100644
@@ -835,6 +835,7 @@ dtb-$(CONFIG_MACH_SUN50I_H6) += \
 	sun50i-h6-tanix-tx6-mini.dtb
 dtb-$(CONFIG_MACH_SUN50I_H616) += \
 	sun50i-h616-orangepi-zero2.dtb \
+	sun50i-h618-orangepi-zero3.dtb \
 	sun50i-h616-x96-mate.dtb
 dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-amarula-relic.dtb \
board/sunxi/MAINTAINERS +5 -0
index 00614372119..f556857a391 100644
@@ -455,6 +455,11 @@ M:	Jernej Skrabec <[email protected]>
 S:	Maintained
 F:	configs/orangepi_zero2_defconfig
 
+ORANGEPI ZERO 3 BOARD
+M:	Andre Przywara <[email protected]>
+S:	Maintained
+F:	configs/orangepi_zero3_defconfig
+
 ORANGEPI PC 2 BOARD
 M:	Andre Przywara <[email protected]>
 S:	Maintained
configs/orangepi_zero3_defconfig new file +32 -0
new file mode 100644
index 00000000000..5a019fed84b
@@ -0,0 +1,32 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-h618-orangepi-zero3"
+CONFIG_SPL=y
+CONFIG_DRAM_SUN50I_H616_DX_ODT=0x07070707
+CONFIG_DRAM_SUN50I_H616_DX_DRI=0x0e0e0e0e
+CONFIG_DRAM_SUN50I_H616_CA_DRI=0x0e0e
+CONFIG_DRAM_SUN50I_H616_ODT_EN=0xaaaaeeee
+CONFIG_DRAM_SUN50I_H616_TPR6=0x44000000
+CONFIG_DRAM_SUN50I_H616_TPR10=0x402f6663
+CONFIG_DRAM_SUN50I_H616_TPR11=0x24242624
+CONFIG_DRAM_SUN50I_H616_TPR12=0x0f0f100f
+CONFIG_MACH_SUN50I_H616=y
+CONFIG_SUNXI_DRAM_H616_LPDDR4=y
+CONFIG_DRAM_CLK=792
+CONFIG_USB1_VBUS_PIN="PC16"
+CONFIG_R_I2C_ENABLE=y
+CONFIG_SPL_SPI_SUNXI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL_I2C=y
+CONFIG_SPL_SYS_I2C_LEGACY=y
+CONFIG_SYS_I2C_MVTWSI=y
+CONFIG_SYS_I2C_SLAVE=0x7f
+CONFIG_SYS_I2C_SPEED=400000
+CONFIG_SPI_FLASH_ZBIT=y
+CONFIG_PHY_MOTORCOMM=y
+CONFIG_SUN8I_EMAC=y
+CONFIG_AXP313_POWER=y
+CONFIG_SPI=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_MUSB_GADGET=y
Signature · 1 line
2.35.8
#14 lore raw
In reply to Andre Przywara

I have tested a newly built u-boot with the patches you provided and it works well. It is the same configuration as what I have been testing with for the last few weeks.

I loaded the U-boot to SPI flash and tested with the SD card removed from the system and put in a USB card reader. The output for that test is below.

For completeness you might want to mention that another difference between the zero2 and zero3 is the emac phy going from Realtek to Motorcomm.

Thank you for fixing my patch attempt. It is the first one I have ever done. Thank you also for your patience with my fumbling attempts. I have learned a lot from you in the last two weeks.

U-Boot SPL 2024.01-rc3-00043-g5c4e9d0c74-dirty (Dec 03 2023 - 18:21:41 -0800)
DRAM: 1024 MiB
Trying to boot from sunxi SPI

NOTICE:  BL31: v2.10.0  (debug):v2.10.0
NOTICE:  BL31: Built : 18:07:18, Nov 23 2023
NOTICE:  BL31: Detected Allwinner H616 SoC (1823)
NOTICE:  BL31: Found U-Boot DTB at 0x4a0b2828, model: OrangePi Zero3
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP305 on RSB
ERROR:   RSB: set run-time address: 0x10003
INFO:    Could not init RSB: -65539
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for erratum 855873 was applied
INFO:    BL31: cortex_a53: CPU workaround for erratum 1530924 was applied
INFO:    PSCI: Suspend is unavailable
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9
INFO:    Changed devicetree.

U-Boot 2024.01-rc3-00043-g5c4e9d0c74-dirty (Dec 03 2023 - 18:21:41 -0800) Allwinner Technology

CPU:   Allwinner H616 (SUN50I)
Model: OrangePi Zero3
DRAM:  1 GiB
Core:  57 devices, 25 uclasses, devicetree: separate
WDT:   Not starting watchdog@30090a0
MMC:   mmc@4020000: 0
Loading Environment from SPIFlash... SF: Detected zb25vq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial@5000000
Out:   serial@5000000
Err:   serial@5000000

Allwinner mUSB OTG (Peripheral)
Net: eth0: ethernet@5020000using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
, eth1: usb_ether
starting USB...
Bus usb@5200000: USB EHCI 1.00
Bus usb@5200400: USB OHCI 1.0
scanning bus usb@5200000 for devices... Device NOT ready
Request Sense returned 02 3A 00
Device NOT ready
Request Sense returned 02 3A 00
Device NOT ready
Request Sense returned 02 3A 00
2 USB Device(s) found
scanning bus usb@5200400 for devices... 1 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot: 0
Card did not respond to voltage select! : -110

Device 0: Vendor: Generic- Rev: 1.00 Prod: SD/MMC
Type: Removable Hard Disk
Capacity: 15193.5 MB = 14.8 GB (31116288 x 512)
... is now current device
Scanning usb 0:1...
Found U-Boot script /boot/boot.scr
1052 bytes read in 1 ms (1 MiB/s)
## Executing script at 4fc00000
Card did not respond to voltage select! : -110
** Bad device specification mmc 0 **
19472 bytes read in 3 ms (6.2 MiB/s)
No FDT memory address configured. Please configure the FDT address via "fdt addr <address>" command. Aborting!
7088139 bytes read in 324 ms (20.9 MiB/s)
22491144 bytes read in 1025 ms (20.9 MiB/s)
Moving Image from 0x40080000 to 0x40200000, end=41800000 ## Loading init Ramdisk from Legacy Image at 4ff00000 ...

   Image Name:   uInitrd
   Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
   Data Size:    7088075 Bytes = 6.8 MiB

Load Address: 00000000
Entry Point: 00000000
Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
Booting using the fdt blob at 0x4fa00000
Working FDT set to 4fa00000
Loading Ramdisk to 4993d000, end 49fff7cb ... OK
Loading Device Tree to 0000000049935000, end 000000004993cc0f ... OK
Working FDT set to 49935000

Starting kernel ...

Welcome to Debian GNU/Linux 12 (bookworm)!

Quoted 44 lines · Andre Przywara

A small update for the OrangePi Zero 3 support series. This fixes USB support, and upgrades the DRAM clock to 792, for better stability (as the other DRAM parameters were tailored to that frequency). I added the tags on the way.
Please test!

=================
The OrangePi Zero 3 is a small development board featuring the Allwinner H618 SoC. Compared to its predecessor OrangePi Zero 2, the new board uses LPDDR4 DRAM instead of DDR3 DRAM, and an X-Powers AXP313 PMIC instead of the AXP305.
U-Boot gained support for both LPDDR4 DRAM and the new PMIC just recently, so add a user for those features by adding a defconfig for the new board.
To make this work, patch 1/3 introduces support for zBIT SPI NOR flash chip, and patch 2/3 removes the default AXP305 PMIC selection when compiling for H616 SoCs.
Patch 3/3 then adds the defconfig. The DT was already synced from the Linux kernel repo a few weeks ago.

Cheers,
Andre

Changelog v1 .. v2:
- add tags
- set DRAM clock to 792 MHz (from the default 720 MHz)
- fix USB support by supplying USB VBUS enable GPIO

Andre Przywara (3):
mtd: spi-nor: Add support for zBIT ZB25VQ128
sunxi: H616: remove default AXP305 selection
sunxi: H616: Add OrangePi Zero 3 board support

  arch/arm/dts/Makefile            |  1 +
  board/sunxi/MAINTAINERS          |  5 +++++
  configs/orangepi_zero2_defconfig |  1 +
  configs/orangepi_zero3_defconfig | 32 ++++++++++++++++++++++++++++++++
  configs/x96_mate_defconfig       |  1 +
  drivers/mtd/spi/Kconfig          |  5 +++++
  drivers/mtd/spi/spi-nor-ids.c    |  5 +++++
  drivers/power/Kconfig            |  1 -
  8 files changed, 50 insertions(+), 1 deletion(-)

create mode 100644 configs/orangepi_zero3_defconfig

#15 lore raw

On Sun, 3 Dec 2023 21:57:51 -0800
Stephen Graf <[email protected]> wrote:

Hi Stephen,

Quoted 5 lines

I have tested a newly built u-boot with the patches you provided and it works well. It is the same configuration as what I have been testing with for the last few weeks.

I loaded the U-boot to SPI flash and tested with the SD card removed from the system and put in a USB card reader. The output for that test is below.

thanks for your testing efforts! Is it OK if I convert this statement into a "Tested-by:" tag with your email, to become part of the commit?

Cheers,
Andre

Quoted 147 lines

For completeness you might want to mention that another difference between the zero2 and zero3 is the emac phy going from Realtek to Motorcomm.

Thank you for fixing my patch attempt. It is the first one I have ever done. Thank you also for your patience with my fumbling attempts. I have learned a lot from you in the last two weeks.

U-Boot SPL 2024.01-rc3-00043-g5c4e9d0c74-dirty (Dec 03 2023 - 18:21:41 -0800)
DRAM: 1024 MiB
Trying to boot from sunxi SPI

NOTICE:  BL31: v2.10.0  (debug):v2.10.0
NOTICE:  BL31: Built : 18:07:18, Nov 23 2023
NOTICE:  BL31: Detected Allwinner H616 SoC (1823)
NOTICE:  BL31: Found U-Boot DTB at 0x4a0b2828, model: OrangePi Zero3
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP305 on RSB
ERROR:   RSB: set run-time address: 0x10003
INFO:    Could not init RSB: -65539
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for erratum 855873 was applied
INFO:    BL31: cortex_a53: CPU workaround for erratum 1530924 was applied
INFO:    PSCI: Suspend is unavailable
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9
INFO:    Changed devicetree.

U-Boot 2024.01-rc3-00043-g5c4e9d0c74-dirty (Dec 03 2023 - 18:21:41 -0800) Allwinner Technology

CPU:   Allwinner H616 (SUN50I)
Model: OrangePi Zero3
DRAM:  1 GiB
Core:  57 devices, 25 uclasses, devicetree: separate
WDT:   Not starting watchdog@30090a0
MMC:   mmc@4020000: 0
Loading Environment from SPIFlash... SF: Detected zb25vq128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial@5000000
Out:   serial@5000000
Err:   serial@5000000

Allwinner mUSB OTG (Peripheral)
Net: eth0: ethernet@5020000using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC de:ad:be:ef:00:01
HOST MAC de:ad:be:ef:00:00
RNDIS ready
, eth1: usb_ether
starting USB...
Bus usb@5200000: USB EHCI 1.00
Bus usb@5200400: USB OHCI 1.0
scanning bus usb@5200000 for devices... Device NOT ready
Request Sense returned 02 3A 00
Device NOT ready
Request Sense returned 02 3A 00
Device NOT ready
Request Sense returned 02 3A 00
2 USB Device(s) found
scanning bus usb@5200400 for devices... 1 USB Device(s) found
scanning usb for storage devices... 1 Storage Device(s) found
Hit any key to stop autoboot: 0
Card did not respond to voltage select! : -110

Device 0: Vendor: Generic- Rev: 1.00 Prod: SD/MMC
Type: Removable Hard Disk
Capacity: 15193.5 MB = 14.8 GB (31116288 x 512)
... is now current device
Scanning usb 0:1...
Found U-Boot script /boot/boot.scr
1052 bytes read in 1 ms (1 MiB/s)
## Executing script at 4fc00000
Card did not respond to voltage select! : -110
** Bad device specification mmc 0 **
19472 bytes read in 3 ms (6.2 MiB/s)
No FDT memory address configured. Please configure the FDT address via "fdt addr <address>" command. Aborting!
7088139 bytes read in 324 ms (20.9 MiB/s)
22491144 bytes read in 1025 ms (20.9 MiB/s)
Moving Image from 0x40080000 to 0x40200000, end=41800000 ## Loading init Ramdisk from Legacy Image at 4ff00000 ...

    Image Name:   uInitrd
    Image Type:   AArch64 Linux RAMDisk Image (gzip compressed)
    Data Size:    7088075 Bytes = 6.8 MiB
    Load Address: 00000000
    Entry Point:  00000000
    Verifying Checksum ... OK
## Flattened Device Tree blob at 4fa00000
    Booting using the fdt blob at 0x4fa00000
Working FDT set to 4fa00000
    Loading Ramdisk to 4993d000, end 49fff7cb ... OK
    Loading Device Tree to 0000000049935000, end 000000004993cc0f ... OK

Working FDT set to 49935000

Starting kernel ...

Welcome to Debian GNU/Linux 12 (bookworm)!

Quoted 44 lines · Andre Przywara

A small update for the OrangePi Zero 3 support series. This fixes USB support, and upgrades the DRAM clock to 792, for better stability (as the other DRAM parameters were tailored to that frequency). I added the tags on the way.
Please test!

=================
The OrangePi Zero 3 is a small development board featuring the Allwinner H618 SoC. Compared to its predecessor OrangePi Zero 2, the new board uses LPDDR4 DRAM instead of DDR3 DRAM, and an X-Powers AXP313 PMIC instead of the AXP305.
U-Boot gained support for both LPDDR4 DRAM and the new PMIC just recently, so add a user for those features by adding a defconfig for the new board.
To make this work, patch 1/3 introduces support for zBIT SPI NOR flash chip, and patch 2/3 removes the default AXP305 PMIC selection when compiling for H616 SoCs.
Patch 3/3 then adds the defconfig. The DT was already synced from the Linux kernel repo a few weeks ago.

Cheers,
Andre

Changelog v1 .. v2:
- add tags
- set DRAM clock to 792 MHz (from the default 720 MHz)
- fix USB support by supplying USB VBUS enable GPIO

Andre Przywara (3):
mtd: spi-nor: Add support for zBIT ZB25VQ128
sunxi: H616: remove default AXP305 selection
sunxi: H616: Add OrangePi Zero 3 board support

  arch/arm/dts/Makefile            |  1 +
  board/sunxi/MAINTAINERS          |  5 +++++
  configs/orangepi_zero2_defconfig |  1 +
  configs/orangepi_zero3_defconfig | 32 ++++++++++++++++++++++++++++++++
  configs/x96_mate_defconfig       |  1 +
  drivers/mtd/spi/Kconfig          |  5 +++++
  drivers/mtd/spi/spi-nor-ids.c    |  5 +++++
  drivers/power/Kconfig            |  1 -
  8 files changed, 50 insertions(+), 1 deletion(-)

create mode 100644 configs/orangepi_zero3_defconfig