Skip to contentSkip to conversation

sunxi: Allwinner A64 SPL support

RFC PATCH New Andre Przywara 5 participants 38 messages Nov 3, 2016 – Nov 19, 2016

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

cover sunxi: Allwinner A64 SPL support

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work, but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

So this series lets the SPL run entirely in AArch32, which is what the BROM comes from anyway. With the help of patch 2/10 and 8/10 we detect that the next binary should be run in AArch64 mode, so patch 9/10 adds the required RMR switch to enter the 64-bit mode.
It compiles for me into less than 20 KB, so plenty of room for debug and future code. Technically running the SPL in 32-bit or 64-bit does not make any difference, actually having it in AArch32 helps FEL boot (which works fine with this series).

The only real drawback of this approach is the build process, which is now split between the SPL (AArch32) and the U-Boot proper (AArch64). Patch 10/10 introduces a new defconfig, which defines CPU_V7 and thus creates a 32-bit binary. This requires an ARM cross-compiler or a native compile on an ARM board. The resulting sunxi-spl.bin can then be either directly written to the SD card or later combined with the AArch64 U-Boot proper into one image file.

What this series still lacks is proper Linux support, because we miss the ARM Trusted Firmware (ATF) binary to be loaded and executed. I have patches to extend the SPL FIT support to handle this very nicely in a generic way, but these patches need some clean up. I didn't want this series to be held back any longer, so I will send the FIT patches later.

I appreciate any comments on this series!

Cheers,
Andre.

Andre Przywara (7):
sun6i: Restrict some register initialization to Allwinner A31 SoC
Makefile: use "arm64" architecture for U-Boot image files
sunxi: provide default DRAM config for sun50i in Kconfig
sunxi: H3/A64: fix non-ODT setting
SPL: read and store arch property from U-Boot image
sunxi: introduce RMR switch to enter payloads in 64-bit mode
sunxi: A64: add 32-bit SPL support

Jens Kuske (3):
sunxi: H3: add and rename some DRAM contoller registers
sunxi: H3: add DRAM controller single bit delay support
sunxi: A64: use H3 DRAM initialization code for A64

 Makefile                                        |   9 +-
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h   |   1 +
 arch/arm/include/asm/arch-sunxi/dram.h          |   2 +-
 arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h |  51 +++---
 arch/arm/lib/spl.c                              |  14 ++
 arch/arm/mach-sunxi/Makefile                    |   2 +
 arch/arm/mach-sunxi/clock_sun6i.c               |   7 +-
 arch/arm/mach-sunxi/dram_sun8i_h3.c             | 213 +++++++++++++++++-------
 arch/arm/mach-sunxi/spl_switch.c                |  60 +++++++
 board/sunxi/Kconfig                             |  17 +-
 common/spl/spl.c                                |   1 +
 common/spl/spl_fit.c                            |   8 +
 configs/pine64_plus_defconfig                   |   4 +-
 configs/sun50i_spl32_defconfig                  |  11 ++
 include/spl.h                                   |   3 +-
 15 files changed, 308 insertions(+), 95 deletions(-)
 create mode 100644 arch/arm/mach-sunxi/spl_switch.c
 create mode 100644 configs/sun50i_spl32_defconfig
Signature · 1 line
2.8.2
#1 lore raw

RFC PATCH 1/10 sun6i: Restrict some register initialization to Allwinner A31 SoC

These days many Allwinner SoCs use clock_sun6i.c, although out of them only the (original sun6i) A31 has a second MBUS clock register. Also setting up the PRCM PLL_CTLR1 register to provide the proper voltage seems to be an A31-only feature as well.
So restrict the initialization to this SoC only to avoid writing bogus values to (undefined) registers in other chips.

---
 arch/arm/mach-sunxi/clock_sun6i.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/mach-sunxi/clock_sun6i.c +5 -0
index ed8cd9b..382fa94 100644
@@ -21,6 +21,8 @@ void clock_init_safe(void)
 {
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+
+#ifdef CONFIG_MACH_SUN6I
 	struct sunxi_prcm_reg * const prcm =
 		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
 
@@ -31,6 +33,7 @@ void clock_init_safe(void)
 		PRCM_PLL_CTRL_LDO_DIGITAL_EN | PRCM_PLL_CTRL_LDO_ANALOG_EN |
 		PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1140));
 	clrbits_le32(&prcm->pll_ctrl1, PRCM_PLL_CTRL_LDO_KEY_MASK);
+#endif
 
 	clock_set_pll1(408000000);
 
@@ -41,7 +44,9 @@ void clock_init_safe(void)
 	writel(AHB1_ABP1_DIV_DEFAULT, &ccm->ahb1_apb1_div);
 
 	writel(MBUS_CLK_DEFAULT, &ccm->mbus0_clk_cfg);
+#ifdef CONFIG_MACH_SUN6I
 	writel(MBUS_CLK_DEFAULT, &ccm->mbus1_clk_cfg);
+#endif
 }
 #endif
 
Signature · 1 line
2.8.2
#2 lore raw

RFC PATCH 1/10 sun6i: Restrict some register initialization to Allwinner A31 SoC

Quoted 8 lines · Andre Przywara

These days many Allwinner SoCs use clock_sun6i.c, although out of them only the (original sun6i) A31 has a second MBUS clock register. Also setting up the PRCM PLL_CTLR1 register to provide the proper voltage seems to be an A31-only feature as well.
So restrict the initialization to this SoC only to avoid writing bogus values to (undefined) registers in other chips.

(However I haven't counter-checked with specs)

Alex

#3 lore raw

RFC PATCH 1/10 sun6i: Restrict some register initialization to Allwinner A31 SoC

Quoted 9 lines · Alexander Graf
Quoted 8 lines · Andre Przywara

These days many Allwinner SoCs use clock_sun6i.c, although out of them only the (original sun6i) A31 has a second MBUS clock register. Also setting up the PRCM PLL_CTLR1 register to provide the proper voltage seems to be an A31-only feature as well.
So restrict the initialization to this SoC only to avoid writing bogus values to (undefined) registers in other chips.

Quoted 6 lines
Quoted 1 line

(However I haven't counter-checked with specs)

#4 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

In reply to Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined to "armv8", and use the arm64 architecture name on creating the image file if that matches.

---
 Makefile | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Makefile +7 -2
index 37cbcb2..e76aeff 100644
@@ -912,13 +912,18 @@ quiet_cmd_cpp_cfg = CFG     $@
 cmd_cpp_cfg = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
 	-DDO_DEPS_ONLY -D__ASSEMBLY__ -x assembler-with-cpp -P -dM -E -o $@ $<
 
+ifeq ($(CPU),armv8)
+IH_ARCH := arm64
+else
+IH_ARCH := $(ARCH)
+endif
 ifdef CONFIG_SPL_LOAD_FIT
-MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+MKIMAGEFLAGS_u-boot.img = -f auto -A $(IH_ARCH) -T firmware -C none -O u-boot \
 	-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
 	-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \
 	$(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST)))
 else
-MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \
+MKIMAGEFLAGS_u-boot.img = -A $(IH_ARCH) -T firmware -C none -O u-boot \
 	-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \
 	-n "U-Boot $(UBOOTRELEASE) for $(BOARD) board"
 endif
Signature · 1 line
2.8.2
#5 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

Quoted 8 lines · Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined to "armv8", and use the arm64 architecture name on creating the image file if that matches.

Why is this important? To know the state you have to be in for SPL->U-Boot transition later?

Why didn't anyone else stumble over this yet? Because nobody's using SPL?

Alex

#6 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

Hi,

Quoted 9 lines · Alexander Graf
Quoted 8 lines · Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined
to "armv8", and use the arm64 architecture name on creating the image file if that matches.

Quoted 4 lines
Quoted 1 line

Why is this important? To know the state you have to be in for SPL->U-Boot transition later?

Yes.

Quoted 1 line

Why didn't anyone else stumble over this yet? Because nobody's using SPL?

Given the warnings and bugs I found when I compiled the SPL for 64 bit I'd assume the latter.

But I was asking this question myself already. Apparently everyone just hacked their firmware chain to live with "arm" in there, APM being a prominent example.

So given this I am a bit wary about the implication of this patch, I hope that people holler if this breaks their platform (and then fix that instead of hacking U-Boot again).

Cheers,
Andre.

#7 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

Quoted 17 lines · Andre Przywara

Hi,

Quoted 9 lines · Alexander Graf
Quoted 8 lines · Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined
to "armv8", and use the arm64 architecture name on creating the image file if that matches.

Quoted 3 lines
Quoted 1 line

Why is this important? To know the state you have to be in for SPL->U-Boot transition later?

Yes.

Quoted 7 lines
Quoted 1 line

Why didn't anyone else stumble over this yet? Because nobody's using SPL?

Given the warnings and bugs I found when I compiled the SPL for 64 bit I'd assume the latter.

But I was asking this question myself already. Apparently everyone just hacked their firmware chain to live with "arm" in there, APM being a prominent example.

APM is "special". They even use the "arm" marker for kernels.

Quoted 3 lines

So given this I am a bit wary about the implication of this patch, I hope that people holler if this breaks their platform (and then fix that instead of hacking U-Boot again).

Well, I guess it's a step into the right direction. I'm still not a huge fan of having both 32bit and 64bit binaries on the same platform, but indicating which one we are is a good idea :).

Alex

#8 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

Hi,

Quoted 20 lines · Alexander Graf
Quoted 19 lines · Andre Przywara

Hi,

Quoted 9 lines · Alexander Graf
Quoted 8 lines · Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined
to "armv8", and use the arm64 architecture name on creating the image file if that matches.

Quoted 3 lines
Quoted 1 line

Why is this important? To know the state you have to be in for SPL->U-Boot transition later?

Yes.

Quoted 2 lines

Why didn't anyone else stumble over this yet? Because nobody's using SPL?

Quoted 8 lines
Quoted 6 lines

Given the warnings and bugs I found when I compiled the SPL for 64 bit I'd assume the latter.

But I was asking this question myself already. Apparently everyone just hacked their firmware chain to live with "arm" in there, APM being a prominent example.

APM is "special". They even use the "arm" marker for kernels.

Yeah, I remember this ;-)

Quoted 7 lines
Quoted 3 lines

So given this I am a bit wary about the implication of this patch, I hope that people holler if this breaks their platform (and then fix that instead of hacking U-Boot again).

