Skip to contentSkip to conversation

Renesas RZ/N1 SoC initial support

RFC PATCH Superseded Ralph Siemsen 5 participants 32 messages Feb 22, 2023 – Mar 8, 2023

Subsystems (7)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover Renesas RZ/N1 SoC initial support

The RZ/N1 is a family of SoC devices from Renesas [1], featuring ARM Cortex-A7 and/or Cortex-M3 CPU, industrial ethernet protocols, integrated Ethernet switch, and numerous peripherals.

This is a first step in upstreaming support for the RZ/N1 family. Currently it contains just enough to boot to the u-boot prompt. Additional patches will follow to support flash, SD, USB, Ethernet, etc.

This work is based on a vendor-supplied u-boot 2017.01 tree [2], which supports several eval boards, none of which I have access to. Instead development has been done on a Schneider RZN1 board, which is fairly similar to the Renesas RZ/N1D-DB Demo board.

[1] https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rz-mpus/rzn1
[2] https://github.com/renesas-rz/rzn1_u-boot/tree/rzn1-stable

Changes in v3:
- many tweaks to clock driver based on reviewer feedback
- rebased to u-boot v2023.04-rc2
- reviewer suggestions added to spkgimage.c
- many small cleanups, checkpatch, FIXMEs resolved

Changes in v2:
- rewrote the stand-alone spkg_utility to integrate into mkimage

Ralph Siemsen (9):
ARM: armv7: add non-SPL enable for Cortex SMPEN
clk: renesas: prepare for non-RCAR clock drivers
clk: renesas: add R906G032 driver
pinctrl: renesas: add R906G032 driver
ram: cadence: add driver for Cadence EDAC
dts: basic devicetree for Renesas RZ/N1 SoC
ARM: rzn1: basic support for Renesas RZ/N1 SoC
board: schneider: add RZN1 board support
tools: spkgimage: add Renesas SPKG format

 arch/arm/Kconfig                              |   17 +
 arch/arm/Makefile                             |    1 +
 arch/arm/cpu/armv7/Kconfig                    |    5 +
 arch/arm/dts/r9a06g032-rzn1-snarc.dts         |   51 +
 arch/arm/dts/r9a06g032.dtsi                   |  226 ++++
 arch/arm/mach-rzn1/Kconfig                    |   32 +
 arch/arm/mach-rzn1/Makefile                   |    3 +
 arch/arm/mach-rzn1/cpu_info.c                 |   19 +
 board/schneider/rzn1-snarc/Kconfig            |   18 +
 board/schneider/rzn1-snarc/Makefile           |    3 +
 board/schneider/rzn1-snarc/ddr_timing.c       |  140 +++
 .../jedec_ddr3_2g_x16_1333h_500_cl8.h         |  399 ++++++
 board/schneider/rzn1-snarc/rzn1.c             |   39 +
 board/schneider/rzn1-snarc/spkgimage.cfg      |   26 +
 boot/image.c                                  |    1 +
 configs/rzn1_snarc_defconfig                  |   21 +
 doc/mkimage.1                                 |   45 +
 drivers/clk/renesas/Kconfig                   |    8 +-
 drivers/clk/renesas/Makefile                  |    6 +-
 drivers/clk/renesas/r9a06g032-clocks.c        | 1077 +++++++++++++++++
 drivers/pinctrl/Makefile                      |    1 +
 drivers/pinctrl/renesas/Kconfig               |    7 +
 drivers/pinctrl/renesas/Makefile              |    1 +
 drivers/pinctrl/renesas/pinctrl-rzn1.c        |  379 ++++++
 drivers/ram/Kconfig                           |    1 +
 drivers/ram/Makefile                          |    2 +
 drivers/ram/cadence/Kconfig                   |   12 +
 drivers/ram/cadence/Makefile                  |    1 +
 drivers/ram/cadence/ddr_async.c               |  311 +++++
 drivers/ram/cadence/ddr_ctrl.c                |  414 +++++++
 drivers/ram/cadence/ddr_ctrl.h                |  175 +++
 include/configs/rzn1-snarc.h                  |   17 +
 include/dt-bindings/clock/r9a06g032-sysctrl.h |  148 +++
 include/dt-bindings/pinctrl/rzn1-pinctrl.h    |  141 +++
 include/image.h                               |    1 +
 tools/Makefile                                |    1 +
 tools/spkgimage.c                             |  330 +++++
 tools/spkgimage.h                             |   45 +
 38 files changed, 4120 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/r9a06g032-rzn1-snarc.dts
 create mode 100644 arch/arm/dts/r9a06g032.dtsi
 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
 create mode 100644 board/schneider/rzn1-snarc/Kconfig
 create mode 100644 board/schneider/rzn1-snarc/Makefile
 create mode 100644 board/schneider/rzn1-snarc/ddr_timing.c
 create mode 100644 board/schneider/rzn1-snarc/jedec_ddr3_2g_x16_1333h_500_cl8.h
 create mode 100644 board/schneider/rzn1-snarc/rzn1.c
 create mode 100644 board/schneider/rzn1-snarc/spkgimage.cfg
 create mode 100644 configs/rzn1_snarc_defconfig
 create mode 100644 drivers/clk/renesas/r9a06g032-clocks.c
 create mode 100644 drivers/pinctrl/renesas/pinctrl-rzn1.c
 create mode 100644 drivers/ram/cadence/Kconfig
 create mode 100644 drivers/ram/cadence/Makefile
 create mode 100644 drivers/ram/cadence/ddr_async.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.h
 create mode 100644 include/configs/rzn1-snarc.h
 create mode 100644 include/dt-bindings/clock/r9a06g032-sysctrl.h
 create mode 100644 include/dt-bindings/pinctrl/rzn1-pinctrl.h
 create mode 100644 tools/spkgimage.c
 create mode 100644 tools/spkgimage.h
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH v3 1/9 ARM: armv7: add non-SPL enable for Cortex SMPEN

Commit 2564fce7eea3 ("sunxi: move Cortex SMPEN setting into start.S") added SPL_ARMV7_SET_CORTEX_SMPEN to enable setting SMP bit. For platforms not using SPL boot, add the corresponding non-SPL config, so that CONFIG_IS_ENABLED(ARMV7_SET_CORTEX_SMPEN) works as expected.

---
This will be used by the following commit that adds ARCH_RZN1.

(no changes since v1)

 arch/arm/cpu/armv7/Kconfig | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/cpu/armv7/Kconfig +5 -0
index f1e4e26b8f..e33e53636a 100644
@@ -107,6 +107,11 @@ config ARMV7_LPAE
 	Say Y here to use the long descriptor page table format. This is
 	required if U-Boot runs in HYP mode.
 
+config ARMV7_SET_CORTEX_SMPEN
+	bool
+	help
+	  Enable the ARM Cortex ACTLR.SMP enable bit in U-boot.
+
 config SPL_ARMV7_SET_CORTEX_SMPEN
 	bool
 	help
Signature · 1 line
2.25.1
#2 lore raw

RFC PATCH v3 2/9 clk: renesas: prepare for non-RCAR clock drivers

In reply to Ralph Siemsen

Allow CONFIG_CLK_RENESAS to be set without bringing in RCAR-GEN2/3 code.

CONFIG_RENESAS is used in drivers/clk/Makefile to control recursion into the drivers/clk/renesas subdirectory. It also controls compilation of renesas-cpg-mssr.c support code for the RCAR-GEN2 and RCAR-GEN3 devices.

