Skip to contentSkip to conversation

arm: Add Analog Devices SC5xx Machine Type

PATCH Superseded Greg Malysa 3 participants 9 messages Apr 11, 2024 – Apr 12, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover arm: Add Analog Devices SC5xx Machine Type

This series adds support for the ADI SC5xx machine type and includes two core drivers that are required for being able to boot any board--a UART driver and the clock tree driver. Our corresponding Linux support relies on u-boot configuring the clocks correctly before booting, so it is not possible to boot any board without the CGU/CDU configuration happening here. The clock tree itself is only used by the UART in this minimal patch set, but is of course broadly useful for all other peripheral drivers to be submitted in future patch sets. There are also no board files or defconfigs included here, but some common definitions that will be used to build board files currently are.

Some of the configuration code in dmcinit and clkinit is quite scary and causes a lot of checkpatch violations. It is modified from code initially provided by ADI, but it has not been fully rewritten. There's a question of how important it is to clean up this code--it has some quality violations, but it has been in use (including in production) for over two years and is known to work for performing the low level SoC initialization, while a rewrite might introduce bugs that could take a significant amount of time to detect in the future.

Please provide any feedback or comments that will be helpful in creating a v2 of this patch that will be ready to submit for inclusion into the main tree, as well as general observations that we should consider in other driver patches before submitting them.

Thank you!

Nathan Barrett-Morrison (3):
arch: arm: Add Analog Devices SC5xx machine type
drivers: clk: adi: Add in SC5XX-family clock driver
drivers: serial: Add in UART for ADI SC5XX-family processors

 MAINTAINERS                                  |  15 +
 arch/arm/Kconfig                             |   6 +
 arch/arm/Makefile                            |   1 +
 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h  | 115 +++
 arch/arm/include/asm/arch-adi/sc5xx/soc.h    |  18 +
 arch/arm/include/asm/arch-adi/sc5xx/spl.h    |  41 +
 arch/arm/include/asm/mach-types.h            |   4 +
 arch/arm/mach-sc5xx/Kconfig                  | 464 +++++++++
 arch/arm/mach-sc5xx/Makefile                 |  19 +
 arch/arm/mach-sc5xx/config.mk                |  21 +
 arch/arm/mach-sc5xx/init/Makefile            |  11 +
 arch/arm/mach-sc5xx/init/clkinit.c           | 543 +++++++++++
 arch/arm/mach-sc5xx/init/clkinit.h           |  18 +
 arch/arm/mach-sc5xx/init/dmcinit.c           | 973 +++++++++++++++++++
 arch/arm/mach-sc5xx/init/dmcinit.h           |  29 +
 arch/arm/mach-sc5xx/init/init.c              |  68 ++
 arch/arm/mach-sc5xx/init/init.h              |  37 +
 arch/arm/mach-sc5xx/init/mem/is43tr16512bl.h |  63 ++
 arch/arm/mach-sc5xx/init/mem/mt41k128m16jt.h |  51 +
 arch/arm/mach-sc5xx/init/mem/mt41k512m16ha.h |  51 +
 arch/arm/mach-sc5xx/init/mem/mt47h128m16rt.h |  50 +
 arch/arm/mach-sc5xx/rcu.c                    |  22 +
 arch/arm/mach-sc5xx/sc57x.c                  |  21 +
 arch/arm/mach-sc5xx/sc58x.c                  |  21 +
 arch/arm/mach-sc5xx/sc59x.c                  |  32 +
 arch/arm/mach-sc5xx/sc59x_64.c               |  36 +
 arch/arm/mach-sc5xx/soc.c                    | 142 +++
 arch/arm/mach-sc5xx/spl.c                    | 140 +++
 drivers/clk/Kconfig                          |   1 +
 drivers/clk/Makefile                         |   1 +
 drivers/clk/adi/Kconfig                      |  83 ++
 drivers/clk/adi/Makefile                     |  16 +
 drivers/clk/adi/clk-adi-pll.c                |  94 ++
 drivers/clk/adi/clk-adi-sc57x.c              | 205 ++++
 drivers/clk/adi/clk-adi-sc58x.c              | 221 +++++
 drivers/clk/adi/clk-adi-sc594.c              | 230 +++++
 drivers/clk/adi/clk-adi-sc598.c              | 307 ++++++
 drivers/clk/adi/clk-shared.c                 |  48 +
 drivers/clk/adi/clk.h                        | 122 +++
 drivers/serial/Makefile                      |   1 +
 drivers/serial/serial_adi_uart4.c            | 228 +++++
 include/configs/sc_adi_common.h              | 226 +++++
 include/dt-bindings/clock/adi-sc5xx-clock.h  | 271 ++++++
 43 files changed, 5066 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/soc.h
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/spl.h
 create mode 100644 arch/arm/mach-sc5xx/Kconfig
 create mode 100644 arch/arm/mach-sc5xx/Makefile
 create mode 100644 arch/arm/mach-sc5xx/config.mk
 create mode 100644 arch/arm/mach-sc5xx/init/Makefile
 create mode 100644 arch/arm/mach-sc5xx/init/clkinit.c
 create mode 100644 arch/arm/mach-sc5xx/init/clkinit.h
 create mode 100644 arch/arm/mach-sc5xx/init/dmcinit.c
 create mode 100644 arch/arm/mach-sc5xx/init/dmcinit.h
 create mode 100644 arch/arm/mach-sc5xx/init/init.c
 create mode 100644 arch/arm/mach-sc5xx/init/init.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/is43tr16512bl.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt41k128m16jt.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt41k512m16ha.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt47h128m16rt.h
 create mode 100644 arch/arm/mach-sc5xx/rcu.c
 create mode 100644 arch/arm/mach-sc5xx/sc57x.c
 create mode 100644 arch/arm/mach-sc5xx/sc58x.c
 create mode 100644 arch/arm/mach-sc5xx/sc59x.c
 create mode 100644 arch/arm/mach-sc5xx/sc59x_64.c
 create mode 100644 arch/arm/mach-sc5xx/soc.c
 create mode 100644 arch/arm/mach-sc5xx/spl.c
 create mode 100644 drivers/clk/adi/Kconfig
 create mode 100644 drivers/clk/adi/Makefile
 create mode 100644 drivers/clk/adi/clk-adi-pll.c
 create mode 100644 drivers/clk/adi/clk-adi-sc57x.c
 create mode 100644 drivers/clk/adi/clk-adi-sc58x.c
 create mode 100644 drivers/clk/adi/clk-adi-sc594.c
 create mode 100644 drivers/clk/adi/clk-adi-sc598.c
 create mode 100644 drivers/clk/adi/clk-shared.c
 create mode 100644 drivers/clk/adi/clk.h
 create mode 100644 drivers/serial/serial_adi_uart4.c
 create mode 100644 include/configs/sc_adi_common.h
 create mode 100644 include/dt-bindings/clock/adi-sc5xx-clock.h
