Skip to contentSkip to conversation

Add fdt-fixups for AM62A variants

PATCH In review Aparna Patra 4 participants 13 messages Apr 30, 2025 – May 28, 2025

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

cover Add fdt-fixups for AM62A variants

This series implements fdt fixups, by reading hardware information from registers and accordingly delete/modify the DT nodes, at run-time.

Aparna Patra (3):
arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes
in fdt
arm: mach-k3: am62a: Fixup thermal zone critical points
arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 92 +++++++++++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 81 ++++++++++++++++
 2 files changed, 173 insertions(+)

base-commit: 56accc56b9aab87ef4809ccc588e1257969cd271

Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

AM62A SOC is available in multiple variants:
-CPU cores (Cortex-A) AM62Ax1 (1 core),
AM62Ax2 (2 cores), AM62Ax4 (4 cores)
-With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41 +++++++++++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++
 2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +41 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
 
 #include "../common_fdt.h"
 
+static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+	char node_path[32];
+
+	if (core_nr < 1)
+		return;
+
+	for (; core_nr < 4; core_nr++) {
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
+		fdt_del_node_path(blob, node_path);
+	}
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+	if (!has_dss) {
+		fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+		fdt_del_node_path(blob, "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");
+	}
+}
+
+static void fdt_fixup_video_codec_nodes_am62a(void *blob, bool has_video_codec)
+{
+	if (!has_video_codec)
+		fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
+}
+
+static void fdt_fixup_canfd_nodes_am62a(void *blob, bool has_canfd)
+{
+	if (!has_canfd)
+		fdt_del_node_path(blob, "/bus@f0000/can@20701000");
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
+	fdt_fixup_dss_nodes_am62a(blob, k3_has_dss());
+	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
+	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
 	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
 	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +40 -0
index cd61abe018..ab281129d7 100644
@@ -19,6 +19,18 @@
 #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_CORE_NR_MASK			GENMASK(19, 18)
+#define JTAG_DEV_CORE_NR_SHIFT			18
+#define JTAG_DEV_CANFD_MASK			BIT(15)
+#define JTAG_DEV_CANFD_SHIFT			15
+#define JTAG_DEV_VIDEO_CODEC_MASK			BIT(14)
+#define JTAG_DEV_VIDEO_CODEC_SHIFT			14
+#define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
+#define JTAG_DEV_DSS_SHIFT			13
+
+#define JTAG_DEV_HAS_DSS_VALUE			0xD
+
 #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
@@ -86,6 +98,34 @@
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	0x70000001
 #endif /* CONFIG_CPU_V7R */
 
+static inline int k3_get_core_nr(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return ((dev_id & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT) + 1;
+}
+
+static inline int k3_has_dss(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (JTAG_DEV_HAS_DSS_VALUE == ((dev_id & JTAG_DEV_DSS_MASK) >> JTAG_DEV_DSS_SHIFT));
+}
+
+static inline int k3_has_video_codec(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return !((dev_id & JTAG_DEV_VIDEO_CODEC_MASK) >> JTAG_DEV_VIDEO_CODEC_SHIFT);
+}
+
+static inline int k3_has_canfd(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
+}
+
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
 static const u32 put_device_ids[] = {};
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/3] arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

On April 30, 2025 thus sayeth Aparna Patra:

Quoted 35 lines

AM62A SOC is available in multiple variants:

(quoted diff) +0 -2
-CPU cores (Cortex-A) AM62Ax1 (1 core),
 AM62Ax2 (2 cores), AM62Ax4 (4 cores)
-With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41 +++++++++++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++
 2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +12 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
 
 #include "../common_fdt.h"
 
+static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+	char node_path[32];
+
+	if (core_nr < 1)
+		return;
+
+	for (; core_nr < 4; core_nr++) {
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
+		fdt_del_node_path(blob, node_path);

arch/arm/mach-k3/am62ax/am62a7_fdt.c line 32

Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +10 -0
+		snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
+		fdt_del_node_path(blob, node_path);
+	}
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+	if (!has_dss) {
+		fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+		fdt_del_node_path(blob, "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");

So for a little background on the upcoming paragraph[0]

I completely agree we should remove the dss{} node but don't think it's wise of us to start trying to unwind the allocation or configuration of the hardware when the hardware isn't there.

In my eyes because we can't really trust the names for the memory carveouts, mailbox and, pinmux nodes as they are just describing their use and are fairly unstable as the boards age we would need to keep up with each node's bindings and follow all the pinmux, mboxes, memory-region phandles via their properties to undo all those nodes which leaves us making too many opinionated decisions on how best to do that in my opinion.

Anywho from that first link I'm trusting Andrew has a plan which from what I've seen could look something like an overlay[1] But time will tell.

~Bryan

[0] https://lore.kernel.org/all/[email protected]/
[1] https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/?id=95010a7c186b86f738615231016aa017ac527612

#3 lore raw

Re: [PATCH 1/3] arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

Quoted 60 lines · Bryan Brattlof

On April 30, 2025 thus sayeth Aparna Patra:

Quoted 35 lines

AM62A SOC is available in multiple variants:

(quoted diff) +0 -2
-CPU cores (Cortex-A) AM62Ax1 (1 core),
  AM62Ax2 (2 cores), AM62Ax4 (4 cores)
-With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
  arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41 +++++++++++++++++++
  .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++
  2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +12 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
 
  #include "../common_fdt.h"
 
+static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+	char node_path[32];
+
+	if (core_nr < 1)
+		return;
+
+	for (; core_nr < 4; core_nr++) {
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
+		fdt_del_node_path(blob, node_path);

arch/arm/mach-k3/am62ax/am62a7_fdt.c line 32

Quoted 10 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +10 -0
+		snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
+		fdt_del_node_path(blob, node_path);
+	}
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+	if (!has_dss) {
+		fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+		fdt_del_node_path(blob, "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");

So for a little background on the upcoming paragraph[0]

I completely agree we should remove the dss{} node but don't think it's wise of us to start trying to unwind the allocation or configuration of the hardware when the hardware isn't there.

In my eyes because we can't really trust the names for the memory carveouts, mailbox and, pinmux nodes as they are just describing their use and are fairly unstable as the boards age we would need to keep up with each node's bindings and follow all the pinmux, mboxes, memory-region phandles via their properties to undo all those nodes which leaves us making too many opinionated decisions on how best to do that in my opinion.

Quoted 8 lines

Anywho from that first link I'm trusting Andrew has a plan which from what I've seen could look something like an overlay[1] But time will tell.

~Bryan

[0] https://lore.kernel.org/all/[email protected]/
[1] https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/commit/?id=95010a7c186b86f738615231016aa017ac527612

Sure Bryan, I will test without the pinmux fixup, and send out the modified patches.

Thanks,
Aparna

Quoted 1 line
#4 lore raw

Re: [PATCH 1/3] arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

In reply to Aparna Patra
Quoted 130 lines · Aparna Patra

AM62A SOC is available in multiple variants:

(quoted diff) +0 -2
-CPU cores (Cortex-A) AM62Ax1 (1 core),
 AM62Ax2 (2 cores), AM62Ax4 (4 cores)
-With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41 +++++++++++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++
 2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +41 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
 
 #include "../common_fdt.h"
 
+static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+	char node_path[32];
+
+	if (core_nr < 1)
+		return;
+
+	for (; core_nr < 4; core_nr++) {
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
+		fdt_del_node_path(blob, node_path);
+	}
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+	if (!has_dss) {
+		fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+		fdt_del_node_path(blob, "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");
+	}
+}
+
+static void fdt_fixup_video_codec_nodes_am62a(void *blob, bool has_video_codec)
+{
+	if (!has_video_codec)
+		fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
+}
+
+static void fdt_fixup_canfd_nodes_am62a(void *blob, bool has_canfd)
+{
+	if (!has_canfd)
+		fdt_del_node_path(blob, "/bus@f0000/can@20701000");
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
+	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
+	fdt_fixup_dss_nodes_am62a(blob, k3_has_dss());
+	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
+	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
 	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
 	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +40 -0
index cd61abe018..ab281129d7 100644
@@ -19,6 +19,18 @@
 #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_CORE_NR_MASK			GENMASK(19, 18)
+#define JTAG_DEV_CORE_NR_SHIFT			18
+#define JTAG_DEV_CANFD_MASK			BIT(15)
+#define JTAG_DEV_CANFD_SHIFT			15
+#define JTAG_DEV_VIDEO_CODEC_MASK			BIT(14)
+#define JTAG_DEV_VIDEO_CODEC_SHIFT			14
+#define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
+#define JTAG_DEV_DSS_SHIFT			13
+
+#define JTAG_DEV_HAS_DSS_VALUE			0xD
+
 #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
@@ -86,6 +98,34 @@
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	0x70000001
 #endif /* CONFIG_CPU_V7R */
 
+static inline int k3_get_core_nr(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return ((dev_id & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT) + 1;
+}
+
+static inline int k3_has_dss(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (JTAG_DEV_HAS_DSS_VALUE == ((dev_id & JTAG_DEV_DSS_MASK) >> JTAG_DEV_DSS_SHIFT));
+}
+
+static inline int k3_has_video_codec(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return !((dev_id & JTAG_DEV_VIDEO_CODEC_MASK) >> JTAG_DEV_VIDEO_CODEC_SHIFT);
+}
+
+static inline int k3_has_canfd(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
+}
+
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
 static const u32 put_device_ids[] = {};
Signature · 1 line
2.34.1

We should do a proper framework for this that scales multiple devices.

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#5 lore raw

Re: [PATCH 1/3] arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

Quoted 97 lines · Nishanth Menon
Quoted 96 lines · Aparna Patra

AM62A SOC is available in multiple variants:

(quoted diff) +0 -2
-CPU cores (Cortex-A) AM62Ax1 (1 core),
  AM62Ax2 (2 cores), AM62Ax4 (4 cores)
-With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
  arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41 +++++++++++++++++++
  .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++
  2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +41 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
 
  #include "../common_fdt.h"
 
+static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+	char node_path[32];
+
+	if (core_nr < 1)
+		return;
+
+	for (; core_nr < 4; core_nr++) {
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/cpus/cpu-map/cluster0/core%d", core_nr);
+		fdt_del_node_path(blob, node_path);
+		snprintf(node_path, sizeof(node_path), "/bus@f0000/watchdog@e0%d0000", core_nr);
+		fdt_del_node_path(blob, node_path);
+	}
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+	if (!has_dss) {
+		fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+		fdt_del_node_path(blob, "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");
+	}
+}
+
+static void fdt_fixup_video_codec_nodes_am62a(void *blob, bool has_video_codec)
+{
+	if (!has_video_codec)
+		fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
+}
+
+static void fdt_fixup_canfd_nodes_am62a(void *blob, bool has_canfd)
+{
+	if (!has_canfd)
+		fdt_del_node_path(blob, "/bus@f0000/can@20701000");
+}
+
  int ft_system_setup(void *blob, struct bd_info *bd)
  {
+	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
+	fdt_fixup_dss_nodes_am62a(blob, k3_has_dss());
+	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
+	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
  	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
  	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +12 -0
index cd61abe018..ab281129d7 100644
@@ -19,6 +19,18 @@
  #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_CORE_NR_MASK			GENMASK(19, 18)
+#define JTAG_DEV_CORE_NR_SHIFT			18
+#define JTAG_DEV_CANFD_MASK			BIT(15)
+#define JTAG_DEV_CANFD_SHIFT			15
+#define JTAG_DEV_VIDEO_CODEC_MASK			BIT(14)
+#define JTAG_DEV_VIDEO_CODEC_SHIFT			14
+#define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
+#define JTAG_DEV_DSS_SHIFT			13
+
+#define JTAG_DEV_HAS_DSS_VALUE			0xD
+
  #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
@@ -86,6 +98,34 @@
  #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	0x70000001
  #endif /* CONFIG_CPU_V7R */
 
Quoted 7 lines

arch/arm/mach-k3/include/mach/am62a_hardware.h line 107

Quoted 7 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +7 -0
+static inline int k3_get_core_nr(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return ((dev_id & JTAG_DEV_CORE_NR_MASK) >> JTAG_DEV_CORE_NR_SHIFT) + 1;
+}
+

I can see these three following components are optional but I don't see any silicon devices without them. The AM62A processor data sheet only lists devices with different A53 and C7 options.

BTW: C7x fixup is missing in this series ;)

Quoted 23 lines
Quoted 23 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +21 -0
+static inline int k3_has_dss(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (JTAG_DEV_HAS_DSS_VALUE == ((dev_id & JTAG_DEV_DSS_MASK) >> JTAG_DEV_DSS_SHIFT));
+}
+
+static inline int k3_has_video_codec(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return !((dev_id & JTAG_DEV_VIDEO_CODEC_MASK) >> JTAG_DEV_VIDEO_CODEC_SHIFT);
+}
+
+static inline int k3_has_canfd(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
+}
+
  #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
Quoted 5 lines
Quoted 4 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +0 -0
  static const u32 put_device_ids[] = {};
Signature · 1 line
2.34.1

We should do a proper framework for this that scales multiple devices.

I agree, this should be reworked afterwards and moved into a framework. We have literally the same logic for AM62 and AM62Ax. I also have temperature fixup patches for the AM64 which are identical again. Would be nice to move most of this logic into a common part.

Thanks for sending those patches!

- Daniel

Quoted 2 lines
#6 lore raw

Re: [PATCH 1/3] arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes in fdt

Quoted 111 lines · Daniel Schultz
Quoted 98 lines · Nishanth Menon
Quoted 97 lines · Aparna Patra

AM62A SOC is available in multiple variants:
-CPU cores (Cortex-A) AM62Ax1 (1 core), AM62Ax2 (2 cores), AM62Ax4 (4 cores) -With and without DSS, CAN-FD & Video-codec support

Remove the relevant FDT nodes by reading the actual configuration from the SoC registers, with that change it is possible to have a single dts/dtb file handling the different variants at runtime.

---
  arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 41
+++++++++++++++++++
  .../arm/mach-k3/include/mach/am62a_hardware.h | 40 ++++++++++++++++++

  2 files changed, 81 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +36 -0
index 7f764ab36b..56fd658202 100644
@@ -8,8 +8,49 @@
     #include "../common_fdt.h"
   +static void fdt_fixup_cores_wdt_nodes_am62a(void *blob, int core_nr)
+{
+    char node_path[32];
+
+    if (core_nr < 1)
+        return;
+
+    for (; core_nr < 4; core_nr++) {
+        snprintf(node_path, sizeof(node_path), "/cpus/cpu@%d", 
 core_nr);
+        fdt_del_node_path(blob, node_path);
+        snprintf(node_path, sizeof(node_path), 
 "/cpus/cpu-map/cluster0/core%d", core_nr);
+        fdt_del_node_path(blob, node_path);
+        snprintf(node_path, sizeof(node_path), 
 "/bus@f0000/watchdog@e0%d0000", core_nr);
+        fdt_del_node_path(blob, node_path);
+    }
+}
+
+static void fdt_fixup_dss_nodes_am62a(void *blob, bool has_dss)
+{
+    if (!has_dss) {
+        fdt_del_node_path(blob, "/bus@f0000/dss@30200000");
+        fdt_del_node_path(blob, 
 "/bus@f0000/pinctrl@f4000/main-dss0-default-pins");
+    }
+}
+
+static void fdt_fixup_video_codec_nodes_am62a(void *blob, bool 
 has_video_codec)
+{
+    if (!has_video_codec)
+        fdt_del_node_path(blob, "/bus@f0000/video-codec@30210000");
+}
+
+static void fdt_fixup_canfd_nodes_am62a(void *blob, bool has_canfd)
+{
+    if (!has_canfd)
+        fdt_del_node_path(blob, "/bus@f0000/can@20701000");
+}
+
   int ft_system_setup(void *blob, struct bd_info *bd)

  {
+    fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
+    fdt_fixup_dss_nodes_am62a(blob, k3_has_dss());
+    fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
+    fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
      fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000); fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
  diff --git a/arch/arm/mach-k3/include/mach/am62a_hardware.h b/arch/arm/mach-k3/include/mach/am62a_hardware.h index cd61abe018..ab281129d7 100644

arch/arm/mach-k3/include/mach/am62a_hardware.h +11 -0
@@ -19,6 +19,18 @@
   #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_CORE_NR_MASK            GENMASK(19, 18)
+#define JTAG_DEV_CORE_NR_SHIFT            18
+#define JTAG_DEV_CANFD_MASK            BIT(15)
+#define JTAG_DEV_CANFD_SHIFT            15
+#define JTAG_DEV_VIDEO_CODEC_MASK            BIT(14)
+#define JTAG_DEV_VIDEO_CODEC_SHIFT            14
+#define JTAG_DEV_DSS_MASK            GENMASK(16, 13)
+#define JTAG_DEV_DSS_SHIFT            13
+
+#define JTAG_DEV_HAS_DSS_VALUE            0xD
+
   #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
@@ -86,6 +98,34 @@
   #define TI_SRAM_SCRATCH_BOARD_EEPROM_START    0x70000001
   #endif /* CONFIG_CPU_V7R */
Quoted 8 lines

arch/arm/mach-k3/include/mach/am62a_hardware.h line 107

Quoted 8 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +6 -0
   +static inline int k3_get_core_nr(void)
+{
+    u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+    return ((dev_id & JTAG_DEV_CORE_NR_MASK) >> 
 JTAG_DEV_CORE_NR_SHIFT) + 1;
+}
+

I can see these three following components are optional but I don't see any silicon devices without them. The AM62A processor data sheet only lists devices with different A53 and C7 options.

Quoted 1 line

BTW: C7x fixup is missing in this series ;)

Daniel, table 4-1 only shows the classification of AM62A family.
please refer to table 9.1 in datasheet for device grades information. There are device grades which doesnot have DSS, Video-codec etc

For C7x, upstream does not include C7x device nodes as of now. Fixups will be added once nodes are included in dts.

Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +19 -0
+static inline int k3_has_dss(void)
+{
+    u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+    return (JTAG_DEV_HAS_DSS_VALUE == ((dev_id & JTAG_DEV_DSS_MASK) 
 >> JTAG_DEV_DSS_SHIFT));
+}
+
+static inline int k3_has_video_codec(void)
+{
+    u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+    return !((dev_id & JTAG_DEV_VIDEO_CODEC_MASK) >> 
 JTAG_DEV_VIDEO_CODEC_SHIFT);
+}
+
+static inline int k3_has_canfd(void)
+{
+    u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+    return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +2 -0
+}
+

  #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) static const u32 put_device_ids[] = {};

Signature · 1 line
2.34.1

We should do a proper framework for this that scales multiple devices.

Quoted 6 lines

I agree, this should be reworked afterwards and moved into a framework. We have literally the same logic for AM62 and AM62Ax. I also have temperature fixup patches for the AM64 which are identical again. Would be nice to move most of this logic into a common part.

Thanks for sending those patches!

- Daniel

Thanks for reviewing the patches Daniel. We will soon define a common framework and reuse APIs wherever possible.
- Aparna

Quoted 2 lines
Quoted 2 lines
#7 lore raw

PATCH 2/3 arm: mach-k3: am62a: Fixup thermal zone critical points

In reply to Aparna Patra

Read the max temperature for the SoC temperature grade from the hardware and modify the critical trip nodes on each thermal zone of FDT at runtime so they are correct with the hardware value for its grade.

---
 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 37 +++++++++++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 18 +++++++++
 2 files changed, 55 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +37 -0
index 56fd658202..40833ca392 100644
@@ -45,12 +45,49 @@ static void fdt_fixup_canfd_nodes_am62a(void *blob, bool has_canfd)
 		fdt_del_node_path(blob, "/bus@f0000/can@20701000");
 }
 
+static int fdt_fixup_trips_node(void *blob, int zoneoffset, int maxc)
+{
+	int node, trip;
+
+	node = fdt_subnode_offset(blob, zoneoffset, "trips");
+	if (node < 0)
+		return -1;
+
+	fdt_for_each_subnode(trip, blob, node) {
+		const char *type = fdt_getprop(blob, trip, "type", NULL);
+
+		if (!type || (strncmp(type, "critical", 8) != 0))
+			continue;
+
+		if (fdt_setprop_u32(blob, trip, "temperature", 1000 * maxc) < 0)
+			return -1;
+	}
+
+	return 0;
+}
+
+static void fdt_fixup_thermal_zone_nodes_am62a(void *blob, int maxc)
+{
+	int node, zone;
+
+	node = fdt_path_offset(blob, "/thermal-zones");
+	if (node < 0)
+		return;
+
+	fdt_for_each_subnode(zone, blob, node) {
+		if (fdt_fixup_trips_node(blob, zone, maxc) < 0)
+			printf("Failed to set temperature in %s critical trips\n",
+			       fdt_get_name(blob, zone, NULL));
+	}
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
 	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
 	fdt_fixup_dss_nodes_am62a(blob, k3_has_dss());
 	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
 	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
+	fdt_fixup_thermal_zone_nodes_am62a(blob, k3_get_max_temp());
 	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
 	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +18 -0
index ab281129d7..0ec04a72f5 100644
@@ -28,8 +28,14 @@
 #define JTAG_DEV_VIDEO_CODEC_SHIFT			14
 #define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
 #define JTAG_DEV_DSS_SHIFT			13
+#define JTAG_DEV_TEMP_MASK			GENMASK(5, 3)
+#define JTAG_DEV_TEMP_SHIFT			3
 
 #define JTAG_DEV_HAS_DSS_VALUE			0xD
+#define JTAG_DEV_TEMP_AUTOMOTIVE        0x5
+
+#define JTAG_DEV_TEMP_EXTENDED_VALUE    105
+#define JTAG_DEV_TEMP_AUTOMOTIVE_VALUE  125
 
 #define CTRLMMR_MAIN_DEVSTAT			(WKUP_CTRL_MMR0_BASE + 0x30)
 #define MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK	GENMASK(6, 3)
@@ -126,6 +132,18 @@ static inline int k3_has_canfd(void)
 	return (dev_id & JTAG_DEV_CANFD_MASK) >> JTAG_DEV_CANFD_SHIFT;
 }
 
+static inline int k3_get_max_temp(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+
+	u32 dev_temp = (dev_id & JTAG_DEV_TEMP_MASK) >> JTAG_DEV_TEMP_SHIFT;
+
+	if (dev_temp == JTAG_DEV_TEMP_AUTOMOTIVE)
+		return JTAG_DEV_TEMP_AUTOMOTIVE_VALUE;
+	else
+		return JTAG_DEV_TEMP_EXTENDED_VALUE;
+}
+
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
 static const u32 put_device_ids[] = {};
Signature · 1 line
2.34.1
#8 lore raw

PATCH 3/3 arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

In reply to Aparna Patra

AM62A SoC has multiple speed grades. Add function to delete non-relevant CPU frequency nodes, based on the information retrieved from hardware registers. Fastest grade's maximum frequency also depends on PMIC voltage,hence to simplify implementation use the smaller value.

---
 arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 14 +++++++++++
 .../arm/mach-k3/include/mach/am62a_hardware.h | 23 +++++++++++++++++++
 2 files changed, 37 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +14 -0
index 40833ca392..9526c5b255 100644
@@ -81,6 +81,19 @@ static void fdt_fixup_thermal_zone_nodes_am62a(void *blob, int maxc)
 	}
 }
 