The support code contains platform specific hardware access (TMU_BASE), and it is not needed for other Renesas devices such as RZ/N1. Therefore, alter Makefile to build renesas-cpg-mssr.c only for RCAR-GEN2/3.

---

Changes in v3:
- added tags

 drivers/clk/renesas/Kconfig  | 2 +-
 drivers/clk/renesas/Makefile | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/clk/renesas/Kconfig +1 -1
index 1686410d6d..6788415eed 100644
@@ -1,6 +1,6 @@
 config CLK_RENESAS
 	bool "Renesas clock drivers"
-	depends on CLK && ARCH_RMOBILE
+	depends on CLK && (ARCH_RMOBILE || ARCH_RZN1)
 	help
 	  Enable support for clock present on Renesas RCar SoCs.
 
drivers/clk/renesas/Makefile +2 -3
index 8f82a7aa3e..a0d8c10bdb 100644
@@ -1,6 +1,5 @@
-obj-$(CONFIG_CLK_RENESAS) += renesas-cpg-mssr.o
 obj-$(CONFIG_CLK_RCAR_CPG_LIB) += rcar-cpg-lib.o
-obj-$(CONFIG_CLK_RCAR_GEN2) += clk-rcar-gen2.o
+obj-$(CONFIG_CLK_RCAR_GEN2) += clk-rcar-gen2.o renesas-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A774A1) += r8a774a1-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A774B1) += r8a774b1-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A774C0) += r8a774c0-cpg-mssr.o
@@ -10,7 +9,7 @@ obj-$(CONFIG_CLK_R8A7791) += r8a7791-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7792) += r8a7792-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7793) += r8a7791-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7794) += r8a7794-cpg-mssr.o
-obj-$(CONFIG_CLK_RCAR_GEN3) += clk-rcar-gen3.o
+obj-$(CONFIG_CLK_RCAR_GEN3) += clk-rcar-gen3.o renesas-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A7795) += r8a7795-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77960) += r8a7796-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77961) += r8a7796-cpg-mssr.o
Signature · 1 line
2.25.1
#3 lore raw

RFC PATCH v3 3/9 clk: renesas: add R906G032 driver

In reply to Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

Notable difference: this version avoids allocating a 'struct clk' for each clock source, as this is problematic before relocation. Instead, it uses the same approach as existing Renesas RCAR2/3 clock drivers, using a temporary structure filled on-the-fly.

---

Changes in v3:
- convert data table to explicit reg/bit numbers
- drop the unused scon, mirack, mirstat fields
- added some kernel docs to structures
- use enum for type field of struct r9a06g032_clkdesc
- cleanup macros for one assignment per line
- add a macro for top-most clock ID value ~0
- use dev_dbg() instead of debug/print
- minor reformatting, declarations before code, etc
- !foo instead of foo == 0
- IS_ERR / PTR_ERR where appropriate
- implement div_table handling
- remove some #if 0 old test code

 drivers/clk/renesas/Kconfig            |    6 +
 drivers/clk/renesas/Makefile           |    1 +
 drivers/clk/renesas/r9a06g032-clocks.c | 1077 ++++++++++++++++++++++++
 3 files changed, 1084 insertions(+)
 create mode 100644 drivers/clk/renesas/r9a06g032-clocks.c
drivers/clk/renesas/Kconfig +6 -0
index 6788415eed..bbc618f464 100644
@@ -130,3 +130,9 @@ config CLK_R8A779A0
 	depends on CLK_RCAR_GEN3
 	help
 	  Enable this to support the clocks on Renesas R8A779A0 SoC.
+
+config CLK_R9A06G032
+	bool "Renesas R9A06G032 clock driver"
+	depends on CLK_RENESAS
+	help
+	  Enable this to support the clocks on Renesas R9A06G032 SoC.
drivers/clk/renesas/Makefile +1 -0
index a0d8c10bdb..7f0ef28367 100644
@@ -19,3 +19,4 @@ obj-$(CONFIG_CLK_R8A77980) += r8a77980-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77990) += r8a77990-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A77995) += r8a77995-cpg-mssr.o
 obj-$(CONFIG_CLK_R8A779A0) += r8a779a0-cpg-mssr.o
+obj-$(CONFIG_CLK_R9A06G032) += r9a06g032-clocks.o
drivers/clk/renesas/r9a06g032-clocks.c new file +1077 -0

1,077 lines not on this page · raw message

Signature · 1 line
2.25.1
#4 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Also, can you please CC me on the entire series ?

Thanks

#5 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Quoted 1 line

Also, can you please CC me on the entire series ?

I've added you to series-cc for future versions. Note that some of the mails are currently stuck in moderation queue (too many recipients). I let patman pick the default recipients.

Ralph

#6 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 17 lines · Ralph Siemsen
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

Quoted 7 lines

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Is this still in sync with Linux 6.1.y ? That's the latest LTS .

Quoted 3 lines
Quoted 1 line

Also, can you please CC me on the entire series ?

I've added you to series-cc for future versions. Note that some of the mails are currently stuck in moderation queue (too many recipients). I let patman pick the default recipients.

Thanks

#7 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 24 lines · Marek Vasut
Quoted 23 lines · Ralph Siemsen
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

Quoted 3 lines
Quoted 1 line

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Is this still in sync with Linux 6.1.y ? That's the latest LTS .

Yes. Although the commits have different hashes than what I reported above, the 6.1.y LTS branch has the same changes.

Note that the u-boot version of the driver has changed considerably from the Linux version. In terms of pulling future diffs over, I would be concerned mostly about keeping the clock tables in sync. There have been a few mistakes found and fixed in those already.

Ralph

#8 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 25 lines · Ralph Siemsen
Quoted 24 lines · Marek Vasut
Quoted 23 lines · Ralph Siemsen
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Is this still in sync with Linux 6.1.y ? That's the latest LTS .

Yes. Although the commits have different hashes than what I reported above, the 6.1.y LTS branch has the same changes.

Then please include the Linux 6.1.y commit ID , or Torvalds' tree if that contains new fixes . Let's not use some old/downstream stuff .

Quoted 1 line

Note that the u-boot version of the driver has changed considerably from the Linux version. In terms of pulling future diffs over, I would be concerned mostly about keeping the clock tables in sync. There have been a few mistakes found and fixed in those already.

Are those fixes in mainline Linux ?

#9 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 26 lines · Marek Vasut
Quoted 25 lines · Ralph Siemsen
Quoted 24 lines · Marek Vasut
Quoted 23 lines · Ralph Siemsen
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Is this still in sync with Linux 6.1.y ? That's the latest LTS .

Yes. Although the commits have different hashes than what I reported above, the 6.1.y LTS branch has the same changes.

Then please include the Linux 6.1.y commit ID , or Torvalds' tree if that contains new fixes . Let's not use some old/downstream stuff .

I've amended the commit message as follows:

Clock driver for the Renesas RZ/N1 SoC family. This is based
on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c as found in commit 02693e11611e ("clk: renesas: r9a06g032: Repair grave increment error") included in Torvalds kernel v6.2. Identical code is in LTS 6.1.y.

Quoted 3 lines
Quoted 1 line

Note that the u-boot version of the driver has changed considerably from the Linux version. In terms of pulling future diffs over, I would be concerned mostly about keeping the clock tables in sync. There have been a few mistakes found and fixed in those already.

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
merged into 5.19, seems to be missing from LTS branches

Regards,
Ralph

#10 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 35 lines · Ralph Siemsen
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Ralph Siemsen
Quoted 24 lines · Marek Vasut
Quoted 23 lines · Ralph Siemsen
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ralph Siemsen

Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c.

