Skip to contentSkip to conversation

arm: mvebu: Support for 98DX25xx/98DX35xx (AlleyCat5)

PATCH Superseded Chris Packham 2 participants 17 messages Sep 16, 2022 – Sep 19, 2022

Subsystems (9)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover arm: mvebu: Support for 98DX25xx/98DX35xx (AlleyCat5)

These patches are based on Marvell's bootloader for the AlleyCat5/5X which was based on u-boot 2018.03. I've split that code into consumable chunks and dropped as much unnecessary stuff as I can. I've also tried to sync the device trees as much as possible with the support that will land in Linux 6.0 although there are still some differences

Chris Packham (7):
net: mvneta: Add support for AlleyCat5
usb: ehci: ehci-marvell: Support for marvell,ac5-ehci
pinctrl: mvebu: Add AlleyCat5 support
misc: mvebu: Add sample at reset driver
arm: mvebu: Support for 98DX25xx/98DX35xx SoC
arm: mvebu: Add RD-AC5X board
tools: kwboot: Add knowledge of Marvell's TIM

 arch/arm/dts/Makefile                      |   3 +-
 arch/arm/dts/ac5-98dx25xx.dtsi             | 292 +++++++++++++++++++++
 arch/arm/dts/ac5-98dx35xx-rd.dts           | 155 +++++++++++
 arch/arm/dts/ac5-98dx35xx.dtsi             |  17 ++
 arch/arm/mach-mvebu/Kconfig                |  14 +-
 arch/arm/mach-mvebu/Makefile               |   1 +
 arch/arm/mach-mvebu/alleycat5/Makefile     |   9 +
 arch/arm/mach-mvebu/alleycat5/clock.c      |  49 ++++
 arch/arm/mach-mvebu/alleycat5/cpu.c        | 129 +++++++++
 arch/arm/mach-mvebu/alleycat5/soc.c        | 229 ++++++++++++++++
 arch/arm/mach-mvebu/arm64-common.c         |  15 ++
 arch/arm/mach-mvebu/include/mach/clock.h   |  11 +
 arch/arm/mach-mvebu/include/mach/cpu.h     |   4 +
 arch/arm/mach-mvebu/include/mach/soc.h     |   4 +
 board/Marvell/mvebu_alleycat-5/MAINTAINERS |   6 +
 board/Marvell/mvebu_alleycat-5/Makefile    |   3 +
 board/Marvell/mvebu_alleycat-5/board.c     |  35 +++
 configs/mvebu_ac5_rd_defconfig             |  89 +++++++
 drivers/misc/Kconfig                       |   6 +
 drivers/misc/Makefile                      |   1 +
 drivers/misc/mvebu_sar/Makefile            |   4 +
 drivers/misc/mvebu_sar/ac5_sar.c           | 119 +++++++++
 drivers/misc/mvebu_sar/sar-uclass.c        | 146 +++++++++++
 drivers/net/Kconfig                        |   2 +-
 drivers/net/mvneta.c                       |  66 ++++-
 drivers/pinctrl/mvebu/Kconfig              |   2 +-
 drivers/usb/host/Kconfig                   |   1 +
 drivers/usb/host/ehci-marvell.c            |  57 +++-
 include/configs/mvebu_alleycat-5.h         |  92 +++++++
 include/dm/uclass-id.h                     |   1 +
 include/fdtdec.h                           |   4 +
 include/mvebu/mvebu_chip_sar.h             |  73 ++++++
 include/mvebu/sar.h                        |  57 ++++
 include/mvebu/var.h                        |  28 ++
 include/sar-uclass.h                       |  23 ++
 lib/fdtdec.c                               |   6 +-
 tools/kwbimage.h                           |  29 ++
 tools/kwboot.c                             |   3 +
 38 files changed, 1767 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/dts/ac5-98dx25xx.dtsi
 create mode 100644 arch/arm/dts/ac5-98dx35xx-rd.dts
 create mode 100644 arch/arm/dts/ac5-98dx35xx.dtsi
 create mode 100644 arch/arm/mach-mvebu/alleycat5/Makefile
 create mode 100644 arch/arm/mach-mvebu/alleycat5/clock.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/cpu.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.c
 create mode 100644 arch/arm/mach-mvebu/include/mach/clock.h
 create mode 100644 board/Marvell/mvebu_alleycat-5/MAINTAINERS
 create mode 100644 board/Marvell/mvebu_alleycat-5/Makefile
 create mode 100644 board/Marvell/mvebu_alleycat-5/board.c
 create mode 100644 configs/mvebu_ac5_rd_defconfig
 create mode 100644 drivers/misc/mvebu_sar/Makefile
 create mode 100644 drivers/misc/mvebu_sar/ac5_sar.c
 create mode 100644 drivers/misc/mvebu_sar/sar-uclass.c
 create mode 100644 include/configs/mvebu_alleycat-5.h
 create mode 100644 include/mvebu/mvebu_chip_sar.h
 create mode 100644 include/mvebu/sar.h
 create mode 100644 include/mvebu/var.h
 create mode 100644 include/sar-uclass.h
Signature · 1 line
2.37.3
#1 lore raw

PATCH 1/7 net: mvneta: Add support for AlleyCat5

Add support for the AlleyCat5 SoC. This lacks the mbus from the other users of the mvneta.c driver so a new compatible string is needed to allow for a different window configuration.

---

 drivers/net/Kconfig  |  2 +-
 drivers/net/mvneta.c | 66 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 64 insertions(+), 4 deletions(-)
drivers/net/Kconfig +1 -1
index 6bbbadc5ee..8df3dce6df 100644
@@ -448,7 +448,7 @@ config MVGBE
 
 config MVNETA
 	bool "Marvell Armada XP/385/3700 network interface support"
-	depends on ARMADA_XP || ARMADA_38X || ARMADA_3700
+	depends on ARMADA_XP || ARMADA_38X || ARMADA_3700 || ALLEYCAT_5
 	select PHYLIB
 	select DM_MDIO
 	help
drivers/net/mvneta.c +63 -3

136 lines not on this page · raw message

Signature · 1 line
2.37.3
#2 lore raw

PATCH 2/7 usb: ehci: ehci-marvell: Support for marvell,ac5-ehci

In reply to Chris Packham

Unlike the other 64-bit mvebu SoCs the AlleyCat5 uses the older ehci block from the 32-bit SoCs. Adapt the ehci-marvell.c driver to cope with the fact that the ac5 does not have the mbus infrastructure the 32-bit SoCs have and ensure USB_EHCI_IS_TDI is selected.

---

 drivers/usb/host/Kconfig        |  1 +
 drivers/usb/host/ehci-marvell.c | 57 +++++++++++++++++++++++++++------
 2 files changed, 48 insertions(+), 10 deletions(-)
drivers/usb/host/Kconfig +1 -0
index a0f48f09a7..628078f495 100644
@@ -178,6 +178,7 @@ config USB_EHCI_MARVELL
 	depends on ARCH_MVEBU || ARCH_KIRKWOOD || ARCH_ORION5X
 	default y
 	select USB_EHCI_IS_TDI if !ARM64
+	select USB_EHCI_IS_TDI if ALLEYCAT_5
 	---help---
 	  Enables support for the on-chip EHCI controller on MVEBU SoCs.
 
drivers/usb/host/ehci-marvell.c +47 -10

96 lines not on this page · raw message

Signature · 1 line
2.37.3
#3 lore raw

PATCH 3/7 pinctrl: mvebu: Add AlleyCat5 support

In reply to Chris Packham

This uses the same IP block as the Armada-8K SoCs.

---

 drivers/pinctrl/mvebu/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mvebu/Kconfig +1 -1
index 574fb4dfb0..7c51d138c8 100644
@@ -15,7 +15,7 @@ config PINCTRL_ARMADA_37XX
 	   Marvell's Armada-37xx SoC.
 
 config PINCTRL_ARMADA_8K
-	depends on ARMADA_8K && PINCTRL_FULL
+	depends on (ARMADA_8K || ALLEYCAT_5) && PINCTRL_FULL
 	bool "Armada 7k/8k pin control driver"
 	help
 	   Support pin multiplexing and pin configuration control on
Signature · 1 line
2.37.3
#4 lore raw

PATCH 4/7 misc: mvebu: Add sample at reset driver

In reply to Chris Packham

Add a new UCLASS_SAR, the generic SAR code and an Alleycat5 driver. This has been adapted from the Marvell SDK but only the AC5 driver has been brought through (other drivers exist for the ap806, ap807 and cp110 IP blocks).

