Skip to contentSkip to conversation

arm: mach-k3: am62: Add core number, gpu and pru autodetection FDT fixups

PATCH In review Francesco Dolcini 2 participants 5 messages Jul 14, 2023 – Jul 21, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover arm: mach-k3: am62: Add core number, gpu and pru autodetection FDT fixups

From: Francesco Dolcini <[email protected]>

AM62x SoC is available in multiple variant:
- CPU cores (Cortex-A) AM62x1 (1 core), AM62x2 (2 cores), AM62x4 (4 cores)
- GPU AM625x with GPU, AM623x without GPU
- PRU (Programmable RT unit) can be present or not on AM62x2/AM62x4

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change is possible to have a single dts/dtb file handling the different variant at runtime. While removing GPU node and CPU nodes also the watchdog node in the same Module Domain is removed.

A similar approach is implemented for example on i.MX8 and STM32MP1 SoC.

Since we start using ft_system_setup on a SoC without msmc ram and fdt_fixup_msmc_ram function fails on those SoC (triggering a reset loop) the first commit fix it by calling that function only on specific SoC.

v2:
- Moved fdt common functions to to common_fdt.c and ft_system_setup function to specific SoC files (eg. am654_fdt.c) and compile them using relevant configuration
- Add GPU and PRU fdt fixup

v1: https://lore.kernel.org/all/[email protected]/

Emanuele Ghidoli (3):
arm: k3: Fix ft_system_setup so it can be enabled on any SoC
arm: mach-k3: am62: Add CTRLMMR_WKUP_JTAG_DEVICE_ID register
definition
arm: mach-k3: am62: Fixup CPU core, gpu and pru nodes in fdt

 arch/arm/mach-k3/Makefile                     |   7 ++
 arch/arm/mach-k3/am625_fdt.c                  |  71 +++++++++++
 arch/arm/mach-k3/am654_fdt.c                  |  12 ++
 arch/arm/mach-k3/common.c                     |  91 --------------
 arch/arm/mach-k3/common_fdt.c                 | 113 ++++++++++++++++++
 arch/arm/mach-k3/common_fdt.h                 |  11 ++
 arch/arm/mach-k3/include/mach/am62_hardware.h |  22 ++++
 arch/arm/mach-k3/j721e_fdt.c                  |  12 ++
 arch/arm/mach-k3/j721s2_fdt.c                 |  12 ++
 9 files changed, 260 insertions(+), 91 deletions(-)
 create mode 100644 arch/arm/mach-k3/am625_fdt.c
 create mode 100644 arch/arm/mach-k3/am654_fdt.c
 create mode 100644 arch/arm/mach-k3/common_fdt.c
 create mode 100644 arch/arm/mach-k3/common_fdt.h
 create mode 100644 arch/arm/mach-k3/j721e_fdt.c
 create mode 100644 arch/arm/mach-k3/j721s2_fdt.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 arm: k3: Fix ft_system_setup so it can be enabled on any SoC

From: Emanuele Ghidoli <[email protected]>

ft_system_setup cannot be enabled on SoC without msmc sram otherwise fdt_fixup_msmc_ram function fails causing system reset.

Fix by moving fdt_fixup_msmc_ram to common_fdt.c file and creating SoC (AM654, J721E and J721S2) specific files for fdt fixups.

This change was verified to not change anything on any existing board (all the J721S2, AM654 and J721E boards requires it,
none of the remaining k3 boards require it).

Fixes 30e96a240156 ("arm: mach-k3: Move MSMC fixup to SoC level")

---
v2:
- Moved fdt common functions to to common_fdt.c and ft_system_setup function to specific SoC files (eg. am654_fdt.c) and compile them using relevant configuration

---
 arch/arm/mach-k3/Makefile     |  6 +++
 arch/arm/mach-k3/am654_fdt.c  | 12 +++++
 arch/arm/mach-k3/common.c     | 91 ---------------------------------
 arch/arm/mach-k3/common_fdt.c | 95 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-k3/common_fdt.h | 11 ++++
 arch/arm/mach-k3/j721e_fdt.c  | 12 +++++
 arch/arm/mach-k3/j721s2_fdt.c | 12 +++++
 7 files changed, 148 insertions(+), 91 deletions(-)
 create mode 100644 arch/arm/mach-k3/am654_fdt.c
 create mode 100644 arch/arm/mach-k3/common_fdt.c
 create mode 100644 arch/arm/mach-k3/common_fdt.h
 create mode 100644 arch/arm/mach-k3/j721e_fdt.c
 create mode 100644 arch/arm/mach-k3/j721s2_fdt.c