For starters, can you please include the exact kernel version , ideally commit ID, from which this way pulled, so that future updates can pull in the diffs from that commit easily ?

Very reasonable request, but a bit difficult to give a concise answer. Originally I took the driver as found in the 5.15 kernel. The driver actually had not changed since 5.13 commit 6bd913f54f2f ("clk: renesas: r9a06g032: Switch to .determine_rate()"). So that's the starting point.

I incorporated subsequent changes to the clock tables and related cleanups. Those were only merged into Linux much later:

2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel f46efcc4746f clk: renesas: r9a06g032: Drop some unused fields 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description

Linux driver also had a few other commits, but these are not applicable to the u-boot version due to structural changes:

6bd913f54f2f clk: renesas: r9a06g032: Switch to .determine_rate() f2fb4fe62390 clk: renesas: Zero init clk_init_data 2182066d95c3 clk: renesas: r9a06g032: Probe possible children 885525c1e7e2 clk: renesas: r9a06g032: Export function to set dmamux 02693e11611e clk: renesas: r9a06g032: Repair grave increment error

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

So I would say it is "up to date" with the lastest Linux commit, even though it is based on an earlier version. Is there a good way to include the above in the commit message, succinctly?

Is this still in sync with Linux 6.1.y ? That's the latest LTS .

Yes. Although the commits have different hashes than what I reported above, the 6.1.y LTS branch has the same changes.

Then please include the Linux 6.1.y commit ID , or Torvalds' tree if that contains new fixes . Let's not use some old/downstream stuff .

Quoted 7 lines

I've amended the commit message as follows:

    Clock driver for the Renesas RZ/N1 SoC family. This is based on the Linux kernel drivers/clk/renesas/r9a06g032-clocks.c as found in commit 02693e11611e ("clk: renesas: r9a06g032: Repair grave
increment error")
    included in Torvalds kernel v6.2. Identical code is in LTS 6.1.y.

Thank you !

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Note that the u-boot version of the driver has changed considerably from the Linux version. In terms of pulling future diffs over, I would be concerned mostly about keeping the clock tables in sync. There have been a few mistakes found and fixed in those already.

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
  merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
   merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then. And please submit the missing patches for LTS branch inclusion too if possible, I guess they were missing Fixes: tag ?

#11 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 11 lines · Marek Vasut
Quoted 8 lines · Ralph Siemsen
Quoted 1 line · Marek Vasut

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel merged into 6.0, and also backported to earlier LTS branches 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then.

Okay, done.

Quoted 1 line

And please submit the missing patches for LTS branch inclusion too if possible, I guess they were missing Fixes: tag ?

Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/[email protected]/
Since it is new feature, I guess one could argue that the clock table fix is not needed in older LTS kernels, since no driver uses that clock. But most likely it was just overlooked. I'll check with Miquel.

Regards,
Ralph

#12 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 13 lines · Ralph Siemsen
Quoted 11 lines · Marek Vasut
Quoted 8 lines · Ralph Siemsen
Quoted 1 line · Marek Vasut

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel merged into 6.0, and also backported to earlier LTS branches 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then.

Quoted 8 lines

Okay, done.

Quoted 1 line

And please submit the missing patches for LTS branch inclusion too if possible, I guess they were missing Fixes: tag ?

Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/[email protected]/
Since it is new feature, I guess one could argue that the clock table fix is not needed in older LTS kernels, since no driver uses that clock. But most likely it was just overlooked. I'll check with Miquel.

Much appreciated, thanks !

+CC Miquel

#13 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Hello Marek & Ralph,

[email protected] wrote on Thu, 23 Feb 2023 01:12:49 +0100:

Quoted 18 lines · Ralph Siemsen
Quoted 17 lines · Marek Vasut
Quoted 11 lines · Ralph Siemsen
Quoted 8 lines · Marek Vasut
Quoted 1 line

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel merged into 6.0, and also backported to earlier LTS branches 2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then.

Okay, done.

Quoted 1 line

And please submit the missing patches for LTS branch inclusion too if >> possible, I guess they were missing Fixes: tag ?

Quoted 8 lines
Quoted 4 lines

Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/[email protected]/
Since it is new feature, I guess one could argue that the clock table > fix is not needed in older LTS kernels, since no driver uses that clock. But most likely it was just overlooked. I'll check with Miquel.

Much appreciated, thanks !

+CC Miquel

As Ralph rightly pointed out, even though the clock description was wrong there was no user at that time so I did not bother with a Fixes tag. Anyhow, as the change does only impact the RTC clock, it should be harmless to backport if you want.

Thanks,
Miquèl

#14 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 27 lines · Miquel Raynal

Hello Marek & Ralph,

[email protected] wrote on Thu, 23 Feb 2023 01:12:49 +0100:

Quoted 23 lines · Ralph Siemsen
Quoted 21 lines · Marek Vasut
Quoted 11 lines · Ralph Siemsen
Quoted 8 lines · Marek Vasut
Quoted 1 line

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
  merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
   merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then.

Okay, done.

Quoted 1 line

And please submit the missing patches for LTS branch inclusion too if >> possible, I guess they were missing Fixes: tag ?

Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/[email protected]/
Since it is new feature, I guess one could argue that the clock table > fix is not needed in older LTS kernels, since no driver uses that clock. But most likely it was just overlooked. I'll check with Miquel.

Quoted 8 lines
Quoted 3 lines

Much appreciated, thanks !

+CC Miquel

As Ralph rightly pointed out, even though the clock description was wrong there was no user at that time so I did not bother with a Fixes tag. Anyhow, as the change does only impact the RTC clock, it should be harmless to backport if you want.

Either way is fine by me, I just want to be sure the u-boot clock tables are in sync with Linux as much as possible, and can be easily resynced in the future, that's all.

#15 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Hi Marek,

[email protected] wrote on Thu, 23 Feb 2023 14:56:41 +0100:

Quoted 29 lines · Miquel Raynal
Quoted 28 lines

Hello Marek & Ralph,

[email protected] wrote on Thu, 23 Feb 2023 01:12:49 +0100:

Quoted 24 lines · Ralph Siemsen
Quoted 13 lines · Marek Vasut
Quoted 11 lines · Ralph Siemsen
Quoted 8 lines · Marek Vasut
Quoted 1 line

Are those fixes in mainline Linux ?

Yes, they are in mainline:
2dee50ab9e72 clk: renesas: r9a06g032: Fix UART clkgrp bitsel
  merged into 6.0, and also backported to earlier LTS branches
2a6da4a11f47 clk: renesas: r9a06g032: Fix the RTC hclock description
   merged into 5.19, seems to be missing from LTS branches

Use Linux 6.2.y as a base then.

Quoted 7 lines

Okay, done.

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

And please submit the missing patches for LTS branch inclusion too if >> possible, I guess they were missing Fixes: tag ?

Seems it was part of a series which added support for the RTC device:
https://lore.kernel.org/all/[email protected]/
Since it is new feature, I guess one could argue that the clock table > fix is not needed in older LTS kernels, since no driver uses that clock. But most likely it was just overlooked. I'll check with Miquel.

Much appreciated, thanks !

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

+CC Miquel

As Ralph rightly pointed out, even though the clock description was wrong there was no user at that time so I did not bother with a Fixes tag. Anyhow, as the change does only impact the RTC clock, it should be harmless to backport if you want.

Either way is fine by me, I just want to be sure the u-boot clock tables are in sync with Linux as much as possible, and can be easily resynced in the future, that's all.

Of course. The fix is mainline already, so on that regard we should be fine.

Thanks,
Miquèl

#16 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 9 lines · Miquel Raynal

Hi Marek,

[email protected] wrote on Thu, 23 Feb 2023 14:56:41 +0100:

Quoted 2 lines

Either way is fine by me, I just want to be sure the u-boot clock tables are in sync with Linux as much as possible, and can be easily resynced in the future, that's all.

Of course. The fix is mainline already, so on that regard we should be fine.

Right, so mainline has all the fixes, the only thing missing there is the "cleanup" of the clock tables, which I have done in the u-boot version under review. Assuming this is satisfactory, I will aim to get the same cleanup done on the clock tables in the kernel side, so they are in sync with u-boot.

Ralp

#17 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 8 lines · Ralph Siemsen
Quoted 7 lines · Miquel Raynal

Hi Marek,

[email protected] wrote on Thu, 23 Feb 2023 14:56:41 +0100:

Quoted 2 lines

Either way is fine by me, I just want to be sure the u-boot clock tables are in sync with Linux as much as possible, and can be easily resynced in the future, that's all.

Quoted 8 lines
Quoted 2 lines

Of course. The fix is mainline already, so on that regard we should be fine.

Right, so mainline has all the fixes, the only thing missing there is the "cleanup" of the clock tables, which I have done in the u-boot version under review. Assuming this is satisfactory, I will aim to get the same cleanup done on the clock tables in the kernel side, so they are in sync with u-boot.

Could you at least submit the clean up to Linux and then sync the result to U-Boot, and indicate the Linux clock table came from commit <something> with extra patch <link> on top ?

I think that would be best.

#18 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Hi Marek,

Quoted 4 lines · Marek Vasut

Could you at least submit the clean up to Linux and then sync the result to U-Boot, and indicate the Linux clock table came from commit <something> with extra patch <link> on top ?

Yes will do. I am refreshing my linux-side patch as we speak.

Ralph

#19 lore raw

Re: [RFC PATCH v3 3/9] clk: renesas: add R906G032 driver

Quoted 9 lines · Ralph Siemsen

Hi Marek,

Quoted 4 lines · Marek Vasut

Could you at least submit the clean up to Linux and then sync the result to U-Boot, and indicate the Linux clock table came from commit <something> with extra patch <link> on top ?

Yes will do. I am refreshing my linux-side patch as we speak.

Thanks !

#20 lore raw

RFC PATCH v3 4/9 pinctrl: renesas: add R906G032 driver

In reply to Ralph Siemsen

Pinctrl/pinconf driver for Renesas RZ/N1 (R906G032) SoC.

This is quite rudimentary right now, and only supports applying a default pin configuration as specified by the device tree.

---

(no changes since v1)

 drivers/pinctrl/Makefile                   |   1 +
 drivers/pinctrl/renesas/Kconfig            |   7 +
 drivers/pinctrl/renesas/Makefile           |   1 +
 drivers/pinctrl/renesas/pinctrl-rzn1.c     | 379 +++++++++++++++++++++
 include/dt-bindings/pinctrl/rzn1-pinctrl.h | 141 ++++++++
 5 files changed, 529 insertions(+)
 create mode 100644 drivers/pinctrl/renesas/pinctrl-rzn1.c
 create mode 100644 include/dt-bindings/pinctrl/rzn1-pinctrl.h
drivers/pinctrl/Makefile +1 -0
index 3b167d099f..450267732c 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_PINCTRL_INTEL) += intel/
 obj-$(CONFIG_ARCH_MTMIPS) += mtmips/
 obj-$(CONFIG_ARCH_NPCM)         += nuvoton/
 obj-$(CONFIG_ARCH_RMOBILE) += renesas/