+static void fdt_fixup_cpu_freq_nodes_am62a(void *blob, int max_freq)
+{
+	if (max_freq >= 1250000000)
+		return;
+	if (max_freq <= 1000000000) {
+		fdt_del_node_path(blob, "/opp-table/opp-1250000000");
+		fdt_del_node_path(blob, "/opp-table/opp-1400000000");
+	}
+	if (max_freq <= 800000000) {
+		fdt_del_node_path(blob, "/opp-table/opp-1000000000");
+	}
+}
+
 int ft_system_setup(void *blob, struct bd_info *bd)
 {
 	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
@@ -88,6 +101,7 @@ int ft_system_setup(void *blob, struct bd_info *bd)
 	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
 	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
 	fdt_fixup_thermal_zone_nodes_am62a(blob, k3_get_max_temp());
+	fdt_fixup_cpu_freq_nodes_am62a(blob, k3_get_a53_max_frequency());
 	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
 	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +23 -0
index 0ec04a72f5..64e4a379fa 100644
@@ -28,6 +28,8 @@
 #define JTAG_DEV_VIDEO_CODEC_SHIFT			14
 #define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
 #define JTAG_DEV_DSS_SHIFT			13
+#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
 
@@ -144,6 +146,27 @@ static inline int k3_get_max_temp(void)
 		return JTAG_DEV_TEMP_EXTENDED_VALUE;
 }
 