---

 drivers/misc/Kconfig                |   6 ++
 drivers/misc/Makefile               |   1 +
 drivers/misc/mvebu_sar/Makefile     |   4 +
 drivers/misc/mvebu_sar/ac5_sar.c    | 119 +++++++++++++++++++++++
 drivers/misc/mvebu_sar/sar-uclass.c | 146 ++++++++++++++++++++++++++++
 include/dm/uclass-id.h              |   1 +
 include/fdtdec.h                    |   4 +
 include/mvebu/mvebu_chip_sar.h      |  73 ++++++++++++++
 include/mvebu/sar.h                 |  57 +++++++++++
 include/mvebu/var.h                 |  28 ++++++
 include/sar-uclass.h                |  23 +++++
 lib/fdtdec.c                        |   6 +-
 12 files changed, 467 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/mvebu_sar/Makefile
 create mode 100644 drivers/misc/mvebu_sar/ac5_sar.c
 create mode 100644 drivers/misc/mvebu_sar/sar-uclass.c
 create mode 100644 include/mvebu/mvebu_chip_sar.h
 create mode 100644 include/mvebu/sar.h
 create mode 100644 include/mvebu/var.h
 create mode 100644 include/sar-uclass.h
drivers/misc/Kconfig +6 -0
index a6da6e215d..4e99ef29d9 100644
@@ -645,4 +645,10 @@ config SL28CPLD
 	  the base driver which provides common access methods for the
 	  sub-drivers.
 
+config MVEBU_SAR
+	bool "MVEBU SAR driver"
+	depends on ARCH_MVEBU
+	help
+	  Support MVEBU SAR driver
+
 endmenu
drivers/misc/Makefile +1 -0
index d494639cd9..3cf976edd8 100644
@@ -62,6 +62,7 @@ obj-$(CONFIG_NUVOTON_NCT6102D) += nuvoton_nct6102d.o
 obj-$(CONFIG_P2SB) += p2sb-uclass.o
 obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
 obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
+obj-$(CONFIG_MVEBU_SAR) += mvebu_sar/
 ifdef CONFIG_QFW
 obj-y += qfw.o
 obj-$(CONFIG_QFW_PIO) += qfw_pio.o
drivers/misc/mvebu_sar/Makefile new file +4 -0
new file mode 100644
index 0000000000..6f339fb7b4
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+obj-$(CONFIG_MVEBU_SAR) += sar-uclass.o
+obj-$(CONFIG_ALLEYCAT_5) += ac5_sar.o
drivers/misc/mvebu_sar/ac5_sar.c new file +119 -0

119 lines not on this page · raw message

drivers/misc/mvebu_sar/sar-uclass.c new file +146 -0

146 lines not on this page · raw message