Well, I guess it's a step into the right direction. I'm still not a huge fan of having both 32bit and 64bit binaries on the same platform, but indicating which one we are is a good idea :).

I was thinking the same. Even if we eventually scratch that idea this patch shouldn't hurt, and makes U-Boot more versatile.

Cheers,
Andre.

#9 lore raw

RFC PATCH 2/10 Makefile: use "arm64" architecture for U-Boot image files

In reply to Andre Przywara
Quoted 11 lines · Andre Przywara

At the moment we use the arch/arm directory for arm64 boards as well, so the Makefile will pick up the "arm" name for the architecture to use for tagging binaries in U-Boot image files.
Differentiate between the two by looking at the CPU variable being defined to "armv8", and use the arm64 architecture name on creating the image file if that matches.

---
 Makefile | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
#10 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

In reply to Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
 board/sunxi/Kconfig           | 3 +++
 configs/pine64_plus_defconfig | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +3 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
 	default 792 if MACH_SUN9I
 	default 312 if MACH_SUN6I || MACH_SUN8I
 	default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+	default 672 if MACH_SUN50I
 	---help---
 	Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
 	must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
 	default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
 	default 127 if MACH_SUN7I
 	default 4145117 if MACH_SUN9I
+	default 3881915 if MACH_SUN50I
 	---help---
 	Set the dram zq value.
 
@@ -171,6 +173,7 @@ config DRAM_ODT_EN
 	bool "sunxi dram odt enable"
 	default n if !MACH_SUN8I_A23
 	default y if MACH_SUN8I_A23
+	default y if MACH_SUN50I
 	---help---
 	Select this to enable dram odt (on die termination).
 
configs/pine64_plus_defconfig +0 -2
index 6d0198f..a53e968 100644
@@ -2,8 +2,6 @@ CONFIG_ARM=y
 CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
 CONFIG_ARCH_SUNXI=y
 CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_CONSOLE_MUX=y
Signature · 1 line
2.8.2
#11 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

Quoted 32 lines · Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
  board/sunxi/Kconfig           | 3 +++
  configs/pine64_plus_defconfig | 2 --
  2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +2 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
  	default 792 if MACH_SUN9I
  	default 312 if MACH_SUN6I || MACH_SUN8I
  	default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+	default 672 if MACH_SUN50I
  	---help---
  	Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
  	must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
  	default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
  	default 127 if MACH_SUN7I
  	default 4145117 if MACH_SUN9I
+	default 3881915 if MACH_SUN50I
  	---help---
  	Set the dram zq value.
 

board/sunxi/Kconfig config DRAM_ODT_EN · line 176

Quoted 4 lines
board/sunxi/Kconfig +1 -0
@@ -171,6 +173,7 @@ config DRAM_ODT_EN
  	bool "sunxi dram odt enable"
  	default n if !MACH_SUN8I_A23
  	default y if MACH_SUN8I_A23
+	default y if MACH_SUN50I

This change isn't obvious. It's not mentioned in the patch description or removed from the defconfig.

Alex

Quoted 16 lines
board/sunxi/Kconfig +0 -0
  	---help---
  	Select this to enable dram odt (on die termination).
 
configs/pine64_plus_defconfig +0 -2
index 6d0198f..a53e968 100644
@@ -2,8 +2,6 @@ CONFIG_ARM=y
  CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
  CONFIG_ARCH_SUNXI=y
  CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
  CONFIG_CONSOLE_MUX=y
#12 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

Hi,

Quoted 31 lines · Alexander Graf
Quoted 30 lines · Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
  board/sunxi/Kconfig           | 3 +++
  configs/pine64_plus_defconfig | 2 --
  2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +2 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
      default 792 if MACH_SUN9I
      default 312 if MACH_SUN6I || MACH_SUN8I
      default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+    default 672 if MACH_SUN50I
      ---help---
      Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
      must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
      default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
      default 127 if MACH_SUN7I
      default 4145117 if MACH_SUN9I
+    default 3881915 if MACH_SUN50I
      ---help---
      Set the dram zq value.
Quoted 8 lines
Quoted 5 lines
board/sunxi/Kconfig +0 -0
  @@ -171,6 +173,7 @@ config DRAM_ODT_EN

bool "sunxi dram odt enable"
default n if !MACH_SUN8I_A23
default y if MACH_SUN8I_A23
+ default y if MACH_SUN50I

This change isn't obvious. It's not mentioned in the patch description or removed from the defconfig.

Oh, right, looks like a rebase artifact, since I juggled the patches around quite a bit. It belongs to patch 10/10, I guess.

Cheers,
Andre.

Quoted 17 lines
Quoted 16 lines

---help---
Select this to enable dram odt (on die termination).
diff --git a/configs/pine64_plus_defconfig
b/configs/pine64_plus_defconfig
index 6d0198f..a53e968 100644

configs/pine64_plus_defconfig +0 -2
@@ -2,8 +2,6 @@ CONFIG_ARM=y
  CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
  CONFIG_ARCH_SUNXI=y
  CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
  CONFIG_CONSOLE_MUX=y
#13 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

Hi,

Quoted 43 lines · Andre Przywara

Hi,

Quoted 31 lines · Alexander Graf
Quoted 30 lines · Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
  board/sunxi/Kconfig           | 3 +++
  configs/pine64_plus_defconfig | 2 --
  2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +2 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
      default 792 if MACH_SUN9I
      default 312 if MACH_SUN6I || MACH_SUN8I
      default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+    default 672 if MACH_SUN50I
      ---help---
      Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
      must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
      default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I
      default 127 if MACH_SUN7I
      default 4145117 if MACH_SUN9I
+    default 3881915 if MACH_SUN50I
      ---help---
      Set the dram zq value.
Quoted 8 lines
Quoted 5 lines
board/sunxi/Kconfig +0 -0
  @@ -171,6 +173,7 @@ config DRAM_ODT_EN

bool "sunxi dram odt enable"
default n if !MACH_SUN8I_A23
default y if MACH_SUN8I_A23
+ default y if MACH_SUN50I

This change isn't obvious. It's not mentioned in the patch description or removed from the defconfig.

Quoted 2 lines

Oh, right, looks like a rebase artifact, since I juggled the patches around quite a bit. It belongs to patch 10/10, I guess.

It is setting a DRAM default, so it is fine, as for it not being removed from the defconfig, it is not yet present in the one defconfig we have for a64. OTOH it would be food to remove the DRAM_CLK and DRAM_ZQ values from configs/pine64_plus_defconfig as part of this patch.

Regards,

Hans

Quoted 21 lines

Cheers,
Andre.

Quoted 17 lines
Quoted 16 lines

---help---
Select this to enable dram odt (on die termination).
diff --git a/configs/pine64_plus_defconfig
b/configs/pine64_plus_defconfig
index 6d0198f..a53e968 100644

configs/pine64_plus_defconfig +0 -2
@@ -2,8 +2,6 @@ CONFIG_ARM=y
  CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
  CONFIG_ARCH_SUNXI=y
  CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
  CONFIG_CONSOLE_MUX=y
#14 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

Hi Hans,

thanks for having a look.

Quoted 47 lines · Hans de Goede

Hi,

Quoted 44 lines · Andre Przywara

Hi,

Quoted 40 lines · Alexander Graf
Quoted 28 lines · Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
  board/sunxi/Kconfig           | 3 +++
  configs/pine64_plus_defconfig | 2 --
  2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +1 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
      default 792 if MACH_SUN9I
      default 312 if MACH_SUN6I || MACH_SUN8I
      default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+    default 672 if MACH_SUN50I
      ---help---
      Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
      must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
      default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I ||

MACH_SUN8I
default 127 if MACH_SUN7I
default 4145117 if MACH_SUN9I

board/sunxi/Kconfig config DRAM_ODT_EN · line 176

Quoted 8 lines
board/sunxi/Kconfig +2 -0
+    default 3881915 if MACH_SUN50I
      ---help---
      Set the dram zq value.
  @@ -171,6 +173,7 @@ config DRAM_ODT_EN
      bool "sunxi dram odt enable"
      default n if !MACH_SUN8I_A23
      default y if MACH_SUN8I_A23
+    default y if MACH_SUN50I

This change isn't obvious. It's not mentioned in the patch description or removed from the defconfig.

Quoted 6 lines
Quoted 2 lines

Oh, right, looks like a rebase artifact, since I juggled the patches around quite a bit. It belongs to patch 10/10, I guess.

It is setting a DRAM default, so it is fine, as for it not being removed from the defconfig, it is not yet present in the one defconfig we have for a64. OTOH it would be food to remove the

No breakfast yet? ;-) ^^^^

Quoted 2 lines

DRAM_CLK and DRAM_ZQ values from configs/pine64_plus_defconfig as part of this patch.

Like the hunk below?

Cheers,
Andre.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

---help---
Select this to enable dram odt (on die termination).
diff --git a/configs/pine64_plus_defconfig
b/configs/pine64_plus_defconfig
index 6d0198f..a53e968 100644

configs/pine64_plus_defconfig +0 -2
@@ -2,8 +2,6 @@ CONFIG_ARM=y
  CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
  CONFIG_ARCH_SUNXI=y
  CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
  CONFIG_CONSOLE_MUX=y
#15 lore raw

RFC PATCH 3/10 sunxi: provide default DRAM config for sun50i in Kconfig

Hi,

Quoted 59 lines · Andre Przywara

Hi Hans,

thanks for having a look.

Quoted 47 lines · Hans de Goede

Hi,

Quoted 44 lines · Andre Przywara

Hi,

Quoted 40 lines · Alexander Graf
Quoted 28 lines · Andre Przywara

To avoid enumerating the very same DRAM values in defconfig files for each and every Allwinner A64 board out there, let's put some sane default values in the Kconfig file.
Boards with different needs can override them at any time.

---
  board/sunxi/Kconfig           | 3 +++
  configs/pine64_plus_defconfig | 2 --
  2 files changed, 3 insertions(+), 2 deletions(-)
board/sunxi/Kconfig +1 -0
index e1d4ab1..d281a65 100644
@@ -145,6 +145,7 @@ config DRAM_CLK
      default 792 if MACH_SUN9I
      default 312 if MACH_SUN6I || MACH_SUN8I
      default 360 if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I
+    default 672 if MACH_SUN50I
      ---help---
      Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
      must be a multiple of 24. For the sun9i (A80), the tested values
@@ -164,6 +165,7 @@ config DRAM_ZQ
      default 123 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I ||

MACH_SUN8I
default 127 if MACH_SUN7I
default 4145117 if MACH_SUN9I