+static inline char k3_get_speed_grade(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+	u32 speed_grade = (dev_id & JTAG_DEV_SPEED_MASK) >>
+			   JTAG_DEV_SPEED_SHIFT;
+
+	return 'A' - 1 + speed_grade;
+}
+
+static inline int k3_get_a53_max_frequency(void)
+{
+	if (k3_get_speed_grade() <= 'N')
+		return 800000000;
+
+	else if (k3_get_speed_grade() <= 'R')
+		return 1000000000;
+
+	else
+		return 1250000000;
+}
+
 #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
 static const u32 put_device_ids[] = {};
Signature · 1 line
2.34.1
#9 lore raw

Re: [PATCH 3/3] arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

Quoted 17 lines · Aparna Patra

AM62A SoC has multiple speed grades. Add function to delete non-relevant CPU frequency nodes, based on the information retrieved from hardware registers. Fastest grade's maximum frequency also depends on PMIC voltage,hence to simplify implementation use the smaller value.

---
  arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 14 +++++++++++
  .../arm/mach-k3/include/mach/am62a_hardware.h | 23 +++++++++++++++++++
  2 files changed, 37 insertions(+)
arch/arm/mach-k3/am62ax/am62a7_fdt.c +0 -0
index 40833ca392..9526c5b255 100644