include/dm/uclass-id.h +1 -0
index a432e43871..2213e76d38 100644
@@ -107,6 +107,7 @@ enum uclass_id {
 	UCLASS_RESET,		/* Reset controller device */
 	UCLASS_RNG,		/* Random Number Generator */
 	UCLASS_RTC,		/* Real time clock device */
+	UCLASS_SAR,		/* Reset Sample Configuration */
 	UCLASS_SCMI_AGENT,	/* Interface with an SCMI server */
 	UCLASS_SCSI,		/* SCSI device */
 	UCLASS_SERIAL,		/* Serial UART */
include/fdtdec.h +4 -0
index 12355afd7f..d8923ba443 100644
@@ -199,6 +199,10 @@ enum fdt_compat_id {
 	COMPAT_ALTERA_SOCFPGA_FPGA0,		/* SOCFPGA FPGA manager */
 	COMPAT_ALTERA_SOCFPGA_NOC,		/* SOCFPGA Arria 10 NOC */
 	COMPAT_ALTERA_SOCFPGA_CLK_INIT,		/* SOCFPGA Arria 10 clk init */
+	COMPAT_MVEBU_SAR,		/* Marvell Sampled-at-Reset */
+	COMPAT_MVEBU_SAR_REG_COMMON,	/* Marvell Sampled-at-Reset Common */
+	COMPAT_MVEBU_SAR_REG_AP806,	/* Marvell Sampled-at-Reset for ap806/ap807 */
+	COMPAT_MVEBU_SAR_REG_CP110,	/* Marvell Sampled-at-Reset for cp110 */
 
 	COMPAT_COUNT,
 };
include/mvebu/mvebu_chip_sar.h new file +73 -0

73 lines not on this page · raw message

include/mvebu/sar.h new file +57 -0

57 lines not on this page · raw message

include/mvebu/var.h new file +28 -0
new file mode 100644
index 0000000000..6bd315c841
@@ -0,0 +1,28 @@
+/* SPDX-License-Identifier:       GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ */
+
+#ifndef _VAR_H_
+#define _VAR_H_
+
+#include <linux/compiler.h>
+
+#define INVALID_KEY	0xFF
+#define MAX_VAR_OPTIONS	10
+
+#define VAR_IS_DEFAULT	0x1
+#define VAR_IS_LAST	0x2
+
+struct var_opts {
+	u8 value;
+	char *desc;
+	u8 flags;
+};
+
+struct var_desc {
+	char *key;
+	char *description;
+};
+
+#endif /* _VAR_H_ */
include/sar-uclass.h new file +23 -0
new file mode 100644
index 0000000000..8b9cc08847
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ */
+
+#include <mvebu/mvebu_chip_sar.h>
+
+struct udevice;
+
+struct sar_ops {
+	int (*sar_init_func)(struct udevice *dev);
+	int (*sar_dump_func)(struct udevice *dev);
+	int (*sar_value_get_func)(struct udevice *dev, enum mvebu_sar_opts sar,
+				  struct sar_val *val);
+	int (*sar_bootsrc_get)(struct udevice *dev, u32 *idx);
+};
+
+struct dm_sar_pdata {
+	void __iomem *sar_base;
+	const char *sar_name;
+};
+
+int mvebu_sar_id_register(struct udevice *dev, u32 sar_id);
lib/fdtdec.c +5 -1
index 96b6b71a60..26e5c82bcd 100644
@@ -74,7 +74,11 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(ALTERA_SOCFPGA_F2SDR2, "altr,socfpga-fpga2sdram2-bridge"),
 	COMPAT(ALTERA_SOCFPGA_FPGA0, "altr,socfpga-a10-fpga-mgr"),
 	COMPAT(ALTERA_SOCFPGA_NOC, "altr,socfpga-a10-noc"),
-	COMPAT(ALTERA_SOCFPGA_CLK_INIT, "altr,socfpga-a10-clk-init")
+	COMPAT(ALTERA_SOCFPGA_CLK_INIT, "altr,socfpga-a10-clk-init"),
+	COMPAT(MVEBU_SAR, "marvell,sample-at-reset"),
+	COMPAT(MVEBU_SAR_REG_COMMON, "marvell,sample-at-reset-common"),
+	COMPAT(MVEBU_SAR_REG_AP806, "marvell,sample-at-reset-ap806"),
+	COMPAT(MVEBU_SAR_REG_CP110, "marvell,sample-at-reset-cp110"),
 };
 
 static const char *const fdt_src_name[] = {
Signature · 1 line
2.37.3
#5 lore raw

PATCH 5/7 arm: mvebu: Support for 98DX25xx/98DX35xx SoC

In reply to Chris Packham

Add support for the Allecat5/Alleycat5X SoC. These are L3 switches with an integrated CPU (referred to as the CnM block in Marvell's documentation). These have dual ARMv8.2 CPUs (Cortex-A55). This support has been ported from Marvell's SDK which is based on a much older version of U-Boot.

---

 arch/arm/dts/ac5-98dx25xx.dtsi           | 292 +++++++++++++++++++++++
 arch/arm/dts/ac5-98dx35xx.dtsi           |  17 ++
 arch/arm/mach-mvebu/Kconfig              |   5 +
 arch/arm/mach-mvebu/Makefile             |   1 +
 arch/arm/mach-mvebu/alleycat5/Makefile   |   9 +
 arch/arm/mach-mvebu/alleycat5/clock.c    |  49 ++++
 arch/arm/mach-mvebu/alleycat5/cpu.c      | 129 ++++++++++
 arch/arm/mach-mvebu/alleycat5/soc.c      | 229 ++++++++++++++++++
 arch/arm/mach-mvebu/arm64-common.c       |  15 ++
 arch/arm/mach-mvebu/include/mach/clock.h |  11 +
 arch/arm/mach-mvebu/include/mach/cpu.h   |   4 +
 arch/arm/mach-mvebu/include/mach/soc.h   |   4 +
 12 files changed, 765 insertions(+)
 create mode 100644 arch/arm/dts/ac5-98dx25xx.dtsi
 create mode 100644 arch/arm/dts/ac5-98dx35xx.dtsi
 create mode 100644 arch/arm/mach-mvebu/alleycat5/Makefile
 create mode 100644 arch/arm/mach-mvebu/alleycat5/clock.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/cpu.c
 create mode 100644 arch/arm/mach-mvebu/alleycat5/soc.c
 create mode 100644 arch/arm/mach-mvebu/include/mach/clock.h
arch/arm/dts/ac5-98dx25xx.dtsi new file +292 -0
new file mode 100644
index 0000000000..c31d2f08cf
@@ -0,0 +1,292 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree For AC5.
+ *
+ * Copyright (C) 2021 Marvell
+ * Copyright (C) 2022 Allied Telesis Labs
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+	model = "Marvell AC5 SoC";
+	compatible = "marvell,ac5";
+	interrupt-parent = <&gic>;
+	#address-cells = <2>;
+	#size-cells = <2>;
+
+	cpus {
+		#address-cells = <2>;
+		#size-cells = <0>;
+
+		cpu-map {
+			cluster0 {
+				core0 {
+					cpu = <&cpu0>;
+				};
+				core1 {
+					cpu = <&cpu1>;
+				};
+			};
+		};
+
+		cpu0: cpu@0 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a55";
+			reg = <0x0 0x0>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+
+		cpu1: cpu@1 {
+			device_type = "cpu";
+			compatible = "arm,cortex-a55";
+			reg = <0x0 0x100>;
+			enable-method = "psci";
+			next-level-cache = <&l2>;
+		};
+
+		l2: l2-cache {
+			compatible = "cache";
+		};
+	};
+
+	psci {
+		compatible = "arm,psci-0.2";
+		method = "smc";
+	};
+
+	timer {
+		compatible = "arm,armv8-timer";
+		interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_PPI 8 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_PPI 10 IRQ_TYPE_LEVEL_HIGH>,
+			     <GIC_PPI 7 IRQ_TYPE_LEVEL_HIGH>;
+	};
+
+	pmu {
+		compatible = "arm,armv8-pmuv3";
+		interrupts = <GIC_PPI 12 IRQ_TYPE_LEVEL_HIGH>;
+	};
+
+	config-space {
+		#address-cells = <0x1>;
+		#size-cells = <0x1>;
+		compatible = "simple-bus";
+
+		sar-reg {
+			compatible = "marvell,sample-at-reset-common";
+			sar-driver = "ac5_sar";
+			sar-name = "ac5_sar";
+			status = "okay";
+		};
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+		dma-ranges;
+
+		internal-regs@7f000000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "simple-bus";
+			/* 16M internal register @ 0x7f00_0000 */
+			ranges = <0x0 0x0 0x7f000000 0x1000000>;
+			dma-coherent;
+
+			uart0: serial@12000 {
+				compatible = "snps,dw-apb-uart";
+				reg = <0x12000 0x100>;
+				reg-shift = <2>;
+				interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+				reg-io-width = <1>;
+				clocks = <&cnm_clock>;
+				status = "okay";
+			};
+
+			uart1: serial@12100 {
+				compatible = "snps,dw-apb-uart";
+				reg = <0x12100 0x100>;
+				reg-shift = <2>;
+				reg-io-width = <1>;
+				clocks = <&cnm_clock>;
+				status = "disabled";
+			};
+
+			uart2: serial@12200 {
+				compatible = "snps,dw-apb-uart";
+				reg = <0x12200 0x100>;
+				reg-shift = <2>;
+				reg-io-width = <1>;
+				clocks = <&cnm_clock>;
+				status = "disabled";
+			};
+
+			uart3: serial@12300 {
+				compatible = "snps,dw-apb-uart";
+				reg = <0x12300 0x100>;
+				reg-shift = <2>;
+				reg-io-width = <1>;
+				clocks = <&cnm_clock>;
+				status = "disabled";
+			};
+
+			mdio: mdio@22004 {
+				#address-cells = <1>;
+				#size-cells = <0>;
+				compatible = "marvell,orion-mdio";
+				reg = <0x22004 0x4>;
+				clocks = <&cnm_clock>;
+			};
+
+			i2c0: i2c@11000 {
+				compatible = "marvell,mv78230-i2c";
+				reg = <0x11000 0x20>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				clocks = <&cnm_clock>;
+				clock-names = "core";
+				interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
+				clock-frequency=<100000>;
+				status = "disabled";
+			};
+
+			i2c1: i2c@11100 {
+				compatible = "marvell,mv78230-i2c";
+				reg = <0x11100 0x20>;
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				clocks = <&cnm_clock>;
+				clock-names = "core";
+				interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
+				clock-frequency=<100000>;
+				status = "disabled";
+			};
+
+			gpio0: gpio@18100 {
+				compatible = "marvell,orion-gpio";
+				reg = <0x18100 0x40>;
+				ngpios = <32>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				status = "okay";
+			};
+
+			gpio1: gpio@18140 {
+				reg = <0x18140 0x40>;
+				compatible = "marvell,orion-gpio";
+				ngpios = <14>;
+				gpio-controller;
+				#gpio-cells = <2>;
+				status = "okay";
+			};
+		};
+
+		/*
+		 * Dedicated section for devices behind 32bit controllers so we
+		 * can configure specific DMA mapping for them
+		 */
+		behind-32bit-controller@7f000000 {
+			compatible = "simple-bus";
+			#address-cells = <0x2>;
+			#size-cells = <0x2>;
+			ranges = <0x0 0x0 0x0 0x7f000000 0x0 0x1000000>;
+			/* Host phy ram starts at 0x200M */
+			dma-ranges = <0x0 0x0 0x2 0x0 0x1 0x0>;
+			dma-coherent;
+
+			eth0: ethernet@20000 {
+				compatible = "marvell,armada-ac5-neta";
+				reg = <0x0 0x20000 0x0 0x4000>;
+				dma-ranges = <0 2 0 0x40000000>;
+				interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&cnm_clock>;
+				phy-mode = "sgmii";
+				status = "disabled";
+			};
+
+			eth1: ethernet@24000 {
+				compatible = "marvell,armada-ac5-neta";
+				reg = <0x0 0x24000 0x0 0x4000>;
+				dma-ranges = <0 2 0 0x40000000>;
+				interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&cnm_clock>;
+				phy-mode = "sgmii";
+				status = "disabled";
+			};
+
+			usb0: usb@80000 {
+				compatible = "marvell,ac5-ehci";
+				reg = <0x0 0x80000 0x0 0x500>;
+				interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
+
+			usb1: usb@a0000 {
+				compatible = "marvell,ac5-ehci";
+				reg = <0x0 0xa0000 0x0 0x500>;
+				interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+				status = "disabled";
+			};
+		};
+
+		pinctrl0: pinctrl@80020100 {
+			compatible = "marvell,mvebu-pinctrl";
+			reg = <0 0x80020100 0 0x20>;
+			pin-count = <46>;
+			max-func = <0xf>;
+			status = "okay";
+		};
+
+		spi0: spi@805a0000 {
+			compatible = "marvell,armada-3700-spi";
+			reg = <0x0 0x805a0000 0x0 0x50>;
+			#address-cells = <0x1>;
+			#size-cells = <0x0>;
+			clocks = <&spi_clock>;
+			interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
+			num-cs = <1>;
+			status = "disabled";
+		};
+
+		spi1: spi@805a8000 {
+			compatible = "marvell,armada-3700-spi";
+			reg = <0x0 0x805a8000 0x0 0x50>;
+			#address-cells = <0x1>;
+			#size-cells = <0x0>;
+			clocks = <&spi_clock>;
+			interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
+			num-cs = <1>;
+			status = "disabled";
+		};
+
+		gic: interrupt-controller@80600000 {
+			compatible = "arm,gic-v3";
+			#interrupt-cells = <3>;
+			interrupt-controller;
+			reg = <0x0 0x80600000 0x0 0x10000>, /* GICD */
+			      <0x0 0x80660000 0x0 0x40000>; /* GICR */
+			interrupts = <GIC_PPI 6 IRQ_TYPE_LEVEL_HIGH>;
+		};
+	};
+
+	clocks {
+		cnm_clock: cnm-clock {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <328000000>;
+		};
+
+		spi_clock: spi-clock {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <200000000>;
+		};
+	};
+};
arch/arm/dts/ac5-98dx35xx.dtsi new file +17 -0
new file mode 100644
index 0000000000..2ab72f854b
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree For AC5X.
+ *
+ * Copyright (C) 2022 Allied Telesis Labs
+ */
+
+#include "ac5-98dx25xx.dtsi"
+
+/ {
+	model = "Marvell AC5X SoC";
+	compatible = "marvell,ac5x", "marvell,ac5";
+};
+
+&cnm_clock {
+	clock-frequency = <325000000>;
+};
arch/arm/mach-mvebu/Kconfig +5 -0
index a81b8e2b0d..400a308985 100644
@@ -49,6 +49,11 @@ config ARMADA_8K
 	bool
 	select ARM64
 
+config ALLEYCAT_5
+	bool
+	select ARM64
+	select HAVE_MVEBU_EFUSE
+
 # Armada PLL frequency (used for NAND clock generation)
 config SYS_MVEBU_PLL_CLOCK
 	int
arch/arm/mach-mvebu/Makefile +1 -0
index 103e64cf20..f7d7f5f8ef 100644
@@ -6,6 +6,7 @@ ifdef CONFIG_ARM64
 
 obj-$(CONFIG_ARMADA_3700) += armada3700/
 obj-$(CONFIG_ARMADA_8K) += armada8k/
+obj-$(CONFIG_ALLEYCAT_5) += alleycat5/
 obj-y += arm64-common.o
 
 else # CONFIG_ARM64
arch/arm/mach-mvebu/alleycat5/Makefile new file +9 -0
new file mode 100644
index 0000000000..43b8b70c84
@@ -0,0 +1,9 @@
+#
+# Copyright (C) 2016 Stefan Roese <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y = cpu.o
+obj-y += soc.o
+obj-y += clock.o
arch/arm/mach-mvebu/alleycat5/clock.c new file +49 -0

49 lines not on this page · raw message

arch/arm/mach-mvebu/alleycat5/cpu.c new file +129 -0

129 lines not on this page · raw message

arch/arm/mach-mvebu/alleycat5/soc.c new file +229 -0

229 lines not on this page · raw message

arch/arm/mach-mvebu/arm64-common.c +15 -0
index 238edbe6ba..c9b6f16c63 100644
@@ -53,6 +53,8 @@ __weak int dram_init_banksize(void)
 		return a8k_dram_init_banksize();
 	else if (CONFIG_IS_ENABLED(ARMADA_3700))
 		return a3700_dram_init_banksize();
+	else if (CONFIG_IS_ENABLED(ALLEYCAT_5))
+		return alleycat5_dram_init_banksize();
 	else
 		return fdtdec_setup_memory_banksize();
 }