arch/arm/mach-k3/Makefile +6 -0
index b5bc2367813c..499bdaa7153d 100644
@@ -10,6 +10,12 @@ obj-$(CONFIG_SOC_K3_AM62A7) += am62ax/
 obj-$(CONFIG_ARM64) += arm64-mmu.o
 obj-$(CONFIG_CPU_V7R) += r5_mpu.o lowlevel_init.o
 obj-$(CONFIG_ARM64) += cache.o
+obj-$(CONFIG_OF_LIBFDT) += common_fdt.o
+ifeq ($(CONFIG_OF_LIBFDT)$(CONFIG_OF_SYSTEM_SETUP),yy)
+obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o
+obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o
+obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o
+endif
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_SOC_K3_AM654) += am654_init.o
 obj-$(CONFIG_SOC_K3_J721E) += j721e_init.o
arch/arm/mach-k3/am654_fdt.c new file +12 -0
new file mode 100644
index 000000000000..652fe8d32bbb
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023 Toradex - https://www.toradex.com/
+ */
+
+#include "common_fdt.h"
+#include <fdt_support.h>
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	return fdt_fixup_msmc_ram_k3(blob);
+}
arch/arm/mach-k3/common.c +0 -91

97 lines not on this page · raw message

arch/arm/mach-k3/common_fdt.c new file +95 -0

95 lines not on this page · raw message

arch/arm/mach-k3/common_fdt.h new file +11 -0
new file mode 100644
index 000000000000..46c3dc5e1197
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright 2023 Toradex - https://www.toradex.com/
+ */
+
+#ifndef _COMMON_FDT_H
+#define _COMMON_FDT_H
+
+int fdt_fixup_msmc_ram_k3(void *blob);
+
+#endif /* _COMMON_FDT_H */
arch/arm/mach-k3/j721e_fdt.c new file +12 -0
new file mode 100644
index 000000000000..652fe8d32bbb
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023 Toradex - https://www.toradex.com/
+ */
+
+#include "common_fdt.h"
+#include <fdt_support.h>
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	return fdt_fixup_msmc_ram_k3(blob);
+}
arch/arm/mach-k3/j721s2_fdt.c new file +12 -0
new file mode 100644
index 000000000000..652fe8d32bbb
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright 2023 Toradex - https://www.toradex.com/
+ */
+
+#include "common_fdt.h"
+#include <fdt_support.h>
+
+int ft_system_setup(void *blob, struct bd_info *bd)
+{
+	return fdt_fixup_msmc_ram_k3(blob);
+}
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 arm: mach-k3: am62: Add CTRLMMR_WKUP_JTAG_DEVICE_ID register definition

In reply to Francesco Dolcini

From: Emanuele Ghidoli <[email protected]>

Add register address and relevant bitmasks and shifts. Allow reading these information:
- device identification
- number of cores (part of device identification)
- features (currently: PRU / no PRU)
- security
- functional safety
- speed grade
- temperature grade
- package

---
v2:
- added reviewed-by afd
- added GPU/PRU mask

---
 arch/arm/mach-k3/include/mach/am62_hardware.h | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm/mach-k3/include/mach/am62_hardware.h +22 -0
index 88d58947269a..acd2d109c2c5 100644
@@ -20,6 +20,28 @@
 #define MCU_CTRL_MMR0_BASE			0x04500000
 #define WKUP_CTRL_MMR0_BASE			0x43000000
 