arch/arm/mach-k3/am62ax/am62a7_fdt.c static void fdt_fixup_thermal_zone_nodes_am62a(void *blob, int maxc) · line 87

Quoted 7 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +4 -0
@@ -81,6 +81,19 @@ static void fdt_fixup_thermal_zone_nodes_am62a(void *blob, int maxc)
  	}
  }
 
+static void fdt_fixup_cpu_freq_nodes_am62a(void *blob, int max_freq)
+{
+	if (max_freq >= 1250000000)
+		return;

I dont think this if case is required. Just let if fail both following conditions.

Quoted 41 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +10 -0
+	if (max_freq <= 1000000000) {
+		fdt_del_node_path(blob, "/opp-table/opp-1250000000");
+		fdt_del_node_path(blob, "/opp-table/opp-1400000000");
+	}
+	if (max_freq <= 800000000) {
+		fdt_del_node_path(blob, "/opp-table/opp-1000000000");
+	}
+}
+
  int ft_system_setup(void *blob, struct bd_info *bd)
  {
  	fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());
@@ -88,6 +101,7 @@ int ft_system_setup(void *blob, struct bd_info *bd)
  	fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
  	fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
  	fdt_fixup_thermal_zone_nodes_am62a(blob, k3_get_max_temp());
+	fdt_fixup_cpu_freq_nodes_am62a(blob, k3_get_a53_max_frequency());
  	fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
  	fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);
 