Signature · 1 line
2.43.2
#1 lore raw

PATCH 1/3 arch: arm: Add Analog Devices SC5xx machine type

From: Nathan Barrett-Morrison <[email protected]>

Add support for the SC5xx machine type from Analog Devices. This includes support for the SC57x, SC58x, SC59x, and SC59x-64 SoCs, which have many common features such as common ADI IP blocks, and SHARC DSP cores. This commit introduces core functionality required for all boards using an SC5xx SoC, such as:

- SPL configuration
- Required CPU hooks such as reset
- Boot ROM interaction to load the stage 2 bootloader in the reference configuration. Other options are possible but not officially supported at this time
- SoC-common configuration expected to be reused by all boards
- Early initialization for system clocks and DDR controller

---

---
 MAINTAINERS                                  |  13 +
 arch/arm/Kconfig                             |   6 +
 arch/arm/Makefile                            |   1 +
 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h  | 115 +++
 arch/arm/include/asm/arch-adi/sc5xx/soc.h    |  18 +
 arch/arm/include/asm/arch-adi/sc5xx/spl.h    |  41 +
 arch/arm/include/asm/mach-types.h            |   4 +
 arch/arm/mach-sc5xx/Kconfig                  | 464 +++++++++
 arch/arm/mach-sc5xx/Makefile                 |  19 +
 arch/arm/mach-sc5xx/config.mk                |  21 +
 arch/arm/mach-sc5xx/init/Makefile            |  11 +
 arch/arm/mach-sc5xx/init/clkinit.c           | 543 +++++++++++
 arch/arm/mach-sc5xx/init/clkinit.h           |  18 +
 arch/arm/mach-sc5xx/init/dmcinit.c           | 973 +++++++++++++++++++
 arch/arm/mach-sc5xx/init/dmcinit.h           |  29 +
 arch/arm/mach-sc5xx/init/init.c              |  68 ++
 arch/arm/mach-sc5xx/init/init.h              |  37 +
 arch/arm/mach-sc5xx/init/mem/is43tr16512bl.h |  63 ++
 arch/arm/mach-sc5xx/init/mem/mt41k128m16jt.h |  51 +
 arch/arm/mach-sc5xx/init/mem/mt41k512m16ha.h |  51 +
 arch/arm/mach-sc5xx/init/mem/mt47h128m16rt.h |  50 +
 arch/arm/mach-sc5xx/rcu.c                    |  22 +
 arch/arm/mach-sc5xx/sc57x.c                  |  21 +
 arch/arm/mach-sc5xx/sc58x.c                  |  21 +
 arch/arm/mach-sc5xx/sc59x.c                  |  32 +
 arch/arm/mach-sc5xx/sc59x_64.c               |  36 +
 arch/arm/mach-sc5xx/soc.c                    | 142 +++
 arch/arm/mach-sc5xx/spl.c                    | 140 +++
 include/configs/sc_adi_common.h              | 226 +++++
 29 files changed, 3236 insertions(+)
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/soc.h
 create mode 100644 arch/arm/include/asm/arch-adi/sc5xx/spl.h
 create mode 100644 arch/arm/mach-sc5xx/Kconfig
 create mode 100644 arch/arm/mach-sc5xx/Makefile
 create mode 100644 arch/arm/mach-sc5xx/config.mk
 create mode 100644 arch/arm/mach-sc5xx/init/Makefile
 create mode 100644 arch/arm/mach-sc5xx/init/clkinit.c
 create mode 100644 arch/arm/mach-sc5xx/init/clkinit.h
 create mode 100644 arch/arm/mach-sc5xx/init/dmcinit.c
 create mode 100644 arch/arm/mach-sc5xx/init/dmcinit.h
 create mode 100644 arch/arm/mach-sc5xx/init/init.c
 create mode 100644 arch/arm/mach-sc5xx/init/init.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/is43tr16512bl.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt41k128m16jt.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt41k512m16ha.h
 create mode 100644 arch/arm/mach-sc5xx/init/mem/mt47h128m16rt.h
 create mode 100644 arch/arm/mach-sc5xx/rcu.c
 create mode 100644 arch/arm/mach-sc5xx/sc57x.c
 create mode 100644 arch/arm/mach-sc5xx/sc58x.c
 create mode 100644 arch/arm/mach-sc5xx/sc59x.c
 create mode 100644 arch/arm/mach-sc5xx/sc59x_64.c
 create mode 100644 arch/arm/mach-sc5xx/soc.c
 create mode 100644 arch/arm/mach-sc5xx/spl.c
 create mode 100644 include/configs/sc_adi_common.h