+obj-$(CONFIG_ARCH_RZN1) += renesas/
 obj-$(CONFIG_PINCTRL_SANDBOX)	+= pinctrl-sandbox.o
 obj-$(CONFIG_PINCTRL_SUNXI)	+= sunxi/
 obj-$(CONFIG_PINCTRL_UNIPHIER)	+= uniphier/
drivers/pinctrl/renesas/Kconfig +7 -0
index 8f994d8d76..b707d7549b 100644
@@ -127,3 +127,10 @@ config PINCTRL_PFC_R7S72100
 	  Support pin multiplexing control on Renesas RZ/A1 R7S72100 SoCs.
 
 endif
+
+config PINCTRL_RZN1
+	bool "Renesas RZ/N1 R906G032 pin control driver"
+	depends on ARCH_RZN1
+	default y if ARCH_RZN1
+	help
+	  Support pin multiplexing control on Renesas RZ/N1 R906G032 SoCs.
drivers/pinctrl/renesas/Makefile +1 -0
index 1198c86855..39b2f65f2e 100644
@@ -18,3 +18,4 @@ obj-$(CONFIG_PINCTRL_PFC_R8A77990) += pfc-r8a77990.o
 obj-$(CONFIG_PINCTRL_PFC_R8A77995) += pfc-r8a77995.o
 obj-$(CONFIG_PINCTRL_PFC_R8A779A0) += pfc-r8a779a0.o
 obj-$(CONFIG_PINCTRL_PFC_R7S72100) += pfc-r7s72100.o
+obj-$(CONFIG_PINCTRL_RZN1) += pinctrl-rzn1.o
drivers/pinctrl/renesas/pinctrl-rzn1.c new file +379 -0

379 lines not on this page · raw message

include/dt-bindings/pinctrl/rzn1-pinctrl.h new file +141 -0

141 lines not on this page · raw message

Signature · 1 line
2.25.1
#21 lore raw

RFC PATCH v3 5/9 ram: cadence: add driver for Cadence EDAC

In reply to Ralph Siemsen

Driver for Cadence EDAC DDR controller, as found in the Renesas RZ/N1.

---