arch/arm/mach-k3/include/mach/am62a_hardware.h +6 -0
index 0ec04a72f5..64e4a379fa 100644
@@ -28,6 +28,8 @@
  #define JTAG_DEV_VIDEO_CODEC_SHIFT			14
  #define JTAG_DEV_DSS_MASK			GENMASK(16, 13)
  #define JTAG_DEV_DSS_SHIFT			13
+#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
 
@@ -144,6 +146,27 @@ static inline int k3_get_max_temp(void)
  		return JTAG_DEV_TEMP_EXTENDED_VALUE;
  }
 
+static inline char k3_get_speed_grade(void)
+{
+	u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+	u32 speed_grade = (dev_id & JTAG_DEV_SPEED_MASK) >>

arch/arm/mach-k3/include/mach/am62a_hardware.h static inline int k3_get_max_temp(void) · line 162

Quoted 10 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +10 -0
+			   JTAG_DEV_SPEED_SHIFT;
+
+	return 'A' - 1 + speed_grade;
+}
+
+static inline int k3_get_a53_max_frequency(void)
+{
+	if (k3_get_speed_grade() <= 'N')
+		return 800000000;
+

^ empty lines where should be none in this function.

- Daniel

Quoted 10 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +7 -0
+	else if (k3_get_speed_grade() <= 'R')
+		return 1000000000;
+
+	else
+		return 1250000000;
+}
+
  #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__)
 
  static const u32 put_device_ids[] = {};