board/sunxi/Kconfig config DRAM_ODT_EN · line 176

Quoted 8 lines
board/sunxi/Kconfig +2 -0
+    default 3881915 if MACH_SUN50I
      ---help---
      Set the dram zq value.
  @@ -171,6 +173,7 @@ config DRAM_ODT_EN
      bool "sunxi dram odt enable"
      default n if !MACH_SUN8I_A23
      default y if MACH_SUN8I_A23
+    default y if MACH_SUN50I

This change isn't obvious. It's not mentioned in the patch description or removed from the defconfig.

Quoted 6 lines
Quoted 2 lines

Oh, right, looks like a rebase artifact, since I juggled the patches around quite a bit. It belongs to patch 10/10, I guess.

It is setting a DRAM default, so it is fine, as for it not being removed from the defconfig, it is not yet present in the one defconfig we have for a64. OTOH it would be food to remove the

Quoted 6 lines

No breakfast yet? ;-) ^^^^

Quoted 2 lines

DRAM_CLK and DRAM_ZQ values from configs/pine64_plus_defconfig as part of this patch.

Like the hunk below?

Ugh, yes like that one, so from my pov this patch is good to go :)

Regards.

Hans

Quoted 21 lines

Cheers,
Andre.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines

---help---
Select this to enable dram odt (on die termination).
diff --git a/configs/pine64_plus_defconfig
b/configs/pine64_plus_defconfig
index 6d0198f..a53e968 100644

configs/pine64_plus_defconfig +0 -2
@@ -2,8 +2,6 @@ CONFIG_ARM=y
  CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
  CONFIG_ARCH_SUNXI=y
  CONFIG_MACH_SUN50I=y
-CONFIG_DRAM_CLK=672
-CONFIG_DRAM_ZQ=3881915
  CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
  CONFIG_CONSOLE_MUX=y
#16 lore raw

RFC PATCH 4/10 sunxi: H3: add and rename some DRAM contoller registers

In reply to Andre Przywara

From: Jens Kuske <[email protected]>

The IOCR registers got renamed to BDLR to match the public documentation of similar controllers.

---
 arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h | 43 ++++++++++++++-----------
 arch/arm/mach-sunxi/dram_sun8i_h3.c             | 34 +++++++++----------
 2 files changed, 41 insertions(+), 36 deletions(-)
arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h +24 -19
index d0f2b8a..867fd12 100644
@@ -81,7 +81,7 @@ struct sunxi_mctl_ctl_reg {
 	u32 rfshtmg;		/* 0x90 refresh timing */
 	u32 rfshctl1;		/* 0x94 */
 	u32 pwrtmg;		/* 0x98 */
-	u8  res3[0x20];		/* 0x9c */
+	u8 res3[0x20];		/* 0x9c */
 	u32 dqsgmr;		/* 0xbc */
 	u32 dtcr;		/* 0xc0 */
 	u32 dtar[4];		/* 0xc4 */
@@ -106,20 +106,23 @@ struct sunxi_mctl_ctl_reg {
 	u32 perfhpr[2];		/* 0x1c4 */
 	u32 perflpr[2];		/* 0x1cc */
 	u32 perfwr[2];		/* 0x1d4 */
-	u8 res8[0x2c];		/* 0x1dc */
-	u32 aciocr;		/* 0x208 */
-	u8 res9[0xf4];		/* 0x20c */
+	u8 res8[0x24];		/* 0x1dc */
+	u32 acmdlr;		/* 0x200 AC master delay line register */
+	u32 aclcdlr;		/* 0x204 AC local calibrated delay line register */
+	u32 aciocr;		/* 0x208 AC I/O configuration register */
+	u8 res9[0x4];		/* 0x20c */
+	u32 acbdlr[31];		/* 0x210 AC bit delay line registers */
+	u8 res10[0x74];		/* 0x28c */
 	struct {		/* 0x300 DATX8 modules*/
-		u32 mdlr;		/* 0x00 */
-		u32 lcdlr[3];		/* 0x04 */
-		u32 iocr[11];		/* 0x10 IO configuration register */
-		u32 bdlr6;		/* 0x3c */
-		u32 gtr;		/* 0x40 */
-		u32 gcr;		/* 0x44 */
-		u32 gsr[3];		/* 0x48 */
+		u32 mdlr;		/* 0x00 master delay line register */
+		u32 lcdlr[3];		/* 0x04 local calibrated delay line registers */
+		u32 bdlr[12];		/* 0x10 bit delay line registers */
+		u32 gtr;		/* 0x40 general timing register */
+		u32 gcr;		/* 0x44 general configuration register */
+		u32 gsr[3];		/* 0x48 general status registers */
 		u8 res0[0x2c];		/* 0x54 */
-	} datx[4];
-	u8 res10[0x388];	/* 0x500 */
+	} dx[4];
+	u8 res11[0x388];	/* 0x500 */
 	u32 upd2;		/* 0x888 */
 };
 