Changes in v3:
- assorted small cleanups
- support version 1.0 silicon (previously #if 0...)

 drivers/ram/Kconfig             |   1 +
 drivers/ram/Makefile            |   2 +
 drivers/ram/cadence/Kconfig     |  12 +
 drivers/ram/cadence/Makefile    |   1 +
 drivers/ram/cadence/ddr_async.c | 311 ++++++++++++++++++++++++
 drivers/ram/cadence/ddr_ctrl.c  | 414 ++++++++++++++++++++++++++++++++
 drivers/ram/cadence/ddr_ctrl.h  | 175 ++++++++++++++
 7 files changed, 916 insertions(+)
 create mode 100644 drivers/ram/cadence/Kconfig
 create mode 100644 drivers/ram/cadence/Makefile
 create mode 100644 drivers/ram/cadence/ddr_async.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.h
drivers/ram/Kconfig +1 -0
index e085119963..2b6d8f1c7b 100644
@@ -108,6 +108,7 @@ config IMXRT_SDRAM
 	  This driver is for the sdram memory interface with the SEMC.
 
 source "drivers/ram/aspeed/Kconfig"
+source "drivers/ram/cadence/Kconfig"
 source "drivers/ram/rockchip/Kconfig"
 source "drivers/ram/sifive/Kconfig"
 source "drivers/ram/stm32mp1/Kconfig"
drivers/ram/Makefile +2 -0
index 83948e2c43..e2d5e730d1 100644
@@ -22,3 +22,5 @@ obj-$(CONFIG_IMXRT_SDRAM) += imxrt_sdram.o
 obj-$(CONFIG_RAM_SIFIVE) += sifive/
 
 obj-$(CONFIG_ARCH_OCTEON) += octeon/
+
+obj-$(CONFIG_CADENCE_DDR_CTRL) += cadence/
drivers/ram/cadence/Kconfig new file +12 -0
new file mode 100644
index 0000000000..2d5469cb8e
@@ -0,0 +1,12 @@
+if RAM || SPL_RAM
+
+config CADENCE_DDR_CTRL
+	bool "Enable Cadence DDR controller"
+	depends on DM
+	help
+	  Enable support for Cadence DDR controller, as found on
+	  the Renesas RZ/N1 SoC. This controller has a large number
+	  of registers which need to be programmed, mostly using values
+	  obtained from Denali SOMA files via a TCL script.
+
+endif
drivers/ram/cadence/Makefile new file +1 -0
new file mode 100644
index 0000000000..16c7fe8488
@@ -0,0 +1 @@
+obj-$(CONFIG_CADENCE_DDR_CTRL) += ddr_async.o ddr_ctrl.o
drivers/ram/cadence/ddr_async.c new file +311 -0

311 lines not on this page · raw message

drivers/ram/cadence/ddr_ctrl.c new file +414 -0

414 lines not on this page · raw message

drivers/ram/cadence/ddr_ctrl.h new file +175 -0

175 lines not on this page · raw message

Signature · 1 line
2.25.1
#22 lore raw

Re: [RFC PATCH v3 5/9] ram: cadence: add driver for Cadence EDAC

Hi Ralph!

On February 22, 2023 thus sayeth Ralph Siemsen:

Quoted 9 lines

Driver for Cadence EDAC DDR controller, as found in the Renesas RZ/N1.

---

Changes in v3:
- assorted small cleanups
- support version 1.0 silicon (previously #if 0...)

Quoted 14 lines
 drivers/ram/Kconfig             |   1 +
 drivers/ram/Makefile            |   2 +
 drivers/ram/cadence/Kconfig     |  12 +
 drivers/ram/cadence/Makefile    |   1 +
 drivers/ram/cadence/ddr_async.c | 311 ++++++++++++++++++++++++
 drivers/ram/cadence/ddr_ctrl.c  | 414 ++++++++++++++++++++++++++++++++
 drivers/ram/cadence/ddr_ctrl.h  | 175 ++++++++++++++
 7 files changed, 916 insertions(+)
 create mode 100644 drivers/ram/cadence/Kconfig
 create mode 100644 drivers/ram/cadence/Makefile
 create mode 100644 drivers/ram/cadence/ddr_async.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.c
 create mode 100644 drivers/ram/cadence/ddr_ctrl.h

Love seeing more boards here, though I know of a few chips that use some type of cadence controller. I'm just curious if it would it make sense to name this with some type of Renesas specific branding?

~Bryan

#23 lore raw

Re: [RFC PATCH v3 5/9] ram: cadence: add driver for Cadence EDAC

Hi Bryan,

Quoted 5 lines · Bryan Brattlof

Hi Ralph!
Love seeing more boards here, though I know of a few chips that use some type of cadence controller. I'm just curious if it would it make sense to name this with some type of Renesas specific branding?

Indeed the this IP from Cadence likely is used in quite a few places. However it is usually quite difficult to figure out exactly which version of the IP is present, what bugs/workarounds are needed, etc.

I am fine with renaming this in a more renesas-specific manner (suggestions welcomed!). On the other hand, it would good to try and encourage having one driver for this, rather than a bunch of similar-but-not-quite-equivalent ones scattered about. Perhaps a non-specific name might help?

Ralph

#24 lore raw

Re: [RFC PATCH v3 5/9] ram: cadence: add driver for Cadence EDAC

Quoted 13 lines · Ralph Siemsen

Hi Bryan,

Quoted 5 lines · Bryan Brattlof

Hi Ralph!
Love seeing more boards here, though I know of a few chips that use some type of cadence controller. I'm just curious if it would it make sense to name this with some type of Renesas specific branding?

Indeed the this IP from Cadence likely is used in quite a few places. However it is usually quite difficult to figure out exactly which version of the IP is present, what bugs/workarounds are needed, etc.

Quoted 5 lines

I am fine with renaming this in a more renesas-specific manner (suggestions welcomed!). On the other hand, it would good to try and encourage having one driver for this, rather than a bunch of similar-but-not-quite-equivalent ones scattered about. Perhaps a non-specific name might help?

Can anyone offer guidance on the naming of the DDR controller? Other than this issue, I have v4 of this patch series ready to post.

Thanks!
Ralph

#25 lore raw

RFC PATCH v3 6/9 dts: basic devicetree for Renesas RZ/N1 SoC

In reply to Ralph Siemsen

This is taken from Linux kernel 5.17, and contains just bare minimum
functionality: CPU, UART and system timer.

Additional functionality (from newer kernel versions) will be added later. Note that the Linux side is under active development.

---
The following changes were made, compared with Linux 5.17:

1) Add node for system controller registers. Declare it as syscon to provide a regmap interface.

2) In the clock controller node (renesas,r9a06g032-sysctrl), replace regs with regmap.

3) Add syscon-reset node, making use of the syscon regmap.

4) Add syscon phandle to ddrctrl. Used for checking h/w version.

5) Simplify the compatible string for all the UARTS, as per doc/device-tree-bindings/serial/snps-dw-apb-uart.txt

I could not find a way to avoid 1) and 2). Putting "syscon" in the compatible string for the clock controller leads to a catch-22, where the driver fails to initialize, and then boot hangs.

Changes in v3:
- add syscon phandle to ddrctl
- simplify UART compatible strings

 arch/arm/dts/r9a06g032.dtsi                   | 226 ++++++++++++++++++
 include/dt-bindings/clock/r9a06g032-sysctrl.h | 148 ++++++++++++
 2 files changed, 374 insertions(+)
 create mode 100644 arch/arm/dts/r9a06g032.dtsi
 create mode 100644 include/dt-bindings/clock/r9a06g032-sysctrl.h