#10 lore raw

Re: [PATCH 3/3] arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

Quoted 14 lines · Daniel Schultz
Quoted 12 lines · Aparna Patra

AM62A SoC has multiple speed grades. Add function to delete non-relevant CPU frequency nodes, based on the information retrieved from hardware registers. Fastest grade's maximum frequency also depends on PMIC voltage,hence to simplify implementation use the smaller value.

---
  arch/arm/mach-k3/am62ax/am62a7_fdt.c          | 14 +++++++++++ .../arm/mach-k3/include/mach/am62a_hardware.h | 23 +++++++++++++++++++

  2 files changed, 37 insertions(+)
Quoted 13 lines

arch/arm/mach-k3/am62ax/am62a7_fdt.c static void · line 87

Quoted 12 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +3 -0
index 40833ca392..9526c5b255 100644
@@ -81,6 +81,19 @@ static void 
 fdt_fixup_thermal_zone_nodes_am62a(void *blob, int maxc)
       }
   }
   +static void fdt_fixup_cpu_freq_nodes_am62a(void *blob, int max_freq)
+{
+    if (max_freq >= 1250000000)
+        return;

I dont think this if case is required. Just let if fail both following conditions.

Agreed, will remove this.

Quoted 51 lines
Quoted 38 lines
arch/arm/mach-k3/am62ax/am62a7_fdt.c +9 -0
+    if (max_freq <= 1000000000) {
+        fdt_del_node_path(blob, "/opp-table/opp-1250000000");
+        fdt_del_node_path(blob, "/opp-table/opp-1400000000");
+    }
+    if (max_freq <= 800000000) {
+        fdt_del_node_path(blob, "/opp-table/opp-1000000000");
+    }
+}
+
   int ft_system_setup(void *blob, struct bd_info *bd)
   {

      fdt_fixup_cores_wdt_nodes_am62a(blob, k3_get_core_nr());

arch/arm/mach-k3/am62ax/am62a7_fdt.c +1 -0
@@ -88,6 +101,7 @@ int ft_system_setup(void *blob, struct bd_info *bd)
       fdt_fixup_video_codec_nodes_am62a(blob, k3_has_video_codec());
       fdt_fixup_canfd_nodes_am62a(blob, k3_has_canfd());
       fdt_fixup_thermal_zone_nodes_am62a(blob, k3_get_max_temp());
+    fdt_fixup_cpu_freq_nodes_am62a(blob, k3_get_a53_max_frequency());
       fdt_fixup_reserved(blob, "tfa", CONFIG_K3_ATF_LOAD_ADDR, 0x80000);
       fdt_fixup_reserved(blob, "optee", CONFIG_K3_OPTEE_LOAD_ADDR, 0x1800000);

  diff --git a/arch/arm/mach-k3/include/mach/am62a_hardware.h b/arch/arm/mach-k3/include/mach/am62a_hardware.h index 0ec04a72f5..64e4a379fa 100644

arch/arm/mach-k3/include/mach/am62a_hardware.h +2 -0
@@ -28,6 +28,8 @@
   #define JTAG_DEV_VIDEO_CODEC_SHIFT            14
   #define JTAG_DEV_DSS_MASK            GENMASK(16, 13)
   #define JTAG_DEV_DSS_SHIFT            13
+#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
   @@ -144,6 +146,27 @@ static inline int k3_get_max_temp(void)

          return JTAG_DEV_TEMP_EXTENDED_VALUE;
  }
  +static inline char k3_get_speed_grade(void)

