diff mbox series

[v4,07/10] ARM: rzn1: basic support for Renesas RZ/N1 SoC

Message ID 20230308202653.1926303-8-ralph.siemsen@linaro.org
State New
Headers show
Series Renesas RZ/N1 SoC initial support | expand

Commit Message

Ralph Siemsen March 8, 2023, 8:26 p.m. UTC
The RZ/N1 is a family of SoC devics from Renesas, featuring:

* ARM Cortex-A7 CPU (single/dual core) and/or Cortex-M3
* Integrated SRAM up to 6MB
* Integrated gigabit ethernet switch
* Optional DDR2/3 controller
* I2C, SPI, UART, NAND, QSPI, SDIO, USB, CAN, RTC, LCD

Add basic support in the form of ARCH_RZN1 symbol.

Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org>
---

(no changes since v1)

 arch/arm/Kconfig              | 17 +++++++++++++++++
 arch/arm/Makefile             |  1 +
 arch/arm/mach-rzn1/Kconfig    | 18 ++++++++++++++++++
 arch/arm/mach-rzn1/Makefile   |  3 +++
 arch/arm/mach-rzn1/cpu_info.c | 19 +++++++++++++++++++
 5 files changed, 58 insertions(+)
 create mode 100644 arch/arm/mach-rzn1/Kconfig
 create mode 100644 arch/arm/mach-rzn1/Makefile
 create mode 100644 arch/arm/mach-rzn1/cpu_info.c

Comments

Marek Vasut April 17, 2023, 5:15 p.m. UTC | #1
On 3/8/23 21:26, Ralph Siemsen wrote:

[...]

> +++ b/arch/arm/Kconfig
> @@ -1031,6 +1031,21 @@ config ARCH_RMOBILE
>   	imply SYS_THUMB_BUILD
>   	imply ARCH_MISC_INIT if DISPLAY_CPUINFO
>   
> +config ARCH_RZN1
> +	bool "Reneasa RZ/N1 SoC"
> +	select CLK
> +	select CLK_RENESAS
> +	select CLK_R9A06G032

Does 'select CLK_R9A06G032' automatically activate the dependencies like 
'CLK_RENESAS' too ?

> +	select DM
> +	select DM_ETH
> +	select DM_SERIAL
> +	select PINCTRL
> +	select PINCONF
> +	select REGMAP
> +	select SYSRESET
> +	select SYSRESET_SYSCON
> +	imply CMD_DM
> +
>   config ARCH_SNAPDRAGON
>   	bool "Qualcomm Snapdragon SoCs"
>   	select ARM64
> @@ -2207,6 +2222,8 @@ source "arch/arm/mach-owl/Kconfig"
>   
>   source "arch/arm/mach-rmobile/Kconfig"
>   
> +source "arch/arm/mach-rzn1/Kconfig"

Should this be in mach-rmobile (which, maybe, should be renamed to 
mach-renesas) ?

[...]

> diff --git a/arch/arm/mach-rzn1/cpu_info.c b/arch/arm/mach-rzn1/cpu_info.c
> new file mode 100644
> index 0000000000..37c2492b51
> --- /dev/null
> +++ b/arch/arm/mach-rzn1/cpu_info.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +
> +#include <common.h>
> +#include <cpu_func.h>
> +
> +#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
> +void enable_caches(void)
> +{

Why not enable icache with icache_enable() too ?

> +	dcache_enable();
> +}
> +#endif
> +
> +#ifdef CONFIG_DISPLAY_CPUINFO
> +int print_cpuinfo(void)
> +{
> +	printf("CPU: Renesas Electronics RZ/N1\n");
> +	return 0;
> +}
> +#endif
Ralph Siemsen April 17, 2023, 6:57 p.m. UTC | #2
On Mon, Apr 17, 2023 at 07:15:07PM +0200, Marek Vasut wrote:
>On 3/8/23 21:26, Ralph Siemsen wrote:
>
>[...]
>
>>+++ b/arch/arm/Kconfig
>>@@ -1031,6 +1031,21 @@ config ARCH_RMOBILE
>>  	imply SYS_THUMB_BUILD
>>  	imply ARCH_MISC_INIT if DISPLAY_CPUINFO
>>+config ARCH_RZN1
>>+	bool "Reneasa RZ/N1 SoC"
>>+	select CLK
>>+	select CLK_RENESAS
>>+	select CLK_R9A06G032
>
>Does 'select CLK_R9A06G032' automatically activate the dependencies 
>like 'CLK_RENESAS' too ?

Do you mean things like CLK_RCAR_CPG_LIB for example?

The new clock driver has no dependencies (except perhaps ARCH_RZN1). 
Since this clock driver is essential to boot, I figured it was best to 
select it in Kconfig, rather than require each board defconfig to 
specify the same options.

If there is a better/preferred approach, I will implement it.