MAINTAINERS +13 -0
index 83fd68e3f3..9693b86ddd 100644
@@ -598,6 +598,19 @@ R:	Marc Murphy <[email protected]>
 S:	Supported
 F:	arch/arm/dts/am335x-sancloud*
 
+ARM SC5XX
+M:	Nathan Barrett-Morrison <[email protected]>
+M:	Greg Malysa <[email protected]>
+M:	Ian Roberts <[email protected]>
+M:	Vasileios Bimpikas <[email protected]>
+M:	Utsav Agarwal <[email protected]>
+M:	Arturs Artamonovs <[email protected]>
+S:	Supported
+T:	git https://github.com/analogdevicesinc/lnxdsp-u-boot
+F:	arch/arm/include/asm/arch-adi/
+F:	arch/arm/mach-sc5xx/
+F:	include/configs/sc_adi_common.h
+
 ARM SNAPDRAGON
 M:	Caleb Connolly <[email protected]>
 M:	Neil Armstrong <[email protected]>
arch/arm/Kconfig +6 -0
index a0842e1933..fdaf4e23d0 100644
@@ -1843,6 +1843,10 @@ config TARGET_LS1046AFRWY
 	  development platform that supports the QorIQ LS1046A
 	  Layerscape Architecture processor.
 
+config ARCH_SC5XX
+	bool "Analog Devices SC5XX-processor family"
+	select STATIC_MACH_TYPE
+
 config TARGET_SL28
 	bool "Support sl28"
 	select ARCH_LS1028A
@@ -2276,6 +2280,8 @@ source "arch/arm/mach-rockchip/Kconfig"
 
 source "arch/arm/mach-s5pc1xx/Kconfig"
 
+source "arch/arm/mach-sc5xx/Kconfig"
+
 source "arch/arm/mach-snapdragon/Kconfig"
 
 source "arch/arm/mach-socfpga/Kconfig"
arch/arm/Makefile +1 -0
index a4266a3e36..734c6d6992 100644
@@ -78,6 +78,7 @@ machine-$(CONFIG_ARCH_OWL)		+= owl
 machine-$(CONFIG_ARCH_RENESAS)		+= renesas
 machine-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip
 machine-$(CONFIG_ARCH_S5PC1XX)		+= s5pc1xx
+machine-$(CONFIG_ARCH_SC5XX)		+= sc5xx
 machine-$(CONFIG_ARCH_SNAPDRAGON)	+= snapdragon
 machine-$(CONFIG_ARCH_SOCFPGA)		+= socfpga
 machine-$(CONFIG_ARCH_STM32)		+= stm32
arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h new file +115 -0

115 lines not on this page · raw message

arch/arm/include/asm/arch-adi/sc5xx/soc.h new file +18 -0
new file mode 100644
index 0000000000..430dbe2dae
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * (C) Copyright 2022 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#ifndef BOARD_ADI_COMMON_SOC_H
+#define BOARD_ADI_COMMON_SOC_H
+
+#include <phy.h>
+
+void fixup_dp83867_phy(struct phy_device *phydev);
+
+#endif
arch/arm/include/asm/arch-adi/sc5xx/spl.h new file +41 -0

41 lines not on this page · raw message

arch/arm/include/asm/mach-types.h +4 -0
index 2713b1d2c5..3e577fc0f1 100644
@@ -5050,4 +5050,8 @@
 #define MACH_TYPE_NASM25               5112
 #define MACH_TYPE_TOMATO               5113
 #define MACH_TYPE_OMAP3_MRC3D          5114
+#define MACH_TYPE_SC57X                5115
+#define MACH_TYPE_SC58X                5116
+#define MACH_TYPE_SC59X                5117
+#define MACH_TYPE_SC59X_64             5118
 #endif