arch/arm/mach-k3/include/mach/am62a_hardware.h +3 -0
+{
+    u32 dev_id = readl(CTRLMMR_WKUP_JTAG_DEVICE_ID);
+    u32 speed_grade = (dev_id & JTAG_DEV_SPEED_MASK) >>

arch/arm/mach-k3/include/mach/am62a_hardware.h static inline int k3_get_max_temp(void) · line 162

Quoted 10 lines
arch/arm/mach-k3/include/mach/am62a_hardware.h +10 -0
+               JTAG_DEV_SPEED_SHIFT;
+
+    return 'A' - 1 + speed_grade;
+}
+
+static inline int k3_get_a53_max_frequency(void)
+{
+    if (k3_get_speed_grade() <= 'N')
+        return 800000000;
+

^ empty lines where should be none in this function.

Quoted 1 line

- Daniel

Will remove the empty lines as well.
Thanks!

Quoted 10 lines
Quoted 10 lines

+    else if (k3_get_speed_grade() <= 'R')
+        return 1000000000;

arch/arm/mach-k3/include/mach/am62a_hardware.h +5 -0
+
+    else
+        return 1250000000;
+}
+

  #if defined(CONFIG_SYS_K3_SPL_ATF) && !defined(__ASSEMBLY__) static const u32 put_device_ids[] = {};

Reviewed-by on the v1 series
#11 lore raw
In reply to Aparna Patra

On April 30, 2025 thus sayeth Aparna Patra:

Quoted 10 lines

This series implements fdt fixups, by reading hardware information from registers and accordingly delete/modify the DT nodes, at run-time.

Aparna Patra (3):
arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes
in fdt
arm: mach-k3: am62a: Fixup thermal zone critical points
arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

Minus the pinmux node all of this looks great

~Bryan

#12 lore raw
Quoted 12 lines · Bryan Brattlof

On April 30, 2025 thus sayeth Aparna Patra:

Quoted 10 lines

This series implements fdt fixups, by reading hardware information from registers and accordingly delete/modify the DT nodes, at run-time.

Aparna Patra (3):
arm: mach-k3: am62a: Fixup CPU core, DSS, CAN-FD and Video-codec nodes
in fdt
arm: mach-k3: am62a: Fixup thermal zone critical points
arm: mach-k3: am62a: Fixup a53 max cpu frequency by speed-grade

Quoted 5 lines

Minus the pinmux node all of this looks great

~Bryan

This is a ton of fixups being done in u-boot. I am not sure this is going to sustain across multiple platforms.

Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D