Skip to contentSkip to conversation

board: ti: Add 32k crystal initialization

PATCH Superseded Vishal Mahaveer 2 participants 8 messages Dec 10, 2025

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover board: ti: Add 32k crystal initialization

Add 32k crystal initialization support for am62x, am62ax and am62px TI boards.

Vishal Mahaveer (6):
board: ti: am62x: Add basic initialization for 32k crystal
board: ti: am62ax: Add basic initialization for 32k crystal
board: ti: am62px: Add basic initialization for 32k crystal
configs: am62x_evm_a53_defconfig: Enable SPL_BOARD_INIT
configs: am62ax_evm_a53_defconfig: Enable SPL_BOARD_INIT
configs: am62px_evm_a53_defconfig: Enable SPL_BOARD_INIT

 board/ti/am62ax/evm.c            | 16 ++++++++++++++++
 board/ti/am62px/evm.c            | 13 +++++++++++++
 board/ti/am62x/evm.c             | 13 +++++++++++++
 configs/am62ax_evm_a53_defconfig |  1 +
 configs/am62px_evm_a53_defconfig |  1 +
 configs/am62x_evm_a53_defconfig  |  1 +
 6 files changed, 45 insertions(+)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/6 board: ti: am62x: Add basic initialization for 32k crystal

Do the basic configuration required for enabling the 32k crystal. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62x/evm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/ti/am62x/evm.c +13 -0
index e9eba57eba7..7a820cc8c07 100644
@@ -137,13 +137,26 @@ int board_late_init(void)
 #endif
 
 #if defined(CONFIG_XPL_BUILD)
+#if IS_ENABLED(CONFIG_SPL_BOARD_INIT)
 void spl_board_init(void)
 {
+	u32 val;
+
+	/* We have 32k crystal, so lets enable it */
+	val = readl(MCU_CTRL_LFXOSC_CTRL);
+	val &= ~(MCU_CTRL_LFXOSC_32K_DISABLE_VAL);
+	writel(val, MCU_CTRL_LFXOSC_CTRL);
+	/* Add any TRIM needed for the crystal here.. */
+	/* Make sure to mux up to take the SoC 32k from the crystal */
+	writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL,
+	       MCU_CTRL_DEVICE_CLKOUT_32K_CTRL);
+
 	enable_caches();
 	if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP))
 		splash_display();
 
 }
+#endif
 
 void spl_perform_board_fixups(struct spl_image_info *spl_image)
 {
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/6 board: ti: am62ax: Add basic initialization for 32k crystal

In reply to Vishal Mahaveer

Do the basic configuration required for enabling the 32k crystal. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62ax/evm.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
board/ti/am62ax/evm.c +16 -0
index da6c31176cd..fffbddbdcc0 100644
@@ -35,3 +35,19 @@ int board_late_init(void)
 	return 0;
 }
 #endif
+
+#if IS_ENABLED(CONFIG_SPL_BOARD_INIT)
+void spl_board_init(void)
+{
+	u32 val;
+
+	/* We have 32k crystal, so lets enable it */
+	val = readl(MCU_CTRL_LFXOSC_CTRL);
+	val &= ~(MCU_CTRL_LFXOSC_32K_DISABLE_VAL);
+	writel(val, MCU_CTRL_LFXOSC_CTRL);
+	/* Add any TRIM needed for the crystal here.. */
+	/* Make sure to mux up to take the SoC 32k from the crystal */
+	writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL,
+	       MCU_CTRL_DEVICE_CLKOUT_32K_CTRL);
+}
+#endif
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/6 board: ti: am62px: Add basic initialization for 32k crystal

In reply to Vishal Mahaveer

Do the basic configuration required for enabling the 32k crystal. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62px/evm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
board/ti/am62px/evm.c +13 -0
index 85c332b9339..7672d1eb272 100644
@@ -43,11 +43,24 @@ struct efi_capsule_update_info update_info = {
 };
 
 #if IS_ENABLED(CONFIG_SPL_BUILD)
+#if IS_ENABLED(CONFIG_SPL_BOARD_INIT)
 void spl_board_init(void)
 {
+	u32 val;
+
+	/* We have 32k crystal, so lets enable it */
+	val = readl(MCU_CTRL_LFXOSC_CTRL);
+	val &= ~(MCU_CTRL_LFXOSC_32K_DISABLE_VAL);
+	writel(val, MCU_CTRL_LFXOSC_CTRL);
+	/* Add any TRIM needed for the crystal here.. */
+	/* Make sure to mux up to take the SoC 32k from the crystal */
+	writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL,
+	       MCU_CTRL_DEVICE_CLKOUT_32K_CTRL);
+
 	enable_caches();
 }
 #endif
+#endif
 
 #if defined(CONFIG_XPL_BUILD)
 void spl_perform_board_fixups(struct spl_image_info *spl_image)
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/6 configs: am62x_evm_a53_defconfig: Enable SPL_BOARD_INIT

In reply to Vishal Mahaveer

Enable the SPL_BOARD_INIT config option to make use of the spl_board_init function.

---
 configs/am62x_evm_a53_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am62x_evm_a53_defconfig +1 -0
index 4da668396d0..58e2daab687 100644
@@ -39,6 +39,7 @@ CONFIG_BOOTCOMMAND="run findfdt; run envboot; bootflow scan -lb"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
 CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/6 configs: am62ax_evm_a53_defconfig: Enable SPL_BOARD_INIT

In reply to Vishal Mahaveer

Enable the SPL_BOARD_INIT config option to make use of the spl_board_init function.

---
 configs/am62ax_evm_a53_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am62ax_evm_a53_defconfig +1 -0
index 3667a0656ed..9dfbc580df4 100644
@@ -30,6 +30,7 @@ CONFIG_BOOTCOMMAND="run envboot; bootflow scan -lb"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
 CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400
Signature · 1 line
2.34.1
#6 lore raw

PATCH 6/6 configs: am62px_evm_a53_defconfig: Enable SPL_BOARD_INIT

In reply to Vishal Mahaveer

Enable the SPL_BOARD_INIT config option to make use of the spl_board_init function.

---
 configs/am62px_evm_a53_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am62px_evm_a53_defconfig +1 -0
index fa857e51137..fbf73633418 100644
@@ -36,6 +36,7 @@ CONFIG_BOOTCOMMAND="run envboot; bootflow scan -lb"
 CONFIG_BOARD_LATE_INIT=y
 CONFIG_SPL_MAX_SIZE=0x58000
 CONFIG_SPL_PAD_TO=0x0
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_SYS_MMCSD_RAW_MODE=y
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
Signature · 1 line
2.34.1
#7 lore raw
In reply to Vishal Mahaveer
Quoted 7 lines · Vishal Mahaveer

Add 32k crystal initialization support for am62x, am62ax and am62px TI boards.

Vishal Mahaveer (6):
board: ti: am62x: Add basic initialization for 32k crystal
board: ti: am62ax: Add basic initialization for 32k crystal
board: ti: am62px: Add basic initialization for 32k crystal

These three functions look identical at first glance, and if so, we need to figure out a better abstraction.

Quoted 3 lines

configs: am62x_evm_a53_defconfig: Enable SPL_BOARD_INIT
configs: am62ax_evm_a53_defconfig: Enable SPL_BOARD_INIT
configs: am62px_evm_a53_defconfig: Enable SPL_BOARD_INIT

And then, the config change should go with the code change. Thanks.

Signature · 1 line
Tom