arch/arm/mach-sc5xx/Kconfig new file +464 -0

464 lines not on this page · raw message

arch/arm/mach-sc5xx/Makefile new file +19 -0
new file mode 100644
index 0000000000..eeb56c078b
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# (C) Copyright 2022 - Analog Devices, Inc.
+#
+# Written and/or maintained by Timesys Corporation
+#
+# Contact: Nathan Barrett-Morrison <[email protected]>
+# Contact: Greg Malysa <[email protected]>
+#
+
+obj-y += soc.o init/
+
+obj-$(CONFIG_SC57X) += sc57x.o
+obj-$(CONFIG_SC58X) += sc58x.o
+obj-$(CONFIG_SC59X) += sc59x.o
+obj-$(CONFIG_SC59X_64) += sc59x_64.o
+
+obj-$(CONFIG_SPL_BUILD) += spl.o
+obj-$(CONFIG_SYSCON) += rcu.o
arch/arm/mach-sc5xx/config.mk new file +21 -0
new file mode 100644
index 0000000000..b80644d6dc
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# (C) Copyright 2022 - Analog Devices, Inc.
+#
+# Written and/or maintained by Timesys Corporation
+#
+# Contact: Nathan Barrett-Morrison <[email protected]>
+# Contact: Greg Malysa <[email protected]>
+#
+
+ifdef CONFIG_SPL_BUILD
+INPUTS-y += $(obj)/u-boot-spl.ldr
+endif
+
+LDR_FLAGS += --bcode=$(CONFIG_SC_BOOT_MODE)
+LDR_FLAGS += --use-vmas
+
+ifndef CONFIG_SC59X_64
+	# Select the Analog Devices processor.
+	PLATFORM_RELFLAGS += -fno-stack-protector -std=gnu89
+endif
arch/arm/mach-sc5xx/init/Makefile new file +11 -0
new file mode 100644
index 0000000000..c2835318a6
@@ -0,0 +1,11 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# (C) Copyright 2022 - Analog Devices, Inc.
+#
+# Written and/or maintained by Timesys Corporation
+#
+# Contact: Nathan Barrett-Morrison <[email protected]>
+# Contact: Greg Malysa <[email protected]>
+#
+
+obj-y += init.o dmcinit.o clkinit.o
arch/arm/mach-sc5xx/init/clkinit.c new file +543 -0

543 lines not on this page · raw message

arch/arm/mach-sc5xx/init/clkinit.h new file +18 -0
new file mode 100644
index 0000000000..b05f4325bf
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * (C) Copyright 2022 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#ifndef CLKINIT_H_
+#define CLKINIT_H_
+
+void clks_init(void);
+
+void dmcdelay(uint32_t delay);
+
+#endif
arch/arm/mach-sc5xx/init/dmcinit.c new file +973 -0

973 lines not on this page · raw message

arch/arm/mach-sc5xx/init/dmcinit.h new file +29 -0
new file mode 100644
index 0000000000..4fc36dd148
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * (C) Copyright 2022 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#ifndef DMCINIT_H_
+#define DMCINIT_H_
+
+#ifdef MEM_MT41K512M16HA
+	#include "mem/mt41k512m16ha.h"
+#elif defined(MEM_MT41K128M16JT)
+	#include "mem/mt41k128m16jt.h"
+#elif defined(MEM_MT47H128M16RT)
+	#include "mem/mt47h128m16rt.h"
+#elif defined(MEM_IS43TR16512BL)
+	#include "mem/is43tr16512bl.h"
+#else
+	#error "No DDR part name is defined for this board."
+#endif
+
+void DMC_Config(void);
+void adi_dmc_reset_lanes(bool reset);
+
+#endif
arch/arm/mach-sc5xx/init/init.c new file +68 -0

68 lines not on this page · raw message

arch/arm/mach-sc5xx/init/init.h new file +37 -0
new file mode 100644
index 0000000000..4fef49cd13
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * (C) Copyright 2022 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#if defined(CONFIG_SC57X) || defined(CONFIG_SC59X)
+#define REG_SPU0_SECUREC0	0x3108B980
+#define REG_SPU0_SECUREC1	0x3108B984
+#define REG_SPU0_SECUREC2	0x3108B988
+#define REG_SPU0_SECUREP_START	0x3108BA00
+#define REG_SPU0_SECUREP_END	0x3108BD24
+#endif
+
+#ifdef CONFIG_SC59X_64
+#define REG_RCU0_BCODE		0x3108C028
+#define REG_TSGENWR0_CNTCR	0x310AE000 /*  TSGENWR0 Counter Control Register */
+#endif
+
+#ifdef CONFIG_SC58X
+#define REG_SPU0_SECUREC0	0x3108C980
+#define REG_SPU0_SECUREC1	0x3108C984
+#define REG_SPU0_SECUREC2	0x3108C988
+#define REG_SPU0_SECUREP_START	0x3108CA00
+#define REG_SPU0_SECUREP_END	0x3108CCF0
+#endif
+
+#define REG_ARMPMU0_PMCR	0x31121E04
+#define REG_ARMPMU0_PMUSERENR	0x31121E08
+#define REG_ARMPMU0_PMLAR	0x31121FB0
+
+void adi_initcode(void);
+void adi_initcode_shared(void);
arch/arm/mach-sc5xx/init/mem/is43tr16512bl.h new file +63 -0