@@ -68,6 +70,9 @@ __weak int dram_init(void)
 	if (CONFIG_IS_ENABLED(ARMADA_3700))
 		return a3700_dram_init();
 
+	if (CONFIG_IS_ENABLED(ALLEYCAT_5))
+		return alleycat5_dram_init();
+
 	if (fdtdec_setup_mem_size_base() != 0)
 		return -EINVAL;
 
@@ -100,6 +105,16 @@ int arch_early_init_r(void)
 			break;
 	}
 
+	i = 0;
+	while (1) {
+		/* Call the pinctrl code via the PINCTRL uclass driver */
+		ret = uclass_get_device(UCLASS_PINCTRL, i++, &dev);
+
+		/* We're done, once no further CP110 device is found */
+		if (ret)
+			break;
+	}
+
 	/* Cause the SATA device to do its early init */
 	uclass_first_device(UCLASS_AHCI, &dev);
 
arch/arm/mach-mvebu/include/mach/clock.h new file +11 -0
new file mode 100644
index 0000000000..93d965ad5a
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ */
+
+#ifndef _MVEBU_CLOCK_H_
+#define _MVEBU_CLOCK_H_
+
+void soc_print_clock_info(void);
+
+#endif /* _MVEBU_CLOCK_H_ */
arch/arm/mach-mvebu/include/mach/cpu.h +4 -0
index b127fce865..c17c2440f1 100644
@@ -174,6 +174,10 @@ int a3700_dram_init_banksize(void);
 /* A3700 PCIe regions fixer for device tree */
 int a3700_fdt_fix_pcie_regions(void *blob);
 
+/* Alleycat5 dram functions */
+int alleycat5_dram_init(void);
+int alleycat5_dram_init_banksize(void);
+
 /*
  * get_ref_clk
  *
arch/arm/mach-mvebu/include/mach/soc.h +4 -0
index 3b9618852c..b9312e37dc 100644
@@ -212,4 +212,8 @@
 #define CONFIG_SYS_TCLK		250000000	/* 250MHz */
 #endif
 
+#ifndef __ASSEMBLY__
+void soc_print_device_info(void);
+int soc_early_init_f(void);
+#endif /* __ASSEMBLY__ */
 #endif /* _MVEBU_SOC_H */
Signature · 1 line
2.37.3
#6 lore raw

PATCH 6/7 arm: mvebu: Add RD-AC5X board

In reply to Chris Packham

The RD-AC5X-32G16HVG6HLG-A0 development board main components and features include:
* Main 12V/54V power supply
* 270 Gbps throughput packet processor on the main board
* DDR4:
* SR1: 2GB DDR4 2400MT/S(1GB x 2 pcs ) with ECC(1GB x 1 pcs)
* SR2: 4GB DDR4 2400MT/S(2GB x 2 pcs ) with ECC(2GB x 1 pcs)
* PCB co-layout with 4GB device to support 8GB (Dual CS) requirement
* 16GB eMMC (Samsung KLMAG1JETD-B041006)
* 16MB SPI NOR(GD25Q127C)
* 32 x 1000 Base-T interfaces
* 16 x 2500 Base-T interfaces
* SR1: 88E2540*4
* SR2: 88E2580*1+88E2540*2
* Six (6) x 25G Base-R SFP28 interfaces
* One (1) x RJ-45 console connector, interfacing to the on board UART
* One (1) x USB Type-A connector, interfacing to the USB 2.0 port (0)
* One (1) x USB Type-mini B connector, interfacing to the USB 2.0 port (1)
* One (1) x RJ-45 1G Base-T Management port, interfacing to the host port (shared with PCIe) Connected to 88E1512 Gigabit Ethernet Phy
* One (1) x Oculink port, interfacing to the PCIe port for external CPU connection
* POE 802.3AT support on Port 1 ~ Port 32, 802.3BT support on Port 33 ~ Port 48 (Microsemi PD69208T4, PD69208M or TI TPS2388,TPS23881 solution)
* POE total power budget 780W
* LED interfaces per network port/POE
* LED interfaces (common) showing system status
* PTP TC mode Supported (Reserved M.2 connector to support BC mode)

---

 arch/arm/dts/Makefile                      |   3 +-
 arch/arm/dts/ac5-98dx35xx-rd.dts           | 155 +++++++++++++++++++++
 arch/arm/mach-mvebu/Kconfig                |   9 +-
 board/Marvell/mvebu_alleycat-5/MAINTAINERS |   6 +
 board/Marvell/mvebu_alleycat-5/Makefile    |   3 +
 board/Marvell/mvebu_alleycat-5/board.c     |  35 +++++
 configs/mvebu_ac5_rd_defconfig             |  89 ++++++++++++
 include/configs/mvebu_alleycat-5.h         |  92 ++++++++++++
 8 files changed, 390 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/ac5-98dx35xx-rd.dts
 create mode 100644 board/Marvell/mvebu_alleycat-5/MAINTAINERS
 create mode 100644 board/Marvell/mvebu_alleycat-5/Makefile
 create mode 100644 board/Marvell/mvebu_alleycat-5/board.c
 create mode 100644 configs/mvebu_ac5_rd_defconfig
 create mode 100644 include/configs/mvebu_alleycat-5.h
arch/arm/dts/Makefile +2 -1
index 7330121dba..a334596ada 100644
@@ -274,7 +274,8 @@ dtb-$(CONFIG_ARCH_MVEBU) +=			\
 	cn9132-db-A.dtb				\
 	cn9132-db-B.dtb				\
 	cn9130-crb-A.dtb			\
-	cn9130-crb-B.dtb
+	cn9130-crb-B.dtb			\
+	ac5-98dx35xx-rd.dtb
 endif
 
 dtb-$(CONFIG_ARCH_SYNQUACER) += synquacer-sc2a11-developerbox.dtb
arch/arm/dts/ac5-98dx35xx-rd.dts new file +155 -0

155 lines not on this page · raw message

arch/arm/mach-mvebu/Kconfig +8 -1
index 400a308985..d27c45d58f 100644
@@ -98,7 +98,7 @@ config CUSTOMER_BOARD_SUPPORT
 	bool
 
 choice
-	prompt "Armada XP/375/38x/3700/7K/8K board select"
+	prompt "Armada XP/375/38x/3700/7K/8K/Alleycat-5 board select"
 	optional
 
 config TARGET_CLEARFOG
@@ -150,6 +150,10 @@ config TARGET_MVEBU_ARMADA_8K
 	select BOARD_LATE_INIT
 	imply SCSI
 
