Skip to contentSkip to conversation

imx9: soc: Reuse and export low_drive_freq_update()

PATCH Applied Primoz Fiser 2 participants 3 messages Aug 7, 2025 – Aug 8, 2025

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

PATCH 1/2 imx9: soc: Reuse and export low_drive_freq_update()

Reuse and export low_drive_freq_update() function. This way global imx9 board_fix_fdt() doesn't duplicate code. While low_drive_freq_update() can be reused on boards such as phyCORE-i.MX93 (TARGET_PHYCORE_IMX93) which is not using the global imx9 board_fix_fdt() implementation.

While at it, make printout logic less verbose by only outputting on the error condition and not on each successful clock fixup. Also drop now invalid comment (low_drive_freq_update() now does fixup for internal and kernel device-tree).

---
 arch/arm/include/asm/arch-imx9/sys_proto.h |  1 +
 arch/arm/mach-imx/imx9/soc.c               | 29 +++++-----------------
 2 files changed, 7 insertions(+), 23 deletions(-)
arch/arm/include/asm/arch-imx9/sys_proto.h +1 -0
index df2148a53c7e..455aa95339e9 100644
@@ -18,6 +18,7 @@ enum imx9_soc_voltage_mode {
 void soc_power_init(void);
 bool m33_is_rom_kicked(void);
 int m33_prepare(void);
+int low_drive_freq_update(void *blob);
 
 enum imx9_soc_voltage_mode soc_target_voltage_mode(void);
 
arch/arm/mach-imx/imx9/soc.c +6 -23
index bb13ca742e3a..7e7a39d46c35 100644
@@ -641,12 +641,10 @@ static int low_drive_fdt_fix_clock(void *fdt, int node_off, u32 clk_index, u32 n
 	return -ENOENT;
 }
 
-static int low_drive_freq_update(void *blob)
+int low_drive_freq_update(void *blob)
 {
-	int nodeoff, ret;
-	int i;
+	int nodeoff, ret, i;
 
-	/* Update kernel dtb clocks for low drive mode */
 	struct low_drive_freq_entry table[] = {
 		{"/soc@0/bus@42800000/mmc@42850000", 0, 266666667},
 		{"/soc@0/bus@42800000/mmc@42860000", 0, 266666667},
@@ -658,8 +656,8 @@ static int low_drive_freq_update(void *blob)
 		if (nodeoff >= 0) {
 			ret = low_drive_fdt_fix_clock(blob, nodeoff, table[i].clk,
 						      table[i].new_rate);
-			if (!ret)
-				printf("%s freq updated\n", table[i].node_path);
+			if (ret)
+				printf("freq update failed for %s\n", table[i].node_path);
 		}
 	}
 
@@ -671,23 +669,8 @@ static int low_drive_freq_update(void *blob)
 int board_fix_fdt(void *fdt)
 {
 	/* Update dtb clocks for low drive mode */
-	if (is_voltage_mode(VOLT_LOW_DRIVE)) {
-		int nodeoff;
-		int i;
-
-		struct low_drive_freq_entry table[] = {
-			{"/soc@0/bus@42800000/mmc@42850000", 0, 266666667},
-			{"/soc@0/bus@42800000/mmc@42860000", 0, 266666667},
-			{"/soc@0/bus@42800000/mmc@428b0000", 0, 266666667},
-		};
-
-		for (i = 0; i < ARRAY_SIZE(table); i++) {
-			nodeoff = fdt_path_offset(fdt, table[i].node_path);
-			if (nodeoff >= 0)
-				low_drive_fdt_fix_clock(fdt, nodeoff, table[i].clk,
-							table[i].new_rate);
-		}
-	}
+	if (is_voltage_mode(VOLT_LOW_DRIVE))
+		low_drive_freq_update(fdt);
 
 	return 0;
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 board: phytec: phycore-imx93: Add VOLT_LOW_DRIVE frequency fixup

For phyCORE-i.MX93 SoMs with i.MX93 parts running in VOLT_LOW_DRIVE mode (SoCs with speed grade fuse set to 900 MHz) reduce usdhc clocks from 400 MHz to 266 MHz. Do this in board code since global imx9 board_fix_fdt() is not used in case of phycore-imx93 board since commit d3b9b7996889 ("board: phytec: imx93: Add eeprom-based hardware introspection").

While at it, add a note to ft_board_setup() function to inform that fixup for Linux device-tree is taken care by ft_system_setup() in imx9 global arch/arm/mach-imx/imx9/soc.c implementation.

---
 board/phytec/phycore_imx93/phycore-imx93.c | 9 +++++++++
 1 file changed, 9 insertions(+)
board/phytec/phycore_imx93/phycore-imx93.c +9 -0
index a55795e06034..b64138053935 100644
@@ -82,6 +82,10 @@ int board_fix_fdt(void *blob)
 
 	emmc_fixup(blob, &data);
 
+	/* Update dtb clocks for low drive mode */
+	if (is_voltage_mode(VOLT_LOW_DRIVE))
+		low_drive_freq_update(blob);
+
 	return 0;
 }
 
@@ -89,5 +93,10 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 {
 	emmc_fixup(blob, NULL);
 
+	/**
+	 * NOTE: VOLT_LOW_DRIVE fixup is done by the ft_system_setup()
+	 * in arch/arm/mach-imx/imx9/soc.c for Linux device-tree.
+	 */
+
 	return 0;
 }
Signature · 1 line
2.34.1
reviewer Applied
#2 lore raw
In reply to Primoz Fiser
Quoted 6 lines · Primoz Fiser

Reuse and export low_drive_freq_update() function. This way global imx9 board_fix_fdt() doesn't duplicate code. While low_drive_freq_update() can be reused on boards such as phyCORE-i.MX93 (TARGET_PHYCORE_IMX93) which is not using the global imx9 board_fix_fdt() implementation.

Quoted 6 lines

While at it, make printout logic less verbose by only outputting on the error condition and not on each successful clock fixup. Also drop now invalid comment (low_drive_freq_update() now does fixup for internal and kernel device-tree).

Applied the series, thanks.