63 lines not on this page · raw message

arch/arm/mach-sc5xx/init/mem/mt41k128m16jt.h new file +51 -0

51 lines not on this page · raw message

arch/arm/mach-sc5xx/init/mem/mt41k512m16ha.h new file +51 -0

51 lines not on this page · raw message

arch/arm/mach-sc5xx/init/mem/mt47h128m16rt.h new file +50 -0

50 lines not on this page · raw message

arch/arm/mach-sc5xx/rcu.c new file +22 -0
new file mode 100644
index 0000000000..49357501a9
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Ian Roberts <[email protected]>
+ */
+
+#include <dm.h>
+#include <syscon.h>
+
+static const struct udevice_id adi_syscon_ids[] = {
+	{ .compatible = "adi,reset-controller" },
+	{ }
+};
+
+U_BOOT_DRIVER(syscon_sc5xx_rcu) = {
+	.name = "sc5xx_rcu",
+	.id = UCLASS_SYSCON,
+	.of_match = adi_syscon_ids,
+};
arch/arm/mach-sc5xx/sc57x.c new file +21 -0
new file mode 100644
index 0000000000..936f206a01
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/arch-adi/sc5xx/sc5xx.h>
+
+#define REG_PADS0_PCFG0 0x31004404
+
+adi_rom_boot = (void (*)(void *, uint32_t, int32_t, void *, uint32_t))0x000000e1;
+
+void sc5xx_enable_rgmii(void)
+{
+	writel((readl(REG_PADS0_PCFG0) | 0xc), REG_PADS0_PCFG0);
+}
arch/arm/mach-sc5xx/sc58x.c new file +21 -0
new file mode 100644
index 0000000000..936f206a01
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/arch-adi/sc5xx/sc5xx.h>
+
+#define REG_PADS0_PCFG0 0x31004404
+
+adi_rom_boot = (void (*)(void *, uint32_t, int32_t, void *, uint32_t))0x000000e1;
+
+void sc5xx_enable_rgmii(void)
+{
+	writel((readl(REG_PADS0_PCFG0) | 0xc), REG_PADS0_PCFG0);
+}
arch/arm/mach-sc5xx/sc59x.c new file +32 -0
new file mode 100644
index 0000000000..0ba3125c5e
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/arch-adi/sc5xx/sc5xx.h>
+
+#define REG_PADS0_PCFG0 0x31004604
+
+#define REG_SCB5_SPI2_OSPI_REMAP        0x30400000
+#define BITM_SCB5_SPI2_OSPI_REMAP_REMAP 0x00000003
+#define ENUM_SCB5_SPI2_OSPI_REMAP_OSPI0 0x00000001
+
+adi_rom_boot = (void (*)(void *, uint32_t, int32_t, void *, uint32_t))0x000000e9;
+
+void sc5xx_enable_rgmii(void)
+{
+	writel((readl(REG_PADS0_PCFG0) | 0xc), REG_PADS0_PCFG0);
+}
+
+void sc59x_remap_ospi(void)
+{
+	clrsetbits_le32(REG_SCB5_SPI2_OSPI_REMAP,
+			BITM_SCB5_SPI2_OSPI_REMAP_REMAP,
+			ENUM_SCB5_SPI2_OSPI_REMAP_OSPI0);
+}
arch/arm/mach-sc5xx/sc59x_64.c new file +36 -0
new file mode 100644
index 0000000000..c084182c8d
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * (C) Copyright 2024 - Analog Devices, Inc.
+ *
+ * Written and/or maintained by Timesys Corporation
+ *
+ * Contact: Nathan Barrett-Morrison <[email protected]>
+ * Contact: Greg Malysa <[email protected]>
+ */
+
+#include <asm/io.h>
+#include <asm/arch-adi/sc5xx/sc5xx.h>
+
+#define REG_PADS0_PCFG0 0x31004604
+
+#define REG_SCB5_SPI2_OSPI_REMAP        0x30400000
+#define BITM_SCB5_SPI2_OSPI_REMAP_REMAP 0x00000003
+#define ENUM_SCB5_SPI2_OSPI_REMAP_OSPI0 0x00000001
+
+adi_rom_boot = (void (*)(void *, uint32_t, int32_t, void *, uint32_t))0x000000e4;
+
+void sc5xx_enable_rgmii(void)
+{
+	writel((readl(REG_PADS0_PCFG0) | 0xc), REG_PADS0_PCFG0);
+
+	// Set dw for little endian operation as well
+	writel(readl(REG_PADS0_PCFG0) & ~(1 << 19), REG_PADS0_PCFG0);
+	writel(readl(REG_PADS0_PCFG0) & ~(1 << 20), REG_PADS0_PCFG0);
+}
+
+void sc59x_remap_ospi(void)
+{
+	clrsetbits_le32(REG_SCB5_SPI2_OSPI_REMAP,
+			BITM_SCB5_SPI2_OSPI_REMAP_REMAP,
+			ENUM_SCB5_SPI2_OSPI_REMAP_OSPI0);
+}
arch/arm/mach-sc5xx/soc.c new file +142 -0