+config TARGET_MVEBU_ALLEYCAT5
+	bool "Support AlleyCat 5 platforms"
+	select ALLEYCAT_5
+
 config TARGET_OCTEONTX2_CN913x
 	bool "Support CN913x platforms"
 	select ARMADA_8K
@@ -258,6 +262,7 @@ config SYS_BOARD
 	default "x530" if TARGET_X530
 	default "db-xc3-24g4xg" if TARGET_DB_XC3_24G4XG
 	default "crs3xx-98dx3236" if TARGET_CRS3XX_98DX3236
+	default "mvebu_alleycat-5" if TARGET_MVEBU_ALLEYCAT5
 
 config SYS_CONFIG_NAME
 	default "clearfog" if TARGET_CLEARFOG
@@ -278,6 +283,7 @@ config SYS_CONFIG_NAME
 	default "x530" if TARGET_X530
 	default "db-xc3-24g4xg" if TARGET_DB_XC3_24G4XG
 	default "crs3xx-98dx3236" if TARGET_CRS3XX_98DX3236
+	default "mvebu_alleycat-5" if TARGET_MVEBU_ALLEYCAT5
 
 config SYS_VENDOR
 	default "Marvell" if TARGET_DB_MV784MP_GP
@@ -297,6 +303,7 @@ config SYS_VENDOR
 	default "gdsys" if TARGET_CONTROLCENTERDC
 	default "alliedtelesis" if TARGET_X530
 	default "mikrotik" if TARGET_CRS3XX_98DX3236
+	default "Marvell" if TARGET_MVEBU_ALLEYCAT5
 
 config SYS_SOC
 	default "mvebu"
board/Marvell/mvebu_alleycat-5/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..480c07c5f0
@@ -0,0 +1,6 @@
+RD-AC5X BOARD
+M:	Chris Packham <[email protected]>
+S:	Maintained
+F:	board/Marvell/mvebu_alleycat-5/
+F:	include/configs/mvebu_alleycat-5.h
+F:	configs/mvebu_ac5_rd_defconfig
board/Marvell/mvebu_alleycat-5/Makefile new file +3 -0
new file mode 100644
index 0000000000..29254b4d64
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier:	GPL-2.0+
+
+obj-y	:= board.o
board/Marvell/mvebu_alleycat-5/board.c new file +35 -0
new file mode 100644
index 0000000000..3303d3c2c9
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <common.h>
+#include <asm/global_data.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+__weak int soc_early_init_f(void)
+{
+	return 0;
+}
+
+int board_early_init_f(void)
+{
+	soc_early_init_f();
+
+	return 0;
+}
+
+int board_early_init_r(void)
+{
+	return 0;
+}
+
+int board_init(void)
+{
+	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+
+	return 0;
+}
+
+int board_late_init(void)
+{
+	return 0;
+}
configs/mvebu_ac5_rd_defconfig new file +89 -0

89 lines not on this page · raw message

include/configs/mvebu_alleycat-5.h new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
2.37.3
#7 lore raw

Re: [PATCH 6/7] arm: mvebu: Add RD-AC5X board

Quoted 5 lines · On Friday 16 September 2022 16:54:22 Chris Packham wrote:

+&spi0 {

arch/arm/dts/ac5-98dx35xx-rd.dts new file +4 -0
+	status = "okay";
+
+	spiflash0: flash@0 {
+		compatible = "jedec,spi-nor";

arch/arm/dts/ac5-98dx35xx-rd.dts line 108

Quoted 10 lines
arch/arm/dts/ac5-98dx35xx-rd.dts new file +10 -0
+		spi-max-frequency = <50000000>;
+		spi-tx-bus-width = <1>; /* 1-single, 2-dual, 4-quad */
+		spi-rx-bus-width = <1>; /* 1-single, 2-dual, 4-quad */
+		reg = <0>;
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		partition@0 {
+			label = "spi_flash_part0";

I guess such label is useless. There is something stored, so it would be a wise idea to put there correct label. I do not know how it is on this platform, but on A3720 at offset 0 is "firmware", which consist of CM3 part, A53 part and U-Boot. It is not even U-Boot itself.

Quoted 14 lines
arch/arm/dts/ac5-98dx35xx-rd.dts new file +14 -0
+			reg = <0x0 0x800000>;
+		};
+
+		parition@1 {
+			label = "spi_flash_part1";
+			reg = <0x800000 0x700000>;
+		};
+
+		parition@2 {
+			label = "spi_flash_part2";
+			reg = <0xF00000 0x100000>;
+		};
+	};
+};

...

Quoted 38 lines
include/configs/mvebu_alleycat-5.h new file +38 -0
+/* Default Env vars */
+#define CONFIG_IPADDR           0.0.0.0 /* In order to cause an error */
+#define CONFIG_SERVERIP         0.0.0.0 /* In order to cause an error */
+#define CONFIG_NETMASK          255.255.255.0
+#define CONFIG_GATEWAYIP        0.0.0.0
+#define CONFIG_ETHPRIME         "eth0"
+#define CONFIG_ROOTPATH                 "/srv/nfs/" /* Default Dir for NFS */
+#define CONFIG_ENV_OVERWRITE        /* ethaddr can be reprogrammed */
+#define CONFIG_EXTRA_ENV_SETTINGS   "bootcmd=run get_images; " \
+			"run set_bootargs; " \
+			"booti $kernel_addr_r " \
+			"$ramdisk_addr_r " \
+			"$fdt_addr_r\0" \
+			"extra_params=pci=pcie_bus_safe\0" \
+			"kernel_addr_r=0x202000000\0" \
+			"initrd_addr=0x206000000\0"    \
+			"initrd_size=0x2000000\0"   \
+			"fdt_addr_r=0x201000000\0"    \
+			"loadaddr=0x202000000\0"      \
+			"hostname=marvell\0"        \
+			"ramdisk_addr_r=0x206000000\0"    \
+			"ramfs_name=-\0"        \
+			"cpuidle=cpuidle.off=1\0"   \
+			"fdt_name=fdt.dtb\0"        \
+			"netdev=eth0\0"         \
+			"ethaddr=00:51:82:11:22:00\0"   \
+			"eth1addr=00:51:82:11:22:01\0"  \
+			"image_name=Image\0"        \
+			"get_ramfs=if test \"${ramfs_name}\"" \
+			" != \"-\"; then setenv " \
+			"ramdisk_addr_r 0x8000000; " \
+			"tftpboot $ramdisk_addr_r " \
+			"$ramfs_name; else setenv " \
+			"ramdisk_addr_r -;fi\0" \
+			"get_images=tftpboot $kernel_addr_r " \
+			"$image_name; tftpboot " \
+			"$fdt_addr_r $fdt_name; " \
+			"run get_ramfs\0"   \

include/configs/mvebu_alleycat-5.h line 73

Quoted 10 lines
include/configs/mvebu_alleycat-5.h new file +10 -0
+			"console=" "console=ttyS0,115200 "\
+			"earlycon=uart8250,mmio32,0xf0512000\0"\
+			"root=root=/dev/nfs rw\0"   \
+			"set_bootargs=setenv bootargs $console"\
+			" $root ip=$ipaddr:$serverip:" \
+			"$gatewayip:$netmask:$hostname"\
+			":$netdev:none nfsroot="\
+			"$serverip:$rootpath,tcp,v3 " \
+			"$extra_params " \
+			"$cpuidle"

This is hard to read, where is the variable name, where there is its value, etc...

And it would be better to use distroboot instead of manually written boot script.

#8 lore raw

Re: [PATCH 6/7] arm: mvebu: Add RD-AC5X board

Quoted 13 lines · Pali Rohár,
Quoted 12 lines · On Friday 16 September 2022 16:54:22 Chris Packham wrote:

