Re: [linux-sunxi] [PATCH 12/17] sunxi: Add support for H616 SoC

2021-01-04 Thread Jernej Škrabec
Dne ponedeljek, 04. januar 2021 ob 03:47:06 CET je Samuel Holland napisal(a):
> On 1/3/21 3:26 AM, Jernej Skrabec wrote:
> > H616 is very similar to H6 so most of the infrastructure can be reused.
> > However, two big differences are that it doesn't have functional SRAM A2
> > which is usually used for TF-A and it doesn't have ARISC co-processor.
> > It also needs bigger SPL size - 48 KiB.
> > 
> > Signed-off-by: Jernej Skrabec 
> > ---
> > 
> >  arch/arm/dts/sunxi-u-boot.dtsi  |  9 +
> >  arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h |  7 +++
> >  arch/arm/mach-sunxi/Kconfig | 11 ++-
> >  arch/arm/mach-sunxi/cpu_info.c  |  2 ++
> >  drivers/power/Kconfig   |  1 +
> >  include/configs/sunxi-common.h  | 10 ++
> >  6 files changed, 39 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/dts/sunxi-u-boot.dtsi
> > b/arch/arm/dts/sunxi-u-boot.dtsi index c77cf7cacf0c..7e8644f390a8 100644
> > --- a/arch/arm/dts/sunxi-u-boot.dtsi
> > +++ b/arch/arm/dts/sunxi-u-boot.dtsi
> > @@ -3,6 +3,9 @@
> > 
> >  #ifdef CONFIG_MACH_SUN50I_H6
> >  #define BL31_ADDR 0x104000
> >  #define  SCP_ADDR 0x114000
> > 
> > +#elif defined(CONFIG_MACH_SUN50I_H616)
> > +#define BL31_ADDR 0x40004000
> > +#define  SCP_ADDR 0x028000
> 
> There should be no SCP_ADDR if there is no SCP firmware.

Nice catch!

> 
> >  #else
> >  #define BL31_ADDR  0x44000
> >  #define  SCP_ADDR  0x5
> > 
> > @@ -61,6 +64,7 @@
> > 
> > };
> > 
> > };
> > 
> > +#ifndef CONFIG_MACH_SUN50I_H616
> > 
> > scp {
> > 
> > description = "SCP 
firmware";
> > type = "firmware";
> > 
> > @@ -73,6 +77,7 @@
> > 
> > missing-msg 
= "scp-sunxi";
> > 
> > };
> > 
> > };
> > 
> > +#endif
> > 
> > @fdt-SEQ {
> > 
> > description = "NAME";
> > 
> > @@ -87,7 +92,11 @@
> > 
> > @config-SEQ {
> > 
> > description = "NAME";
> > firmware = "atf";
> > 
> > +#ifdef CONFIG_MACH_SUN50I_H616
> > +   loadables = "uboot";
> > +#else
> > 
> > loadables = "scp", 
"uboot";
> > 
> > +#endif
> > 
> > fdt = "fdt-SEQ";
> > 
> > };
> > 
> > };
> > 
> > diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> > b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h index
> > 6392cb07b472..d9cf8ae04288 100644
> > --- a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> > +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> > @@ -28,13 +28,20 @@
> > 
> >  #define SUNXI_GIC400_BASE  0x0302
> >  #define SUNXI_IOMMU_BASE   0x030F
> > 
> > +#ifdef CONFIG_MACH_SUN50I_H6
> > 
> >  #define SUNXI_DRAM_COM_BASE0x04002000
> >  #define SUNXI_DRAM_CTL0_BASE   0x04003000
> >  #define SUNXI_DRAM_PHY0_BASE   0x04005000
> > 
> > +#endif
> > 
> >  #define SUNXI_NFC_BASE 0x04011000
> >  #define SUNXI_MMC0_BASE0x0402
> >  #define SUNXI_MMC1_BASE0x04021000
> >  #define SUNXI_MMC2_BASE0x04022000
> > 
> > +#ifdef CONFIG_MACH_SUN50I_H616
> > +#define SUNXI_DRAM_COM_BASE0x047FA000
> > +#define SUNXI_DRAM_CTL0_BASE   0x047FB000
> > +#define SUNXI_DRAM_PHY0_BASE   0x0480
> > +#endif
> > 
> >  #define SUNXI_UART0_BASE   0x0500
> >  #define SUNXI_UART1_BASE   0x05000400
> > 
> > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > index 1a5497989f04..859b30d74ceb 100644
> > --- a/arch/arm/mach-sunxi/Kconfig
> > +++ b/arch/arm/mach-sunxi/Kconfig
> > @@ -190,9 +190,10 @@ config MACH_SUNXI_H3_H5
> > 
> > select SUPPORT_SPL
> >  
> >  # TODO: try out A80's 8GiB DRAM space
> > 
> > +# TODO: H616 supports 4 GiB DRAM space
> > 
> >  config SUNXI_DRAM_MAX_SIZE
> >  
> > hex
> > 
> > -   default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || 
MACH_SUN50I_H6
> > +   default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || 
MACH_SUN50I_H6 ||
> > MACH_SUN50I_H616> 
> > default 0x8000
> >  
> >  choice
> > 
> > @@ -354,6 +355,12 @@ config MACH_SUN50I_H6
> > 
> > select PHY_SUN4I_USB
> > select DRAM_SUN50I_H6
> > 
> > +config MACH_SUN50I_H616
> > +   bool "sun50i (A