arch/arm/dts/r9a06g032.dtsi new file +226 -0
new file mode 100644
index 0000000000..e0ddffb074
@@ -0,0 +1,226 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Base Device Tree Source for the Renesas RZ/N1D (R9A06G032)
+ *
+ * Copyright (C) 2018 Renesas Electronics Europe Limited
+ *
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/r9a06g032-sysctrl.h>
+
+/ {
+	compatible = "renesas,r9a06g032";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <0>;
+			clocks = <&sysctrl R9A06G032_CLK_A7MP>;
+		};
+
+		cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a7";
+			reg = <1>;
+			clocks = <&sysctrl R9A06G032_CLK_A7MP>;
+			enable-method = "renesas,r9a06g032-smp";
+			cpu-release-addr = <0 0x4000c204>;
+		};
+	};
+
+	ext_jtag_clk: extjtagclk {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <0>;
+	};
+
+	ext_mclk: extmclk {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <40000000>;
+	};
+
+	ext_rgmii_ref: extrgmiiref {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <0>;
+	};
+
+	ext_rtc_clk: extrtcclk {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <0>;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		interrupt-parent = <&gic>;
+		ranges;
+
+		plat_regs: system-controller@4000c000 {
+			compatible = "syscon";
+			reg = <0x4000c000 0x1000>;
+			u-boot,dm-pre-reloc;
+		};
+
+		sysctrl: clock {
+			compatible = "renesas,r9a06g032-sysctrl";
+			#clock-cells = <1>;
+			regmap = <&plat_regs>;
+			u-boot,dm-pre-reloc;
+
+			clocks = <&ext_mclk>, <&ext_rtc_clk>,
+					<&ext_jtag_clk>, <&ext_rgmii_ref>;
+			clock-names = "mclk", "rtc", "jtag", "rgmii_ref_ext";
+		};
+
+		ddrctrl: memory-controller@4000d000 {
+			compatible = "cadence,ddr-ctrl";
+			reg = <0x4000d000 0x1000>, <0x4000e000 0x100>;
+			reg-names = "ddrc", "phy";
+			interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&sysctrl R9A06G032_CLK_DDRC>, <&sysctrl R9A06G032_HCLK_DDRC>;
+			clock-names = "clk_ddrc", "hclk_ddrc";
+			syscon = <&plat_regs>;
+			status = "disabled";
+		};
+
+		uart0: serial@40060000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x40060000 0x400>;
+			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART0>, <&sysctrl R9A06G032_HCLK_UART0>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart1: serial@40061000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x40061000 0x400>;
+			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART1>, <&sysctrl R9A06G032_HCLK_UART1>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart2: serial@40062000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x40062000 0x400>;
+			interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART2>, <&sysctrl R9A06G032_HCLK_UART2>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart3: serial@50000000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x50000000 0x400>;
+			interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART3>, <&sysctrl R9A06G032_HCLK_UART3>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart4: serial@50001000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x50001000 0x400>;
+			interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART4>, <&sysctrl R9A06G032_HCLK_UART4>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart5: serial@50002000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x50002000 0x400>;
+			interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART5>, <&sysctrl R9A06G032_HCLK_UART5>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart6: serial@50003000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x50003000 0x400>;
+			interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART6>, <&sysctrl R9A06G032_HCLK_UART6>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		uart7: serial@50004000 {
+			compatible = "snps,dw-apb-uart";
+			reg = <0x50004000 0x400>;
+			interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
+			reg-shift = <2>;
+			reg-io-width = <4>;
+			clocks = <&sysctrl R9A06G032_CLK_UART7>, <&sysctrl R9A06G032_HCLK_UART7>;
+			clock-names = "baudclk", "apb_pclk";
+			status = "disabled";
+		};
+
+		pinctrl: pinctrl@40067000 {
+			compatible = "renesas,r9a06g032-pinctrl", "renesas,rzn1-pinctrl";
+			reg = <0x40067000 0x1000>, <0x51000000 0x480>;
+			clocks = <&sysctrl R9A06G032_HCLK_PINCONFIG>;
+			clock-names = "bus";
+			status = "disabled";
+		};
+
+		gic: interrupt-controller@44101000 {
+			compatible = "arm,gic-400", "arm,cortex-a7-gic";
+			interrupt-controller;
+			#interrupt-cells = <3>;
+			reg = <0x44101000 0x1000>, /* Distributer */
+			      <0x44102000 0x2000>, /* CPU interface */
+			      <0x44104000 0x2000>, /* Virt interface control */
+			      <0x44106000 0x2000>; /* Virt CPU interface */
+			interrupts =
+				<GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
+		};
+	};
+
+	timer {
+		compatible = "arm,cortex-a7-timer",
+			     "arm,armv7-timer";
+		interrupt-parent = <&gic>;
+		arm,cpu-registers-not-fw-configured;
+		always-on;
+		interrupts =
+			<GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+			<GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+			<GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+			<GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
+	};
+
+	reboot {
+		compatible = "syscon-reboot";
+		regmap = <&plat_regs>;
+		offset = <0x198>;       /* sysctrl.RSTEN */
+		mask = <0x40>;          /* bit 6 = SWRST_REQ */
+		value = <0x40>;
+	};
+};
include/dt-bindings/clock/r9a06g032-sysctrl.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
2.25.1
#26 lore raw

RFC PATCH v3 7/9 ARM: rzn1: basic support for Renesas RZ/N1 SoC

In reply to Ralph Siemsen

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.

---

(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
arch/arm/Kconfig +17 -0
index bd7fffcce0..8e2a30f852 100644
@@ -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"
arch/arm/Makefile +1 -0
index ac602aed9c..1ec95a87e1 100644
@@ -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
arch/arm/mach-rzn1/Kconfig new file +18 -0
new file mode 100644
index 0000000000..707895874d
@@ -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
arch/arm/mach-rzn1/Makefile new file +3 -0
new file mode 100644
index 0000000000..b20f845c0f
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-y = cpu_info.o
arch/arm/mach-rzn1/cpu_info.c new file +19 -0
new file mode 100644
index 0000000000..37c2492b51
@@ -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
Signature · 1 line
2.25.1
#27 lore raw

RFC PATCH v3 8/9 board: schneider: add RZN1 board support

In reply to Ralph Siemsen

Add support for Schneider Electronics RZ/N1D and RZ/N1S boards, which are based on the Reneasas RZ/N1 SoC devices.

The intention is to support both boards using a single defconfig, and to handle the differences at runtime.

---

Changes in v3:
- rename board LCES to rzn1-snarc
- move CONFIG_SYS_NS16550_MEM32 to Kconfig
- define CFG_SYS_INIT_RAM_{ADDR,SIZE}
- removed debug uart settings from defconfig

 arch/arm/dts/r9a06g032-rzn1-snarc.dts         |  51 +++
 arch/arm/mach-rzn1/Kconfig                    |  14 +
 board/schneider/rzn1-snarc/Kconfig            |  18 +
 board/schneider/rzn1-snarc/Makefile           |   3 +
 board/schneider/rzn1-snarc/ddr_timing.c       | 140 ++++++
 .../jedec_ddr3_2g_x16_1333h_500_cl8.h         | 399 ++++++++++++++++++
 board/schneider/rzn1-snarc/rzn1.c             |  39 ++
 configs/rzn1_snarc_defconfig                  |  21 +
 include/configs/rzn1-snarc.h                  |  17 +
 9 files changed, 702 insertions(+)
 create mode 100644 arch/arm/dts/r9a06g032-rzn1-snarc.dts
 create mode 100644 board/schneider/rzn1-snarc/Kconfig
 create mode 100644 board/schneider/rzn1-snarc/Makefile
 create mode 100644 board/schneider/rzn1-snarc/ddr_timing.c
 create mode 100644 board/schneider/rzn1-snarc/jedec_ddr3_2g_x16_1333h_500_cl8.h
 create mode 100644 board/schneider/rzn1-snarc/rzn1.c
 create mode 100644 configs/rzn1_snarc_defconfig
 create mode 100644 include/configs/rzn1-snarc.h
arch/arm/dts/r9a06g032-rzn1-snarc.dts new file +51 -0
new file mode 100644
index 0000000000..abb269cc21
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for Schneider RZ/N1 Board
+ *
+ * Based on r9a06g032-rzn1d400-db.dts
+ */
+
+/dts-v1/;
+
+#include "r9a06g032.dtsi"
+#include <dt-bindings/pinctrl/rzn1-pinctrl.h>
+
+/ {
+	model = "Schneider RZ/N1 Board";
+	compatible = "schneider,rzn1", "renesas,r9a06g032";
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x80000000 0x10000000>;
+	};
+};
+
+&ddrctrl {
+	status = "okay";
+};
+
+&pinctrl {
+	status = "okay";
+
+	pins_uart0: pins_uart0 {
+		pinmux = <
+			RZN1_PINMUX(103, RZN1_FUNC_UART0_I)     /* UART0_TXD */
+			RZN1_PINMUX(104, RZN1_FUNC_UART0_I)     /* UART0_RXD */
+			>;
+		bias-disable;
+	};
+};
+
+&uart0 {
+	pinctrl-0 = <&pins_uart0>;
+	pinctrl-names = "default";
+	status = "okay";
+};
arch/arm/mach-rzn1/Kconfig +14 -0
index 707895874d..4b13afbb32 100644
@@ -15,4 +15,18 @@ endchoice
 config SYS_SOC
 	default "rzn1"
 