+&spi0 {

arch/arm/dts/ac5-98dx35xx-rd.dts new file +11 -0
+     status = "okay";
+
+     spiflash0: flash@0 {
+             compatible = "jedec,spi-nor";
+             spi-max-frequency = <50000000>;
+             spi-tx-bus-width = <1>; /* 1-single, 2-dual, 4-quad */
+             spi-rx-bus-width = <1>; /* 1-single, 2-dual, 4-quad */
+             reg = <0>;
+
+             #address-cells = <1>;
+             #size-cells = <1>;
Quoted 9 lines

arch/arm/dts/ac5-98dx35xx-rd.dts line 108

Quoted 3 lines
arch/arm/dts/ac5-98dx35xx-rd.dts new file +3 -0
+
+             partition@0 {
+                     label = "spi_flash_part0";

I guess such label is useless. There is something stored, so it would be a wise idea to put there correct label. I do not know how it is on this platform, but on A3720 at offset 0 is "firmware", which consist of CM3 part, A53 part and U-Boot. It is not even U-Boot itself.

These are the names from the Linux SDK for the board. The first part will be the bootloader (mvddr+atf+u-boot). Somewhere in there is also the u-boot environment. I'm tempted just to drop the partitions altogether, they don't do anything useful for u-boot.

Quoted 71 lines
Quoted 15 lines
arch/arm/dts/ac5-98dx35xx-rd.dts new file +14 -0
+                     reg = <0x0 0x800000>;
+             };
+
+             parition@1 {
+                     label = "spi_flash_part1";
+                     reg = <0x800000 0x700000>;
+             };
+
+             parition@2 {
+                     label = "spi_flash_part2";
+                     reg = <0xF00000 0x100000>;
+             };
+     };
+};

...

include/configs/mvebu_alleycat-5.h

Quoted 7 lines
include/configs/mvebu_alleycat-5.h new file +7 -0
+/* Default Env vars */
+#define CONFIG_IPADDR           0.0.0.0 /* In order to cause an error */
+#define CONFIG_SERVERIP         0.0.0.0 /* In order to cause an error */
+#define CONFIG_NETMASK          255.255.255.0
+#define CONFIG_GATEWAYIP        0.0.0.0
+#define CONFIG_ETHPRIME         "eth0"
+#define CONFIG_ROOTPATH                 "/srv/nfs/" /* Default Dir for

NFS */

Quoted 31 lines
include/configs/mvebu_alleycat-5.h new file +31 -0
+#define CONFIG_ENV_OVERWRITE        /* ethaddr can be reprogrammed */
+#define CONFIG_EXTRA_ENV_SETTINGS   "bootcmd=run get_images; " \
+                     "run set_bootargs; " \
+                     "booti $kernel_addr_r " \
+                     "$ramdisk_addr_r " \
+                     "$fdt_addr_r\0" \
+                     "extra_params=pci=pcie_bus_safe\0" \
+                     "kernel_addr_r=0x202000000\0" \
+                     "initrd_addr=0x206000000\0"    \
+                     "initrd_size=0x2000000\0"   \
+                     "fdt_addr_r=0x201000000\0"    \
+                     "loadaddr=0x202000000\0"      \
+                     "hostname=marvell\0"        \
+                     "ramdisk_addr_r=0x206000000\0"    \
+                     "ramfs_name=-\0"        \
+                     "cpuidle=cpuidle.off=1\0"   \
+                     "fdt_name=fdt.dtb\0"        \
+                     "netdev=eth0\0"         \
+                     "ethaddr=00:51:82:11:22:00\0"   \
+                     "eth1addr=00:51:82:11:22:01\0"  \
+                     "image_name=Image\0"        \
+                     "get_ramfs=if test \"${ramfs_name}\"" \
+                     " != \"-\"; then setenv " \
+                     "ramdisk_addr_r 0x8000000; " \
+                     "tftpboot $ramdisk_addr_r " \
+                     "$ramfs_name; else setenv " \
+                     "ramdisk_addr_r -;fi\0" \
+                     "get_images=tftpboot $kernel_addr_r " \
+                     "$image_name; tftpboot " \
+                     "$fdt_addr_r $fdt_name; " \
+                     "run get_ramfs\0"   \

include/configs/mvebu_alleycat-5.h line 73

Quoted 10 lines
include/configs/mvebu_alleycat-5.h new file +10 -0
+                     "console=" "console=ttyS0,115200 "\
+                     "earlycon=uart8250,mmio32,0xf0512000\0"\
+                     "root=root=/dev/nfs rw\0"   \
+                     "set_bootargs=setenv bootargs $console"\
+                     " $root ip=$ipaddr:$serverip:" \
+                     "$gatewayip:$netmask:$hostname"\
+                     ":$netdev:none nfsroot="\
+                     "$serverip:$rootpath,tcp,v3 " \
+                     "$extra_params " \
+                     "$cpuidle"

This is hard to read, where is the variable name, where there is its value, etc...

Quoted 3 lines

And it would be better to use distroboot instead of manually written boot script.

Yep I'll try to clean that up. Again this is straight from the older SDK so it'snot follow current best practice.

Quoted 1 line
#9 lore raw

PATCH 7/7 tools: kwboot: Add knowledge of Marvell's TIM

In reply to Chris Packham

Marvell's proprietary TIM (trusted image) is used on the Armada-3700 and AlledCat5/5X (and possibly others). It has a whole host of features that work to implement a version of secure boot.

Kwboot's interest in this format is simply to detect that the image is one of these and not attempt to patch it (the images will work over UART boot as-is). This is done by checking for a specific magic value ("TIMH") in the first 32bits of the image.

---
It might be possible to make the check more robust by validating more of the image. There is a checksum field that might be useful for this purpose. I haven't done this as I couldn't figure out Marvell's validation of this field.

 tools/kwbimage.h | 29 +++++++++++++++++++++++++++++
 tools/kwboot.c   |  3 +++
 2 files changed, 32 insertions(+)