Re: [linux-sunxi] [PATCH 12/17] sunxi: Add support for H616 SoC

2021-01-03 Thread Samuel Holland
On 1/3/21 3:26 AM, Jernej Skrabec wrote:
> H616 is very similar to H6 so most of the infrastructure can be reused.
> However, two big differences are that it doesn't have functional SRAM A2
> which is usually used for TF-A and it doesn't have ARISC co-processor.
> It also needs bigger SPL size - 48 KiB.
> 
> Signed-off-by: Jernej Skrabec 
> ---
>  arch/arm/dts/sunxi-u-boot.dtsi  |  9 +
>  arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h |  7 +++
>  arch/arm/mach-sunxi/Kconfig | 11 ++-
>  arch/arm/mach-sunxi/cpu_info.c  |  2 ++
>  drivers/power/Kconfig   |  1 +
>  include/configs/sunxi-common.h  | 10 ++
>  6 files changed, 39 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
> index c77cf7cacf0c..7e8644f390a8 100644
> --- a/arch/arm/dts/sunxi-u-boot.dtsi
> +++ b/arch/arm/dts/sunxi-u-boot.dtsi
> @@ -3,6 +3,9 @@
>  #ifdef CONFIG_MACH_SUN50I_H6
>  #define BL31_ADDR 0x104000
>  #define  SCP_ADDR 0x114000
> +#elif defined(CONFIG_MACH_SUN50I_H616)
> +#define BL31_ADDR 0x40004000
> +#define  SCP_ADDR 0x028000

There should be no SCP_ADDR if there is no SCP firmware.