142 lines not on this page · raw message

arch/arm/mach-sc5xx/spl.c new file +140 -0

102 lines not on this page · raw message

include/configs/sc_adi_common.h new file +226 -0

226 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.2

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH 1/3] arch: arm: Add Analog Devices SC5xx machine type

Quoted 28 lines · Greg Malysa

From: Nathan Barrett-Morrison <[email protected]>

Add support for the SC5xx machine type from Analog Devices. This includes support for the SC57x, SC58x, SC59x, and SC59x-64 SoCs, which have many common features such as common ADI IP blocks, and SHARC DSP cores. This commit introduces core functionality required for all boards using an SC5xx SoC, such as:

- SPL configuration
- Required CPU hooks such as reset
- Boot ROM interaction to load the stage 2 bootloader in the reference configuration. Other options are possible but not officially supported at this time
- SoC-common configuration expected to be reused by all boards
- Early initialization for system clocks and DDR controller

---

Quoted 8 lines
---
 MAINTAINERS                                  |  13 +
 arch/arm/Kconfig                             |   6 +
 arch/arm/Makefile                            |   1 +
 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h  | 115 +++
 arch/arm/include/asm/arch-adi/sc5xx/soc.h    |  18 +
 arch/arm/include/asm/arch-adi/sc5xx/spl.h    |  41 +
 arch/arm/include/asm/mach-types.h            |   4 +

We shouldn't be adding more to mach-types.h.

Quoted 1 line
 arch/arm/mach-sc5xx/Kconfig                  | 464 +++++++++

Here and elsewhere I think I saw whitespace issues (help should be <TAB><space><space>) in the entries, along with adding "default n" for new options, and that's not needed as n is the default.

[snip]

Quoted 5 lines
arch/arm/mach-sc5xx/config.mk new file +0 -0
new file mode 100644
index 0000000000..b80644d6dc

[snip]

arch/arm/mach-sc5xx/config.mk line 21

Quoted 4 lines
arch/arm/mach-sc5xx/config.mk new file +4 -0
+ifndef CONFIG_SC59X_64
+	# Select the Analog Devices processor.
+	PLATFORM_RELFLAGS += -fno-stack-protector -std=gnu89
+endif

We should be using the defaults here.

Also:
- Please switch to plain text environment instead of defining in board.h and so on.
- Audit your #include usage, I saw more <config.h> that is likely needed for example.

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH 1/3] arch: arm: Add Analog Devices SC5xx machine type

Hi Tom,

Thanks for the quick feedback. I'll go through our patches and review the #include usage as part of preparing for v2, and we'll work out switching to the plain text environment as well. I'll drop the custom compiler options and make sure we weren't actually relying on them--possibly it was just necessary for the initial set of init code we started with. I believe we're not using the mach type constants anywhere so that will be straightforward to drop as well.

Thanks,
Greg

Quoted 70 lines · Tom Rini
Quoted 28 lines · Greg Malysa

From: Nathan Barrett-Morrison <[email protected]>

Add support for the SC5xx machine type from Analog Devices. This includes support for the SC57x, SC58x, SC59x, and SC59x-64 SoCs, which have many common features such as common ADI IP blocks, and SHARC DSP cores. This commit introduces core functionality required for all boards using an SC5xx SoC, such as:

- SPL configuration
- Required CPU hooks such as reset
- Boot ROM interaction to load the stage 2 bootloader in the reference configuration. Other options are possible but not officially supported at this time
- SoC-common configuration expected to be reused by all boards
- Early initialization for system clocks and DDR controller

---

Quoted 8 lines
---
 MAINTAINERS                                  |  13 +
 arch/arm/Kconfig                             |   6 +
 arch/arm/Makefile                            |   1 +
 arch/arm/include/asm/arch-adi/sc5xx/sc5xx.h  | 115 +++
 arch/arm/include/asm/arch-adi/sc5xx/soc.h    |  18 +
 arch/arm/include/asm/arch-adi/sc5xx/spl.h    |  41 +
 arch/arm/include/asm/mach-types.h            |   4 +

We shouldn't be adding more to mach-types.h.

Quoted 1 line
 arch/arm/mach-sc5xx/Kconfig                  | 464 +++++++++

Here and elsewhere I think I saw whitespace issues (help should be <TAB><space><space>) in the entries, along with adding "default n" for new options, and that's not needed as n is the default.

[snip]

Quoted 5 lines
arch/arm/mach-sc5xx/config.mk new file +0 -0
new file mode 100644
index 0000000000..b80644d6dc

[snip]

arch/arm/mach-sc5xx/config.mk line 21

Quoted 4 lines
arch/arm/mach-sc5xx/config.mk new file +4 -0
+ifndef CONFIG_SC59X_64
+     # Select the Analog Devices processor.
+     PLATFORM_RELFLAGS += -fno-stack-protector -std=gnu89
+endif

We should be using the defaults here.