+choice
+	prompt "Board select"
+	default TARGET_SCHNEIDER_RZN1
+
+config TARGET_SCHNEIDER_RZN1
+	bool "Schneider RZN1 board"
+	help
+	  Support the Schneider RZN1D and RZN1S boards, which are based
+	  on the Renesas RZ/N1 SoC.
+
+endchoice
+
+source "board/schneider/rzn1-snarc/Kconfig"
+
 endif
board/schneider/rzn1-snarc/Kconfig new file +18 -0
new file mode 100644
index 0000000000..bb6d394077
@@ -0,0 +1,18 @@
+if TARGET_SCHNEIDER_RZN1
+
+config TEXT_BASE
+	default 0x20040000 if ARCH_RZN1
+
+config SYS_MONITOR_LEN
+	default 524288 if ARCH_RZN1
+
+config SYS_BOARD
+	default "rzn1-snarc"
+
+config SYS_VENDOR
+	default "schneider"
+
+config SYS_CONFIG_NAME
+	default "rzn1-snarc"
+
+endif
board/schneider/rzn1-snarc/Makefile new file +3 -0
new file mode 100644
index 0000000000..95c151898b
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0+
+
+obj-y	:= rzn1.o ddr_timing.o
board/schneider/rzn1-snarc/ddr_timing.c new file +140 -0

140 lines not on this page · raw message

board/schneider/rzn1-snarc/jedec_ddr3_2g_x16_1333h_500_cl8.h new file +399 -0

399 lines not on this page · raw message

board/schneider/rzn1-snarc/rzn1.c new file +39 -0
new file mode 100644
index 0000000000..a6cb21822f
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <dm.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_init(void)
+{
+	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
+
+	return 0;
+}
+
+int dram_init(void)
+{
+	struct udevice *dev;
+	int err;
+
+	/* This will end up calling cadence_ddr_probe() */
+	err = uclass_get_device(UCLASS_RAM, 0, &dev);
+	if (err) {
+		debug("DRAM init failed: %d\n", err);
+		return err;
+	}
+
+	if (fdtdec_setup_mem_size_base() != 0)
+		return -EINVAL;
+
+	return 0;
+}
+
+int dram_init_banksize(void)
+{
+	fdtdec_setup_memory_banksize();
+
+	return 0;
+}
configs/rzn1_snarc_defconfig new file +21 -0
new file mode 100644
index 0000000000..f0df13bcd9
@@ -0,0 +1,21 @@
+CONFIG_ARM=y
+CONFIG_SYS_ARCH_TIMER=y
+CONFIG_SYS_THUMB_BUILD=y
+CONFIG_ARCH_RZN1=y
+CONFIG_SYS_MALLOC_LEN=0xb0000
+CONFIG_SYS_MALLOC_F_LEN=0x800
+CONFIG_NR_DRAM_BANKS=1
+CONFIG_DEFAULT_DEVICE_TREE="r9a06g032-rzn1-snarc"
+CONFIG_SYS_LOAD_ADDR=0x80008000
+CONFIG_SYS_MEMTEST_START=0x80000000
+CONFIG_SYS_MEMTEST_END=0x8fffffff
+CONFIG_CMD_MEMTEST=y
+CONFIG_SYS_ALT_MEMTEST=y
+# CONFIG_SYS_ALT_MEMTEST_BITFLIP is not set
+CONFIG_CMD_CLK=y
+CONFIG_OF_CONTROL=y
+CONFIG_RAM=y
+CONFIG_CADENCE_DDR_CTRL=y
+CONFIG_SYS_NS16550=y
+CONFIG_SYS_NS16550_MEM32=y
+# CONFIG_EFI_LOADER is not set
include/configs/rzn1-snarc.h new file +17 -0
new file mode 100644
index 0000000000..b97cb48eaa
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Configuration settings for the Schneider RZ/N1 board
+ */
+
+#ifndef __RZN1_H
+#define __RZN1_H
+
+/* Internal RAM */
+#define CFG_SYS_INIT_RAM_ADDR	0x20000000
+#define CFG_SYS_INIT_RAM_SIZE	(1 * 1024 * 1024)
+
+/* DDR */
+#define CFG_SYS_SDRAM_BASE	0x80000000
+#define CFG_SYS_SDRAM_SIZE	(256 * 1024 * 1024)
+
+#endif	/* __RZN1_H */
Signature · 1 line
2.25.1
#28 lore raw

RFC PATCH v3 9/9 tools: spkgimage: add Renesas SPKG format

In reply to Ralph Siemsen

Renesas RZ/N1 devices contain BootROM code that loads a custom SPKG image from QSPI, NAND or USB DFU. Support this format in mkimage tool.

SPKGs can optionally be signed, however creation of signed SPKG is not currently supported.

Example of how to use it:

tools/mkimage -n board/schneider/rzn1-snarc/spkgimage.cfg \
	-T spkgimage -a 0x20040000 -e 0x20040000 \
	-d u-boot.bin u-boot.bin.spkg

The config file (spkgimage.cfg in this example) contains additional parameters such as NAND ECC settings.

---

Changes in v3:
- provide definition of __packed (as done in kwbimage.h)
- explain why a local copy of roundup() is needed
- document spkgimage in doc/mkimage.1
- add range checks when parsing config file values
- add line numbers for reporting errors in config file
- rename SPKG_HEADER_SIGNATURE to SPKG_HEADER_MARKER
- fix segfault when image is padded by less than 4 bytes
- minor style and typo fixes

Changes in v2:
- rewrote the stand-alone spkg_utility to integrate into mkimage

 board/schneider/rzn1-snarc/spkgimage.cfg |  26 ++
 boot/image.c                             |   1 +
 doc/mkimage.1                            |  45 ++++
 include/image.h                          |   1 +
 tools/Makefile                           |   1 +
 tools/spkgimage.c                        | 330 +++++++++++++++++++++++
 tools/spkgimage.h                        |  45 ++++
 7 files changed, 449 insertions(+)
 create mode 100644 board/schneider/rzn1-snarc/spkgimage.cfg
 create mode 100644 tools/spkgimage.c
 create mode 100644 tools/spkgimage.h
board/schneider/rzn1-snarc/spkgimage.cfg new file +26 -0
new file mode 100644
index 0000000000..b5faf96b00
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# (C) Copyright 2022 Schneider Electric
+#
+# SPKG image header, for booting on RZ/N1
+
+# b[35:32] SPKG version
+VERSION			1
+
+# b[42:41]  ECC Block size: 0=256 bytes, 1=512 bytes, 2=1024 bytes
+NAND_ECC_BLOCK_SIZE	1
+
+# b[45]     NAND enable (boolean)
+NAND_ECC_ENABLE		1
+
+# b[50:48]  ECC Scheme: 0=BCH2 1=BCH4 2=BCH8 3=BCH16 4=BCH24 5=BCH32
+NAND_ECC_SCHEME		3
+
+# b[63:56]  ECC bytes per block
+NAND_BYTES_PER_ECC_BLOCK 28
+
+# Provide dummy BLp header (boolean)
+ADD_DUMMY_BLP		1
+
+# Pad the image to a multiple of
+PADDING			64K
boot/image.c +1 -0
index 958dbf8534..5c4f9b807d 100644
@@ -181,6 +181,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_SUNXI_EGON, "sunxi_egon",  "Allwinner eGON Boot Image" },
 	{	IH_TYPE_SUNXI_TOC0, "sunxi_toc0",  "Allwinner TOC0 Boot Image" },
 	{	IH_TYPE_FDT_LEGACY, "fdt_legacy", "legacy Image with Flat Device Tree ", },