tools/kwbimage.h +29 -0
index 505522332b..8aab26952a 100644
@@ -224,6 +224,28 @@ struct register_set_hdr_v1 {
 #define OPT_HDR_V1_BINARY_TYPE   0x2
 #define OPT_HDR_V1_REGISTER_TYPE 0x3
 
+/* TIM (trusted image), Armada 3700, AlleyCat5 */
+struct tim_block_hdr {
+	uint32_t signature_id;
+	uint16_t opcode;
+	uint16_t blocksize;
+} __packed;
+
+struct tim_hdr {
+	struct tim_block_hdr hdr;
+	uint32_t trusted;
+	uint32_t signed_tim_size;
+	uint32_t unsigned_tim_size;
+	uint32_t unique_id;
+	uint64_t loadaddr;
+	uint32_t flags;
+	uint32_t software_prot_version;
+	uint32_t num_blocks;
+	uint32_t checksum;
+} __packed;
+
+#define TIM_HDR_SIGNATURE	0x54494d48 /* "TIMH" */
+
 /*
  * Byte 8 of the image header contains the version number. In the v0
  * header, byte 8 was reserved, and always set to 0. In the v1 header,
@@ -270,6 +292,13 @@ static inline size_t kwbheader_size_for_csum(const void *header)
 		return kwbheader_size(header);
 }
 
+static inline bool kwbimage_is_tim(void *img)
+{
+	const struct tim_hdr *hdr = img;
+
+	return le32_to_cpu(hdr->hdr.signature_id) == TIM_HDR_SIGNATURE;
+}
+
 static inline struct ext_hdr_v0 *ext_hdr_v0_first(void *img)
 {
 	struct main_hdr_v0 *mhdr;
tools/kwboot.c +3 -0
index da4fe32da2..a9b3d0fd04 100644
@@ -1869,6 +1869,9 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
 	if (*size < sizeof(struct main_hdr_v1))
 		goto err;
 
+	if (kwbimage_is_tim(img))
+		return 0;
+
 	image_ver = kwbimage_version(img);
 	if (image_ver != 0 && image_ver != 1) {
 		fprintf(stderr, "Invalid image header version\n");
Signature · 1 line
2.37.3
#10 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Hello! I think it does not make sense to hack kwboot to skip validation of kwbimage format when ad-hoc TIM header is detected. kwboot has now lot of features which requires and expects valid kwbimage format and is now written to work specially with 32-bit mvebu ARM BootROMs.

TIM and kwbimage are totally different formats and it really does not make sense to starting rewriting kwboot to support also other format. Instead it would be better to write other dedicated tool for it.

For example, there is already tool mox-imager [1], which despite its name supports all A3720 BootROMS and mvebu64boot [2] which supports A70x0, A80x0 and CN9130 BootROMS.

[1] - https://gitlab.nic.cz/turris/mox-imager
[2] - https://github.com/pali/mvebu64boot

Quoted 84 lines · On Friday 16 September 2022 16:54:23 Chris Packham wrote:

Marvell's proprietary TIM (trusted image) is used on the Armada-3700 and AlledCat5/5X (and possibly others). It has a whole host of features that work to implement a version of secure boot.

Kwboot's interest in this format is simply to detect that the image is one of these and not attempt to patch it (the images will work over UART boot as-is). This is done by checking for a specific magic value ("TIMH") in the first 32bits of the image.

---
It might be possible to make the check more robust by validating more of the image. There is a checksum field that might be useful for this purpose. I haven't done this as I couldn't figure out Marvell's validation of this field.

 tools/kwbimage.h | 29 +++++++++++++++++++++++++++++
 tools/kwboot.c   |  3 +++
 2 files changed, 32 insertions(+)
tools/kwbimage.h +29 -0
index 505522332b..8aab26952a 100644
@@ -224,6 +224,28 @@ struct register_set_hdr_v1 {
 #define OPT_HDR_V1_BINARY_TYPE   0x2
 #define OPT_HDR_V1_REGISTER_TYPE 0x3
 
+/* TIM (trusted image), Armada 3700, AlleyCat5 */
+struct tim_block_hdr {
+	uint32_t signature_id;
+	uint16_t opcode;
+	uint16_t blocksize;
+} __packed;
+
+struct tim_hdr {
+	struct tim_block_hdr hdr;
+	uint32_t trusted;
+	uint32_t signed_tim_size;
+	uint32_t unsigned_tim_size;
+	uint32_t unique_id;
+	uint64_t loadaddr;
+	uint32_t flags;
+	uint32_t software_prot_version;
+	uint32_t num_blocks;
+	uint32_t checksum;
+} __packed;
+
+#define TIM_HDR_SIGNATURE	0x54494d48 /* "TIMH" */
+
 /*
  * Byte 8 of the image header contains the version number. In the v0
  * header, byte 8 was reserved, and always set to 0. In the v1 header,
@@ -270,6 +292,13 @@ static inline size_t kwbheader_size_for_csum(const void *header)
 		return kwbheader_size(header);
 }
 
+static inline bool kwbimage_is_tim(void *img)
+{
+	const struct tim_hdr *hdr = img;
+
+	return le32_to_cpu(hdr->hdr.signature_id) == TIM_HDR_SIGNATURE;
+}
+
 static inline struct ext_hdr_v0 *ext_hdr_v0_first(void *img)
 {
 	struct main_hdr_v0 *mhdr;
tools/kwboot.c +3 -0
index da4fe32da2..a9b3d0fd04 100644
@@ -1869,6 +1869,9 @@ kwboot_img_patch(void *img, size_t *size, int baudrate)
 	if (*size < sizeof(struct main_hdr_v1))
 		goto err;
 
+	if (kwbimage_is_tim(img))
+		return 0;
+
 	image_ver = kwbimage_version(img);
 	if (image_ver != 0 && image_ver != 1) {
 		fprintf(stderr, "Invalid image header version\n");
Signature · 1 line
2.37.3
#11 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Quoted 9 lines · Pali Rohár,

Hello! I think it does not make sense to hack kwboot to skip validation of kwbimage format when ad-hoc TIM header is detected. kwboot has now lot of features which requires and expects valid kwbimage format and is now written to work specially with 32-bit mvebu ARM BootROMs.

TIM and kwbimage are totally different formats and it really does not make sense to starting rewriting kwboot to support also other format. Instead it would be better to write other dedicated tool for it.

Quoted 6 lines

For example, there is already tool mox-imager [1], which despite its name supports all A3720 BootROMS and mvebu64boot [2] which supports A70x0, A80x0 and CN9130 BootROMS.

[1] - https://gitlab.nic.cz/turris/mox-imager
[2] - https://github.com/pali/mvebu64boot

Yeah I tend to agree.

Mvebu64boot would fit better since this is a 64 bit Marveel SoC but again I'd have to teach it about TIM. One reason I went with kwboot (aside from not knowing anything else existed) was that the hand off between the uart boot sequence and the xmodem was awkward with the "official" methods (2 different transfer with 2 different protocols).

I do wonder if the boot seqence and xmodem stuff could be abstracted out to something that could be reused by other tools.

I the short term at least I'll drop this out of the series.

Quoted 89 lines · On Friday 16 September 2022 16:54:23 Chris Packham wrote:

tools/kwbimage.h static inline size_t kwbheader_size_for_csum(const

Quoted 54 lines

Marvell's proprietary TIM (trusted image) is used on the Armada-3700 and AlledCat5/5X (and possibly others). It has a whole host of features that work to implement a version of secure boot.

Kwboot's interest in this format is simply to detect that the image is one of these and not attempt to patch it (the images will work over UART boot as-is). This is done by checking for a specific magic value ("TIMH") in the first 32bits of the image.

---
It might be possible to make the check more robust by validating more of the image. There is a checksum field that might be useful for this purpose. I haven't done this as I couldn't figure out Marvell's validation of this field.

 tools/kwbimage.h | 29 +++++++++++++++++++++++++++++
 tools/kwboot.c   |  3 +++
 2 files changed, 32 insertions(+)
tools/kwbimage.h +22 -0
index 505522332b..8aab26952a 100644
@@ -224,6 +224,28 @@ struct register_set_hdr_v1 {
 #define OPT_HDR_V1_BINARY_TYPE   0x2
 #define OPT_HDR_V1_REGISTER_TYPE 0x3
 
+/* TIM (trusted image), Armada 3700, AlleyCat5 */
+struct tim_block_hdr {
+     uint32_t signature_id;
+     uint16_t opcode;
+     uint16_t blocksize;
+} __packed;
+
+struct tim_hdr {
+     struct tim_block_hdr hdr;
+     uint32_t trusted;
+     uint32_t signed_tim_size;
+     uint32_t unsigned_tim_size;
+     uint32_t unique_id;
+     uint64_t loadaddr;
+     uint32_t flags;
+     uint32_t software_prot_version;
+     uint32_t num_blocks;
+     uint32_t checksum;
+} __packed;
+
+#define TIM_HDR_SIGNATURE    0x54494d48 /* "TIMH" */
+
 /*
  * Byte 8 of the image header contains the version number. In the v0
  * header, byte 8 was reserved, and always set to 0. In the v1 header,
@@ -270,6 +292,13 @@ static inline size_t kwbheader_size_for_csum(const

void *header)

tools/kwboot.c kwboot_img_patch(void *img, size_t *size, int

Quoted 18 lines
tools/kwbimage.h +7 -0
              return kwbheader_size(header);
 }
 
+static inline bool kwbimage_is_tim(void *img)
+{
+     const struct tim_hdr *hdr = img;
+
+     return le32_to_cpu(hdr->hdr.signature_id) == TIM_HDR_SIGNATURE;
+}
+
 static inline struct ext_hdr_v0 *ext_hdr_v0_first(void *img)
 {
      struct main_hdr_v0 *mhdr;
tools/kwboot.c +0 -0
index da4fe32da2..a9b3d0fd04 100644
@@ -1869,6 +1869,9 @@ kwboot_img_patch(void *img, size_t *size, int

baudrate)

Quoted 12 lines
tools/kwboot.c +3 -1
      if (*size < sizeof(struct main_hdr_v1))
              goto err;
 
+     if (kwbimage_is_tim(img))
+             return 0;
+
      image_ver = kwbimage_version(img);
      if (image_ver != 0 && image_ver != 1) {
              fprintf(stderr, "Invalid image header version\n");
--

2.37.3

#12 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Quoted 15 lines · On Friday 16 September 2022 22:34:52 Chris Packham wrote:
Quoted 13 lines · Pali Rohár,

Hello! I think it does not make sense to hack kwboot to skip validation of kwbimage format when ad-hoc TIM header is detected. kwboot has now lot of features which requires and expects valid kwbimage format and is now written to work specially with 32-bit mvebu ARM BootROMs.

TIM and kwbimage are totally different formats and it really does not make sense to starting rewriting kwboot to support also other format. Instead it would be better to write other dedicated tool for it.

For example, there is already tool mox-imager [1], which despite its name supports all A3720 BootROMS and mvebu64boot [2] which supports A70x0, A80x0 and CN9130 BootROMS.

Quoted 8 lines
Quoted 2 lines

[1] - https://gitlab.nic.cz/turris/mox-imager
[2] - https://github.com/pali/mvebu64boot

Yeah I tend to agree.

Mvebu64boot would fit better since this is a 64 bit Marveel SoC but again I'd have to teach it about TIM.

mox-imager already implements generating and parsing TIM images as this is used on A3720. But for UART booting is used custom WTPTP protocol, not variant of xmodem.

Quoted 100 lines

One reason I went with kwboot (aside from
not knowing anything else existed) was that the hand off between the uart boot sequence and the xmodem was awkward with the "official" methods (2 different transfer with 2 different protocols).

I do wonder if the boot seqence and xmodem stuff could be abstracted out to something that could be reused by other tools.

I the short term at least I'll drop this out of the series.

Quoted 89 lines · On Friday 16 September 2022 16:54:23 Chris Packham wrote:

tools/kwbimage.h static inline size_t kwbheader_size_for_csum(const

Quoted 54 lines

Marvell's proprietary TIM (trusted image) is used on the Armada-3700 and AlledCat5/5X (and possibly others). It has a whole host of features that work to implement a version of secure boot.

Kwboot's interest in this format is simply to detect that the image is one of these and not attempt to patch it (the images will work over UART boot as-is). This is done by checking for a specific magic value ("TIMH") in the first 32bits of the image.

---
It might be possible to make the check more robust by validating more of the image. There is a checksum field that might be useful for this purpose. I haven't done this as I couldn't figure out Marvell's validation of this field.

 tools/kwbimage.h | 29 +++++++++++++++++++++++++++++
 tools/kwboot.c   |  3 +++
 2 files changed, 32 insertions(+)
tools/kwbimage.h +22 -0
index 505522332b..8aab26952a 100644
@@ -224,6 +224,28 @@ struct register_set_hdr_v1 {
 #define OPT_HDR_V1_BINARY_TYPE   0x2
 #define OPT_HDR_V1_REGISTER_TYPE 0x3
 
+/* TIM (trusted image), Armada 3700, AlleyCat5 */
+struct tim_block_hdr {
+     uint32_t signature_id;
+     uint16_t opcode;
+     uint16_t blocksize;
+} __packed;
+
+struct tim_hdr {
+     struct tim_block_hdr hdr;
+     uint32_t trusted;
+     uint32_t signed_tim_size;
+     uint32_t unsigned_tim_size;
+     uint32_t unique_id;
+     uint64_t loadaddr;
+     uint32_t flags;
+     uint32_t software_prot_version;
+     uint32_t num_blocks;
+     uint32_t checksum;
+} __packed;
+
+#define TIM_HDR_SIGNATURE    0x54494d48 /* "TIMH" */
+
 /*
  * Byte 8 of the image header contains the version number. In the v0
  * header, byte 8 was reserved, and always set to 0. In the v1 header,
@@ -270,6 +292,13 @@ static inline size_t kwbheader_size_for_csum(const

void *header)

tools/kwboot.c kwboot_img_patch(void *img, size_t *size, int

Quoted 18 lines
tools/kwbimage.h +7 -0
              return kwbheader_size(header);
 }
 
+static inline bool kwbimage_is_tim(void *img)
+{
+     const struct tim_hdr *hdr = img;
+
+     return le32_to_cpu(hdr->hdr.signature_id) == TIM_HDR_SIGNATURE;
+}
+
 static inline struct ext_hdr_v0 *ext_hdr_v0_first(void *img)
 {
      struct main_hdr_v0 *mhdr;
tools/kwboot.c +0 -0
index da4fe32da2..a9b3d0fd04 100644
@@ -1869,6 +1869,9 @@ kwboot_img_patch(void *img, size_t *size, int

baudrate)

Quoted 12 lines
tools/kwboot.c +3 -1
      if (*size < sizeof(struct main_hdr_v1))
              goto err;
 
+     if (kwbimage_is_tim(img))
+             return 0;
+
      image_ver = kwbimage_version(img);
      if (image_ver != 0 && image_ver != 1) {
              fprintf(stderr, "Invalid image header version\n");
--

2.37.3

#13 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

In reply to Chris Packham
Quoted 2 lines · On Friday 16 September 2022 22:34:52 Chris Packham wrote:

I do wonder if the boot seqence and xmodem stuff could be abstracted out to something that could be reused by other tools.

In the past I was thinking about it... but I come to the conclusion that it is easier to write specific tools which implements communication with just one BootROM. Trying to write one universal thing just opens a lot of issues and at the end it would do same thing like if you implement N independent applications and then additional "launcher" application which starts the correct one.

It looks like that most Marvell SoCs use xmodem protocol. Except 3720 which uses WTPTP. But as I figured out, every SoC use slightly modified protocol based on xmodem. So well, in theory "sx" would work. But if you want to have other features (like progress bar or bootrom output or speed change) then all this is bootrom specific and has to be implemented directly into xmodem state machine. So either you provide N xmodem implementations or try to create something "hookable" and since beginning I have feeling that "hooks" would just introduce new bugs and make it harder to debug.

kwboot is currently in the state that it supports kwbimage v0 and kwbimage v1 formats, which IIRC covers all 32-bit widely used SoCs from kirkwood, dove, armada and switches which integrates those CPUs, and probably also avanta. At lot of stages it expects valid kwbimage and that is why there is validation at the beginning. It injects 32-bit ARM binary code for changing UART speed and requires above SoC (as it touches internal registers, which are same on all those mentioned). It also contains workarounds for bugs in Armada 385 BootROMs.

I really think that kwboot is now in state when it is not easily possible to extend it for different platform without lot of energy and extra testing that it does not break something existing.

#14 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Hi Pali,

Quoted 32 lines · Pali Rohár
Quoted 2 lines · On Friday 16 September 2022 22:34:52 Chris Packham wrote:

I do wonder if the boot seqence and xmodem stuff could be abstracted out to something that could be reused by other tools.

In the past I was thinking about it... but I come to the conclusion that it is easier to write specific tools which implements communication with just one BootROM. Trying to write one universal thing just opens a lot of issues and at the end it would do same thing like if you implement N independent applications and then additional "launcher" application which starts the correct one.

It looks like that most Marvell SoCs use xmodem protocol. Except 3720 which uses WTPTP. But as I figured out, every SoC use slightly modified protocol based on xmodem. So well, in theory "sx" would work. But if you want to have other features (like progress bar or bootrom output or speed change) then all this is bootrom specific and has to be implemented directly into xmodem state machine. So either you provide N xmodem implementations or try to create something "hookable" and since beginning I have feeling that "hooks" would just introduce new bugs and make it harder to debug.

kwboot is currently in the state that it supports kwbimage v0 and kwbimage v1 formats, which IIRC covers all 32-bit widely used SoCs from kirkwood, dove, armada and switches which integrates those CPUs, and probably also avanta. At lot of stages it expects valid kwbimage and that is why there is validation at the beginning. It injects 32-bit ARM binary code for changing UART speed and requires above SoC (as it touches internal registers, which are same on all those mentioned). It also contains workarounds for bugs in Armada 385 BootROMs.

Quoted 3 lines

I really think that kwboot is now in state when it is not easily possible to extend it for different platform without lot of energy and extra testing that it does not break something existing.

Having looked more into mox-imager (and WtpDownloader) I've realised that the AlleyCat5 uses something called "TIM" but it's different to the format used by Armada-3700. I suspect what I'm actually dealing with is a TIMv0 that pre-dates the version used by Armada-3700. All the more reason to do something new instead of trying to shoe-horn it into one of the existing places. I'll probably end up making a fork of your mvebu64boot and adapting it (mox-imager just does too much).

#15 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Quoted 7 lines · On Monday 19 September 2022 10:57:10 Chris Packham wrote:

Having looked more into mox-imager (and WtpDownloader) I've realised that the AlleyCat5 uses something called "TIM" but it's different to the format used by Armada-3700. I suspect what I'm actually dealing with is a TIMv0 that pre-dates the version used by Armada-3700. All the more reason to do something new instead of trying to shoe-horn it into one of the existing places. I'll probably end up making a fork of your mvebu64boot and adapting it (mox-imager just does too much).

Hello! If that AC5 TIM format is different than A3720 TIM then it really makes sense to create a new tool. Forking mvebu64boot into completely new project seems like the easiest way how to achieve working tool without being afraid to break existing support.

Anyway, is not there any Marvell tool for this AC5 TIM format? Like A3720 TBB or WtpDownloader?

#16 lore raw

Re: [PATCH 7/7] tools: kwboot: Add knowledge of Marvell's TIM

Quoted 10 lines · Pali Rohár
Quoted 7 lines · On Monday 19 September 2022 10:57:10 Chris Packham wrote:

Having looked more into mox-imager (and WtpDownloader) I've realised that the AlleyCat5 uses something called "TIM" but it's different to the format used by Armada-3700. I suspect what I'm actually dealing with is a TIMv0 that pre-dates the version used by Armada-3700. All the more reason to do something new instead of trying to shoe-horn it into one of the existing places. I'll probably end up making a fork of your mvebu64boot and adapting it (mox-imager just does too much).

Quoted 7 lines

Hello! If that AC5 TIM format is different than A3720 TIM then it really makes sense to create a new tool. Forking mvebu64boot into completely new project seems like the easiest way how to achieve working tool without being afraid to break existing support.

Anyway, is not there any Marvell tool for this AC5 TIM format? Like A3720 TBB or WtpDownloader?

Nope the only official support is send the boot pattern using ascii/raw then send the image using xmodem. Which is what led to me looking for an alternative that can actually tell when the SoC has detected the pattern and hand off to the xmodem download. Supporting the signed images would be a bonus but not for my immediate need for recovering from bad bootloaders.