Also:
- Please switch to plain text environment instead of defining in board.h and so on.
- Audit your #include usage, I saw more <config.h> that is likely needed for example.

--
Tom

Signature · 2 lines
Greg Malysa
Timesys Corporation
#4 lore raw

PATCH 2/3 drivers: clk: adi: Add in SC5XX-family clock driver

In reply to Greg Malysa

From: Nathan Barrett-Morrison <[email protected]>

This adds support for the SC5XX clock trees which are required for reading clock speeds on the SoCs. This is largely a port of the same support for Linux, which has not yet been submitted upstream.

---

 MAINTAINERS                                 |   1 +
 drivers/clk/Kconfig                         |   1 +
 drivers/clk/Makefile                        |   1 +
 drivers/clk/adi/Kconfig                     |  83 ++++++
 drivers/clk/adi/Makefile                    |  16 +
 drivers/clk/adi/clk-adi-pll.c               |  94 ++++++
 drivers/clk/adi/clk-adi-sc57x.c             | 205 +++++++++++++
 drivers/clk/adi/clk-adi-sc58x.c             | 221 ++++++++++++++
 drivers/clk/adi/clk-adi-sc594.c             | 230 +++++++++++++++
 drivers/clk/adi/clk-adi-sc598.c             | 307 ++++++++++++++++++++
 drivers/clk/adi/clk-shared.c                |  48 +++
 drivers/clk/adi/clk.h                       | 122 ++++++++
 include/dt-bindings/clock/adi-sc5xx-clock.h | 271 +++++++++++++++++
 13 files changed, 1600 insertions(+)
 create mode 100644 drivers/clk/adi/Kconfig
 create mode 100644 drivers/clk/adi/Makefile
 create mode 100644 drivers/clk/adi/clk-adi-pll.c
 create mode 100644 drivers/clk/adi/clk-adi-sc57x.c
 create mode 100644 drivers/clk/adi/clk-adi-sc58x.c
 create mode 100644 drivers/clk/adi/clk-adi-sc594.c
 create mode 100644 drivers/clk/adi/clk-adi-sc598.c
 create mode 100644 drivers/clk/adi/clk-shared.c
 create mode 100644 drivers/clk/adi/clk.h
 create mode 100644 include/dt-bindings/clock/adi-sc5xx-clock.h
MAINTAINERS +1 -0
index 9693b86ddd..a9f52a6c7e 100644
@@ -609,6 +609,7 @@ S:	Supported
 T:	git https://github.com/analogdevicesinc/lnxdsp-u-boot
 F:	arch/arm/include/asm/arch-adi/
 F:	arch/arm/mach-sc5xx/
+F:	drivers/clk/adi/
 F:	include/configs/sc_adi_common.h
 
 ARM SNAPDRAGON
drivers/clk/Kconfig +1 -0
index 017dd260a5..d8c619add4 100644
@@ -246,6 +246,7 @@ config CLK_ZYNQMP
 	  This clock driver adds support for clock realted settings for
 	  ZynqMP platform.
 
+source "drivers/clk/adi/Kconfig"
 source "drivers/clk/analogbits/Kconfig"
 source "drivers/clk/at91/Kconfig"
 source "drivers/clk/exynos/Kconfig"
drivers/clk/Makefile +1 -0
index 638ad04bae..847b9b2911 100644
@@ -12,6 +12,7 @@ obj-$(CONFIG_$(SPL_TPL_)CLK_CCF) += clk-fixed-factor.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_COMPOSITE_CCF) += clk-composite.o
 obj-$(CONFIG_$(SPL_TPL_)CLK_GPIO) += clk-gpio.o
 
+obj-y += adi/
 obj-y += analogbits/
 obj-y += imx/
 obj-$(CONFIG_CLK_JH7110) += starfive/
drivers/clk/adi/Kconfig new file +83 -0

83 lines not on this page · raw message

drivers/clk/adi/Makefile new file +16 -0
new file mode 100644
index 0000000000..f3f1fd92e5
@@ -0,0 +1,16 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# (C) Copyright 2022 - Analog Devices, Inc.
+#
+# Written and/or maintained by Timesys Corporation
+#
+# Contact: Nathan Barrett-Morrison <[email protected]>
+# Contact: Greg Malysa <[email protected]>
+#
+
+obj-$(CONFIG_COMMON_CLK_ADI_SHARED) += clk-shared.o clk-adi-pll.o
+
+obj-$(CONFIG_COMMON_CLK_ADI_SC594)  += clk-adi-sc594.o
+obj-$(CONFIG_COMMON_CLK_ADI_SC598)  += clk-adi-sc598.o
+obj-$(CONFIG_COMMON_CLK_ADI_SC58X)  += clk-adi-sc58x.o
+obj-$(CONFIG_COMMON_CLK_ADI_SC57X)  += clk-adi-sc57x.o
drivers/clk/adi/clk-adi-pll.c new file +94 -0

94 lines not on this page · raw message

drivers/clk/adi/clk-adi-sc57x.c new file +205 -0

205 lines not on this page · raw message

drivers/clk/adi/clk-adi-sc58x.c new file +221 -0