+	{	IH_TYPE_RENESAS_SPKG, "spkgimage", "Renesas SPKG Image" },
 	{	-1,		    "",		  "",			},
 };
 
doc/mkimage.1 +45 -0

51 lines not on this page · raw message

include/image.h +1 -0
index 7717a4c13d..acfbb6a53a 100644
@@ -230,6 +230,7 @@ enum image_type_t {
 	IH_TYPE_SUNXI_EGON,		/* Allwinner eGON Boot Image */
 	IH_TYPE_SUNXI_TOC0,		/* Allwinner TOC0 Boot Image */
 	IH_TYPE_FDT_LEGACY,		/* Binary Flat Device Tree Blob	in a Legacy Image */
+	IH_TYPE_RENESAS_SPKG,		/* Renesas SPKG image */
 
 	IH_TYPE_COUNT,			/* Number of image types */
 };
tools/Makefile +1 -0
index e13effbb66..1d7abcb916 100644
@@ -125,6 +125,7 @@ dumpimage-mkimage-objs := aisimage.o \
 			stm32image.o \
 			$(ROCKCHIP_OBS) \
 			socfpgaimage.o \
+			spkgimage.o \
 			sunxi_egon.o \
 			lib/crc16-ccitt.o \
 			lib/hash-checksum.o \
tools/spkgimage.c new file +330 -0

330 lines not on this page · raw message

tools/spkgimage.h new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.25.1
Reviewed-by on v3 9/9
#29 lore raw

Re: [RFC PATCH v3 9/9] tools: spkgimage: add Renesas SPKG format

Hi Ralph,

Quoted 43 lines · Ralph Siemsen

Renesas RZ/N1 devices contain BootROM code that loads a custom SPKG image from QSPI, NAND or USB DFU. Support this format in mkimage tool.

SPKGs can optionally be signed, however creation of signed SPKG is not currently supported.

Example of how to use it:

tools/mkimage -n board/schneider/rzn1-snarc/spkgimage.cfg \
-T spkgimage -a 0x20040000 -e 0x20040000 \
-d u-boot.bin u-boot.bin.spkg

The config file (spkgimage.cfg in this example) contains additional parameters such as NAND ECC settings.

---

Changes in v3:
- provide definition of __packed (as done in kwbimage.h)
- explain why a local copy of roundup() is needed
- document spkgimage in doc/mkimage.1
- add range checks when parsing config file values
- add line numbers for reporting errors in config file
- rename SPKG_HEADER_SIGNATURE to SPKG_HEADER_MARKER
- fix segfault when image is padded by less than 4 bytes
- minor style and typo fixes

Changes in v2:
- rewrote the stand-alone spkg_utility to integrate into mkimage

 board/schneider/rzn1-snarc/spkgimage.cfg |  26 ++
 boot/image.c                             |   1 +
 doc/mkimage.1                            |  45 ++++
 include/image.h                          |   1 +
 tools/Makefile                           |   1 +
 tools/spkgimage.c                        | 330 +++++++++++++++++++++++
 tools/spkgimage.h                        |  45 ++++
 7 files changed, 449 insertions(+)
 create mode 100644 board/schneider/rzn1-snarc/spkgimage.cfg
 create mode 100644 tools/spkgimage.c
 create mode 100644 tools/spkgimage.h

[..]

Can you please add some details to doc/ for this SoC and how it boots, the use of mkimage, etc.?

Also as a follow-on, can you add a binman entry type for this so that building a functioning image is automatic?

Finally, please add comments to struct spkg_hdr members below

Quoted 52 lines
tools/spkgimage.h new file +45 -1
new file mode 100644
index 0000000000..7be127b50f
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+/*
+ * Renesas RZ/N1 Package Table format
+ * (C) 2015-2016 Renesas Electronics Europe, LTD
+ * All rights reserved.
+ *
+ * Converted to mkimage plug-in
+ * (C) Copyright 2022 Schneider Electric
+ */
+
+#ifndef _SPKGIMAGE_H_
+#define _SPKGIMAGE_H_
+
+#ifdef __GNUC__
+#define __packed __attribute((packed))
+#else
+#define __packed
+#endif
+
+#define SPKG_HEADER_MARKER     {'R', 'Z', 'N', '1'}
+#define SPKG_HEADER_SIZE       24
+#define SPKG_HEADER_COUNT      8
+#define SPKG_BLP_SIZE          264
+#define SPKG_CRC_SIZE          4
+
+/* SPKG header */
+struct spkg_hdr {
+       uint8_t         marker[4];      /* aka magic */
+       uint8_t         version;
+       uint8_t         ecc;
+       uint8_t         ecc_scheme;
+       uint8_t         ecc_bytes;
+       uint32_t        payload_length; /* only HIGHER 24 bits */
+       uint32_t        load_address;
+       uint32_t        execution_offset;
+       uint32_t        crc; /* of this header */
+} __packed;
+
+struct spkg_file {
+       struct spkg_hdr header[SPKG_HEADER_COUNT];
+       uint8_t         payload[0];
+       /* then the CRC */
+} __packed;
+
+#endif
--
Quoted 2 lines

2.25.1

Regards,
Simon

#30 lore raw

Re: [RFC PATCH v3 9/9] tools: spkgimage: add Renesas SPKG format

Hi Simon,

Thanks for your review!

Quoted 3 lines · Simon Glass

Can you please add some details to doc/ for this SoC and how it boots, the use of mkimage, etc.?

Sure, I will cobble something together. Any particular good examples to look at for inspiration?

Quoted 2 lines

Also as a follow-on, can you add a binman entry type for this so that building a functioning image is automatic?

I'm talking a look at this as well. In this case though, it would just automate the call to mkimage, as there are no other binaries.

Quoted 1 line

Finally, please add comments to struct spkg_hdr members below

Yes, although they will be pretty much verbatim from the user manual, which documents the format. The docs are available publicly, but you need to click through a few links to reach them.

Regards,
Ralph

#31 lore raw

Re: [RFC PATCH v3 9/9] tools: spkgimage: add Renesas SPKG format

Hi Ralph,

Quoted 5 lines · Ralph Siemsen

Hi Simon,

Thanks for your review!

Quoted 7 lines
Quoted 3 lines · Simon Glass

Can you please add some details to doc/ for this SoC and how it boots, the use of mkimage, etc.?

Sure, I will cobble something together. Any particular good examples to look at for inspiration?

You could try doc/board/rockchip

Quoted 4 lines
Quoted 3 lines

Also as a follow-on, can you add a binman entry type for this so that building a functioning image is automatic?

Quoted 9 lines

I'm talking a look at this as well. In this case though, it would just automate the call to mkimage, as there are no other binaries.

Quoted 1 line

Finally, please add comments to struct spkg_hdr members below

Yes, although they will be pretty much verbatim from the user manual, which documents the format. The docs are available publicly, but you need to click through a few links to reach them.

OK. Still, it is handy to have it in the code. Downloading a PDF to understand the code it not great.

Regards,
Simon