+#define CTRLMMR_WKUP_JTAG_DEVICE_ID		(WKUP_CTRL_MMR0_BASE + 0x18)
+#define JTAG_DEV_ID_MASK			GENMASK(31, 18)
+#define JTAG_DEV_ID_SHIFT			18
+#define JTAG_DEV_CORE_NR_MASK			GENMASK(21, 19)
+#define JTAG_DEV_CORE_NR_SHIFT			19
+#define JTAG_DEV_GPU_MASK			BIT(18)
+#define JTAG_DEV_GPU_SHIFT			18
+#define JTAG_DEV_FEATURES_MASK			GENMASK(17, 13)
+#define JTAG_DEV_FEATURES_SHIFT			13
+#define JTAG_DEV_SECURITY_MASK			BIT(12)
+#define JTAG_DEV_SECURITY_SHIFT			12
+#define JTAG_DEV_SAFETY_MASK			BIT(11)
+#define JTAG_DEV_SAFETY_SHIFT			11
+#define JTAG_DEV_SPEED_MASK			GENMASK(10, 6)
+#define JTAG_DEV_SPEED_SHIFT			6
+#define JTAG_DEV_TEMP_MASK			GENMASK(5, 3)
+#define JTAG_DEV_TEMP_SHIFT			3
+#define JTAG_DEV_PKG_MASK			GENMASK(2, 0)
+#define JTAG_DEV_PKG_SHIFT			0
+
+#define JTAG_DEV_FEATURE_NO_PRU			0x4
+
 #define CTRLMMR_MAIN_DEVSTAT			(WKUP_CTRL_MMR0_BASE + 0x30)
 #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK	GENMASK(6, 3)
 #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT	3
Signature · 1 line
2.25.1
#3 lore raw

PATCH v2 3/3 arm: mach-k3: am62: Fixup CPU core, gpu and pru nodes in fdt

In reply to Francesco Dolcini

From: Emanuele Ghidoli <[email protected]>

AM62x SoC is available in multiple variant:
- CPU cores (Cortex-A) AM62x1 (1 core), AM62x2 (2 cores), AM62x4 (4 cores)
- GPU AM625x with GPU, AM623x without GPU
- PRU (Programmable RT unit) can be present or not on AM62x2/AM62x4

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change is possible to have a single dts/dtb file handling the different variant at runtime. While removing GPU node and CPU nodes also the watchdog node in the same Module Domain is removed.

A similar approach is implemented for example on i.MX8 and STM32MP1 SoC.

---
v2:
- add GPU/PRU fixups

---
 arch/arm/mach-k3/Makefile     |  1 +
 arch/arm/mach-k3/am625_fdt.c  | 71 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-k3/common_fdt.c | 18 +++++++++
 3 files changed, 90 insertions(+)
 create mode 100644 arch/arm/mach-k3/am625_fdt.c
arch/arm/mach-k3/Makefile +1 -0
index 499bdaa7153d..fd77b8bbba5c 100644
@@ -15,6 +15,7 @@ ifeq ($(CONFIG_OF_LIBFDT)$(CONFIG_OF_SYSTEM_SETUP),yy)
 obj-$(CONFIG_SOC_K3_AM654) += am654_fdt.o
 obj-$(CONFIG_SOC_K3_J721E) += j721e_fdt.o
 obj-$(CONFIG_SOC_K3_J721S2) += j721s2_fdt.o
+obj-$(CONFIG_SOC_K3_AM625) += am625_fdt.o
 endif
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj-$(CONFIG_SOC_K3_AM654) += am654_init.o
arch/arm/mach-k3/am625_fdt.c new file +71 -0

71 lines not on this page · raw message

arch/arm/mach-k3/common_fdt.c +18 -0
index c86fe3a5890b..9478f605441f 100644
@@ -93,3 +93,21 @@ int fdt_fixup_msmc_ram_k3(void *blob)
 
 	return ret;
 }
+
+int fdt_del_node_path(void *blob, const char *path)
+{
+	int ret;
+	int nodeoff;
+
+	nodeoff = fdt_path_offset(blob, path);
+	if (nodeoff < 0)
+		return 0; /* Not found, skip it */
+
+	ret = fdt_del_node(blob, nodeoff);
+	if (ret < 0)
+		printf("Unable to delete node %s, err=%s\n", path, fdt_strerror(ret));
+	else
+		debug("Deleted node %s\n", path);
+
+	return ret;
+}
Signature · 1 line
2.25.1
#4 lore raw
In reply to Francesco Dolcini
Quoted 8 lines · Francesco Dolcini

From: Francesco Dolcini <[email protected]>

AM62x SoC is available in multiple variant:
- CPU cores (Cortex-A) AM62x1 (1 core), AM62x2 (2 cores), AM62x4 (4 cores)
- GPU AM625x with GPU, AM623x without GPU
- PRU (Programmable RT unit) can be present or not on AM62x2/AM62x4

[...]

Applied to u-boot/master, thanks!

Signature · 1 line
Tom