Skip to contentSkip to conversation

Add support for Allwinner R329

RFC PATCH In review Icenowy Zheng 3 participants 26 messages Jul 22, 2021 – Nov 6, 2021

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

cover Add support for Allwinner R329

This patchset adds Allwinner R329 support to U-Boot.

First, some code refactors happen for SoCs w/o SCP/MMC2.

Then the basical support for R329 come as several parts (memory map, clocks, pinmux, DRAM, final Kconfig option).

Then, as the RFC part of this patchset, some device tree related changes.

Finally it comes the defconfig file for a R329 board, Sipeed Maix IIA Dock.

This patchset is RFC mainly because of the DT-related part, as no DT binding is mainlined in Linux now (it's still WIP). All other patches are ready for being reviewed and, if proper, merged.

Icenowy Zheng (13):
sunxi: decide the inclusion of SCP by SCP_ADDR existence
sunxi: only include alias for eMMC when mmc2 used
mmc: sunxi: conditionally include MMC2 initialization code
sunxi: add memory addresses for R329 SoC
sunxi: add support for R329 clocks
sunxi: add support for basical pinmux setup on R329
sunxi: add support for R329 DRAM controller
sunxi: add Kconfig option for R329
sunxi: sync R329 CCU binding headers from internal WIP kernel tree
clk: sunxi: add support for R329 in sunxi DM clock driver
mmc: sunxi: add support for R329 MMC controller
sunxi: sync R329 DTs from internal WIP kernel tree
sunxi: add support for Sipeed Maix IIA Dock board

 arch/arm/cpu/armv8/fel_utils.S                |   2 +-
 arch/arm/dts/Makefile                         |   2 +
 arch/arm/dts/sun50i-r329-maix-iia-dock.dts    |  36 ++
 arch/arm/dts/sun50i-r329-maix-iia.dtsi        |  45 +++
 arch/arm/dts/sun50i-r329.dtsi                 | 225 +++++++++++
 arch/arm/dts/sunxi-u-boot.dtsi                |   8 +-
 arch/arm/include/asm/arch-sunxi/boot0.h       |   4 +-
 .../include/asm/arch-sunxi/clock_sun50i_h6.h  |  17 +
 arch/arm/include/asm/arch-sunxi/cpu.h         |   3 +
 .../include/asm/arch-sunxi/cpu_sun50i_r329.h  |  58 +++
 arch/arm/include/asm/arch-sunxi/dram.h        |   2 +
 .../include/asm/arch-sunxi/dram_sun50i_r329.h | 232 +++++++++++
 arch/arm/include/asm/arch-sunxi/gpio.h        |   3 +
 arch/arm/include/asm/arch-sunxi/prcm_sun50i.h |  33 ++
 arch/arm/mach-sunxi/Kconfig                   |  37 +-
 arch/arm/mach-sunxi/Makefile                  |   2 +
 arch/arm/mach-sunxi/board.c                   |   4 +
 arch/arm/mach-sunxi/clock_sun50i_h6.c         |  49 ++-
 arch/arm/mach-sunxi/cpu_info.c                |   2 +
 arch/arm/mach-sunxi/dram_sun50i_r329.c        | 377 ++++++++++++++++++
 arch/arm/mach-sunxi/dram_timings/Makefile     |   1 +
 arch/arm/mach-sunxi/dram_timings/ddr3_r329.c  |  89 +++++
 board/sunxi/MAINTAINERS                       |   5 +
 board/sunxi/board.c                           |  20 +
 common/spl/Kconfig                            |   1 +
 configs/sipeed_maix_iia_dock_defconfig        |   8 +
 drivers/clk/sunxi/Kconfig                     |   7 +
 drivers/clk/sunxi/Makefile                    |   1 +
 drivers/clk/sunxi/clk_r329.c                  |  94 +++++
 drivers/mmc/sunxi_mmc.c                       |   3 +
 include/configs/sunxi-common.h                |   3 +
 include/dt-bindings/clock/sun50i-r329-ccu.h   |  73 ++++
 include/dt-bindings/clock/sun50i-r329-r-ccu.h |  32 ++
 include/dt-bindings/reset/sun50i-r329-ccu.h   |  45 +++
 include/dt-bindings/reset/sun50i-r329-r-ccu.h |  23 ++
 35 files changed, 1535 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia-dock.dts
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia.dtsi
 create mode 100644 arch/arm/dts/sun50i-r329.dtsi
 create mode 100644 arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h
 create mode 100644 arch/arm/include/asm/arch-sunxi/dram_sun50i_r329.h
 create mode 100644 arch/arm/mach-sunxi/dram_sun50i_r329.c
 create mode 100644 arch/arm/mach-sunxi/dram_timings/ddr3_r329.c
 create mode 100644 configs/sipeed_maix_iia_dock_defconfig
 create mode 100644 drivers/clk/sunxi/clk_r329.c
 create mode 100644 include/dt-bindings/clock/sun50i-r329-ccu.h
 create mode 100644 include/dt-bindings/clock/sun50i-r329-r-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-r329-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-r329-r-ccu.h
Signature · 1 line
2.30.2
#1 lore raw

RFC PATCH 1/13 sunxi: decide the inclusion of SCP by SCP_ADDR existence

There are more Allwinner SoCs that do not have a SCP now.

When there's no SCP_ADDR macro defined, we can assume there's no SCP available.

Drop the scp part of FIT description when SCP_ADDR does not exist.

---
 arch/arm/dts/sunxi-u-boot.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +2 -2
index 06da009fa2..4a6ed3a7dd 100644
@@ -64,7 +64,7 @@
 					};
 				};
 
-#ifndef CONFIG_MACH_SUN50I_H616
+#ifdef SCP_ADDR
 				scp {
 					description = "SCP firmware";
 					type = "firmware";
@@ -92,7 +92,7 @@
 				@config-SEQ {
 					description = "NAME";
 					firmware = "atf";
-#ifdef CONFIG_MACH_SUN50I_H616
+#ifndef SCP_ADDR
 					loadables = "uboot";
 #else
 					loadables = "scp", "uboot";
Signature · 1 line
2.30.2
Reviewed-by on v1 1/13
#2 lore raw

Re: [RFC PATCH 01/13] sunxi: decide the inclusion of SCP by SCP_ADDR existence

Quoted 8 lines · On Thu, 22 Jul 2021 14:30:03 +0800 Icenowy Zheng <[email protected]> wrote:

There are more Allwinner SoCs that do not have a SCP now.

When there's no SCP_ADDR macro defined, we can assume there's no SCP available.

Drop the scp part of FIT description when SCP_ADDR does not exist.

I like that one, unless someone screams, I will take ASAP.

Cheers,
Andre

Quoted 26 lines
---
 arch/arm/dts/sunxi-u-boot.dtsi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/dts/sunxi-u-boot.dtsi +2 -2
index 06da009fa2..4a6ed3a7dd 100644
@@ -64,7 +64,7 @@
 					};
 				};
 