>  #else
>  #define BL31_ADDR  0x44000
>  #define  SCP_ADDR  0x5
> @@ -61,6 +64,7 @@
>   };
>   };
>  
> +#ifndef CONFIG_MACH_SUN50I_H616
>   scp {
>   description = "SCP firmware";
>   type = "firmware";
> @@ -73,6 +77,7 @@
>   missing-msg = "scp-sunxi";
>   };
>   };
> +#endif
>  
>   @fdt-SEQ {
>   description = "NAME";
> @@ -87,7 +92,11 @@
>   @config-SEQ {
>   description = "NAME";
>   firmware = "atf";
> +#ifdef CONFIG_MACH_SUN50I_H616
> + loadables = "uboot";
> +#else
>   loadables = "scp", "uboot";
> +#endif
>   fdt = "fdt-SEQ";
>   };
>   };
> diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h 
> b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> index 6392cb07b472..d9cf8ae04288 100644
> --- a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> +++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
> @@ -28,13 +28,20 @@
>  #define SUNXI_GIC400_BASE0x0302
>  #define SUNXI_IOMMU_BASE 0x030F
>  
> +#ifdef CONFIG_MACH_SUN50I_H6
>  #define SUNXI_DRAM_COM_BASE  0x04002000
>  #define SUNXI_DRAM_CTL0_BASE 0x04003000
>  #define SUNXI_DRAM_PHY0_BASE 0x04005000
> +#endif
>  #define SUNXI_NFC_BASE   0x04011000
>  #define SUNXI_MMC0_BASE  0x0402
>  #define SUNXI_MMC1_BASE  0x04021000
>  #define SUNXI_MMC2_BASE  0x04022000
> +#ifdef CONFIG_MACH_SUN50I_H616
> +#define SUNXI_DRAM_COM_BASE  0x047FA000
> +#define SUNXI_DRAM_CTL0_BASE 0x047FB000
> +#define SUNXI_DRAM_PHY0_BASE 0x0480
> +#endif
>  
>  #define SUNXI_UART0_BASE 0x0500
>  #define SUNXI_UART1_BASE 0x05000400
> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index 1a5497989f04..859b30d74ceb 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -190,9 +190,10 @@ config MACH_SUNXI_H3_H5
>   select SUPPORT_SPL
>  
>  # TODO: try out A80's 8GiB DRAM space
> +# TODO: H616 supports 4 GiB DRAM space
>  config SUNXI_DRAM_MAX_SIZE
>   hex
> - default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN50I_H6
> + default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN50I_H6 
> || MACH_SUN50I_H616
>   default 0x8000
>  
>  choice
> @@ -354,6 +355,12 @@ config MACH_SUN50I_H6
>   select PHY_SUN4I_USB
>   select DRAM_SUN50I_H6
>  
> +config MACH_SUN50I_H616
> + bool "sun50i (Allwinner H616)"
> + select ARM64
> + select DRAM_SUN50I_H616
> + select SUN50I_GEN_H6
> +
>  endchoice
>  
>  # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
> @@ -589,6 +596,7 @@ config SYS_CLK_FREQ
>   default 81600 if MACH_SUN50I || MACH_SUN50I_H5
>   default 100800 if MACH_SUN8I
>   default 100800 if MACH_SUN9I
> + default 100800 if MACH_SUN50I_H616
>  
>  config SYS_CONFIG_NAME
>   default "sun4i" if MACH_SUN4I
> @@ -599,6 +607,7 @@ config SYS_CONFIG_NAME
>   default "sun9i" if MACH_SUN9I
>   default "sun50i" if MACH_SUN50I
>   default "sun50i" if MACH_SUN50I_H6
> + default "sun50i" if M

[linux-sunxi] [PATCH 12/17] sunxi: Add support for H616 SoC

2021-01-03 Thread Jernej Skrabec
H616 is very similar to H6 so most of the infrastructure can be reused.
However, two big differences are that it doesn't have functional SRAM A2
which is usually used for TF-A and it doesn't have ARISC co-processor.
It also needs bigger SPL size - 48 KiB.

Signed-off-by: Jernej Skrabec 
---
 arch/arm/dts/sunxi-u-boot.dtsi  |  9 +
 arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h |  7 +++
 arch/arm/mach-sunxi/Kconfig | 11 ++-
 arch/arm/mach-sunxi/cpu_info.c  |  2 ++
 drivers/power/Kconfig   |  1 +
 include/configs/sunxi-common.h  | 10 ++
 6 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/sunxi-u-boot.dtsi b/arch/arm/dts/sunxi-u-boot.dtsi
index c77cf7cacf0c..7e8644f390a8 100644
--- a/arch/arm/dts/sunxi-u-boot.dtsi
+++ b/arch/arm/dts/sunxi-u-boot.dtsi
@@ -3,6 +3,9 @@
 #ifdef CONFIG_MACH_SUN50I_H6
 #define BL31_ADDR 0x104000
 #define  SCP_ADDR 0x114000