>
>>+	select DM
>>+	select DM_ETH
>>+	select DM_SERIAL
>>+	select PINCTRL
>>+	select PINCONF
>>+	select REGMAP
>>+	select SYSRESET
>>+	select SYSRESET_SYSCON
>>+	imply CMD_DM
>>+
>>  config ARCH_SNAPDRAGON
>>  	bool "Qualcomm Snapdragon SoCs"
>>  	select ARM64
>>@@ -2207,6 +2222,8 @@ source "arch/arm/mach-owl/Kconfig"
>>  source "arch/arm/mach-rmobile/Kconfig"
>>+source "arch/arm/mach-rzn1/Kconfig"
>
>Should this be in mach-rmobile (which, maybe, should be renamed to 
>mach-renesas) ?

I vaguely recall that I discussed this with someone (possibly you), 
likely on IRC. And I think the conclusion was there was a significant 
enough difference (possibly Cortex-A7 versus A9?).

I don't have a strong preference, if moving to mach-rmobile makes sense, 
let me know and I can give it a go.

>>+#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
>>+void enable_caches(void)
>>+{
>
>Why not enable icache with icache_enable() too ?

The I-cache is enabled quite early in arch/arm/cpu/armv7/start.S

Ralph
Marek Vasut April 17, 2023, 8:30 p.m. UTC | #3
On 4/17/23 20:57, Ralph Siemsen wrote:
> On Mon, Apr 17, 2023 at 07:15:07PM +0200, Marek Vasut wrote:
>> On 3/8/23 21:26, Ralph Siemsen wrote:
>>
>> [...]
>>
>>> +++ b/arch/arm/Kconfig
>>> @@ -1031,6 +1031,21 @@ config ARCH_RMOBILE
>>>      imply SYS_THUMB_BUILD
>>>      imply ARCH_MISC_INIT if DISPLAY_CPUINFO
>>> +config ARCH_RZN1
>>> +    bool "Reneasa RZ/N1 SoC"
>>> +    select CLK
>>> +    select CLK_RENESAS
>>> +    select CLK_R9A06G032
>>
>> Does 'select CLK_R9A06G032' automatically activate the dependencies 
>> like 'CLK_RENESAS' too ?
> 
> Do you mean things like CLK_RCAR_CPG_LIB for example?
> 
> The new clock driver has no dependencies (except perhaps ARCH_RZN1). 
> Since this clock driver is essential to boot, I figured it was best to 
> select it in Kconfig, rather than require each board defconfig to 
> specify the same options.
> 
> If there is a better/preferred approach, I will implement it.

I mean, if you drop 'CLK' and 'CLK_RENESAS' from this list, do they 
still get selected because 'CLK_R8A06G032' is in this list ? If yes, 
then drop them from this list, else keep them.

>>> +    select DM
>>> +    select DM_ETH
>>> +    select DM_SERIAL
>>> +    select PINCTRL
>>> +    select PINCONF
>>> +    select REGMAP
>>> +    select SYSRESET
>>> +    select SYSRESET_SYSCON
>>> +    imply CMD_DM
>>> +
>>>  config ARCH_SNAPDRAGON
>>>      bool "Qualcomm Snapdragon SoCs"
>>>      select ARM64
>>> @@ -2207,6 +2222,8 @@ source "arch/arm/mach-owl/Kconfig"
>>>  source "arch/arm/mach-rmobile/Kconfig"
>>> +source "arch/arm/mach-rzn1/Kconfig"
>>
>> Should this be in mach-rmobile (which, maybe, should be renamed to 
>> mach-renesas) ?
> 
> I vaguely recall that I discussed this with someone (possibly you), 
> likely on IRC. And I think the conclusion was there was a significant 
> enough difference (possibly Cortex-A7 versus A9?).
> 
> I don't have a strong preference, if moving to mach-rmobile makes sense, 
> let me know and I can give it a go.

I think it does make sense to keep all the renesas stuff in mach-rmobile 
. We can rename that to mach-renesas in some subsequent patch.

>>> +#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
>>> +void enable_caches(void)
>>> +{
>>
>> Why not enable icache with icache_enable() too ?
> 
> The I-cache is enabled quite early in arch/arm/cpu/armv7/start.S

Add a comment please.
Ralph Siemsen April 17, 2023, 8:44 p.m. UTC | #4
On Mon, Apr 17, 2023 at 10:30:26PM +0200, Marek Vasut wrote:
>I mean, if you drop 'CLK' and 'CLK_RENESAS' from this list, do they 
>still get selected because 'CLK_R8A06G032' is in this list ? If yes, 
>then drop them from this list, else keep them.

If I drop the first two, I get some kconfig warnings:

WARNING: unmet direct dependencies detected for CLK_R9A06G032
   Depends on [n]: CLK_RENESAS [=n]
   Selected by [y]:
   - ARCH_RZN1 [=y] && <choice>

And there is no output on the UART.

>>I don't have a strong preference, if moving to mach-rmobile makes 
>>sense, let me know and I can give it a go.
>
>I think it does make sense to keep all the renesas stuff in 
>mach-rmobile . We can rename that to mach-renesas in some subsequent 
>patch.

Okay, I will try moving it. Does this also then mean I should abandon 
ARCH_RZN1 in favour of ARCH_RMOBILE? This could be more challenging...

>>>Why not enable icache with icache_enable() too ?
>>
>>The I-cache is enabled quite early in arch/arm/cpu/armv7/start.S
>
>Add a comment please.

Done!

Ralph
Marek Vasut April 17, 2023, 10:23 p.m. UTC | #5
On 4/17/23 22:44, Ralph Siemsen wrote:
> On Mon, Apr 17, 2023 at 10:30:26PM +0200, Marek Vasut wrote:
>> I mean, if you drop 'CLK' and 'CLK_RENESAS' from this list, do they 
>> still get selected because 'CLK_R8A06G032' is in this list ? If yes, 
>> then drop them from this list, else keep them.
> 
> If I drop the first two, I get some kconfig warnings:
> 
> WARNING: unmet direct dependencies detected for CLK_R9A06G032
>    Depends on [n]: CLK_RENESAS [=n]
>    Selected by [y]:
>    - ARCH_RZN1 [=y] && <choice>
> 
> And there is no output on the UART.

Aha, so one has to list all of them deps. In that case, no change needed 
here.

>>> I don't have a strong preference, if moving to mach-rmobile makes 
>>> sense, let me know and I can give it a go.
>>
>> I think it does make sense to keep all the renesas stuff in 
>> mach-rmobile . We can rename that to mach-renesas in some subsequent 
>> patch.
> 
> Okay, I will try moving it. Does this also then mean I should abandon 
> ARCH_RZN1 in favour of ARCH_RMOBILE? This could be more challenging...

I think so, RZA1 is also not rmobile and I think it has its own RZA1 
thing already, see:
arch/arm/mach-rmobile/Kconfig:config RZA1

So in your case, it would be RZN1 , just like that.
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bd7fffcce0..8e2a30f852 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1031,6 +1031,21 @@  config ARCH_RMOBILE
 	imply SYS_THUMB_BUILD
 	imply ARCH_MISC_INIT if DISPLAY_CPUINFO
 
+config ARCH_RZN1
+	bool "Reneasa RZ/N1 SoC"
+	select CLK
+	select CLK_RENESAS
+	select CLK_R9A06G032
+	select DM
+	select DM_ETH
+	select DM_SERIAL
+	select PINCTRL
+	select PINCONF
+	select REGMAP
+	select SYSRESET
+	select SYSRESET_SYSCON
+	imply CMD_DM
+
 config ARCH_SNAPDRAGON
 	bool "Qualcomm Snapdragon SoCs"
 	select ARM64
@@ -2207,6 +2222,8 @@  source "arch/arm/mach-owl/Kconfig"
 
 source "arch/arm/mach-rmobile/Kconfig"
 
+source "arch/arm/mach-rzn1/Kconfig"
+
 source "arch/arm/mach-meson/Kconfig"
 
 source "arch/arm/mach-mediatek/Kconfig"
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index ac602aed9c..1ec95a87e1 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -76,6 +76,7 @@  machine-$(CONFIG_ARCH_ORION5X)		+= orion5x
 machine-$(CONFIG_ARCH_OWL)		+= owl
 machine-$(CONFIG_ARCH_RMOBILE)		+= rmobile
 machine-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip
+machine-$(CONFIG_ARCH_RZN1)		+= rzn1
 machine-$(CONFIG_ARCH_S5PC1XX)		+= s5pc1xx
 machine-$(CONFIG_ARCH_SNAPDRAGON)	+= snapdragon
 machine-$(CONFIG_ARCH_SOCFPGA)		+= socfpga
diff --git a/arch/arm/mach-rzn1/Kconfig b/arch/arm/mach-rzn1/Kconfig
new file mode 100644
index 0000000000..707895874d
--- /dev/null
+++ b/arch/arm/mach-rzn1/Kconfig
@@ -0,0 +1,18 @@ 
+if ARCH_RZN1
+
+choice
+	prompt "Target Renesas RZ/N1 SoC select"
+	default RZN1
+
+config RZN1
+	bool "Renesas ARM SoCs RZ/N1 (32bit)"
+	select CPU_V7A
+	select ARMV7_SET_CORTEX_SMPEN if !SPL
+	select SPL_ARMV7_SET_CORTEX_SMPEN if SPL
+
+endchoice
+
+config SYS_SOC
+	default "rzn1"
+
+endif
diff --git a/arch/arm/mach-rzn1/Makefile b/arch/arm/mach-rzn1/Makefile
new file mode 100644
index 0000000000..b20f845c0f
--- /dev/null
+++ b/arch/arm/mach-rzn1/Makefile
@@ -0,0 +1,3 @@ 
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y = cpu_info.o
diff --git a/arch/arm/mach-rzn1/cpu_info.c b/arch/arm/mach-rzn1/cpu_info.c
new file mode 100644
index 0000000000..37c2492b51
--- /dev/null
+++ b/arch/arm/mach-rzn1/cpu_info.c
@@ -0,0 +1,19 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <cpu_func.h>
+
+#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
+void enable_caches(void)
+{
+	dcache_enable();
+}
+#endif
+
+#ifdef CONFIG_DISPLAY_CPUINFO
+int print_cpuinfo(void)
+{
+	printf("CPU: Renesas Electronics RZ/N1\n");
+	return 0;
+}
+#endif