-#ifndef CONFIG_MACH_SUN50I_H616
+#ifdef SCP_ADDR
 				scp {
 					description = "SCP firmware";
 					type = "firmware";
@@ -92,7 +92,7 @@
 				@config-SEQ {
 					description = "NAME";
 					firmware = "atf";
-#ifdef CONFIG_MACH_SUN50I_H616
+#ifndef SCP_ADDR
 					loadables = "uboot";
 #else
 					loadables = "scp", "uboot";
#3 lore raw

RFC PATCH 2/13 sunxi: only include alias for eMMC when mmc2 used

In reply to Icenowy Zheng

Some Allwinner SoCs (e.g. R329) doesn't have a MMC2 controller at all, and on boards that we do not utilize MMC2, the alias for it is just useless.

Only include the alias when we specify CONFIG_MMC_SUNXI_EXTRA_SLOT to 2.

---
 arch/arm/dts/sunxi-u-boot.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/dts/sunxi-u-boot.dtsi +2 -0
index 4a6ed3a7dd..b7244c1112 100644
@@ -13,7 +13,9 @@
 / {
 	aliases {
 		mmc0 = &mmc0;
+#if CONFIG_MMC_SUNXI_EXTRA_SLOT == 2
 		mmc1 = &mmc2;
+#endif
 	};
 
 	binman: binman {
Signature · 1 line
2.30.2
Reviewed-by on v1 2/13
#4 lore raw

Re: [RFC PATCH 02/13] sunxi: only include alias for eMMC when mmc2 used

Quoted 7 lines · On Thu, 22 Jul 2021 14:30:04 +0800 Icenowy Zheng <[email protected]> wrote:

Some Allwinner SoCs (e.g. R329) doesn't have a MMC2 controller at all, and on boards that we do not utilize MMC2, the alias for it is just useless.

Only include the alias when we specify CONFIG_MMC_SUNXI_EXTRA_SLOT to 2.

Meh, not a friend of #ifdefs everywhere, but ideally we get rid of this one day anyway, and it's in U-Boot DT "overlay" only, so:

Cheers,
Andre

Quoted 18 lines
---
 arch/arm/dts/sunxi-u-boot.dtsi | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/dts/sunxi-u-boot.dtsi +2 -0
index 4a6ed3a7dd..b7244c1112 100644
@@ -13,7 +13,9 @@
 / {
 	aliases {
 		mmc0 = &mmc0;
+#if CONFIG_MMC_SUNXI_EXTRA_SLOT == 2
 		mmc1 = &mmc2;
+#endif
 	};
 
 	binman: binman {
#5 lore raw

RFC PATCH 3/13 mmc: sunxi: conditionally include MMC2 initialization code

In reply to Icenowy Zheng

Allwinner R329 has no MMC2.

Only include the code of MMC2 if the base address of it is defined.

---
 drivers/mmc/sunxi_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/sunxi_mmc.c +2 -0
index 178b8cf106..6b809c001f 100644
@@ -73,10 +73,12 @@ static int mmc_resource_init(int sdc_no)
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC1_BASE;
 		priv->mclkreg = &ccm->sd1_clk_cfg;
 		break;
+#ifdef SUNXI_MMC2_BASE
 	case 2:
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC2_BASE;
 		priv->mclkreg = &ccm->sd2_clk_cfg;
 		break;
+#endif
 #ifdef SUNXI_MMC3_BASE
 	case 3:
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC3_BASE;
Signature · 1 line
2.30.2
Reviewed-by on v1 3/13
#6 lore raw

Re: [RFC PATCH 03/13] mmc: sunxi: conditionally include MMC2 initialization code

On Thu, 22 Jul 2021 14:30:05 +0800
Icenowy Zheng <[email protected]> wrote:

Hi Icenowy,

Quoted 5 lines

Allwinner R329 has no MMC2.

Only include the code of MMC2 if the base address of it is defined.

One day (TM) we will hopefully get somehow rid of those #ifdefs somehow, but until then it looks OK.

Thanks!
Andre

Quoted 21 lines
---
 drivers/mmc/sunxi_mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/mmc/sunxi_mmc.c +2 -0
index 178b8cf106..6b809c001f 100644
@@ -73,10 +73,12 @@ static int mmc_resource_init(int sdc_no)
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC1_BASE;
 		priv->mclkreg = &ccm->sd1_clk_cfg;
 		break;
+#ifdef SUNXI_MMC2_BASE
 	case 2:
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC2_BASE;
 		priv->mclkreg = &ccm->sd2_clk_cfg;
 		break;
+#endif
 #ifdef SUNXI_MMC3_BASE
 	case 3:
 		priv->reg = (struct sunxi_mmc *)SUNXI_MMC3_BASE;
#7 lore raw

RFC PATCH 4/13 sunxi: add memory addresses for R329 SoC

In reply to Icenowy Zheng

Allwinner R329 SoC has a different memory map with previous post-H6 SoCs.

Add the memory map to a dedicated header file, fill everywhere that uses a hardcoded MMIO address and specify the SPL/ATF load address.

---
 arch/arm/cpu/armv8/fel_utils.S                |  2 +-
 arch/arm/dts/sunxi-u-boot.dtsi                |  2 +
 arch/arm/include/asm/arch-sunxi/boot0.h       |  4 +-
 .../include/asm/arch-sunxi/clock_sun50i_h6.h  | 17 ++++++
 arch/arm/include/asm/arch-sunxi/cpu.h         |  2 +
 .../include/asm/arch-sunxi/cpu_sun50i_r329.h  | 58 +++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/prcm_sun50i.h | 33 +++++++++++
 include/configs/sunxi-common.h                |  3 +
 8 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h
arch/arm/cpu/armv8/fel_utils.S +1 -1
index 7def44ad1d..aa16d79df9 100644
@@ -40,7 +40,7 @@ ENTRY(return_to_fel)
 	str	w2, [x1]
 
 	ldr	x0, =0xfa50392f		// CPU hotplug magic
-#ifdef CONFIG_MACH_SUN50I_H616
+#if defined(CONFIG_MACH_SUN50I_H616) || defined(CONFIG_MACH_SUN50I_R329)
 	ldr	x2, =(SUNXI_R_CPUCFG_BASE + 0x1c0)
 	str	w0, [x2], #0x4
 #elif CONFIG_MACH_SUN50I_H6
arch/arm/dts/sunxi-u-boot.dtsi +2 -0
index b7244c1112..9bb6fffeb4 100644
@@ -5,6 +5,8 @@
 #define  SCP_ADDR 0x114000
 #elif defined(CONFIG_MACH_SUN50I_H616)
 #define BL31_ADDR 0x40000000
+#elif defined(CONFIG_MACH_SUN50I_R329)
+#define BL31_ADDR 0x124000
 #else
 #define BL31_ADDR  0x44000
 #define  SCP_ADDR  0x50000
arch/arm/include/asm/arch-sunxi/boot0.h +3 -1
index e8e8e38f05..a791c7c403 100644
@@ -39,7 +39,9 @@
 	.word	0xf57ff06f	// isb     sy
 	.word	0xe320f003	// wfi
 	.word	0xeafffffd	// b       @wfi
-#ifndef CONFIG_SUN50I_GEN_H6
+#if defined(CONFIG_MACH_SUN50I_R329)
+	.word	0x08100040	// writeable RVBAR mapping address
+#elif !defined(CONFIG_SUN50I_GEN_H6)
 	.word	0x017000a0	// writeable RVBAR mapping address
 #else
 	.word	0x09010040	// writeable RVBAR mapping address
arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +17 -0
index 37df4410ea..6c3b8ea351 100644
@@ -250,10 +250,19 @@ struct sunxi_ccm_reg {
 #define CCM_PLL6_LOCK			BIT(28)
 #define CCM_PLL6_CTRL_N_SHIFT		8
 #define CCM_PLL6_CTRL_N_MASK		(0xff << CCM_PLL6_CTRL_N_SHIFT)
+#ifndef CONFIG_MACH_SUN50I_R329
 #define CCM_PLL6_CTRL_DIV1_SHIFT	0
 #define CCM_PLL6_CTRL_DIV1_MASK		(0x1 << CCM_PLL6_CTRL_DIV1_SHIFT)
 #define CCM_PLL6_CTRL_DIV2_SHIFT	1
 #define CCM_PLL6_CTRL_DIV2_MASK		(0x1 << CCM_PLL6_CTRL_DIV2_SHIFT)
+#else
+#define CCM_PLL6_CTRL_M_SHIFT	1
+#define CCM_PLL6_CTRL_M_MASK		(0x1 << CCM_PLL6_CTRL_DIV2_SHIFT)
+#define CCM_PLL6_CTRL_DIV1_SHIFT	16
+#define CCM_PLL6_CTRL_DIV1_MASK		(0x7 << CCM_PLL6_CTRL_DIV1_SHIFT)
+#define CCM_PLL6_CTRL_DIV2_SHIFT	20
+#define CCM_PLL6_CTRL_DIV2_MASK		(0x7 << CCM_PLL6_CTRL_DIV2_SHIFT)
+#endif
 
 /* cpu_axi bit field*/
 #define CCM_CPU_AXI_MUX_MASK		(0x3 << 24)
@@ -285,6 +294,14 @@ struct sunxi_ccm_reg {
 
 /* apb1 bit field */
 #define CCM_APB1_DEFAULT		0x03000102
+#elif CONFIG_MACH_SUN50I_R329
+#define CCM_PLL6_DEFAULT		0xa8216300
+
+/* ahb bit field */
+#define CCM_PSI_AHB1_AHB2_DEFAULT	0x03000002
+
+/* apb1 bit field */
+#define CCM_APB1_DEFAULT		0x02000001
 #endif
 
 /* apb2 bit field */
arch/arm/include/asm/arch-sunxi/cpu.h +2 -0
index b08f202374..20d04cac74 100644
@@ -8,6 +8,8 @@
 
 #if defined(CONFIG_MACH_SUN9I)
 #include <asm/arch/cpu_sun9i.h>
+#elif defined(CONFIG_MACH_SUN50I_R329)
+#include <asm/arch/cpu_sun50i_r329.h>
 #elif defined(CONFIG_SUN50I_GEN_H6)
 #include <asm/arch/cpu_sun50i_h6.h>
 #else
arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h new file +58 -0

58 lines not on this page · raw message

arch/arm/include/asm/arch-sunxi/prcm_sun50i.h +33 -0
index 5f636e8384..1aba5f0122 100644
@@ -37,8 +37,41 @@ struct sunxi_prcm_reg {
 	u32 w1_gate_reset;	/* 0x1ec */
 	u8 res10[0x1c];		/* 0x1f0 */
 	u32 rtc_gate_reset;	/* 0x20c */
+#ifdef CONFIG_MACH_SUN50I_R329
+	u8 res11[0xdf0];	/* 0x210 */
+
+	u32 pll1_cfg;		/* 0x1000 pll1 (cpux) control */
+	u8 reserved_0x1004[0xc];
+	u32 pll6_cfg;		/* 0x1010 pll6 (periph) control */
+	u8 reserved_0x1014[0xc];
+	u32 pll2_cfg;		/* 0x1020 pll2 (audio) control */
+	u8 reserved_0x1024[0xc];
+	u32 pll_audio1_cfg;	/* 0x1030 pll audio1 control */
+	u8 reserved_0x1034[0xdc];
+	u32 pll6_pat0;		/* 0x1110 pll6 (periph) pattern0 */
+	u32 pll6_pat1;		/* 0x1114 pll6 (periph) pattern1 */
+	u8 reserved_0x1118[0x8];
+	u32 pll2_pat0;		/* 0x1120 pll2 (audio) pattern0 */
+	u32 pll2_pat1;		/* 0x1120 pll2 (audio) pattern1 */
+	u8 reserved_0x1128[0x8];
+	u32 pll_audio1_pat0;	/* 0x1130 pll audio1 pattern0 */
+	u32 pll_audio1_pat1;	/* 0x1130 pll audio1 pattern1 */
+	u8 reserved_0x1138[0x1c8];
+	u32 pll1_bias;		/* 0x1300 pll1 (cpux) bias */
+	u8 reserved_0x1304[0xc];
+	u32 pll6_bias;		/* 0x1310 pll6 (periph) bias */
+	u8 reserved_0x1314[0xc];
+	u32 pll2_bias;		/* 0x1320 pll6 (periph0) bias */
+	u8 reserved_0x1324[0xc];
+	u32 pll_audio1_bias;	/* 0x1330 pll audio1 bias */
+	u8 reserved_0x1334[0xcc];
+	u32 pll1_tun;		/* 0x1400 pll1 (cpux) tunning */
+#endif
 };
 check_member(sunxi_prcm_reg, rtc_gate_reset, 0x20c);
+#ifdef CONFIG_MACH_SUN50I_R329
+check_member(sunxi_prcm_reg, pll1_tun, 0x1400);
+#endif
 
 #define PRCM_TWI_GATE		(1 << 0)
 #define PRCM_TWI_RESET		(1 << 16)
include/configs/sunxi-common.h +3 -0
index 9e37e99684..a114c1addc 100644
@@ -181,6 +181,9 @@
 /* end of SRAM A2 on H6 for now */
 #define LOW_LEVEL_SRAM_STACK		0x00118000
 #endif
+#elif CONFIG_SUNXI_SRAM_ADDRESS == 0x100000
+#define CONFIG_SPL_MAX_SIZE		0x7fa0		/* 32 KiB */
+#define LOW_LEVEL_SRAM_STACK		0x00120000	/* 64 KiB inside SRAM A2 */
 #else
 #define CONFIG_SPL_MAX_SIZE		0x5fa0		/* 24KB on sun4i/sun7i */
 #define LOW_LEVEL_SRAM_STACK		0x00008000	/* End of sram */
Signature · 1 line
2.30.2
maintainer
#8 lore raw

Re: [RFC PATCH 04/13] sunxi: add memory addresses for R329 SoC

Quoted 37 lines · Icenowy Zheng

Allwinner R329 SoC has a different memory map with previous post-H6 SoCs.

Add the memory map to a dedicated header file, fill everywhere that uses a hardcoded MMIO address and specify the SPL/ATF load address.

---
 arch/arm/cpu/armv8/fel_utils.S                |  2 +-
 arch/arm/dts/sunxi-u-boot.dtsi                |  2 +
 arch/arm/include/asm/arch-sunxi/boot0.h       |  4 +-
 .../include/asm/arch-sunxi/clock_sun50i_h6.h  | 17 ++++++
 arch/arm/include/asm/arch-sunxi/cpu.h         |  2 +
 .../include/asm/arch-sunxi/cpu_sun50i_r329.h  | 58 +++++++++++++++++++
 arch/arm/include/asm/arch-sunxi/prcm_sun50i.h | 33 +++++++++++
 include/configs/sunxi-common.h                |  3 +
 8 files changed, 119 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h
arch/arm/cpu/armv8/fel_utils.S +1 -1
index 7def44ad1d..aa16d79df9 100644
@@ -40,7 +40,7 @@ ENTRY(return_to_fel)
 	str	w2, [x1]
 
 	ldr	x0, =0xfa50392f		// CPU hotplug magic
-#ifdef CONFIG_MACH_SUN50I_H616
+#if defined(CONFIG_MACH_SUN50I_H616) || defined(CONFIG_MACH_SUN50I_R329)
 	ldr	x2, =(SUNXI_R_CPUCFG_BASE + 0x1c0)
 	str	w0, [x2], #0x4
 #elif CONFIG_MACH_SUN50I_H6
arch/arm/dts/sunxi-u-boot.dtsi +0 -0
index b7244c1112..9bb6fffeb4 100644

arch/arm/dts/sunxi-u-boot.dtsi line 9

Quoted 5 lines
arch/arm/dts/sunxi-u-boot.dtsi +2 -0
@@ -5,6 +5,8 @@
 #define  SCP_ADDR 0x114000
 #elif defined(CONFIG_MACH_SUN50I_H616)
 #define BL31_ADDR 0x40000000
+#elif defined(CONFIG_MACH_SUN50I_R329)
+#define BL31_ADDR 0x124000

This was changed to 0x00110000 while upstreaming TF-A support. (I see you already updated this in your branch.)

Quoted 24 lines
arch/arm/dts/sunxi-u-boot.dtsi +0 -0
 #else
 #define BL31_ADDR  0x44000
 #define  SCP_ADDR  0x50000
arch/arm/include/asm/arch-sunxi/boot0.h +3 -1
index e8e8e38f05..a791c7c403 100644
@@ -39,7 +39,9 @@
 	.word	0xf57ff06f	// isb     sy
 	.word	0xe320f003	// wfi
 	.word	0xeafffffd	// b       @wfi
-#ifndef CONFIG_SUN50I_GEN_H6
+#if defined(CONFIG_MACH_SUN50I_R329)
+	.word	0x08100040	// writeable RVBAR mapping address
+#elif !defined(CONFIG_SUN50I_GEN_H6)
 	.word	0x017000a0	// writeable RVBAR mapping address
 #else
 	.word	0x09010040	// writeable RVBAR mapping address
arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +0 -0
index 37df4410ea..6c3b8ea351 100644
@@ -250,10 +250,19 @@ struct sunxi_ccm_reg {
 #define CCM_PLL6_LOCK			BIT(28)

arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h struct sunxi_ccm_reg { · line 260

Quoted 10 lines
arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +4 -0
 #define CCM_PLL6_CTRL_N_SHIFT		8
 #define CCM_PLL6_CTRL_N_MASK		(0xff << CCM_PLL6_CTRL_N_SHIFT)
+#ifndef CONFIG_MACH_SUN50I_R329
 #define CCM_PLL6_CTRL_DIV1_SHIFT	0
 #define CCM_PLL6_CTRL_DIV1_MASK		(0x1 << CCM_PLL6_CTRL_DIV1_SHIFT)
 #define CCM_PLL6_CTRL_DIV2_SHIFT	1
 #define CCM_PLL6_CTRL_DIV2_MASK		(0x1 << CCM_PLL6_CTRL_DIV2_SHIFT)
+#else
+#define CCM_PLL6_CTRL_M_SHIFT	1
+#define CCM_PLL6_CTRL_M_MASK		(0x1 << CCM_PLL6_CTRL_DIV2_SHIFT)

This should be using CCM_PLL6_CTRL_M_SHIFT.

Quoted 42 lines
arch/arm/include/asm/arch-sunxi/clock_sun50i_h6.h +13 -0
+#define CCM_PLL6_CTRL_DIV1_SHIFT	16
+#define CCM_PLL6_CTRL_DIV1_MASK		(0x7 << CCM_PLL6_CTRL_DIV1_SHIFT)
+#define CCM_PLL6_CTRL_DIV2_SHIFT	20
+#define CCM_PLL6_CTRL_DIV2_MASK		(0x7 << CCM_PLL6_CTRL_DIV2_SHIFT)
+#endif
 
 /* cpu_axi bit field*/
 #define CCM_CPU_AXI_MUX_MASK		(0x3 << 24)
@@ -285,6 +294,14 @@ struct sunxi_ccm_reg {
 
 /* apb1 bit field */
 #define CCM_APB1_DEFAULT		0x03000102
+#elif CONFIG_MACH_SUN50I_R329
+#define CCM_PLL6_DEFAULT		0xa8216300
+
+/* ahb bit field */
+#define CCM_PSI_AHB1_AHB2_DEFAULT	0x03000002
+
+/* apb1 bit field */
+#define CCM_APB1_DEFAULT		0x02000001
 #endif
 
 /* apb2 bit field */
arch/arm/include/asm/arch-sunxi/cpu.h +2 -0
index b08f202374..20d04cac74 100644
@@ -8,6 +8,8 @@
 
 #if defined(CONFIG_MACH_SUN9I)
 #include <asm/arch/cpu_sun9i.h>
+#elif defined(CONFIG_MACH_SUN50I_R329)
+#include <asm/arch/cpu_sun50i_r329.h>
 #elif defined(CONFIG_SUN50I_GEN_H6)
 #include <asm/arch/cpu_sun50i_h6.h>
 #else
arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h new file +0 -0
new file mode 100644
index 0000000000..3d2237a59f

arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h line 8

Quoted 8 lines
arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h new file +8 -0
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2021 Sipeed
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _SUNXI_CPU_SUN50I_H6_H
+#define _SUNXI_CPU_SUN50I_H6_H

minor: the header guard here does not match (and the comment at the bottom matches even less).

arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h line 11

Quoted 3 lines
arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h new file +3 -0
+
+#define SUNXI_SRAM_A1_BASE		0x00020000
+#define SUNXI_SRAM_A2_BASE		0x00100000

These should probably match the values we used in TF-A, including some similar comment.

Quoted 74 lines
arch/arm/include/asm/arch-sunxi/cpu_sun50i_r329.h new file +47 -0
+
+#define SUNXI_TIMER_BASE		0x02000000
+#define SUNXI_PIO_BASE			0x02000400
+#define SUNXI_CCM_BASE			0x02001000
+
+#define SUNXI_UART0_BASE		0x02500000
+#define SUNXI_UART1_BASE		0x02500400
+#define SUNXI_UART2_BASE		0x02500800
+#define SUNXI_UART3_BASE		0x02500C00
+#define SUNXI_TWI0_BASE			0x02502000
+#define SUNXI_TWI1_BASE			0x02502400
+
+#define SUNXI_SRAMC_BASE		0x03000000
+#define SUNXI_DMA_BASE			0x03002000
+/* SID address space starts at 0x03006000, but e-fuse is at offset 0x200 */
+#define SUNXI_SIDC_BASE			0x03006000
+#define SUNXI_SID_BASE			0x03006200
+
+#define SUNXI_GIC400_BASE		0x03020000
+#define SUNXI_SS_BASE			0x03040000
+#define SUNXI_DRAM_COM_BASE		0x03102000
+#define SUNXI_DRAM_CTL0_BASE		0x03103000
+
+#define SUNXI_NFC_BASE			0x04011000
+#define SUNXI_MMC0_BASE			0x04020000
+#define SUNXI_MMC1_BASE			0x04021000
+#define SUNXI_SPI0_BASE			0x04025000
+#define SUNXI_SPI1_BASE			0x04026000
+#define SUNXI_USB0_BASE			0x04100000
+#define SUNXI_USB1_BASE			0x04201000
+#define SUNXI_GMAC_BASE			0x04500000
+
+#define SUNXI_R_CPUCFG_BASE		0x07000400
+#define SUNXI_PRCM_BASE			0x07010000
+#define SUNXI_R_WDOG_BASE		0x07020400
+#define SUNXI_R_PIO_BASE		0x07022000
+#define SUNXI_R_UART_BASE		0x07080000
+#define SUNXI_R_TWI_BASE		0x07081400
+#define SUNXI_RTC_BASE			0x07090000
+
+#ifndef __ASSEMBLY__
+void sunxi_board_init(void);
+void sunxi_reset(void);
+int sunxi_get_sid(unsigned int *sid);
+#endif
+
+#endif /* _SUNXI_CPU_SUN9I_H */
arch/arm/include/asm/arch-sunxi/prcm_sun50i.h +19 -0
index 5f636e8384..1aba5f0122 100644
@@ -37,8 +37,41 @@ struct sunxi_prcm_reg {
 	u32 w1_gate_reset;	/* 0x1ec */
 	u8 res10[0x1c];		/* 0x1f0 */
 	u32 rtc_gate_reset;	/* 0x20c */
+#ifdef CONFIG_MACH_SUN50I_R329
+	u8 res11[0xdf0];	/* 0x210 */
+
+	u32 pll1_cfg;		/* 0x1000 pll1 (cpux) control */
+	u8 reserved_0x1004[0xc];
+	u32 pll6_cfg;		/* 0x1010 pll6 (periph) control */
+	u8 reserved_0x1014[0xc];
+	u32 pll2_cfg;		/* 0x1020 pll2 (audio) control */
+	u8 reserved_0x1024[0xc];
+	u32 pll_audio1_cfg;	/* 0x1030 pll audio1 control */
+	u8 reserved_0x1034[0xdc];
+	u32 pll6_pat0;		/* 0x1110 pll6 (periph) pattern0 */
+	u32 pll6_pat1;		/* 0x1114 pll6 (periph) pattern1 */
+	u8 reserved_0x1118[0x8];
+	u32 pll2_pat0;		/* 0x1120 pll2 (audio) pattern0 */
+	u32 pll2_pat1;		/* 0x1120 pll2 (audio) pattern1 */
+	u8 reserved_0x1128[0x8];
+	u32 pll_audio1_pat0;	/* 0x1130 pll audio1 pattern0 */
+	u32 pll_audio1_pat1;	/* 0x1130 pll audio1 pattern1 */

arch/arm/include/asm/arch-sunxi/prcm_sun50i.h struct sunxi_prcm_reg { · line 68

Quoted 10 lines
arch/arm/include/asm/arch-sunxi/prcm_sun50i.h +10 -0
+	u8 reserved_0x1138[0x1c8];
+	u32 pll1_bias;		/* 0x1300 pll1 (cpux) bias */
+	u8 reserved_0x1304[0xc];
+	u32 pll6_bias;		/* 0x1310 pll6 (periph) bias */
+	u8 reserved_0x1314[0xc];
+	u32 pll2_bias;		/* 0x1320 pll6 (periph0) bias */
+	u8 reserved_0x1324[0xc];
+	u32 pll_audio1_bias;	/* 0x1330 pll audio1 bias */
+	u8 reserved_0x1334[0xcc];
+	u32 pll1_tun;		/* 0x1400 pll1 (cpux) tunning */

spelling: tuning

Regards,
Samuel

Quoted 24 lines
arch/arm/include/asm/arch-sunxi/prcm_sun50i.h +4 -0
+#endif
 };
 check_member(sunxi_prcm_reg, rtc_gate_reset, 0x20c);
+#ifdef CONFIG_MACH_SUN50I_R329
+check_member(sunxi_prcm_reg, pll1_tun, 0x1400);
+#endif
 
 #define PRCM_TWI_GATE		(1 << 0)
 #define PRCM_TWI_RESET		(1 << 16)
include/configs/sunxi-common.h +3 -0
index 9e37e99684..a114c1addc 100644
@@ -181,6 +181,9 @@
 /* end of SRAM A2 on H6 for now */
 #define LOW_LEVEL_SRAM_STACK		0x00118000
 #endif
+#elif CONFIG_SUNXI_SRAM_ADDRESS == 0x100000
+#define CONFIG_SPL_MAX_SIZE		0x7fa0		/* 32 KiB */
+#define LOW_LEVEL_SRAM_STACK		0x00120000	/* 64 KiB inside SRAM A2 */
 #else
 #define CONFIG_SPL_MAX_SIZE		0x5fa0		/* 24KB on sun4i/sun7i */
 #define LOW_LEVEL_SRAM_STACK		0x00008000	/* End of sram */
#9 lore raw

RFC PATCH 5/13 sunxi: add support for R329 clocks

In reply to Icenowy Zheng

R329 has a quite different clock tree than other SoCs. It has only 4 PLLs and its PLL-PERIPH has two post dividers, one for the normal PLL-PERIPH-2x output and another for a special PLL-PERIPH-800M output. In addition, its PLL configuration registers are in PRCM memory zone, not the ordinary CPUX CCU one.

Add support for basical R329 clock initialization.

---
 arch/arm/mach-sunxi/clock_sun50i_h6.c | 49 ++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 5 deletions(-)
arch/arm/mach-sunxi/clock_sun50i_h6.c +44 -5
index a947463e0a..28bc5fccd8 100644
@@ -9,6 +9,13 @@ void clock_init_safe(void)
 {
 	struct sunxi_ccm_reg *const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN50I_R329
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+	struct sunxi_prcm_reg *const pllccm = prcm;
+#else
+	struct sunxi_ccm_reg *const pllccm = ccm;
+#endif
 
 	/* this seems to enable PLLs on H616 */
 	if (IS_ENABLED(CONFIG_MACH_SUN50I_H616))
@@ -16,22 +23,26 @@ void clock_init_safe(void)
 
 	clock_set_pll1(408000000);
 
-	writel(CCM_PLL6_DEFAULT, &ccm->pll6_cfg);
-	while (!(readl(&ccm->pll6_cfg) & CCM_PLL6_LOCK))
+	writel(CCM_PLL6_DEFAULT, &pllccm->pll6_cfg);
+	while (!(readl(&pllccm->pll6_cfg) & CCM_PLL6_LOCK))
 		;
 
 	clrsetbits_le32(&ccm->cpu_axi_cfg, CCM_CPU_AXI_APB_MASK | CCM_CPU_AXI_AXI_MASK,
 			CCM_CPU_AXI_DEFAULT_FACTORS);
 
 	writel(CCM_PSI_AHB1_AHB2_DEFAULT, &ccm->psi_ahb1_ahb2_cfg);
+#ifdef CCM_AHB3_DEFAULT
 	writel(CCM_AHB3_DEFAULT, &ccm->ahb3_cfg);
+#endif
 	writel(CCM_APB1_DEFAULT, &ccm->apb1_cfg);
 
+#ifndef CONFIG_MACH_SUN50I_R329
 	/*
 	 * The mux and factor are set, but the clock will be enabled in
 	 * DRAM initialization code.
 	 */
 	writel(MBUS_CLK_SRC_PLL6X2 | MBUS_CLK_M(3), &ccm->mbus_cfg);
+#endif
 }
 #endif
 
@@ -60,8 +71,20 @@ void clock_set_pll1(unsigned int clk)
 {
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN50I_R329
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+	struct sunxi_prcm_reg *const pllccm = prcm;
+#else
+	struct sunxi_ccm_reg *const pllccm = ccm;
+#endif
 	u32 val;
 
+#ifdef CONFIG_MACH_SUN50I_R329
+	/* Fix undervoltage reset threshold */
+	clrsetbits_le32(0x070901f4, 0xfff, 0xc0);
+#endif
+
 	/* Do not support clocks < 288MHz as they need factor P */
 	if (clk < 288000000) clk = 288000000;
 
@@ -73,11 +96,11 @@ void clock_set_pll1(unsigned int clk)
 
 	/* clk = 24*n/p, p is ignored if clock is >288MHz */
 	writel(CCM_PLL1_CTRL_EN | CCM_PLL1_LOCK_EN | CCM_PLL1_CLOCK_TIME_2 |
-#ifdef CONFIG_MACH_SUN50I_H616
+#ifndef CONFIG_MACH_SUN50I_H6
 	       CCM_PLL1_OUT_EN |
 #endif
-	       CCM_PLL1_CTRL_N(clk / 24000000), &ccm->pll1_cfg);
-	while (!(readl(&ccm->pll1_cfg) & CCM_PLL1_LOCK)) {}
+	       CCM_PLL1_CTRL_N(clk / 24000000), &pllccm->pll1_cfg);
+	while (!(readl(&pllccm->pll1_cfg) & CCM_PLL1_LOCK)) {}
 
 	/* Switch CPU to PLL1 */
 	val = readl(&ccm->cpu_axi_cfg);
@@ -87,6 +110,7 @@ void clock_set_pll1(unsigned int clk)
 }
 #endif
 
+#ifndef CONFIG_MACH_SUN50I_R329
 unsigned int clock_get_pll6(void)
 {
 	struct sunxi_ccm_reg *const ccm =
@@ -102,6 +126,21 @@ unsigned int clock_get_pll6(void)
 	/* The register defines PLL6-2X or PLL6-4X, not plain PLL6 */
 	return 24000000 / m * n / div1 / div2;
 }
+#else
+unsigned int clock_get_pll6(void)
+{
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+
+	uint32_t rval = readl(&prcm->pll6_cfg);
+	int m = ((rval & CCM_PLL6_CTRL_M_MASK) >> CCM_PLL6_CTRL_M_SHIFT) + 1;
+	int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT) + 1;
+	int div1 = ((rval & CCM_PLL6_CTRL_DIV1_MASK) >>
+			CCM_PLL6_CTRL_DIV1_SHIFT) + 1;
+	/* The register defines PLL6-2X, not plain PLL6 */
+	return 24000000 / m * n / div1 / 2;
+}
+#endif
 
 int clock_twi_onoff(int port, int state)
 {
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 5/13
#10 lore raw

Re: [RFC PATCH 05/13] sunxi: add support for R329 clocks

Quoted 9 lines · Icenowy Zheng

R329 has a quite different clock tree than other SoCs. It has only 4 PLLs and its PLL-PERIPH has two post dividers, one for the normal PLL-PERIPH-2x output and another for a special PLL-PERIPH-800M output. In addition, its PLL configuration registers are in PRCM memory zone, not the ordinary CPUX CCU one.

Add support for basical R329 clock initialization.

One minor comment below.

Quoted 88 lines
---
 arch/arm/mach-sunxi/clock_sun50i_h6.c | 49 ++++++++++++++++++++++++---
 1 file changed, 44 insertions(+), 5 deletions(-)
arch/arm/mach-sunxi/clock_sun50i_h6.c +28 -5
index a947463e0a..28bc5fccd8 100644
@@ -9,6 +9,13 @@ void clock_init_safe(void)
 {
 	struct sunxi_ccm_reg *const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN50I_R329
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+	struct sunxi_prcm_reg *const pllccm = prcm;
+#else
+	struct sunxi_ccm_reg *const pllccm = ccm;
+#endif
 
 	/* this seems to enable PLLs on H616 */
 	if (IS_ENABLED(CONFIG_MACH_SUN50I_H616))
@@ -16,22 +23,26 @@ void clock_init_safe(void)
 
 	clock_set_pll1(408000000);
 
-	writel(CCM_PLL6_DEFAULT, &ccm->pll6_cfg);
-	while (!(readl(&ccm->pll6_cfg) & CCM_PLL6_LOCK))
+	writel(CCM_PLL6_DEFAULT, &pllccm->pll6_cfg);
+	while (!(readl(&pllccm->pll6_cfg) & CCM_PLL6_LOCK))
 		;
 
 	clrsetbits_le32(&ccm->cpu_axi_cfg, CCM_CPU_AXI_APB_MASK | CCM_CPU_AXI_AXI_MASK,
 			CCM_CPU_AXI_DEFAULT_FACTORS);
 
 	writel(CCM_PSI_AHB1_AHB2_DEFAULT, &ccm->psi_ahb1_ahb2_cfg);
+#ifdef CCM_AHB3_DEFAULT
 	writel(CCM_AHB3_DEFAULT, &ccm->ahb3_cfg);
+#endif
 	writel(CCM_APB1_DEFAULT, &ccm->apb1_cfg);
 
+#ifndef CONFIG_MACH_SUN50I_R329
 	/*
 	 * The mux and factor are set, but the clock will be enabled in
 	 * DRAM initialization code.
 	 */
 	writel(MBUS_CLK_SRC_PLL6X2 | MBUS_CLK_M(3), &ccm->mbus_cfg);
+#endif
 }
 #endif
 
@@ -60,8 +71,20 @@ void clock_set_pll1(unsigned int clk)
 {
 	struct sunxi_ccm_reg * const ccm =
 		(struct sunxi_ccm_reg *)SUNXI_CCM_BASE;
+#ifdef CONFIG_MACH_SUN50I_R329
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+	struct sunxi_prcm_reg *const pllccm = prcm;
+#else
+	struct sunxi_ccm_reg *const pllccm = ccm;
+#endif
 	u32 val;
 
+#ifdef CONFIG_MACH_SUN50I_R329
+	/* Fix undervoltage reset threshold */
+	clrsetbits_le32(0x070901f4, 0xfff, 0xc0);
+#endif
+
 	/* Do not support clocks < 288MHz as they need factor P */
 	if (clk < 288000000) clk = 288000000;
 
@@ -73,11 +96,11 @@ void clock_set_pll1(unsigned int clk)
 
 	/* clk = 24*n/p, p is ignored if clock is >288MHz */
 	writel(CCM_PLL1_CTRL_EN | CCM_PLL1_LOCK_EN | CCM_PLL1_CLOCK_TIME_2 |
-#ifdef CONFIG_MACH_SUN50I_H616
+#ifndef CONFIG_MACH_SUN50I_H6
 	       CCM_PLL1_OUT_EN |
 #endif
-	       CCM_PLL1_CTRL_N(clk / 24000000), &ccm->pll1_cfg);
-	while (!(readl(&ccm->pll1_cfg) & CCM_PLL1_LOCK)) {}
+	       CCM_PLL1_CTRL_N(clk / 24000000), &pllccm->pll1_cfg);
+	while (!(readl(&pllccm->pll1_cfg) & CCM_PLL1_LOCK)) {}
 
 	/* Switch CPU to PLL1 */
 	val = readl(&ccm->cpu_axi_cfg);

arch/arm/mach-sunxi/clock_sun50i_h6.c void clock_set_pll1(unsigned int clk) · line 113

Quoted 4 lines
arch/arm/mach-sunxi/clock_sun50i_h6.c +1 -0
@@ -87,6 +110,7 @@ void clock_set_pll1(unsigned int clk)
 }
 #endif
 
+#ifndef CONFIG_MACH_SUN50I_R329

The negative condition here will make it messier to add more branches in the future, so I suggest flipping the conditional block.

Quoted 26 lines
arch/arm/mach-sunxi/clock_sun50i_h6.c +15 -0
 unsigned int clock_get_pll6(void)
 {
 	struct sunxi_ccm_reg *const ccm =
@@ -102,6 +126,21 @@ unsigned int clock_get_pll6(void)
 	/* The register defines PLL6-2X or PLL6-4X, not plain PLL6 */
 	return 24000000 / m * n / div1 / div2;
 }
+#else
+unsigned int clock_get_pll6(void)
+{
+	struct sunxi_prcm_reg *const prcm =
+		(struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
+
+	uint32_t rval = readl(&prcm->pll6_cfg);
+	int m = ((rval & CCM_PLL6_CTRL_M_MASK) >> CCM_PLL6_CTRL_M_SHIFT) + 1;
+	int n = ((rval & CCM_PLL6_CTRL_N_MASK) >> CCM_PLL6_CTRL_N_SHIFT) + 1;
+	int div1 = ((rval & CCM_PLL6_CTRL_DIV1_MASK) >>
+			CCM_PLL6_CTRL_DIV1_SHIFT) + 1;
+	/* The register defines PLL6-2X, not plain PLL6 */
+	return 24000000 / m * n / div1 / 2;
+}
+#endif
 
 int clock_twi_onoff(int port, int state)
 {
#11 lore raw

RFC PATCH 6/13 sunxi: add support for basical pinmux setup on R329

In reply to Icenowy Zheng

Allwinner R329 SoC is the first known Allwinner SoC that has two possible pinmux setups for MMC0 controller.

Support configuration of both setups of MMC0 and UART0 at PB4/5.

---
 arch/arm/include/asm/arch-sunxi/gpio.h |  3 +++
 arch/arm/mach-sunxi/Kconfig            |  7 +++++++
 arch/arm/mach-sunxi/board.c            |  4 ++++
 board/sunxi/board.c                    | 20 ++++++++++++++++++++
 4 files changed, 34 insertions(+)
arch/arm/include/asm/arch-sunxi/gpio.h +3 -0
index 2969a530ae..da9acfab78 100644
@@ -166,12 +166,14 @@ enum sunxi_gpio_number {
 #define SUN8I_A83T_GPB_UART0	2
 #define SUN8I_V3S_GPB_UART0	3
 #define SUN50I_GPB_UART0	4
+#define SUN50I_R329_GPB_UART0	2
 
 #define SUNXI_GPC_NAND		2
 #define SUNXI_GPC_SPI0		3
 #define SUNXI_GPC_SDC2		3
 #define SUN6I_GPC_SDC3		4
 #define SUN50I_GPC_SPI0		4
+#define SUN50I_R329_GPC_SDC0	3
 
 #define SUN8I_GPD_SDC1		3
 #define SUNXI_GPD_LCD0		2
@@ -185,6 +187,7 @@ enum sunxi_gpio_number {
 #define SUNXI_GPF_SDC0		2
 #define SUNXI_GPF_UART0		4
 #define SUN8I_GPF_UART0		3
+#define SUN50I_R329_GPF_SDC0	5
 
 #define SUN4I_GPG_SDC1		4
 #define SUN5I_GPG_SDC1		2
arch/arm/mach-sunxi/Kconfig +7 -0
index 49f94f095c..391a3dd9e5 100644
@@ -672,6 +672,13 @@ config MMC3_CD_PIN
 	---help---
 	See MMC0_CD_PIN help text.
 
+config MMC0_PINS
+	string "Pins for mmc0"
+	default "PF"
+	depends on MACH_SUN50I_R329
+	---help---
+	See MMC1_PINS help text.
+
 config MMC1_PINS
 	string "Pins for mmc1"
 	default ""
arch/arm/mach-sunxi/board.c +4 -0
index e979e426dd..1aa31c7e05 100644
@@ -129,6 +129,10 @@ static int gpio_init(void)
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(0), SUN50I_H616_GPH_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(1), SUN50I_H616_GPH_UART0);
 	sunxi_gpio_set_pull(SUNXI_GPH(1), SUNXI_GPIO_PULL_UP);
+#elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_MACH_SUN50I_R329)
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(4), SUN50I_R329_GPB_UART0);
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(5), SUN50I_R329_GPB_UART0);
+	sunxi_gpio_set_pull(SUNXI_GPB(5), SUNXI_GPIO_PULL_UP);
 #elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_MACH_SUN8I_A83T)
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(9), SUN8I_A83T_GPB_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(10), SUN8I_A83T_GPB_UART0);
board/sunxi/board.c +20 -0
index 67acc01d83..bfc90345d9 100644
@@ -417,12 +417,32 @@ static void mmc_pinmux_setup(int sdc)
 
 	switch (sdc) {
 	case 0:
+#if defined(CONFIG_MACH_SUN50I_R329)
+		pins = sunxi_name_to_gpio_bank(CONFIG_MMC0_PINS);
+
+		if (pins == SUNXI_GPIO_C) {
+			/* SDC0: PC0-PC6 */
+			for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(6); pin++) {
+				sunxi_gpio_set_cfgpin(pin, SUN50I_R329_GPC_SDC0);
+				sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+				sunxi_gpio_set_drv(pin, 2);
+			}
+		} else {
+			/* SDC0: PF0-PF5 */
+			for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
+				sunxi_gpio_set_cfgpin(pin, SUN50I_R329_GPF_SDC0);
+				sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+				sunxi_gpio_set_drv(pin, 2);
+			}
+		}
+#else
 		/* SDC0: PF0-PF5 */
 		for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
 			sunxi_gpio_set_cfgpin(pin, SUNXI_GPF_SDC0);
 			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
 			sunxi_gpio_set_drv(pin, 2);
 		}
+#endif
 		break;
 
 	case 1:
Signature · 1 line
2.30.2
maintainer
#12 lore raw

Re: [RFC PATCH 06/13] sunxi: add support for basical pinmux setup on R329

Quoted 45 lines · Icenowy Zheng

Allwinner R329 SoC is the first known Allwinner SoC that has two possible pinmux setups for MMC0 controller.

Support configuration of both setups of MMC0 and UART0 at PB4/5.

---
 arch/arm/include/asm/arch-sunxi/gpio.h |  3 +++
 arch/arm/mach-sunxi/Kconfig            |  7 +++++++
 arch/arm/mach-sunxi/board.c            |  4 ++++
 board/sunxi/board.c                    | 20 ++++++++++++++++++++
 4 files changed, 34 insertions(+)
arch/arm/include/asm/arch-sunxi/gpio.h +3 -0
index 2969a530ae..da9acfab78 100644
@@ -166,12 +166,14 @@ enum sunxi_gpio_number {
 #define SUN8I_A83T_GPB_UART0	2
 #define SUN8I_V3S_GPB_UART0	3
 #define SUN50I_GPB_UART0	4
+#define SUN50I_R329_GPB_UART0	2
 
 #define SUNXI_GPC_NAND		2
 #define SUNXI_GPC_SPI0		3
 #define SUNXI_GPC_SDC2		3
 #define SUN6I_GPC_SDC3		4
 #define SUN50I_GPC_SPI0		4
+#define SUN50I_R329_GPC_SDC0	3
 
 #define SUN8I_GPD_SDC1		3
 #define SUNXI_GPD_LCD0		2
@@ -185,6 +187,7 @@ enum sunxi_gpio_number {
 #define SUNXI_GPF_SDC0		2
 #define SUNXI_GPF_UART0		4
 #define SUN8I_GPF_UART0		3
+#define SUN50I_R329_GPF_SDC0	5
 
 #define SUN4I_GPG_SDC1		4
 #define SUN5I_GPG_SDC1		2
arch/arm/mach-sunxi/Kconfig +0 -0
index 49f94f095c..391a3dd9e5 100644

arch/arm/mach-sunxi/Kconfig config MMC3_CD_PIN · line 681

Quoted 10 lines
arch/arm/mach-sunxi/Kconfig +7 -0
@@ -672,6 +672,13 @@ config MMC3_CD_PIN
 	---help---
 	See MMC0_CD_PIN help text.
 
+config MMC0_PINS
+	string "Pins for mmc0"
+	default "PF"
+	depends on MACH_SUN50I_R329
+	---help---
+	See MMC1_PINS help text.
+

Please make this a Boolean MMC0_PINS_PC (this area was changed since you sent these patches).

Quoted 23 lines
arch/arm/mach-sunxi/Kconfig +0 -0
 config MMC1_PINS
 	string "Pins for mmc1"
 	default ""
arch/arm/mach-sunxi/board.c +4 -0
index e979e426dd..1aa31c7e05 100644
@@ -129,6 +129,10 @@ static int gpio_init(void)
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(0), SUN50I_H616_GPH_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPH(1), SUN50I_H616_GPH_UART0);
 	sunxi_gpio_set_pull(SUNXI_GPH(1), SUNXI_GPIO_PULL_UP);
+#elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_MACH_SUN50I_R329)
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(4), SUN50I_R329_GPB_UART0);
+	sunxi_gpio_set_cfgpin(SUNXI_GPB(5), SUN50I_R329_GPB_UART0);
+	sunxi_gpio_set_pull(SUNXI_GPB(5), SUNXI_GPIO_PULL_UP);
 #elif CONFIG_CONS_INDEX == 1 && defined(CONFIG_MACH_SUN8I_A83T)
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(9), SUN8I_A83T_GPB_UART0);
 	sunxi_gpio_set_cfgpin(SUNXI_GPB(10), SUN8I_A83T_GPB_UART0);
board/sunxi/board.c +0 -0
index 67acc01d83..bfc90345d9 100644

board/sunxi/board.c static void mmc_pinmux_setup(int sdc) · line 420

Quoted 4 lines
board/sunxi/board.c +1 -0
@@ -417,12 +417,32 @@ static void mmc_pinmux_setup(int sdc)
 
 	switch (sdc) {
 	case 0:
+#if defined(CONFIG_MACH_SUN50I_R329)

Please use if (IS_ENABLED(...)).

Regards,
Samuel

Quoted 29 lines
board/sunxi/board.c +19 -0
+		pins = sunxi_name_to_gpio_bank(CONFIG_MMC0_PINS);
+
+		if (pins == SUNXI_GPIO_C) {
+			/* SDC0: PC0-PC6 */
+			for (pin = SUNXI_GPC(0); pin <= SUNXI_GPC(6); pin++) {
+				sunxi_gpio_set_cfgpin(pin, SUN50I_R329_GPC_SDC0);
+				sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+				sunxi_gpio_set_drv(pin, 2);
+			}
+		} else {
+			/* SDC0: PF0-PF5 */
+			for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
+				sunxi_gpio_set_cfgpin(pin, SUN50I_R329_GPF_SDC0);
+				sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
+				sunxi_gpio_set_drv(pin, 2);
+			}
+		}
+#else
 		/* SDC0: PF0-PF5 */
 		for (pin = SUNXI_GPF(0); pin <= SUNXI_GPF(5); pin++) {
 			sunxi_gpio_set_cfgpin(pin, SUNXI_GPF_SDC0);
 			sunxi_gpio_set_pull(pin, SUNXI_GPIO_PULL_UP);
 			sunxi_gpio_set_drv(pin, 2);
 		}
+#endif
 		break;
 
 	case 1:
#13 lore raw

RFC PATCH 7/13 sunxi: add support for R329 DRAM controller

In reply to Icenowy Zheng

R329 has a new DRAM controller, which looks like a combination of the H6/H616 MCTL_COM part and the SUNXI_DW MCTL_CTL part. This design has already got reused by Allwinner, and V831/V833 SoCs have similar memory controller.

Add support for it. To prepare for further support of other SoCs, routines with socid parameter are added, although not checked now.

---
 arch/arm/include/asm/arch-sunxi/cpu.h         |   1 +
 arch/arm/include/asm/arch-sunxi/dram.h        |   2 +
 .../include/asm/arch-sunxi/dram_sun50i_r329.h | 232 +++++++++++
 arch/arm/mach-sunxi/Kconfig                   |  16 +-
 arch/arm/mach-sunxi/Makefile                  |   2 +
 arch/arm/mach-sunxi/dram_sun50i_r329.c        | 377 ++++++++++++++++++
 arch/arm/mach-sunxi/dram_timings/Makefile     |   1 +
 arch/arm/mach-sunxi/dram_timings/ddr3_r329.c  |  89 +++++
 8 files changed, 719 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/include/asm/arch-sunxi/dram_sun50i_r329.h
 create mode 100644 arch/arm/mach-sunxi/dram_sun50i_r329.c
 create mode 100644 arch/arm/mach-sunxi/dram_timings/ddr3_r329.c
arch/arm/include/asm/arch-sunxi/cpu.h +1 -0
index 20d04cac74..a968af6012 100644
@@ -21,5 +21,6 @@
 #define SOCID_V3S	0x1681
 #define SOCID_H5	0x1718
 #define SOCID_R40	0x1701
+#define SOCID_R329	0x1851
 
 #endif /* _SUNXI_CPU_H */
arch/arm/include/asm/arch-sunxi/dram.h +2 -0
index c3b3e1f512..36549a47c5 100644
@@ -31,6 +31,8 @@
 #include <asm/arch/dram_sun50i_h6.h>
 #elif defined(CONFIG_MACH_SUN50I_H616)
 #include <asm/arch/dram_sun50i_h616.h>
+#elif defined(CONFIG_MACH_SUN50I_R329)
+#include <asm/arch/dram_sun50i_r329.h>
 #else
 #include <asm/arch/dram_sun4i.h>
 #endif
arch/arm/include/asm/arch-sunxi/dram_sun50i_r329.h new file +232 -0

232 lines not on this page · raw message

arch/arm/mach-sunxi/Kconfig +15 -1
index 391a3dd9e5..c9bb47a8bd 100644
@@ -54,6 +54,12 @@ config DRAM_SUN50I_H616
 	  Select this dram controller driver for some sun50i platforms,
 	  like H616.
 
+config DRAM_SUN50I_R329
+	bool
+	help
+	  Select this dram controller driver for some sun50i platforms,
+	  like R329.
+
 if DRAM_SUN50I_H616
 config DRAM_SUN50I_H616_WRITE_LEVELING
 	bool "H616 DRAM write leveling"
@@ -402,7 +408,7 @@ config ARM_BOOT_HOOK_RMR
 	This allows both the SPL and the U-Boot proper to be entered in
 	either mode and switch to AArch64 if needed.
 
-if SUNXI_DRAM_DW || DRAM_SUN50I_H6
+if SUNXI_DRAM_DW || DRAM_SUN50I_H6 || DRAM_SUN50I_R329
 config SUNXI_DRAM_DDR3
 	bool
 
@@ -424,6 +430,14 @@ config SUNXI_DRAM_DDR3_1333
 	This option is the original only supported memory type, which suits
 	many H3/H5/A64 boards available now.
 
+config SUNXI_DRAM_DDR3_R329
+	bool "DDR3 found in R329 chip"
+	select SUNXI_DRAM_DDR3
+	depends on DRAM_SUN50I_R329
+	---help---
+	This option is only for the DDR3 memory chip which is co-packaged in
+	Allwinner R329 SoC.
+
 config SUNXI_DRAM_LPDDR3_STOCK
 	bool "LPDDR3 with Allwinner stock configuration"
 	select SUNXI_DRAM_LPDDR3
arch/arm/mach-sunxi/Makefile +2 -0
index 3f081d92f3..f90393cbbc 100644
@@ -42,4 +42,6 @@ obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_sun50i_h6.o
 obj-$(CONFIG_DRAM_SUN50I_H6)	+= dram_timings/
 obj-$(CONFIG_DRAM_SUN50I_H616)	+= dram_sun50i_h616.o
 obj-$(CONFIG_DRAM_SUN50I_H616)	+= dram_timings/
+obj-$(CONFIG_DRAM_SUN50I_R329)	+= dram_sun50i_r329.o
+obj-$(CONFIG_DRAM_SUN50I_R329)	+= dram_timings/
 endif
arch/arm/mach-sunxi/dram_sun50i_r329.c new file +377 -0

377 lines not on this page · raw message

arch/arm/mach-sunxi/dram_timings/Makefile +1 -0
index 39a8756c29..32d5f15c61 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_SUNXI_DRAM_DDR3_1333)	+= ddr3_1333.o
+obj-$(CONFIG_SUNXI_DRAM_DDR3_R329)	+= ddr3_r329.o
 obj-$(CONFIG_SUNXI_DRAM_LPDDR3_STOCK)	+= lpddr3_stock.o
 obj-$(CONFIG_SUNXI_DRAM_DDR2_V3S)	+= ddr2_v3s.o
 obj-$(CONFIG_SUNXI_DRAM_H6_LPDDR3)	+= h6_lpddr3.o
arch/arm/mach-sunxi/dram_timings/ddr3_r329.c new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
2.30.2
maintainer Tested-by on v1 7/13
#14 lore raw

Re: [RFC PATCH 07/13] sunxi: add support for R329 DRAM controller

Quoted 9 lines · Icenowy Zheng

R329 has a new DRAM controller, which looks like a combination of the H6/H616 MCTL_COM part and the SUNXI_DW MCTL_CTL part. This design has already got reused by Allwinner, and V831/V833 SoCs have similar memory controller.

Add support for it. To prepare for further support of other SoCs, routines with socid parameter are added, although not checked now.

I cannot really review the DRAM init part. But it works, so that's probably good enough.

There are a couple of magic values I happen to have an explanation for:

Quoted 16 lines
arch/arm/mach-sunxi/dram_sun50i_r329.c new file +0 -0
new file mode 100644
index 0000000000..730883999c

...> +unsigned long sunxi_dram_init(void)

arch/arm/mach-sunxi/dram_sun50i_r329.c new file +10 -0
+{
+	struct sunxi_mctl_com_reg * const mctl_com =
+			(struct sunxi_mctl_com_reg *)SUNXI_DRAM_COM_BASE;
+	struct sunxi_mctl_ctl_reg * const mctl_ctl =
+			(struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE;
+
+	struct dram_para para = {
+		.dual_rank = 0,
+		.bus_full_width = 1,
+		.row_bits = 16,

arch/arm/mach-sunxi/dram_sun50i_r329.c line 341

Quoted 10 lines
arch/arm/mach-sunxi/dram_sun50i_r329.c new file +10 -0
+		.bank_bits = 3,
+		.page_size = 8192,
+
+		.dx_read_delays  = SUN50I_R329_DX_READ_DELAYS,
+		.dx_write_delays = SUN50I_R329_DX_WRITE_DELAYS,
+		.ac_delays	 = SUN50I_R329_AC_DELAYS,
+	};
+
+	/* Unknown magic */
+	writel(0x10, 0x07010250);

This is VDD_SYS_POWEROFF_GATING_REG, presumably disabling pad hold.

arch/arm/mach-sunxi/dram_sun50i_r329.c line 343

Quoted 2 lines
arch/arm/mach-sunxi/dram_sun50i_r329.c new file +2 -0
+	writel(0x330000, 0x07010310);
+	writel(0x330003, 0x07010310);

This is a resistor calibration process. See here:

https://github.com/smaeul/sun20i_d1_spl/blob/342cb1d8/include/arch/cpu_ncat.h#L172
https://github.com/smaeul/sun20i_d1_spl/blob/342cb1d8/board/sun20iw1p1/clock.c#L186

Some other BSP code has:

#define REG_CALIB_CONTROL_REG           0x0310
#define OHMS200_REG                     0x0314
#define OHMS240_REG                     0x0318
#define REG_CALIB_STATUS_REG            0x031c

So this suggests we are calibrating the termination resistors.

Regards,
Samuel

Quoted 34 lines
arch/arm/mach-sunxi/dram_sun50i_r329.c new file +34 -0
+
+#if defined(CONFIG_MACH_SUN50I_R329)
+	uint16_t socid = SOCID_R329;
+#endif
+
+	mctl_sys_init(&para);
+	if (mctl_channel_init(socid, &para))
+		return 0;
+
+	udelay(1);
+
+	clrbits_le32(&mctl_ctl->unk_0x0a0, 0xffff);
+	clrbits_le32(&mctl_ctl->pwrctl, 0x1);
+
+	/* HDR/DDR dynamic mode */
+	clrbits_le32(&mctl_ctl->pgcr[0], 0xf000);
+
+	/* power down zq calibration module for power save */
+	setbits_le32(&mctl_ctl->zqcr, ZQCR_PWRDOWN);
+
+	/* DQ hold disable (tpr13[26] == 1) */
+	clrbits_le32(&mctl_ctl->pgcr[2], (1 << 13));
+
+	mctl_auto_detect_dram_size(&para);
+	mctl_apply_para(&para);
+
+	/* enable master access */
+	writel(0xffffffff, &mctl_com->maer0);
+	writel(0x7f, &mctl_com->maer1);
+	writel(0xffff, &mctl_com->maer2);
+
+	return (1UL << (para.row_bits + para.bank_bits)) * para.page_size *
+	       (para.dual_rank ? 2 : 1);
+}
#15 lore raw

RFC PATCH 8/13 sunxi: add Kconfig option for R329

In reply to Icenowy Zheng

As most code are ready for basic R329 support, let's add a Kconfig option for it.

---
 arch/arm/mach-sunxi/Kconfig    | 14 +++++++++++++-
 arch/arm/mach-sunxi/cpu_info.c |  2 ++
 common/spl/Kconfig             |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/Kconfig +13 -1
index c9bb47a8bd..9d3ec82497 100644
@@ -128,6 +128,7 @@ config SUN8I_RSB
 config SUNXI_SRAM_ADDRESS
 	hex
 	default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
+	default 0x100000 if MACH_SUN50I_R329
 	default 0x20000 if SUN50I_GEN_H6
 	default 0x0
 	---help---
@@ -371,6 +372,12 @@ config MACH_SUN50I_H616
 	select DRAM_SUN50I_H616
 	select SUN50I_GEN_H6
 
+config MACH_SUN50I_R329
+	bool "sun50i (Allwinner R329)"
+	select ARM64
+	select DRAM_SUN50I_R329
+	select SUN50I_GEN_H6
+
 endchoice
 
 # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
@@ -420,7 +427,8 @@ config SUNXI_DRAM_LPDDR3
 
 choice
 	prompt "DRAM Type and Timing"
-	default SUNXI_DRAM_DDR3_1333 if !MACH_SUN8I_V3S
+	default SUNXI_DRAM_DDR3_1333 if !MACH_SUN8I_V3S && !MACH_SUN50I_R329
+	default SUNXI_DRAM_DDR3_R329 if MACH_SUN50I_R329
 	default SUNXI_DRAM_DDR2_V3S if MACH_SUN8I_V3S
 
 config SUNXI_DRAM_DDR3_1333
@@ -488,6 +496,7 @@ config DRAM_CLK
 		       MACH_SUN8I_V3S
 	default 672 if MACH_SUN50I
 	default 744 if MACH_SUN50I_H6
+	default 775 if MACH_SUN50I_R329
 	default 720 if MACH_SUN50I_H616
 	---help---
 	Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
@@ -510,6 +519,7 @@ config DRAM_ZQ
 		       MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_A83T
 	default 127 if MACH_SUN7I
 	default 14779 if MACH_SUN8I_V3S
+	default 3067 if MACH_SUN50I_R329
 	default 3881979 if MACH_SUNXI_H3_H5 || MACH_SUN8I_R40 || MACH_SUN50I_H6
 	default 4145117 if MACH_SUN9I
 	default 3881915 if MACH_SUN50I
@@ -616,6 +626,7 @@ config SYS_CLK_FREQ
 	default 1008000000 if MACH_SUN9I
 	default 888000000 if MACH_SUN50I_H6
 	default 1008000000 if MACH_SUN50I_H616
+	default 1008000000 if MACH_SUN50I_R329
 
 config SYS_CONFIG_NAME
 	default "sun4i" if MACH_SUN4I
@@ -627,6 +638,7 @@ config SYS_CONFIG_NAME
 	default "sun50i" if MACH_SUN50I
 	default "sun50i" if MACH_SUN50I_H6
 	default "sun50i" if MACH_SUN50I_H616
+	default "sun50i" if MACH_SUN50I_R329
 
 config SYS_BOARD
 	default "sunxi"
arch/arm/mach-sunxi/cpu_info.c +2 -0
index ba33ef2430..8021f4c307 100644
@@ -101,6 +101,8 @@ int print_cpuinfo(void)
 	puts("CPU:   Allwinner H6 (SUN50I)\n");
 #elif defined CONFIG_MACH_SUN50I_H616
 	puts("CPU:   Allwinner H616 (SUN50I)\n");
+#elif defined CONFIG_MACH_SUN50I_R329
+	puts("CPU:   Allwinner R329 (SUN50I)\n");
 #else
 #warning Please update cpu_info.c with correct CPU information
 	puts("CPU:   SUNXI Family\n");
common/spl/Kconfig +1 -0
index 2df3e5d869..ed4477ff93 100644
@@ -150,6 +150,7 @@ config SPL_TEXT_BASE
 	hex "SPL Text Base"
 	default ISW_ENTRY_ADDR if AM43XX || AM33XX || OMAP54XX || ARCH_KEYSTONE
 	default 0x10060 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN9I
+	default 0x100060 if MACH_SUN50I_R329
 	default 0x20060 if SUN50I_GEN_H6
 	default 0x00060 if ARCH_SUNXI
 	default 0xfffc0000 if ARCH_ZYNQMP
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 8/13
#16 lore raw

Re: [RFC PATCH 08/13] sunxi: add Kconfig option for R329

Quoted 4 lines · Icenowy Zheng

As most code are ready for basic R329 support, let's add a Kconfig option for it.

with one minor comment below.

Quoted 32 lines
---
 arch/arm/mach-sunxi/Kconfig    | 14 +++++++++++++-
 arch/arm/mach-sunxi/cpu_info.c |  2 ++
 common/spl/Kconfig             |  1 +
 3 files changed, 16 insertions(+), 1 deletion(-)
arch/arm/mach-sunxi/Kconfig +7 -0
index c9bb47a8bd..9d3ec82497 100644
@@ -128,6 +128,7 @@ config SUN8I_RSB
 config SUNXI_SRAM_ADDRESS
 	hex
 	default 0x10000 if MACH_SUN9I || MACH_SUN50I || MACH_SUN50I_H5
+	default 0x100000 if MACH_SUN50I_R329
 	default 0x20000 if SUN50I_GEN_H6
 	default 0x0
 	---help---
@@ -371,6 +372,12 @@ config MACH_SUN50I_H616
 	select DRAM_SUN50I_H616
 	select SUN50I_GEN_H6
 
+config MACH_SUN50I_R329
+	bool "sun50i (Allwinner R329)"
+	select ARM64
+	select DRAM_SUN50I_R329
+	select SUN50I_GEN_H6
+
 endchoice
 
 # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"

arch/arm/mach-sunxi/Kconfig config SUNXI_DRAM_LPDDR3 · line 432

Quoted 7 lines
arch/arm/mach-sunxi/Kconfig +2 -1
@@ -420,7 +427,8 @@ config SUNXI_DRAM_LPDDR3
 
 choice
 	prompt "DRAM Type and Timing"
-	default SUNXI_DRAM_DDR3_1333 if !MACH_SUN8I_V3S
+	default SUNXI_DRAM_DDR3_1333 if !MACH_SUN8I_V3S && !MACH_SUN50I_R329
+	default SUNXI_DRAM_DDR3_R329 if MACH_SUN50I_R329
 	default SUNXI_DRAM_DDR2_V3S if MACH_SUN8I_V3S

The first matching line is used, so you can reorder these to remove the negations.

Regards,
Samuel

Quoted 60 lines
arch/arm/mach-sunxi/Kconfig +4 -0
 config SUNXI_DRAM_DDR3_1333
@@ -488,6 +496,7 @@ config DRAM_CLK
 		       MACH_SUN8I_V3S
 	default 672 if MACH_SUN50I
 	default 744 if MACH_SUN50I_H6
+	default 775 if MACH_SUN50I_R329
 	default 720 if MACH_SUN50I_H616
 	---help---
 	Set the dram clock speed, valid range 240 - 480 (prior to sun9i),
@@ -510,6 +519,7 @@ config DRAM_ZQ
 		       MACH_SUN8I_A23 || MACH_SUN8I_A33 || MACH_SUN8I_A83T
 	default 127 if MACH_SUN7I
 	default 14779 if MACH_SUN8I_V3S
+	default 3067 if MACH_SUN50I_R329
 	default 3881979 if MACH_SUNXI_H3_H5 || MACH_SUN8I_R40 || MACH_SUN50I_H6
 	default 4145117 if MACH_SUN9I
 	default 3881915 if MACH_SUN50I
@@ -616,6 +626,7 @@ config SYS_CLK_FREQ
 	default 1008000000 if MACH_SUN9I
 	default 888000000 if MACH_SUN50I_H6
 	default 1008000000 if MACH_SUN50I_H616
+	default 1008000000 if MACH_SUN50I_R329
 
 config SYS_CONFIG_NAME
 	default "sun4i" if MACH_SUN4I
@@ -627,6 +638,7 @@ config SYS_CONFIG_NAME
 	default "sun50i" if MACH_SUN50I
 	default "sun50i" if MACH_SUN50I_H6
 	default "sun50i" if MACH_SUN50I_H616
+	default "sun50i" if MACH_SUN50I_R329
 
 config SYS_BOARD
 	default "sunxi"
arch/arm/mach-sunxi/cpu_info.c +2 -0
index ba33ef2430..8021f4c307 100644
@@ -101,6 +101,8 @@ int print_cpuinfo(void)
 	puts("CPU:   Allwinner H6 (SUN50I)\n");
 #elif defined CONFIG_MACH_SUN50I_H616
 	puts("CPU:   Allwinner H616 (SUN50I)\n");
+#elif defined CONFIG_MACH_SUN50I_R329
+	puts("CPU:   Allwinner R329 (SUN50I)\n");
 #else
 #warning Please update cpu_info.c with correct CPU information
 	puts("CPU:   SUNXI Family\n");
common/spl/Kconfig +1 -0
index 2df3e5d869..ed4477ff93 100644
@@ -150,6 +150,7 @@ config SPL_TEXT_BASE
 	hex "SPL Text Base"
 	default ISW_ENTRY_ADDR if AM43XX || AM33XX || OMAP54XX || ARCH_KEYSTONE
 	default 0x10060 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN9I
+	default 0x100060 if MACH_SUN50I_R329
 	default 0x20060 if SUN50I_GEN_H6
 	default 0x00060 if ARCH_SUNXI
 	default 0xfffc0000 if ARCH_ZYNQMP
#17 lore raw

RFC PATCH 9/13 sunxi: sync R329 CCU binding headers from internal WIP kernel tree

In reply to Icenowy Zheng
---
 include/dt-bindings/clock/sun50i-r329-ccu.h   | 73 +++++++++++++++++++
 include/dt-bindings/clock/sun50i-r329-r-ccu.h | 32 ++++++++
 include/dt-bindings/reset/sun50i-r329-ccu.h   | 45 ++++++++++++
 include/dt-bindings/reset/sun50i-r329-r-ccu.h | 23 ++++++
 4 files changed, 173 insertions(+)
 create mode 100644 include/dt-bindings/clock/sun50i-r329-ccu.h
 create mode 100644 include/dt-bindings/clock/sun50i-r329-r-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-r329-ccu.h
 create mode 100644 include/dt-bindings/reset/sun50i-r329-r-ccu.h
include/dt-bindings/clock/sun50i-r329-ccu.h new file +73 -0
new file mode 100644
index 0000000000..769a40a175
@@ -0,0 +1,73 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2021 Sipeed
+ */
+
+#ifndef _DT_BINDINGS_CLK_SUN50I_R329_CCU_H_
+#define _DT_BINDINGS_CLK_SUN50I_R329_CCU_H_
+
+#define CLK_CPUX		1
+
+#define CLK_APB1		5
+
+#define CLK_CE			7
+#define CLK_BUS_CE		8
+#define CLK_AIPU		9
+#define CLK_BUS_VE		10
+#define CLK_BUS_DMA		11
+#define CLK_BUS_MSGBOX		12
+#define CLK_BUS_SPINLOCK	13
+#define CLK_BUS_HSTIMER		14
+#define CLK_AVS			15
+#define CLK_BUS_DBG		16
+#define CLK_BUS_PWM		17
+
+#define CLK_MBUS_DMA		19
+#define CLK_MBUS_CE		20
+#define CLK_MBUS_NAND		21
+#define CLK_MBUS_CSI		22
+#define CLK_MBUS_ISP		23
+
+#define CLK_NAND0		25
+#define CLK_NAND1		26
+#define CLK_BUS_NAND		27
+#define CLK_MMC0		28
+#define CLK_MMC1		29
+#define CLK_BUS_MMC0		30
+#define CLK_BUS_MMC1		31
+#define CLK_BUS_UART0		32
+#define CLK_BUS_UART1		33
+#define CLK_BUS_UART2		34
+#define CLK_BUS_UART3		35
+#define CLK_BUS_I2C0		36
+#define CLK_BUS_I2C1		37
+#define CLK_BUS_SCR		38
+#define CLK_SPI0		39
+#define CLK_SPI1		40
+#define CLK_BUS_SPI0		41
+#define CLK_BUS_SPI1		42
+#define CLK_EMAC_25M_DIV	43
+#define CLK_EMAC_25M		44
+#define CLK_BUS_EMAC		45
+#define CLK_IR_RX		46
+#define CLK_BUS_IR_RX		47
+#define CLK_IR_TX		48
+#define CLK_BUS_IR_TX		49
+#define CLK_I2S0		50
+#define CLK_I2S1		51
+#define CLK_BUS_I2S0		52
+#define CLK_BUS_I2S1		53
+#define CLK_SPDIF		54
+#define CLK_BUS_SPDIF		55
+#define CLK_USB_OHCI0		56
+#define CLK_USB_PHY0		57
+#define CLK_USB_OHCI1		58
+#define CLK_USB_PHY1		59
+#define CLK_BUS_OHCI0		60
+#define CLK_BUS_OHCI1		61
+#define CLK_BUS_EHCI0		62
+#define CLK_BUS_OTG		63
+#define CLK_LEDC		64
+#define CLK_BUS_LEDC		65
+
+#endif /* _DT_BINDINGS_CLK_SUN50I_R329_CCU_H_ */
include/dt-bindings/clock/sun50i-r329-r-ccu.h new file +32 -0
new file mode 100644
index 0000000000..2044d25383
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2021 Sipeed
+ */
+
+#ifndef _DT_BINDINGS_CLK_SUN50I_R329_R_CCU_H_
+#define _DT_BINDINGS_CLK_SUN50I_R329_R_CCU_H_
+
+#define CLK_R_APB1		12
+
+#define CLK_R_BUS_GPADC		14
+#define CLK_R_BUS_THS		15
+#define CLK_R_PWM		16
+#define CLK_R_BUS_PWM		17
+#define CLK_R_CODEC_ADC		18
+#define CLK_R_CODEC_DAC		19
+#define CLK_R_BUS_CODEC		20
+#define CLK_R_DMIC		21
+#define CLK_R_BUS_DMIC		22
+#define CLK_R_BUS_LRADC		23
+#define CLK_R_I2S		24
+#define CLK_R_I2S_ASRC		25
+#define CLK_R_BUS_I2S		26
+#define CLK_R_BUS_UART		27
+#define CLK_R_BUS_I2C		28
+#define CLK_R_IR		29
+#define CLK_R_BUS_IR		30
+#define CLK_R_BUS_MSGBOX	31
+#define CLK_R_BUS_SPINLOCK	32
+#define CLK_R_BUS_RTC		33
+
+#endif /* _DT_BINDINGS_CLK_SUN50I_R329_R_CCU_H_ */
include/dt-bindings/reset/sun50i-r329-ccu.h new file +45 -0

45 lines not on this page · raw message

include/dt-bindings/reset/sun50i-r329-r-ccu.h new file +23 -0
new file mode 100644
index 0000000000..e65a317afb
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: (GPL-2.0+ or MIT) */
+/*
+ * Copyright (c) 2021 Sipeed
+ */
+
+#ifndef _DT_BINDINGS_RST_SUN50I_R329_R_CCU_H_
+#define _DT_BINDINGS_RST_SUN50I_R329_R_CCU_H_
+
+#define RST_R_BUS_GPADC		0
+#define RST_R_BUS_THS		1
+#define RST_R_BUS_PWM		2
+#define RST_R_BUS_CODEC		3
+#define RST_R_BUS_DMIC		4
+#define RST_R_BUS_LRADC		5
+#define RST_R_BUS_I2S		6
+#define RST_R_BUS_UART		7
+#define RST_R_BUS_I2C		8
+#define RST_R_BUS_IR		9
+#define RST_R_BUS_MSGBOX	10
+#define RST_R_BUS_SPINLOCK	11
+#define RST_R_BUS_RTC		12
+
+#endif /* _DT_BINDINGS_RST_SUN50I_R329_R_CCU_H_ */
Signature · 1 line
2.30.2
#18 lore raw

RFC PATCH 10/13 clk: sunxi: add support for R329 in sunxi DM clock driver

In reply to Icenowy Zheng

Currently only a subset of clocks/resets (similar to other SoCs) are supported.

---
 drivers/clk/sunxi/Kconfig    |  7 +++
 drivers/clk/sunxi/Makefile   |  1 +
 drivers/clk/sunxi/clk_r329.c | 94 ++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_r329.c
drivers/clk/sunxi/Kconfig +7 -0
index bf084fa7a8..8dd3be4683 100644
@@ -86,6 +86,13 @@ config CLK_SUN50I_H616
 	  This enables common clock driver support for platforms based
 	  on Allwinner H616 SoC.
 
+config CLK_SUN50I_R329
+	bool "Clock driver for Allwinner R329"
+	default MACH_SUN50I_R329
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner R329 SoC.
+
 config CLK_SUN50I_A64
 	bool "Clock driver for Allwinner A64"
 	default MACH_SUN50I
drivers/clk/sunxi/Makefile +1 -0
index 4f9282a8b9..050f7ecc46 100644
@@ -19,4 +19,5 @@ obj-$(CONFIG_CLK_SUN9I_A80) += clk_a80.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_H6) += clk_h6.o
 obj-$(CONFIG_CLK_SUN50I_H616) += clk_h616.o
+obj-$(CONFIG_CLK_SUN50I_R329) += clk_r329.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
drivers/clk/sunxi/clk_r329.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 10/13
#19 lore raw

Re: [RFC PATCH 10/13] clk: sunxi: add support for R329 in sunxi DM clock driver

Quoted 4 lines · Icenowy Zheng

Currently only a subset of clocks/resets (similar to other SoCs) are supported.

Quoted 43 lines
---
 drivers/clk/sunxi/Kconfig    |  7 +++
 drivers/clk/sunxi/Makefile   |  1 +
 drivers/clk/sunxi/clk_r329.c | 94 ++++++++++++++++++++++++++++++++++++
 3 files changed, 102 insertions(+)
 create mode 100644 drivers/clk/sunxi/clk_r329.c
drivers/clk/sunxi/Kconfig +7 -0
index bf084fa7a8..8dd3be4683 100644
@@ -86,6 +86,13 @@ config CLK_SUN50I_H616
 	  This enables common clock driver support for platforms based
 	  on Allwinner H616 SoC.
 
+config CLK_SUN50I_R329
+	bool "Clock driver for Allwinner R329"
+	default MACH_SUN50I_R329
+	help
+	  This enables common clock driver support for platforms based
+	  on Allwinner R329 SoC.
+
 config CLK_SUN50I_A64
 	bool "Clock driver for Allwinner A64"
 	default MACH_SUN50I
drivers/clk/sunxi/Makefile +1 -0
index 4f9282a8b9..050f7ecc46 100644
@@ -19,4 +19,5 @@ obj-$(CONFIG_CLK_SUN9I_A80) += clk_a80.o
 obj-$(CONFIG_CLK_SUN8I_H3) += clk_h3.o
 obj-$(CONFIG_CLK_SUN50I_H6) += clk_h6.o
 obj-$(CONFIG_CLK_SUN50I_H616) += clk_h616.o
+obj-$(CONFIG_CLK_SUN50I_R329) += clk_r329.o
 obj-$(CONFIG_CLK_SUN50I_A64) += clk_a64.o
drivers/clk/sunxi/clk_r329.c new file +2 -0
new file mode 100644
index 0000000000..17157214b6
@@ -0,0 +1,94 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*

drivers/clk/sunxi/clk_r329.c line 12

Quoted 10 lines
drivers/clk/sunxi/clk_r329.c new file +10 -0
+ * Copyright (C) 2021 Sipeed
+ * Based on clk_h616.c, which is:
+ *   Copyright (C) 2021 Jernej Skrabec <[email protected]>
+ */
+
+#include <common.h>
+#include <clk-uclass.h>
+#include <dm.h>
+#include <errno.h>
+#include <asm/arch/ccu.h>

This will need to be updated when you rebase:

#include <clk/sunxi.h>

Regards,
Samuel

Quoted 83 lines
drivers/clk/sunxi/clk_r329.c new file +82 -0
+#include <dt-bindings/clock/sun50i-r329-ccu.h>
+#include <dt-bindings/reset/sun50i-r329-ccu.h>
+#include <linux/bitops.h>
+
+static struct ccu_clk_gate r329_gates[] = {
+	[CLK_BUS_MMC0]		= GATE(0x84c, BIT(0)),
+	[CLK_BUS_MMC1]		= GATE(0x84c, BIT(1)),
+
+	[CLK_BUS_UART0]		= GATE(0x90c, BIT(0)),
+	[CLK_BUS_UART1]		= GATE(0x90c, BIT(1)),
+	[CLK_BUS_UART2]		= GATE(0x90c, BIT(2)),
+	[CLK_BUS_UART3]		= GATE(0x90c, BIT(3)),
+
+	[CLK_SPI0]		= GATE(0x940, BIT(31)),
+	[CLK_SPI1]		= GATE(0x944, BIT(31)),
+
+	[CLK_BUS_SPI0]		= GATE(0x96c, BIT(0)),
+	[CLK_BUS_SPI1]		= GATE(0x96c, BIT(1)),
+
+	[CLK_BUS_EMAC]		= GATE(0x97c, BIT(0)),
+
+	[CLK_USB_PHY0]		= GATE(0xa70, BIT(29)),
+	[CLK_USB_OHCI0]		= GATE(0xa70, BIT(31)),
+
+	[CLK_USB_PHY1]		= GATE(0xa74, BIT(29)),
+	[CLK_USB_OHCI1]		= GATE(0xa74, BIT(31)),
+
+	[CLK_BUS_OHCI0]		= GATE(0xa8c, BIT(0)),
+	[CLK_BUS_OHCI1]		= GATE(0xa8c, BIT(1)),
+	[CLK_BUS_EHCI0]		= GATE(0xa8c, BIT(4)),
+	[CLK_BUS_OTG]		= GATE(0xa8c, BIT(8)),
+};
+
+static struct ccu_reset r329_resets[] = {
+	[RST_BUS_MMC0]		= RESET(0x84c, BIT(16)),
+	[RST_BUS_MMC1]		= RESET(0x84c, BIT(17)),
+
+	[RST_BUS_UART0]		= RESET(0x90c, BIT(16)),
+	[RST_BUS_UART1]		= RESET(0x90c, BIT(17)),
+	[RST_BUS_UART2]		= RESET(0x90c, BIT(18)),
+	[RST_BUS_UART3]		= RESET(0x90c, BIT(19)),
+
+	[RST_BUS_SPI0]		= RESET(0x96c, BIT(16)),
+	[RST_BUS_SPI1]		= RESET(0x96c, BIT(17)),
+
+	[RST_BUS_EMAC]		= RESET(0x97c, BIT(16)),
+
+	[RST_USB_PHY0]		= RESET(0xa70, BIT(30)),
+
+	[RST_USB_PHY1]		= RESET(0xa74, BIT(30)),
+
+	[RST_BUS_OHCI0]		= RESET(0xa8c, BIT(16)),
+	[RST_BUS_OHCI1]		= RESET(0xa8c, BIT(17)),
+	[RST_BUS_EHCI0]		= RESET(0xa8c, BIT(20)),
+	[RST_BUS_OTG]		= RESET(0xa8c, BIT(24)),
+};
+
+static const struct ccu_desc r329_ccu_desc = {
+	.gates = r329_gates,
+	.resets = r329_resets,
+};
+
+static int r329_clk_bind(struct udevice *dev)
+{
+	return sunxi_reset_bind(dev, ARRAY_SIZE(r329_resets));
+}
+
+static const struct udevice_id r329_ccu_ids[] = {
+	{ .compatible = "allwinner,sun50i-r329-ccu",
+	  .data = (ulong)&r329_ccu_desc },
+	{ }
+};
+
+U_BOOT_DRIVER(clk_sun50i_r329) = {
+	.name		= "sun50i_r329_ccu",
+	.id		= UCLASS_CLK,
+	.of_match	= r329_ccu_ids,
+	.priv_auto	= sizeof(struct ccu_priv),
+	.ops		= &sunxi_clk_ops,
+	.probe		= sunxi_clk_probe,
+	.bind		= r329_clk_bind,
+};
#20 lore raw

RFC PATCH 11/13 mmc: sunxi: add support for R329 MMC controller

In reply to Icenowy Zheng

R329 SoC has similar MMC controllers with previous Allwinner SoCs.

Add support for it by adding its compatible string.

---
 drivers/mmc/sunxi_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/sunxi_mmc.c +1 -0
index 6b809c001f..59cc28794d 100644
@@ -734,6 +734,7 @@ static const struct udevice_id sunxi_mmc_ids[] = {
 	{ .compatible = "allwinner,sun50i-h6-emmc" },
 	{ .compatible = "allwinner,sun50i-a100-mmc" },
 	{ .compatible = "allwinner,sun50i-a100-emmc" },
+	{ .compatible = "allwinner,sun50i-r329-mmc" },
 	{ /* sentinel */ }
 };
 
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 11/13
#21 lore raw

Re: [RFC PATCH 11/13] mmc: sunxi: add support for R329 MMC controller

Quoted 5 lines · Icenowy Zheng

R329 SoC has similar MMC controllers with previous Allwinner SoCs.

Add support for it by adding its compatible string.

It really is that simple; as far as I can tell, the other checks are covered by CONFIG_SUN50I_GEN_H6.

Quoted 17 lines
---
 drivers/mmc/sunxi_mmc.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/sunxi_mmc.c +1 -0
index 6b809c001f..59cc28794d 100644
@@ -734,6 +734,7 @@ static const struct udevice_id sunxi_mmc_ids[] = {
 	{ .compatible = "allwinner,sun50i-h6-emmc" },
 	{ .compatible = "allwinner,sun50i-a100-mmc" },
 	{ .compatible = "allwinner,sun50i-a100-emmc" },
+	{ .compatible = "allwinner,sun50i-r329-mmc" },
 	{ /* sentinel */ }
 };
 
#22 lore raw

RFC PATCH 12/13 sunxi: sync R329 DTs from internal WIP kernel tree

In reply to Icenowy Zheng
---
 arch/arm/dts/Makefile                      |   2 +
 arch/arm/dts/sun50i-r329-maix-iia-dock.dts |  36 ++++
 arch/arm/dts/sun50i-r329-maix-iia.dtsi     |  45 +++++
 arch/arm/dts/sun50i-r329.dtsi              | 225 +++++++++++++++++++++
 4 files changed, 308 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia-dock.dts
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia.dtsi
 create mode 100644 arch/arm/dts/sun50i-r329.dtsi
arch/arm/dts/Makefile +2 -0
index 3941a08cf4..cfafb80a5f 100644
@@ -643,6 +643,8 @@ dtb-$(CONFIG_MACH_SUN50I_H6) += \
 	sun50i-h6-tanix-tx6.dtb
 dtb-$(CONFIG_MACH_SUN50I_H616) += \
 	sun50i-h616-orangepi-zero2.dtb
+dtb-$(CONFIG_MACH_SUN50I_R329) += \
+	sun50i-r329-maix-iia-dock.dtb
 dtb-$(CONFIG_MACH_SUN50I) += \
 	sun50i-a64-amarula-relic.dtb \
 	sun50i-a64-bananapi-m64.dtb \
arch/arm/dts/sun50i-r329-maix-iia-dock.dts new file +36 -0
new file mode 100644
index 0000000000..2588eb6adb
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+// Copyright (c) 2021 Sipeed
+
+/dts-v1/;
+
+#include "sun50i-r329-maix-iia.dtsi"
+
+/ {
+	model = "Sipeed MAIX-II A Dock";
+	compatible = "sipeed,maix-iia-dock", "sipeed,maix-iia",
+		     "allwinner,sun50i-r329";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&uart0_pb_pins>;
+	status = "okay";
+};
+
+&mmc0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&mmc0_pf_pins>;
+
+	vmmc-supply = <&reg_vcc3v3>;
+	bus-width = <4>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
+	status = "okay";
+};
arch/arm/dts/sun50i-r329-maix-iia.dtsi new file +45 -0

45 lines not on this page · raw message

arch/arm/dts/sun50i-r329.dtsi new file +225 -0

225 lines not on this page · raw message

Signature · 1 line
2.30.2
maintainer
#23 lore raw

Re: [RFC PATCH 12/13] sunxi: sync R329 DTs from internal WIP kernel tree

Quoted 10 lines · Icenowy Zheng
---
 arch/arm/dts/Makefile                      |   2 +
 arch/arm/dts/sun50i-r329-maix-iia-dock.dts |  36 ++++
 arch/arm/dts/sun50i-r329-maix-iia.dtsi     |  45 +++++
 arch/arm/dts/sun50i-r329.dtsi              | 225 +++++++++++++++++++++
 4 files changed, 308 insertions(+)
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia-dock.dts
 create mode 100644 arch/arm/dts/sun50i-r329-maix-iia.dtsi
 create mode 100644 arch/arm/dts/sun50i-r329.dtsi

One thing to note when you rebase: you will need to add the watchdog node for rebooting to work.

Regards,
Samuel

#24 lore raw

RFC PATCH 13/13 sunxi: add support for Sipeed Maix IIA Dock board

In reply to Icenowy Zheng

Maix IIA is a SoM by Sipeed, and a official baseboard is sold with it.

Add support for this official baseboard with Maix IIA attached.

---
 board/sunxi/MAINTAINERS                | 5 +++++
 configs/sipeed_maix_iia_dock_defconfig | 8 ++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 configs/sipeed_maix_iia_dock_defconfig
board/sunxi/MAINTAINERS +5 -0
index 4fc26077b2..ae7c6a131a 100644
@@ -493,6 +493,11 @@ M:	VishnuPatekar <[email protected]>
 S:	Maintained
 F:	configs/Sinovoip_BPI_M3_defconfig
 
+SIPEED MAIX IIA DOCK BOARD
+M:	Icenowy Zheng <[email protected]>
+S:	Maintained
+F:	configs/sipeed_maix_iia_dock_defconfig
+
 SOPINE BOARD
 M:	Icenowy Zheng <[email protected]>
 S:	Maintained
configs/sipeed_maix_iia_dock_defconfig new file +8 -0
new file mode 100644
index 0000000000..a839f65e10
@@ -0,0 +1,8 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_DEFAULT_DEVICE_TREE="sun50i-r329-maix-iia-dock"
+CONFIG_SPL=y
+CONFIG_MACH_SUN50I_R329=y
+CONFIG_MMC0_CD_PIN="PF6"
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_ENV_FAT_DEVICE_AND_PART="1:auto"
Signature · 1 line
2.30.2
maintainer
#25 lore raw
In reply to Icenowy Zheng
Quoted 4 lines · Icenowy Zheng

This patchset adds Allwinner R329 support to U-Boot.

First, some code refactors happen for SoCs w/o SCP/MMC2.

Quoted 8 lines

Then the basical support for R329 come as several parts (memory map, clocks, pinmux, DRAM, final Kconfig option).

Then, as the RFC part of this patchset, some device tree related changes.

Finally it comes the defconfig file for a R329 board, Sipeed Maix IIA Dock.

I was able to boot into Linux on my MaixSense, but I also needed the top patch from your branch here:

https://github.com/sipeed/u-boot/commits/r329-wip

Otherwise, U-Boot complained that $kernel_addr_r overlapped reserved memory.

Quoted 3 lines

This patchset is RFC mainly because of the DT-related part, as no DT binding is mainlined in Linux now (it's still WIP). All other patches are ready for being reviewed and, if proper, merged.

Yes, I would like to have the Kconfig available so I can support R329 in my pinctrl series.

Regards,
Samuel