@@ -174,12 +177,14 @@ struct sunxi_mctl_ctl_reg {
 
 #define ZQCR_PWRDOWN	(0x1 << 31)	/* ZQ power down */
 
-#define DATX_IOCR_DQ(x)	(x)		/* DQ0-7 IOCR index */
-#define DATX_IOCR_DM	(8)		/* DM IOCR index */
-#define DATX_IOCR_DQS	(9)		/* DQS IOCR index */
-#define DATX_IOCR_DQSN	(10)		/* DQSN IOCR index */
+#define ACBDLR_WRITE_DELAY(x)	((x) << 8)
 
-#define DATX_IOCR_WRITE_DELAY(x)	((x) << 8)
-#define DATX_IOCR_READ_DELAY(x)		((x) << 0)
+#define DXBDLR_DQ(x)	(x)		/* DQ0-7 BDLR index */
+#define DXBDLR_DM	(8)		/* DM BDLR index */
+#define DXBDLR_DQS	(9)		/* DQS BDLR index */
+#define DXBDLR_DQSN	(10)		/* DQSN BDLR index */
+
+#define DXBDLR_WRITE_DELAY(x)	((x) << 8)
+#define DXBDLR_READ_DELAY(x)	((x) << 0)
 
 #endif /* _SUNXI_DRAM_SUN8I_H3_H */
arch/arm/mach-sunxi/dram_sun8i_h3.c +17 -17
index b08b8e6..3dd6803 100644
@@ -72,21 +72,21 @@ static void mctl_dq_delay(u32 read, u32 write)
 	u32 val;
 
 	for (i = 0; i < 4; i++) {
-		val = DATX_IOCR_WRITE_DELAY((write >> (i * 4)) & 0xf) |
-		      DATX_IOCR_READ_DELAY(((read >> (i * 4)) & 0xf) * 2);
+		val = DXBDLR_WRITE_DELAY((write >> (i * 4)) & 0xf) |
+		      DXBDLR_READ_DELAY(((read >> (i * 4)) & 0xf) * 2);
 
-		for (j = DATX_IOCR_DQ(0); j <= DATX_IOCR_DM; j++)
-			writel(val, &mctl_ctl->datx[i].iocr[j]);
+		for (j = DXBDLR_DQ(0); j <= DXBDLR_DM; j++)
+			writel(val, &mctl_ctl->dx[i].bdlr[j]);
 	}
 
 	clrbits_le32(&mctl_ctl->pgcr[0], 1 << 26);
 
 	for (i = 0; i < 4; i++) {
-		val = DATX_IOCR_WRITE_DELAY((write >> (16 + i * 4)) & 0xf) |
-		      DATX_IOCR_READ_DELAY((read >> (16 + i * 4)) & 0xf);
+		val = DXBDLR_WRITE_DELAY((write >> (16 + i * 4)) & 0xf) |
+		      DXBDLR_READ_DELAY((read >> (16 + i * 4)) & 0xf);
 
-		writel(val, &mctl_ctl->datx[i].iocr[DATX_IOCR_DQS]);
-		writel(val, &mctl_ctl->datx[i].iocr[DATX_IOCR_DQSN]);
+		writel(val, &mctl_ctl->dx[i].bdlr[DXBDLR_DQS]);
+		writel(val, &mctl_ctl->dx[i].bdlr[DXBDLR_DQSN]);
 	}
 
 	setbits_le32(&mctl_ctl->pgcr[0], 1 << 26);
@@ -344,7 +344,7 @@ static int mctl_channel_init(struct dram_para *para)
 
 	/* set dramc odt */
 	for (i = 0; i < 4; i++)
-		clrsetbits_le32(&mctl_ctl->datx[i].gcr, (0x3 << 4) |
+		clrsetbits_le32(&mctl_ctl->dx[i].gcr, (0x3 << 4) |
 				(0x1 << 1) | (0x3 << 2) | (0x3 << 12) |
 				(0x3 << 14),
 				IS_ENABLED(CONFIG_DRAM_ODT_EN) ? 0x0 : 0x2);
@@ -364,8 +364,8 @@ static int mctl_channel_init(struct dram_para *para)
 
 	/* set half DQ */
 	if (para->bus_width != 32) {
-		writel(0x0, &mctl_ctl->datx[2].gcr);
-		writel(0x0, &mctl_ctl->datx[3].gcr);
+		writel(0x0, &mctl_ctl->dx[2].gcr);
+		writel(0x0, &mctl_ctl->dx[3].gcr);
 	}
 
 	/* data training configuration */
@@ -386,17 +386,17 @@ static int mctl_channel_init(struct dram_para *para)
 	/* detect ranks and bus width */
 	if (readl(&mctl_ctl->pgsr[0]) & (0xfe << 20)) {
 		/* only one rank */
-		if (((readl(&mctl_ctl->datx[0].gsr[0]) >> 24) & 0x2) ||
-		    ((readl(&mctl_ctl->datx[1].gsr[0]) >> 24) & 0x2)) {
+		if (((readl(&mctl_ctl->dx[0].gsr[0]) >> 24) & 0x2) ||
+		    ((readl(&mctl_ctl->dx[1].gsr[0]) >> 24) & 0x2)) {
 			clrsetbits_le32(&mctl_ctl->dtcr, 0xf << 24, 0x1 << 24);
 			para->dual_rank = 0;
 		}
 
 		/* only half DQ width */
-		if (((readl(&mctl_ctl->datx[2].gsr[0]) >> 24) & 0x1) ||
-		    ((readl(&mctl_ctl->datx[3].gsr[0]) >> 24) & 0x1)) {
-			writel(0x0, &mctl_ctl->datx[2].gcr);
-			writel(0x0, &mctl_ctl->datx[3].gcr);
+		if (((readl(&mctl_ctl->dx[2].gsr[0]) >> 24) & 0x1) ||
+		    ((readl(&mctl_ctl->dx[3].gsr[0]) >> 24) & 0x1)) {
+			writel(0x0, &mctl_ctl->dx[2].gcr);
+			writel(0x0, &mctl_ctl->dx[3].gcr);
 			para->bus_width = 16;
 		}
 
Signature · 1 line
2.8.2
#17 lore raw

RFC PATCH 5/10 sunxi: H3: add DRAM controller single bit delay support

In reply to Andre Przywara

From: Jens Kuske <[email protected]>

Instead of setting the delay for whole bytes allow setting it for each individual bit. Also add support for address/command lane delays.

---
 arch/arm/mach-sunxi/dram_sun8i_h3.c | 54 ++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 27 deletions(-)
arch/arm/mach-sunxi/dram_sun8i_h3.c +27 -27
index 3dd6803..1647d76 100644
@@ -16,12 +16,13 @@
 #include <linux/kconfig.h>
 
 struct dram_para {
-	u32 read_delays;
-	u32 write_delays;
 	u16 page_size;
 	u8 bus_width;
 	u8 dual_rank;
 	u8 row_bits;
+	const u8 dx_read_delays[4][11];
+	const u8 dx_write_delays[4][11];
+	const u8 ac_delays[31];
 };
 
 static inline int ns_to_t(int nanoseconds)
@@ -64,34 +65,25 @@ static void mctl_phy_init(u32 val)
 	mctl_await_completion(&mctl_ctl->pgsr[0], PGSR_INIT_DONE, 0x1);
 }
 
-static void mctl_dq_delay(u32 read, u32 write)
+static void mctl_set_bit_delays(struct dram_para *para)
 {
 	struct sunxi_mctl_ctl_reg * const mctl_ctl =
 			(struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
 	int i, j;
-	u32 val;
-
-	for (i = 0; i < 4; i++) {
-		val = DXBDLR_WRITE_DELAY((write >> (i * 4)) & 0xf) |
-		      DXBDLR_READ_DELAY(((read >> (i * 4)) & 0xf) * 2);
-
-		for (j = DXBDLR_DQ(0); j <= DXBDLR_DM; j++)
-			writel(val, &mctl_ctl->dx[i].bdlr[j]);
-	}
 
 	clrbits_le32(&mctl_ctl->pgcr[0], 1 << 26);
 
-	for (i = 0; i < 4; i++) {
-		val = DXBDLR_WRITE_DELAY((write >> (16 + i * 4)) & 0xf) |
-		      DXBDLR_READ_DELAY((read >> (16 + i * 4)) & 0xf);
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 11; j++)
+			writel(DXBDLR_WRITE_DELAY(para->dx_write_delays[i][j]) |
+			       DXBDLR_READ_DELAY(para->dx_read_delays[i][j]),
+			       &mctl_ctl->dx[i].bdlr[j]);
 
-		writel(val, &mctl_ctl->dx[i].bdlr[DXBDLR_DQS]);
-		writel(val, &mctl_ctl->dx[i].bdlr[DXBDLR_DQSN]);
-	}
+	for (i = 0; i < 31; i++)
+		writel(ACBDLR_WRITE_DELAY(para->ac_delays[i]),
+		       &mctl_ctl->acbdlr[i]);
 
 	setbits_le32(&mctl_ctl->pgcr[0], 1 << 26);
-
-	udelay(1);
 }
 
 static void mctl_set_master_priority(void)
@@ -372,11 +364,8 @@ static int mctl_channel_init(struct dram_para *para)
 	clrsetbits_le32(&mctl_ctl->dtcr, 0xf << 24,
 			(para->dual_rank ? 0x3 : 0x1) << 24);
 
-
-	if (para->read_delays || para->write_delays) {
-		mctl_dq_delay(para->read_delays, para->write_delays);
-		udelay(50);
-	}
+	mctl_set_bit_delays(para);
+	udelay(50);
 
 	mctl_zq_calibration(para);
 
@@ -458,12 +447,23 @@ unsigned long sunxi_dram_init(void)
 			(struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
 
 	struct dram_para para = {
-		.read_delays = 0x00007979,	/* dram_tpr12 */
-		.write_delays = 0x6aaa0000,	/* dram_tpr11 */
 		.dual_rank = 0,
 		.bus_width = 32,
 		.row_bits = 15,
 		.page_size = 4096,
+
+		.dx_read_delays =  {{ 18, 18, 18, 18, 18, 18, 18, 18, 18,  0,  0 },
+		                    { 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 },
+		                    { 18, 18, 18, 18, 18, 18, 18, 18, 18,  0,  0 },
+		                    { 14, 14, 14, 14, 14, 14, 14, 14, 14,  0,  0 }},
+		.dx_write_delays = {{  0,  0,  0,  0,  0,  0,  0,  0,  0, 10, 10 },
+		                    {  0,  0,  0,  0,  0,  0,  0,  0,  0, 10, 10 },
+		                    {  0,  0,  0,  0,  0,  0,  0,  0,  0, 10, 10 },
+		                    {  0,  0,  0,  0,  0,  0,  0,  0,  0,  6,  6 }},
+		.ac_delays = {  0,  0,  0,  0,  0,  0,  0,  0,
+		                0,  0,  0,  0,  0,  0,  0,  0,
+		                0,  0,  0,  0,  0,  0,  0,  0,
+		                0,  0,  0,  0,  0,  0,  0      },
 	};
 
 	mctl_sys_init(&para);
Signature · 1 line
2.8.2
#18 lore raw

RFC PATCH 6/10 sunxi: A64: use H3 DRAM initialization code for A64

In reply to Andre Przywara

From: Jens Kuske <[email protected]>

The A64 DRAM controller is very similar to the H3 one, so the code can be reused with some small changes. [Andre: fixed up typo, merged in fixes from Jens]

---
 arch/arm/include/asm/arch-sunxi/clock_sun6i.h   |   1 +
 arch/arm/include/asm/arch-sunxi/dram.h          |   2 +-
 arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h |  10 +-
 arch/arm/mach-sunxi/Makefile                    |   1 +
 arch/arm/mach-sunxi/clock_sun6i.c               |   2 +-
 arch/arm/mach-sunxi/dram_sun8i_h3.c             | 139 +++++++++++++++++++-----
 6 files changed, 123 insertions(+), 32 deletions(-)
arch/arm/include/asm/arch-sunxi/clock_sun6i.h +1 -0
index be9fcfd..3f87672 100644
@@ -322,6 +322,7 @@ struct sunxi_ccm_reg {
 #define CCM_DRAMCLK_CFG_DIV0_MASK	(0xf << 8)
 #define CCM_DRAMCLK_CFG_SRC_PLL5	(0x0 << 20)
 #define CCM_DRAMCLK_CFG_SRC_PLL6x2	(0x1 << 20)
+#define CCM_DRAMCLK_CFG_SRC_PLL11	(0x1 << 20) /* A64 only */
 #define CCM_DRAMCLK_CFG_SRC_MASK	(0x3 << 20)
 #define CCM_DRAMCLK_CFG_UPD		(0x1 << 16)
 #define CCM_DRAMCLK_CFG_RST		(0x1 << 31)
arch/arm/include/asm/arch-sunxi/dram.h +1 -1
index e0be744..53e6d47 100644
@@ -24,7 +24,7 @@
 #include <asm/arch/dram_sun8i_a33.h>
 #elif defined(CONFIG_MACH_SUN8I_A83T)
 #include <asm/arch/dram_sun8i_a83t.h>
-#elif defined(CONFIG_MACH_SUN8I_H3)
+#elif defined(CONFIG_MACH_SUN8I_H3) || defined(CONFIG_MACH_SUN50I)
 #include <asm/arch/dram_sun8i_h3.h>
 #elif defined(CONFIG_MACH_SUN9I)
 #include <asm/arch/dram_sun9i.h>
arch/arm/include/asm/arch-sunxi/dram_sun8i_h3.h +7 -3
index 867fd12..b0e5d93 100644
@@ -15,7 +15,8 @@
 
 struct sunxi_mctl_com_reg {
 	u32 cr;			/* 0x00 control register */
-	u8 res0[0xc];		/* 0x04 */
+	u8 res0[0x8];		/* 0x04 */
+	u32 tmr;		/* 0x0c (A64 only) */
 	u32 mcr[16][2];		/* 0x10 */
 	u32 bwcr;		/* 0x90 bandwidth control register */
 	u32 maer;		/* 0x94 master enable register */
@@ -32,7 +33,9 @@ struct sunxi_mctl_com_reg {
 	u32 swoffr;		/* 0xc4 */
 	u8 res2[0x8];		/* 0xc8 */
 	u32 cccr;		/* 0xd0 */
-	u8 res3[0x72c];		/* 0xd4 */
+	u8 res3[0x54];		/* 0xd4 */
+	u32 mdfs_bwlr[3];	/* 0x128 (A64 only) */
+	u8 res4[0x6cc];		/* 0x134 */
 	u32 protect;		/* 0x800 */
 };
 
@@ -81,7 +84,8 @@ struct sunxi_mctl_ctl_reg {
 	u32 rfshtmg;		/* 0x90 refresh timing */
 	u32 rfshctl1;		/* 0x94 */
 	u32 pwrtmg;		/* 0x98 */
-	u8 res3[0x20];		/* 0x9c */
+	u8 res3[0x1c];		/* 0x9c */
+	u32 vtfcr;		/* 0xb8 (A64 only) */
 	u32 dqsgmr;		/* 0xbc */
 	u32 dtcr;		/* 0xc0 */
 	u32 dtar[4];		/* 0xc4 */
arch/arm/mach-sunxi/Makefile +1 -0
index e73114e..7daba11 100644
@@ -50,4 +50,5 @@ obj-$(CONFIG_MACH_SUN8I_A33)	+= dram_sun8i_a33.o
 obj-$(CONFIG_MACH_SUN8I_A83T)	+= dram_sun8i_a83t.o
 obj-$(CONFIG_MACH_SUN8I_H3)	+= dram_sun8i_h3.o
 obj-$(CONFIG_MACH_SUN9I)	+= dram_sun9i.o
+obj-$(CONFIG_MACH_SUN50I)	+= dram_sun8i_h3.o
 endif
arch/arm/mach-sunxi/clock_sun6i.c +1 -1
index 382fa94..4570060 100644
@@ -218,7 +218,7 @@ done:
 }
 #endif
 
-#ifdef CONFIG_MACH_SUN8I_A33
+#if defined(CONFIG_MACH_SUN8I_A33) || defined(CONFIG_MACH_SUN50I)
 void clock_set_pll11(unsigned int clk, bool sigma_delta_enable)
 {
 	struct sunxi_ccm_reg * const ccm =
arch/arm/mach-sunxi/dram_sun8i_h3.c +112 -27

234 lines not on this page · raw message

Signature · 1 line
2.8.2
#19 lore raw

RFC PATCH 7/10 sunxi: H3/A64: fix non-ODT setting

In reply to Andre Przywara

According to Jens disabling the on-die-termination should set bit 5, not bit 1 in the respective register. Fix this.

---
 arch/arm/mach-sunxi/dram_sun8i_h3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-sunxi/dram_sun8i_h3.c +1 -1
index 2dc2071..3d569fc 100644
@@ -385,7 +385,7 @@ static int mctl_channel_init(struct dram_para *para)
 		clrsetbits_le32(&mctl_ctl->dx[i].gcr, (0x3 << 4) |
 				(0x1 << 1) | (0x3 << 2) | (0x3 << 12) |
 				(0x3 << 14),
-				IS_ENABLED(CONFIG_DRAM_ODT_EN) ? 0x0 : 0x2);
+				IS_ENABLED(CONFIG_DRAM_ODT_EN) ? 0x0 : 0x20);
 
 	/* AC PDR should always ON */
 	setbits_le32(&mctl_ctl->aciocr, 0x1 << 1);
Signature · 1 line
2.8.2
#20 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

In reply to Andre Przywara

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
 				header_size;
 		}
 		spl_image->os = image_get_os(header);
+		spl_image->arch = image_get_arch(header);
 		spl_image->name = image_get_name(header);
 		debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
 			(int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +8 -0
index aae556f..a5d903b 100644
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
 	return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+	return IH_ARCH_DEFAULT;
+}
+
 int spl_load_simple_fit(struct spl_image_info *spl_image,
 			struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
 	int src_sector;
 	void *dst, *src;
+	const char *arch_str;
 
 	/*
 	 * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	data_offset = fdt_getprop_u32(fit, node, "data-offset");
 	data_size = fdt_getprop_u32(fit, node, "data-size");
 	load = fdt_getprop_u32(fit, node, "load");
+	arch_str = fdt_getprop(fit, node, "arch", NULL);
 	debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
 	spl_image->load_addr = load;
 	spl_image->entry_point = load;
 	spl_image->os = IH_OS_U_BOOT;
+	spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
 	/*
 	 * Work out where to place the image. We read it so that the first
include/spl.h +2 -1
index e080a82..6a9d2fb 100644
@@ -22,11 +22,12 @@
 
 struct spl_image_info {
 	const char *name;
-	u8 os;
 	u32 load_addr;
 	u32 entry_point;
 	u32 size;
 	u32 flags;
+	u8 os;
+	u8 arch;
 };
 
 /*
Signature · 1 line
2.8.2
#21 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

Hi Andre,

Quoted 9 lines · Andre Przywara

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

Quoted 7 lines
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
Quoted 17 lines
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                                header_size;
                }
                spl_image->os = image_get_os(header);
+               spl_image->arch = image_get_arch(header);
                spl_image->name = image_get_name(header);
                debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
                        (int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +0 -0
index aae556f..a5d903b 100644

common/spl/spl_fit.c static int get_aligned_image_size(struct spl_load_info *info, int data_size, · line 130

Quoted 8 lines
common/spl/spl_fit.c +5 -0
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
        return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+       return IH_ARCH_DEFAULT;
+}
+

Do we need this weak function, or could we just add a normal function in the ARM code somewhere?

If you don't think we need much error checking you could do something like:

#ifdef CONFIG_ARM
... possible strcmp() here
return IH_ARCH_ARM;
#endif

Quoted 29 lines
common/spl/spl_fit.c +3 -0
 int spl_load_simple_fit(struct spl_image_info *spl_image,
                        struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
        int src_sector;
        void *dst, *src;
+       const char *arch_str;
 
        /*
         * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        data_offset = fdt_getprop_u32(fit, node, "data-offset");
        data_size = fdt_getprop_u32(fit, node, "data-size");
        load = fdt_getprop_u32(fit, node, "load");
+       arch_str = fdt_getprop(fit, node, "arch", NULL);
        debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
        spl_image->load_addr = load;
        spl_image->entry_point = load;
        spl_image->os = IH_OS_U_BOOT;
+       spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
        /*
         * Work out where to place the image. We read it so that the first
include/spl.h +0 -0
index e080a82..6a9d2fb 100644

include/spl.h line 30

Quoted 10 lines
include/spl.h +2 -1
@@ -22,11 +22,12 @@
 
 struct spl_image_info {
        const char *name;
-       u8 os;
        u32 load_addr;
        u32 entry_point;
        u32 size;
        u32 flags;
+       u8 os;
+       u8 arch;

Can you please add a struct comment?

Quoted 6 lines
include/spl.h +0 -1
 };
 
 /*
--

2.8.2

Regards,
Simon

#22 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

On 05/11/16 16:10, Simon Glass wrote:

Hi Simon,

Quoted 18 lines · Andre Przywara
Quoted 9 lines

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

Quoted 7 lines
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
Quoted 1 line

Thanks!

Quoted 21 lines
Quoted 21 lines
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                                header_size;
                }
                spl_image->os = image_get_os(header);
+               spl_image->arch = image_get_arch(header);
                spl_image->name = image_get_name(header);
                debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
                        (int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +0 -0
index aae556f..a5d903b 100644
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
        return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
Quoted 8 lines

common/spl/spl_fit.c static int get_aligned_image_size(struct spl_load_info *info, int data_size, · line 130

Quoted 5 lines
common/spl/spl_fit.c +5 -0
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+       return IH_ARCH_DEFAULT;
+}
+

Do we need this weak function, or could we just add a normal function in the ARM code somewhere?

Mmh, but this here is generic code. In a later patch I provide an ARM specific function under arch/arm, but so far this weak function just mimics the current behaviour: return the current architecture.

Quoted 6 lines

If you don't think we need much error checking you could do something like:

#ifdef CONFIG_ARM
... possible strcmp() here
return IH_ARCH_ARM;
#endif

So I found the weak function more elegant than #ifdef-ing architecture specific code into a generic file.
Is there any issue with weak functions, shall we avoid them?

Quoted 31 lines
Quoted 31 lines
common/spl/spl_fit.c +3 -0
 int spl_load_simple_fit(struct spl_image_info *spl_image,
                        struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
        int src_sector;
        void *dst, *src;
+       const char *arch_str;
 
        /*
         * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        data_offset = fdt_getprop_u32(fit, node, "data-offset");
        data_size = fdt_getprop_u32(fit, node, "data-size");
        load = fdt_getprop_u32(fit, node, "load");
+       arch_str = fdt_getprop(fit, node, "arch", NULL);
        debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
        spl_image->load_addr = load;
        spl_image->entry_point = load;
        spl_image->os = IH_OS_U_BOOT;
+       spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
        /*
         * Work out where to place the image. We read it so that the first
include/spl.h +0 -0
index e080a82..6a9d2fb 100644
@@ -22,11 +22,12 @@
 
Quoted 11 lines

include/spl.h line 30

Quoted 9 lines
include/spl.h +2 -1
 struct spl_image_info {
        const char *name;
-       u8 os;
        u32 load_addr;
        u32 entry_point;
        u32 size;
        u32 flags;
+       u8 os;
+       u8 arch;

Can you please add a struct comment?

Is that something specific / a special documentation format or do you mean just document the structure members?

Cheers,
Andre.

#23 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

Hi Andre,

Quoted 62 lines · Andr? Przywara

On 05/11/16 16:10, Simon Glass wrote:

Hi Simon,

Quoted 18 lines · Andre Przywara
Quoted 9 lines

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

Quoted 7 lines
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
Quoted 1 line

Thanks!

Quoted 21 lines
Quoted 21 lines
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                                header_size;
                }
                spl_image->os = image_get_os(header);
+               spl_image->arch = image_get_arch(header);
                spl_image->name = image_get_name(header);
                debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
                        (int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +0 -0
index aae556f..a5d903b 100644
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
        return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
Quoted 8 lines

common/spl/spl_fit.c static int get_aligned_image_size(struct spl_load_info *info, int data_size, · line 130

Quoted 5 lines
common/spl/spl_fit.c +5 -0
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+       return IH_ARCH_DEFAULT;
+}
+

Do we need this weak function, or could we just add a normal function in the ARM code somewhere?

Mmh, but this here is generic code. In a later patch I provide an ARM specific function under arch/arm, but so far this weak function just mimics the current behaviour: return the current architecture.

Quoted 2 lines

If you don't think we need much error checking you could do something like:

Quoted 7 lines
Quoted 4 lines

#ifdef CONFIG_ARM
... possible strcmp() here
return IH_ARCH_ARM;
#endif

So I found the weak function more elegant than #ifdef-ing architecture specific code into a generic file.

Fair enough.

Quoted 1 line

Is there any issue with weak functions, shall we avoid them?

Well they can be confusing since it's hard to know which function gets linked in. We have things like CONFIG_MISC_INIT_F, rather than make misc_init() weak.

Quoted 44 lines
Quoted 32 lines
Quoted 32 lines
common/spl/spl_fit.c +3 -0
 int spl_load_simple_fit(struct spl_image_info *spl_image,
                        struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
        int src_sector;
        void *dst, *src;
+       const char *arch_str;
 
        /*
         * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        data_offset = fdt_getprop_u32(fit, node, "data-offset");
        data_size = fdt_getprop_u32(fit, node, "data-size");
        load = fdt_getprop_u32(fit, node, "load");
+       arch_str = fdt_getprop(fit, node, "arch", NULL);
        debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
        spl_image->load_addr = load;
        spl_image->entry_point = load;
        spl_image->os = IH_OS_U_BOOT;
+       spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
        /*
         * Work out where to place the image. We read it so that the first
include/spl.h +0 -0
index e080a82..6a9d2fb 100644
@@ -22,11 +22,12 @@
 
Quoted 11 lines

include/spl.h line 30

Quoted 9 lines
include/spl.h +2 -1
 struct spl_image_info {
        const char *name;
-       u8 os;
        u32 load_addr;
        u32 entry_point;
        u32 size;
        u32 flags;
+       u8 os;
+       u8 arch;

Can you please add a struct comment?

Quoted 2 lines

Is that something specific / a special documentation format or do you mean just document the structure members?

The latter - see struct spl_load_info for an example. If we improve the code we change everyone wins :-)

Regards,
Simon

Quoted 1 line
#24 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

On 19/11/16 13:49, Simon Glass wrote:

Hi Simon,

Quoted 71 lines · Andr? Przywara
Quoted 62 lines · Simon Glass

Hi Simon,

Quoted 18 lines · Andre Przywara
Quoted 9 lines

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

Quoted 7 lines
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
Quoted 1 line

Thanks!

Quoted 21 lines
Quoted 21 lines
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                                header_size;
                }
                spl_image->os = image_get_os(header);
+               spl_image->arch = image_get_arch(header);
                spl_image->name = image_get_name(header);
                debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
                        (int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +0 -0
index aae556f..a5d903b 100644
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
        return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
Quoted 8 lines

common/spl/spl_fit.c static int get_aligned_image_size(struct spl_load_info *info, int data_size, · line 130

Quoted 5 lines
common/spl/spl_fit.c +5 -0
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+       return IH_ARCH_DEFAULT;
+}
+

Do we need this weak function, or could we just add a normal function in the ARM code somewhere?

Mmh, but this here is generic code. In a later patch I provide an ARM specific function under arch/arm, but so far this weak function just mimics the current behaviour: return the current architecture.

Quoted 2 lines

If you don't think we need much error checking you could do something like:

Quoted 7 lines
Quoted 4 lines

#ifdef CONFIG_ARM
... possible strcmp() here
return IH_ARCH_ARM;
#endif

So I found the weak function more elegant than #ifdef-ing architecture specific code into a generic file.

Quoted 7 lines

Fair enough.

Quoted 1 line

Is there any issue with weak functions, shall we avoid them?

Well they can be confusing since it's hard to know which function gets linked in. We have things like CONFIG_MISC_INIT_F, rather than make misc_init() weak.

I see. But I think in this case a weak function is neater. I will add a comment to the non-weak definition pointing out its nature, if that helps.

Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 30 lines
common/spl/spl_fit.c +3 -0
 int spl_load_simple_fit(struct spl_image_info *spl_image,
                        struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
        int src_sector;
        void *dst, *src;
+       const char *arch_str;
 
        /*
         * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        data_offset = fdt_getprop_u32(fit, node, "data-offset");
        data_size = fdt_getprop_u32(fit, node, "data-size");
        load = fdt_getprop_u32(fit, node, "load");
+       arch_str = fdt_getprop(fit, node, "arch", NULL);
        debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
        spl_image->load_addr = load;
        spl_image->entry_point = load;
        spl_image->os = IH_OS_U_BOOT;
+       spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
        /*
         * Work out where to place the image. We read it so that the first
include/spl.h +0 -0
index e080a82..6a9d2fb 100644

include/spl.h line 30

Quoted 10 lines
include/spl.h +2 -1
@@ -22,11 +22,12 @@
 
 struct spl_image_info {
        const char *name;
-       u8 os;
        u32 load_addr;
        u32 entry_point;
        u32 size;
        u32 flags;
+       u8 os;
+       u8 arch;

Can you please add a struct comment?

Quoted 5 lines
Quoted 2 lines

Is that something specific / a special documentation format or do you mean just document the structure members?

The latter - see struct spl_load_info for an example. If we improve the code we change everyone wins :-)

Yeah, sorry for that stupid question: When I just wanted to add something I saw what you meant in the struct next to it ;-)

Cheers,
Andre.

#25 lore raw

RFC PATCH 8/10 SPL: read and store arch property from U-Boot image

Hi Andre,

Quoted 77 lines · Andr? Przywara

On 19/11/16 13:49, Simon Glass wrote:

Hi Simon,

Quoted 73 lines · Andr? Przywara
Quoted 62 lines · Simon Glass

Hi Simon,

Quoted 18 lines · Andre Przywara
Quoted 9 lines

Read the specified "arch" value from a legacy or FIT U-Boot image and store it in our SPL data structure.
This allows loaders to take the target architecture in account for custom loading procedures.
Having the complete string -> arch mapping for FIT based images in the SPL would be too big, so we leave it up to architectures (or boards) to overwrite the weak function that does the actual translation, possibly covering only the required subset there.

Quoted 7 lines
---
 common/spl/spl.c     | 1 +
 common/spl/spl_fit.c | 8 ++++++++
 include/spl.h        | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)
Quoted 1 line

Thanks!

Quoted 21 lines
Quoted 21 lines
common/spl/spl.c +1 -0
index bdb165a..f76ddd2 100644
@@ -114,6 +114,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
                                header_size;
                }
                spl_image->os = image_get_os(header);
+               spl_image->arch = image_get_arch(header);
                spl_image->name = image_get_name(header);
                debug("spl: payload image: %.*s load addr: 0x%x size: %d\n",
                        (int)sizeof(spl_image->name), spl_image->name,
common/spl/spl_fit.c +0 -0
index aae556f..a5d903b 100644
@@ -123,6 +123,11 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
        return (data_size + info->bl_len - 1) / info->bl_len;
 }
 
Quoted 8 lines

common/spl/spl_fit.c static int get_aligned_image_size(struct spl_load_info *info, int data_size, · line 130

Quoted 5 lines
common/spl/spl_fit.c +5 -0
+__weak u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+       return IH_ARCH_DEFAULT;
+}
+

Do we need this weak function, or could we just add a normal function in the ARM code somewhere?

Mmh, but this here is generic code. In a later patch I provide an ARM specific function under arch/arm, but so far this weak function just mimics the current behaviour: return the current architecture.

Quoted 2 lines

If you don't think we need much error checking you could do something like:

Quoted 7 lines
Quoted 4 lines

#ifdef CONFIG_ARM
... possible strcmp() here
return IH_ARCH_ARM;
#endif

So I found the weak function more elegant than #ifdef-ing architecture specific code into a generic file.

Fair enough.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Is there any issue with weak functions, shall we avoid them?

Well they can be confusing since it's hard to know which function gets linked in. We have things like CONFIG_MISC_INIT_F, rather than make misc_init() weak.

I see. But I think in this case a weak function is neater. I will add a comment to the non-weak definition pointing out its nature, if that helps.

OK, well more comments help.

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 43 lines
Quoted 31 lines
common/spl/spl_fit.c +3 -0
 int spl_load_simple_fit(struct spl_image_info *spl_image,
                        struct spl_load_info *info, ulong sector, void *fit)
 {
@@ -136,6 +141,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        int base_offset, align_len = ARCH_DMA_MINALIGN - 1;
        int src_sector;
        void *dst, *src;
+       const char *arch_str;
 
        /*
         * Figure out where the external images start. This is the base for the
@@ -184,10 +190,12 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
        data_offset = fdt_getprop_u32(fit, node, "data-offset");
        data_size = fdt_getprop_u32(fit, node, "data-size");
        load = fdt_getprop_u32(fit, node, "load");
+       arch_str = fdt_getprop(fit, node, "arch", NULL);
        debug("data_offset=%x, data_size=%x\n", data_offset, data_size);
        spl_image->load_addr = load;
        spl_image->entry_point = load;
        spl_image->os = IH_OS_U_BOOT;
+       spl_image->arch = spl_genimg_get_arch_id(arch_str);
 
        /*
         * Work out where to place the image. We read it so that the first
include/spl.h +0 -0
index e080a82..6a9d2fb 100644

include/spl.h line 30

Quoted 10 lines
include/spl.h +2 -1
@@ -22,11 +22,12 @@
 
 struct spl_image_info {
        const char *name;
-       u8 os;
        u32 load_addr;
        u32 entry_point;
        u32 size;
        u32 flags;
+       u8 os;
+       u8 arch;

Can you please add a struct comment?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Is that something specific / a special documentation format or do you mean just document the structure members?

The latter - see struct spl_load_info for an example. If we improve the code we change everyone wins :-)

Yeah, sorry for that stupid question: When I just wanted to add something I saw what you meant in the struct next to it ;-)

Yes that's what I mean, thanks.

Regards,
Simon

#26 lore raw

RFC PATCH 9/10 sunxi: introduce RMR switch to enter payloads in 64-bit mode

In reply to Andre Przywara

The ARMv8 capable Allwinner A64 SoC comes out of reset in AArch32 mode. To run AArch64 code, we have to trigger a warm reset via the RMR register, which proceeds with code execution at the address stored in the RVBAR register.
If the bootable payload in the FIT image is using a different architecture than the SPL has been compiled for, enter it via this said RMR switch mechanism, by writing the entry point address into the MMIO mapped, writable version of the RVBAR register.
Then the warm reset is triggered via a system register write. If the payload architecture is the same as the SPL, we use the normal branch as usual.

---
 arch/arm/lib/spl.c               | 14 ++++++++++
 arch/arm/mach-sunxi/Makefile     |  1 +
 arch/arm/mach-sunxi/spl_switch.c | 60 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 arch/arm/mach-sunxi/spl_switch.c
arch/arm/lib/spl.c +14 -0
index e606d47..ae3d81c 100644
@@ -63,3 +63,17 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image, void *arg)
 	image_entry(0, machid, arg);
 }
 #endif
+
+u8 spl_genimg_get_arch_id(const char *arch_str)
+{
+	if (!arch_str)
+		return IH_ARCH_DEFAULT;
+
+	if (!strcmp(arch_str, "arm"))
+		return IH_ARCH_ARM;
+
+	if (!strcmp(arch_str, "arm64"))
+		return IH_ARCH_ARM64;
+
+	return IH_ARCH_DEFAULT;
+}
arch/arm/mach-sunxi/Makefile +1 -0
index 7daba11..128091e 100644
@@ -51,4 +51,5 @@ obj-$(CONFIG_MACH_SUN8I_A83T)	+= dram_sun8i_a83t.o
 obj-$(CONFIG_MACH_SUN8I_H3)	+= dram_sun8i_h3.o
 obj-$(CONFIG_MACH_SUN9I)	+= dram_sun9i.o
 obj-$(CONFIG_MACH_SUN50I)	+= dram_sun8i_h3.o
+obj-$(CONFIG_MACH_SUN50I)	+= spl_switch.o
 endif
arch/arm/mach-sunxi/spl_switch.c new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
2.8.2
#27 lore raw

RFC PATCH 9/10 sunxi: introduce RMR switch to enter payloads in 64-bit mode

Hi Andre,

Quoted 12 lines · Andre Przywara

The ARMv8 capable Allwinner A64 SoC comes out of reset in AArch32 mode. To run AArch64 code, we have to trigger a warm reset via the RMR register, which proceeds with code execution at the address stored in the RVBAR register.
If the bootable payload in the FIT image is using a different architecture than the SPL has been compiled for, enter it via this said RMR switch mechanism, by writing the entry point address into the MMIO mapped, writable version of the RVBAR register.
Then the warm reset is triggered via a system register write. If the payload architecture is the same as the SPL, we use the normal branch as usual.

Quoted 3 lines
---
 arch/arm/lib/spl.c               | 14 ++++++++++

I think the changes to this file should go in a separate patch as they are generic to ARM.

Quoted 4 lines
 arch/arm/mach-sunxi/Makefile     |  1 +
 arch/arm/mach-sunxi/spl_switch.c | 60 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+)
 create mode 100644 arch/arm/mach-sunxi/spl_switch.c

[...]

Regards,
Simon

#28 lore raw

RFC PATCH 10/10 sunxi: A64: add 32-bit SPL support

In reply to Andre Przywara

When compiling the SPL for the Allwinner A64 in AArch64 mode, we can't use the more compact Thumb2 encoding, which only exists for AArch32 code. This makes the SPL rather big, up to a point where any code additions or even a different compiler may easily exceed the 32KB limit that the Allwinner BROM imposes.
Introduce a separate, mostly generic sun50i-a64 configuration, which defines the CPU_V7 symbol and thus will create a 32-bit binary using the memory-saving Thumb2 encoding.
This should only be used for the SPL, the U-Boot proper should still be using the existing 64-bit configuration. The SPL code can switch to AArch64 if needed, so a 32-bit SPL can be combined with a 64-bit U-Boot proper to eventually launch arm64 kernels.

---
 board/sunxi/Kconfig            | 14 ++++++++++++--
 configs/pine64_plus_defconfig  |  2 +-
 configs/sun50i_spl32_defconfig | 11 +++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)
 create mode 100644 configs/sun50i_spl32_defconfig
board/sunxi/Kconfig +12 -2
index d281a65..da8785a 100644
@@ -43,6 +43,10 @@ config SUNXI_GEN_SUN6I
 	watchdog, etc.
 
 
+config MACH_SUN50I
+	bool
+	select SUNXI_GEN_SUN6I
+
 choice
 	prompt "Sunxi SoC Variant"
 	optional
@@ -121,10 +125,16 @@ config MACH_SUN9I
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 
-config MACH_SUN50I
+config MACH_SUN50I_64
 	bool "sun50i (Allwinner A64)"
+	select MACH_SUN50I
 	select ARM64
-	select SUNXI_GEN_SUN6I
+
+config MACH_SUN50I_32
+	bool "sun50i (Allwinner A64) SPL-32bit"
+	select MACH_SUN50I
+	select CPU_V7
+	select SUPPORT_SPL
 
 endchoice
 
configs/pine64_plus_defconfig +1 -1
index a53e968..634652e 100644
@@ -1,7 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
 CONFIG_ARCH_SUNXI=y
-CONFIG_MACH_SUN50I=y
+CONFIG_MACH_SUN50I_64=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_CONSOLE_MUX=y
configs/sun50i_spl32_defconfig new file +11 -0
new file mode 100644
index 0000000..12d102d
@@ -0,0 +1,11 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN50I_32=y
+CONFIG_DRAM_CLK=672
+CONFIG_SPL=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
+CONFIG_OF_LIST="sun50i-a64-pine64 sun50i-a64-pine64-plus"
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+# CONFIG_CMD_FPGA is not set
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
Signature · 1 line
2.8.2
#29 lore raw

cover sunxi: Allwinner A64 SPL support

In reply to Andre Przywara
Quoted 10 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Alex

#30 lore raw

cover sunxi: Allwinner A64 SPL support

<Adding Peter Robinson to the Cc to see how much he will
object my packaging ideas>

Hi,

First of all cool stuff! Thank you Andre and all others involved for making this happen.

Quoted 12 lines · Alexander Graf
Quoted 10 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

Quoted 6 lines

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Later down in the mail Andre says that in 32 bit (thumb) mode the size goes down to 20KB which gives us a lot more head-room then the 32600 out of 32768 bytes available for the 64 bit version.

With that said I agree with you (Alex) that having a 32 bit SPL + 64 bit u-boot proper is worry-some from a distro pov.

What I would like to see is:

1) Ensure we keep a pure 64 bit build working, which should lead to a fully functional u-boot-sunxi-with-spl.bin just like how things work for current 32 bit boards. This will give distros an easy way to deal with this and is also easier for users who built from source (like people who to the occasional contribution but are not really into u-boot).

2) Offer the 32 bit option in the do 2 builds, combine 32 bit SPL with 64 bit u-boot proper (and ATF) as Andre is suggesting as an option.

We may need to strip some features from "1" in the future, e.g. no NAND support.

For distros we could then still opt to use 2, to e.g. get NAND support. One solution I have in mind is:

a) Do a native 32 bit build for the 32 bit SPL, store the SPL somewhere (just like we store u-boot-sunxi-with-spl.bin for end users to dd for other 32 bit boards), on Fedora this build would generate uboot-images-armv7.noarch.rpm (we already put all the generated u-boot-sunxi-with-spl.bin files in this noarch rpm).

b) Do a native 64 bit build which stores both a 64 bit u-boot-sunxi-with-spl.bin as well as just a u-boot.bin (unless we can extract the latter easy enough), on fedora this build would generate uboot-images-armv8.noarch.rpm (as we already do).

c) Have a separate noarch (in rpm terms) package which depends on the 2 packages build from a. and b. this is This can then just combine the results from a. and b. into a mixed 32 + 64 bit u-boot-sunxi-with-spl.bin we could call this uboot-images-arm-mixed.noarch.rpm :)

So although not pretty from the Fedora pov I can see ways to work around things and even be able to use "2" in Fedora.

Regards,

Hans

#31 lore raw

cover sunxi: Allwinner A64 SPL support

Hi,

Quoted 32 lines · Hans de Goede

<Adding Peter Robinson to the Cc to see how much he will
object my packaging ideas>

Hi,

First of all cool stuff! Thank you Andre and all others involved for making this happen.

Quoted 18 lines · Alexander Graf
Quoted 11 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit,
this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 4 lines
Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Quoted 7 lines

Later down in the mail Andre says that in 32 bit (thumb) mode the size goes down to 20KB which gives us a lot more head-room then the 32600 out of 32768 bytes available for the 64 bit version.

With that said I agree with you (Alex) that having a 32 bit SPL + 64 bit u-boot proper is worry-some from a distro pov.

What's even nastier is the requirement of a cross compiler even for a native build. Do Fedora and Suse offer packaged cross-compilers for the other ARM bitness, respectively?

Quoted 9 lines

What I would like to see is:

1) Ensure we keep a pure 64 bit build working, which should lead to a fully functional u-boot-sunxi-with-spl.bin just like how things work for current 32 bit boards. This will give distros an easy way to deal with this and is also easier for users who built from source (like people who to the occasional contribution but are not really into u-boot).

Quoted 3 lines

2) Offer the 32 bit option in the do 2 builds, combine 32 bit SPL with 64 bit u-boot proper (and ATF) as Andre is suggesting as an option.

Indeed providing the two options seems like a sensible approach, even with the hacks needed to package it. I will try to bake a joint series so that people can play with it.

Quoted 2 lines

We may need to strip some features from "1" in the future, e.g. no NAND support.

I am afraid that the SPL build is already quite minimal, at least I couldn't find any really useless function in the dump. But lets keep the hope up ;-)

Quoted 16 lines

For distros we could then still opt to use 2, to e.g. get NAND support. One solution I have in mind is:

a) Do a native 32 bit build for the 32 bit SPL, store the SPL somewhere (just like we store u-boot-sunxi-with-spl.bin for end users to dd for other 32 bit boards), on Fedora this build would generate uboot-images-armv7.noarch.rpm (we already put all the generated u-boot-sunxi-with-spl.bin files in this noarch rpm).

b) Do a native 64 bit build which stores both a 64 bit u-boot-sunxi-with-spl.bin as well as just a u-boot.bin (unless we can extract the latter easy enough), on fedora this build would generate uboot-images-armv8.noarch.rpm (as we already do).

Quoted 5 lines

c) Have a separate noarch (in rpm terms) package which depends on the 2 packages build from a. and b. this is This can then just combine the results from a. and b. into a mixed 32 + 64 bit u-boot-sunxi-with-spl.bin we could call this uboot-images-arm-mixed.noarch.rpm :)

Don't forget ATF ;-)

I still wonder why _every_ distribution aims to build the firmware for _every_ board, but I think we had this discussion already. And having an automated way of building it which gets exercised regularly isn't a bad thing, I guess.

Cheers,
Andre.

Quoted 7 lines

So although not pretty from the Fedora pov I can see ways to work around things and even be able to use "2" in Fedora.

Regards,

Hans

#32 lore raw

cover sunxi: Allwinner A64 SPL support

Quoted 37 lines · Andre Przywara

Hi,

Quoted 34 lines · Hans de Goede

<Adding Peter Robinson to the Cc to see how much he will
object my packaging ideas>

Hi,

First of all cool stuff! Thank you Andre and all others involved for making this happen.

Quoted 12 lines · Alexander Graf
Quoted 11 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit,
this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

Quoted 8 lines

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Later down in the mail Andre says that in 32 bit (thumb) mode the size goes down to 20KB which gives us a lot more head-room then the 32600 out of 32768 bytes available for the 64 bit version.

Quoted 5 lines
Quoted 2 lines

With that said I agree with you (Alex) that having a 32 bit SPL + 64 bit u-boot proper is worry-some from a distro pov.

What's even nastier is the requirement of a cross compiler even for a native build. Do Fedora and Suse offer packaged cross-compilers for the other ARM bitness, respectively?

Andreas Faerber was working on cross compilers in openSUSE, but I don't think they're part of the distribution yet.

Alex

#33 lore raw

cover sunxi: Allwinner A64 SPL support

Hi,

Quoted 38 lines · Alexander Graf
Quoted 37 lines · Andre Przywara

Hi,

Quoted 34 lines · Hans de Goede

<Adding Peter Robinson to the Cc to see how much he will
object my packaging ideas>

Hi,

First of all cool stuff! Thank you Andre and all others involved for making this happen.

Quoted 12 lines · Alexander Graf
Quoted 11 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

While it is possible and seems natural to let the SPL also run in 64-bit,
this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

Quoted 8 lines

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Later down in the mail Andre says that in 32 bit (thumb) mode the size goes down to 20KB which gives us a lot more head-room then the 32600 out of 32768 bytes available for the 64 bit version.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

With that said I agree with you (Alex) that having a 32 bit SPL + 64 bit u-boot proper is worry-some from a distro pov.

What's even nastier is the requirement of a cross compiler even for a native build. Do Fedora and Suse offer packaged cross-compilers for the other ARM bitness, respectively?

Andreas Faerber was working on cross compilers in openSUSE, but I don't think they're part of the distribution yet.

Fedora does have cross-compilers (for kernel and u-boot use, no support for userland stuff). But as I outlined in my other mail, with modern rpm you can do a build on all archs (which you want to do anyways to get a native mkimage everywhere) and then use %ifarch armv7hl / %ifarch aarch64 to build u-boot binaries when doing a native build on armv7 / aarch64 and store all the build binaries (one binary per supported board) under /usr/share/u-boot and put /usr/share/u-boot in a noarch sub-pkg, and Fedora's compose tools will then make that noarch sub-pkg from that one specific arch build available in the repos for all archs.

Combine this with an extra noarch package which depends on the noarch u-boot-images rpms generated by both the 32 and 64 bit build and that extra package can generate a combined img ready for dd-ing to a sdcard. If you solve it like this you do not need cross compilation. Yes this is not pretty, but it will work (at least for Fedora, I do not know how Suse's tools deal with noarch sub-packages of a non noarch rpm, rpm itself can handle this, but something needs to copy the generated noarch sub-rpm to the other archs).

Regards,

Hans

#34 lore raw

cover sunxi: Allwinner A64 SPL support

Quoted 64 lines · Hans de Goede

Hi,

Quoted 41 lines · Alexander Graf
Quoted 40 lines · Andre Przywara

Hi,

Quoted 37 lines · Hans de Goede

<Adding Peter Robinson to the Cc to see how much he will
object my packaging ideas>

Hi,

First of all cool stuff! Thank you Andre and all others involved for making this happen.

Quoted 19 lines · Alexander Graf
Quoted 7 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

Quoted 6 lines

While it is possible and seems natural to let the SPL also run in 64-bit,
this creates a really large binary (32600 Bytes in my case). With some
hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards? I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

Quoted 4 lines
Quoted 3 lines

but any addition will probably break it and exceed the 32KB limit that
the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

Later down in the mail Andre says that in 32 bit (thumb) mode the size goes down to 20KB which gives us a lot more head-room then the 32600 out of 32768 bytes available for the 64 bit version.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

With that said I agree with you (Alex) that having a 32 bit SPL + 64 bit u-boot proper is worry-some from a distro pov.

What's even nastier is the requirement of a cross compiler even for a native build. Do Fedora and Suse offer packaged cross-compilers for the other ARM bitness, respectively?

Andreas Faerber was working on cross compilers in openSUSE, but I don't think they're part of the distribution yet.

Fedora does have cross-compilers (for kernel and u-boot use, no support for userland stuff). But as I outlined in my other mail, with modern rpm you can do a build on all archs (which you want to do anyways to get a native mkimage everywhere) and then use %ifarch armv7hl / %ifarch aarch64 to build u-boot binaries when doing a native build on armv7 / aarch64 and store all the build binaries (one binary per supported board) under /usr/share/u-boot and put /usr/share/u-boot in a noarch sub-pkg, and Fedora's compose tools will then make that noarch sub-pkg from that one specific arch build available in the repos for all archs.

Quoted 9 lines

Combine this with an extra noarch package which depends on the noarch u-boot-images rpms generated by both the 32 and 64 bit build and that extra package can generate a combined img ready for dd-ing to a sdcard. If you solve it like this you do not need cross compilation. Yes this is not pretty, but it will work (at least for Fedora, I do not know how Suse's tools deal with noarch sub-packages of a non noarch rpm, rpm itself can handle this, but something needs to copy the generated noarch sub-rpm to the other archs).

Yes, it's possible, but means that we need to build armv7l and aarch64 in the same repository. It also means that we actually *have* to build armv7l at all to compile a pine64 SPL, which I'd rather not want to limit myself to ;).

Alex

#35 lore raw

cover sunxi: Allwinner A64 SPL support

In reply to Alexander Graf

Hi,

Quoted 8 lines · Alexander Graf
Quoted 7 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

Quoted 6 lines
Quoted 3 lines

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards?

Mmmh, interesting idea, may be worth a try alone for the sake of the 64-bit fixes to the SPL code I have done in this process. But I am not sure it doesn't already break for people using just a different compiler. I even started to chop of some bytes here and there to bring the size down (I gained 200 Bytes at the ctype implementation, yeah!)

Quoted 2 lines

I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

I totally agree, even for me it's quite a pain, because a "make clean" (which you need in between) removes the build result of that other bitness, so you always have to remember to copy the binaries first (and then up using stale copies afterwards).

Quoted 4 lines
Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

I spent some time into looking at readelf dumps to find the reason for the bigger size, but nothing really stood out. Still it is a bit odd, since the size ratio for U-Boot proper is much better (like +20% for 64-bit).
A promising approach I then tried was to use -mabi=ilp32, which GCC itself supports for quite a while already. But that was running into ICEs, with no obviously bogus code. If someone more compiler-savvy could take a look later, I'd be grateful.

That being said I will try to revive the AArch64 port tonight and push this somewhere, so that people can have a look.

Cheers,
Andre.

#36 lore raw

cover sunxi: Allwinner A64 SPL support

Hi,

Quoted 36 lines · Andre Przywara

Hi,

Quoted 8 lines · Alexander Graf
Quoted 7 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

Quoted 6 lines
Quoted 3 lines

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards?

Mmmh, interesting idea, may be worth a try alone for the sake of the 64-bit fixes to the SPL code I have done in this process. But I am not sure it doesn't already break for people using just a different compiler. I even started to chop of some bytes here and there to bring the size down (I gained 200 Bytes at the ctype implementation, yeah!)

Quoted 2 lines

I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

I totally agree, even for me it's quite a pain, because a "make clean" (which you need in between) removes the build result of that other bitness, so you always have to remember to copy the binaries first (and then up using stale copies afterwards).

Quoted 3 lines
Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Quoted 6 lines
Quoted 1 line

Do you have some section size comparisons between the two?

I spent some time into looking at readelf dumps to find the reason for the bigger size, but nothing really stood out. Still it is a bit odd, since the size ratio for U-Boot proper is much better (like +20% for 64-bit).

IIRC we build the SPL as thumb2, and u-boot proper as regular armv7, which may explain why the impact on the SPL for going 64 bit is much larger.

Anyways I'm a fan of just going with 64 bits for now + trying to squeeze some bytes of the size left and right too.

Have you looked at the size(s) of the C-string sections? In the past we've had linker bugs where unused C-strings where kept in the final linked binary, and even if you're not hitting that bug then strings may make up for a significant chunk of the size and we could try to make various (error) messages less verbose (or add some CONFIG option to do so) to make things smaller.

Regards,

Hans

Quoted 11 lines

A promising approach I then tried was to use -mabi=ilp32, which GCC itself supports for quite a while already. But that was running into ICEs, with no obviously bogus code. If someone more compiler-savvy could take a look later, I'd be grateful.

That being said I will try to revive the AArch64 port tonight and push this somewhere, so that people can have a look.

Cheers,
Andre.

#37 lore raw

cover sunxi: Allwinner A64 SPL support

In reply to Andre Przywara

Hi,

Quoted 47 lines · Andre Przywara

Hi,

Quoted 8 lines · Alexander Graf
Quoted 7 lines · Andre Przywara

Hi,

this is my first take on the SPL support for the Allwinner A64 SoC. The actual meat - the DRAM initialization code - has been provided by Jens - many thanks for that!
The rest of the patches mostly deal with the 32-bit/64-bit switch.

Quoted 6 lines
Quoted 3 lines

While it is possible and seems natural to let the SPL also run in 64-bit, this creates a really large binary (32600 Bytes in my case). With some hacks (plus some fixes to make the SPL 64-bit safe) I got this to work,

So how about we merge the 64bit version first (since that's *way* easier to compile for everyone) and then consider the move to 32bit afterwards?

Mmmh, interesting idea, may be worth a try alone for the sake of the 64-bit fixes to the SPL code I have done in this process. But I am not sure it doesn't already break for people using just a different compiler. I even started to chop of some bytes here and there to bring the size down (I gained 200 Bytes at the ctype implementation, yeah!)

Quoted 2 lines

I don't even want to start to imagine how to squeeze a 32bit SPL build into the build process for our U-Boot binaries.

I totally agree, even for me it's quite a pain, because a "make clean" (which you need in between) removes the build result of that other bitness, so you always have to remember to copy the binaries first (and then up using stale copies afterwards).

Quoted 4 lines
Quoted 2 lines

but any addition will probably break it and exceed the 32KB limit that the BROM imposes. Debug is the first obvious victim here.

Do you have some section size comparisons between the two?

I spent some time into looking at readelf dumps to find the reason for the bigger size, but nothing really stood out. Still it is a bit odd, since the size ratio for U-Boot proper is much better (like +20% for 64-bit).
A promising approach I then tried was to use -mabi=ilp32, which GCC itself supports for quite a while already. But that was running into ICEs, with no obviously bogus code. If someone more compiler-savvy could take a look later, I'd be grateful.

Quoted 2 lines

That being said I will try to revive the AArch64 port tonight and push this somewhere, so that people can have a look.

Just a quick update: The 64-bit SPL patches were in a worse state than I originally thought and I failed to resurrect them quickly again.

After spending some hours with debugging (the old way via writing to SD cards) I discovered that there is apparently a regression in 2016.11-rc3 over the 2016.09 release with respect to these patches.
So my old 64-bit SPL patches work in the branch which is on top of 2016.09, but break after rebasing them to 2016.11-rc3. I now managed to squash these patches in between the two releases, so I should be able to bisect them later tonight. I keep you posted.

Cheers,
Andre.