+#elif defined(CONFIG_MACH_SUN50I_H616)
+#define BL31_ADDR 0x40004000
+#define  SCP_ADDR 0x028000
 #else
 #define BL31_ADDR  0x44000
 #define  SCP_ADDR  0x5
@@ -61,6 +64,7 @@
};
};
 
+#ifndef CONFIG_MACH_SUN50I_H616
scp {
description = "SCP firmware";
type = "firmware";
@@ -73,6 +77,7 @@
missing-msg = "scp-sunxi";
};
};
+#endif
 
@fdt-SEQ {
description = "NAME";
@@ -87,7 +92,11 @@
@config-SEQ {
description = "NAME";
firmware = "atf";
+#ifdef CONFIG_MACH_SUN50I_H616
+   loadables = "uboot";
+#else
loadables = "scp", "uboot";
+#endif
fdt = "fdt-SEQ";
};
};
diff --git a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h 
b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
index 6392cb07b472..d9cf8ae04288 100644
--- a/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
+++ b/arch/arm/include/asm/arch-sunxi/cpu_sun50i_h6.h
@@ -28,13 +28,20 @@
 #define SUNXI_GIC400_BASE  0x0302
 #define SUNXI_IOMMU_BASE   0x030F
 
+#ifdef CONFIG_MACH_SUN50I_H6
 #define SUNXI_DRAM_COM_BASE0x04002000
 #define SUNXI_DRAM_CTL0_BASE   0x04003000
 #define SUNXI_DRAM_PHY0_BASE   0x04005000
+#endif
 #define SUNXI_NFC_BASE 0x04011000
 #define SUNXI_MMC0_BASE0x0402
 #define SUNXI_MMC1_BASE0x04021000
 #define SUNXI_MMC2_BASE0x04022000
+#ifdef CONFIG_MACH_SUN50I_H616
+#define SUNXI_DRAM_COM_BASE0x047FA000
+#define SUNXI_DRAM_CTL0_BASE   0x047FB000
+#define SUNXI_DRAM_PHY0_BASE   0x0480
+#endif
 
 #define SUNXI_UART0_BASE   0x0500
 #define SUNXI_UART1_BASE   0x05000400
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 1a5497989f04..859b30d74ceb 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -190,9 +190,10 @@ config MACH_SUNXI_H3_H5
select SUPPORT_SPL
 
 # TODO: try out A80's 8GiB DRAM space
+# TODO: H616 supports 4 GiB DRAM space
 config SUNXI_DRAM_MAX_SIZE
hex
-   default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN50I_H6
+   default 0xC000 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN50I_H6 
|| MACH_SUN50I_H616
default 0x8000
 
 choice
@@ -354,6 +355,12 @@ config MACH_SUN50I_H6
select PHY_SUN4I_USB
select DRAM_SUN50I_H6
 
+config MACH_SUN50I_H616
+   bool "sun50i (Allwinner H616)"
+   select ARM64
+   select DRAM_SUN50I_H616
+   select SUN50I_GEN_H6
+
 endchoice
 
 # The sun8i SoCs share a lot, this helps to avoid a lot of "if A23 || A33"
@@ -589,6 +596,7 @@ config SYS_CLK_FREQ
default 81600 if MACH_SUN50I || MACH_SUN50I_H5
default 100800 if MACH_SUN8I
default 100800 if MACH_SUN9I
+   default 100800 if MACH_SUN50I_H616
 
 config SYS_CONFIG_NAME
default "sun4i" if MACH_SUN4I
@@ -599,6 +607,7 @@ config SYS_CONFIG_NAME
default "sun9i" if MACH_SUN9I
default "sun50i" if MACH_SUN50I
default "sun50i" if MACH_SUN50I_H6
+   default "sun50i" if MACH_SUN50I_H616
 
 config SYS_BOARD
default "sunxi"
diff --git a/arch/arm/mach-sunxi/cpu_info.c b/arch/arm/mach-sunxi/cpu_info.c
index 875e5a1a8a8e..ba33ef24300c 100644
--- a/arch/arm/mach-sunxi/cpu_info.c
+++ b/arch/arm/mach-sunxi/cpu_info.c
@@ -9