221 lines not on this page · raw message

drivers/clk/adi/clk-adi-sc594.c new file +230 -0

230 lines not on this page · raw message

drivers/clk/adi/clk-adi-sc598.c new file +307 -0

307 lines not on this page · raw message

drivers/clk/adi/clk-shared.c new file +48 -0

48 lines not on this page · raw message

drivers/clk/adi/clk.h new file +122 -0

122 lines not on this page · raw message

include/dt-bindings/clock/adi-sc5xx-clock.h new file +271 -0

271 lines not on this page · raw message

Signature · 1 line
2.43.2
#5 lore raw

PATCH 3/3 drivers: serial: Add in UART for ADI SC5XX-family processors

In reply to Greg Malysa

From: Nathan Barrett-Morrison <[email protected]>

---

 MAINTAINERS                       |   1 +
 drivers/serial/Makefile           |   1 +
 drivers/serial/serial_adi_uart4.c | 228 ++++++++++++++++++++++++++++++
 3 files changed, 230 insertions(+)
 create mode 100644 drivers/serial/serial_adi_uart4.c
MAINTAINERS +1 -0
index a9f52a6c7e..b1f206bb05 100644
@@ -610,6 +610,7 @@ T:	git https://github.com/analogdevicesinc/lnxdsp-u-boot
 F:	arch/arm/include/asm/arch-adi/
 F:	arch/arm/mach-sc5xx/
 F:	drivers/clk/adi/
+F:	drivers/serial/serial_adi_uart4.c
 F:	include/configs/sc_adi_common.h
 
 ARM SNAPDRAGON
drivers/serial/Makefile +1 -0
index 403ab1ded6..dbe598b740 100644
@@ -65,3 +65,4 @@ obj-$(CONFIG_S5P4418_PL011_SERIAL) += serial_s5p4418_pl011.o
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_USB_TTY) += usbtty.o
 endif
+obj-$(CONFIG_UART4_SERIAL) += serial_adi_uart4.o
drivers/serial/serial_adi_uart4.c new file +228 -0

228 lines not on this page · raw message

Signature · 1 line
2.43.2
#6 lore raw
In reply to Greg Malysa
Quoted 21 lines · Greg Malysa

This series adds support for the ADI SC5xx machine type and includes two core drivers that are required for being able to boot any board--a UART driver and the clock tree driver. Our corresponding Linux support relies on u-boot configuring the clocks correctly before booting, so it is not possible to boot any board without the CGU/CDU configuration happening here. The clock tree itself is only used by the UART in this minimal patch set, but is of course broadly useful for all other peripheral drivers to be submitted in future patch sets. There are also no board files or defconfigs included here, but some common definitions that will be used to build board files currently are.

Some of the configuration code in dmcinit and clkinit is quite scary and causes a lot of checkpatch violations. It is modified from code initially provided by ADI, but it has not been fully rewritten. There's a question of how important it is to clean up this code--it has some quality violations, but it has been in use (including in production) for over two years and is known to work for performing the low level SoC initialization, while a rewrite might introduce bugs that could take a significant amount of time to detect in the future.

Quoted 4 lines

Please provide any feedback or comments that will be helpful in creating a v2 of this patch that will be ready to submit for inclusion into the main tree, as well as general observations that we should consider in other driver patches before submitting them.

Does this series pass CI currently? Thanks.

Signature · 1 line
Tom
#7 lore raw

I'm afraid I have to admit I don't know. I'll work with our IT team to make sure we can run CI locally, and when v2 comes around the answer will be yes.

Quoted 32 lines · Tom Rini
Quoted 21 lines · Greg Malysa

This series adds support for the ADI SC5xx machine type and includes two core drivers that are required for being able to boot any board--a UART driver and the clock tree driver. Our corresponding Linux support relies on u-boot configuring the clocks correctly before booting, so it is not possible to boot any board without the CGU/CDU configuration happening here. The clock tree itself is only used by the UART in this minimal patch set, but is of course broadly useful for all other peripheral drivers to be submitted in future patch sets. There are also no board files or defconfigs included here, but some common definitions that will be used to build board files currently are.

Some of the configuration code in dmcinit and clkinit is quite scary and causes a lot of checkpatch violations. It is modified from code initially provided by ADI, but it has not been fully rewritten. There's a question of how important it is to clean up this code--it has some quality violations, but it has been in use (including in production) for over two years and is known to work for performing the low level SoC initialization, while a rewrite might introduce bugs that could take a significant amount of time to detect in the future.

Quoted 4 lines

Please provide any feedback or comments that will be helpful in creating a v2 of this patch that will be ready to submit for inclusion into the main tree, as well as general observations that we should consider in other driver patches before submitting them.

Does this series pass CI currently? Thanks.

--
Tom

Signature · 2 lines
Greg Malysa
Timesys Corporation
#8 lore raw
Quoted 4 lines · Greg Malysa

I'm afraid I have to admit I don't know. I'll work with our IT team to make sure we can run CI locally, and when v2 comes around the answer will be yes.

AFAIR, I think you the only exception to open a PR in the github fork is to run CI.

- Nuno Sá