Skip to contentSkip to conversation

board: ti: Add 32k crystal initialization

PATCH Superseded Vishal Mahaveer 3 participants 7 messages Jan 8 – Jan 21

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover board: ti: Add 32k crystal initialization

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

Changes for v2:
- Created a common API which can be called from individual board files
- Squashed defconfig and board file changes into single commits

Vishal Mahaveer (4):
board: ti: common: Add function for initialization of 32k crystal
board: ti: am62x: Enable 32k crystal on the board
board: ti: am62ax: Enable 32k crystal on the board
board: ti: am62px: Enable 32k crystal on the board

 board/ti/am62ax/evm.c           |  7 +++++++
 board/ti/am62px/evm.c           |  4 ++++
 board/ti/am62x/evm.c            |  4 ++++
 board/ti/common/Kconfig         |  5 +++++
 board/ti/common/Makefile        |  1 +
 board/ti/common/k3_32k_lfosc.c  | 22 ++++++++++++++++++++++
 board/ti/common/k3_32k_lfosc.h  | 15 +++++++++++++++
 configs/am62ax_evm_r5_defconfig |  2 ++
 configs/am62px_evm_r5_defconfig |  2 ++
 configs/am62x_evm_r5_defconfig  |  2 ++
 10 files changed, 64 insertions(+)
 create mode 100644 board/ti/common/k3_32k_lfosc.c
 create mode 100644 board/ti/common/k3_32k_lfosc.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/4 board: ti: common: Add function for initialization of 32k crystal

Add a common helper function for doing the basic configuration required for enabling the 32k crystal on some of the TI boards.

---
 board/ti/common/Kconfig        |  5 +++++
 board/ti/common/Makefile       |  1 +
 board/ti/common/k3_32k_lfosc.c | 22 ++++++++++++++++++++++
 board/ti/common/k3_32k_lfosc.h | 15 +++++++++++++++
 4 files changed, 43 insertions(+)
 create mode 100644 board/ti/common/k3_32k_lfosc.c
 create mode 100644 board/ti/common/k3_32k_lfosc.h
board/ti/common/Kconfig +5 -0
index 3dd2852e6b0..409454813f3 100644
@@ -22,6 +22,11 @@ config CAPE_EEPROM_BUS_NUM
 	default 2
 	depends on SUPPORT_EXTENSION_SCAN
 
+config TI_K3_BOARD_LFOSC
+	bool "Initialize 32k LFOSC"
+	help
+	  Enable the 32k LFOSC on the device
+
 config TI_COMMON_CMD_OPTIONS
 	bool "Enable cmd options on TI platforms"
 	imply CMD_ASKENV
board/ti/common/Makefile +1 -0
index f58935b4103..b40c93cf312 100644
@@ -5,3 +5,4 @@ obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o
 obj-${CONFIG_$(PHASE_)SUPPORT_EXTENSION_SCAN} += cape_detect.o
 obj-${CONFIG_OF_LIBFDT} += fdt_ops.o
 obj-${CONFIG_ARCH_K3} += k3-ddr.o
+obj-${CONFIG_TI_K3_BOARD_LFOSC} += k3_32k_lfosc.o
board/ti/common/k3_32k_lfosc.c new file +22 -0
new file mode 100644
index 00000000000..24c5bad76b9
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Library to support LFOSC operations common to some of the K3 devices
+ *
+ * Copyright (C) 2026 Texas Instruments Incorporated - https://www.ti.com/
+ */
+
+#include <asm/arch/hardware.h>
+
+void enable_32k_lfosc(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);
+}
board/ti/common/k3_32k_lfosc.h new file +15 -0
new file mode 100644
index 00000000000..08752033f2e
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Library to support LFOSC operations common to some of the K3 devices
+ *
+ * Copyright (C) 2026 Texas Instruments Incorporated - https://www.ti.com/
+ */
+#ifndef __32K_LFOSC_OPS_H
+#define __32K_LFOSC_OPS_H
+
+/**
+ * enable_32k_lfosc - Do basic initialization of the 32k crystal
+ */
+void enable_32k_lfosc(void);
+
+#endif /* __32K_LFOSC_OPS_H */
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/4 board: ti: am62x: Enable 32k crystal on the board

In reply to Vishal Mahaveer

Enable 32k crystal on the board. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62x/evm.c           | 4 ++++
 configs/am62x_evm_r5_defconfig | 2 ++
 2 files changed, 6 insertions(+)
board/ti/am62x/evm.c +4 -0
index e9eba57eba7..2e8336900d1 100644
@@ -24,6 +24,7 @@
 
 #include "../common/board_detect.h"
 #include "../common/fdt_ops.h"
+#include "../common/k3_32k_lfosc.h"
 
 #define board_is_am62x_skevm()  (board_ti_k3_is("AM62-SKEVM") || \
 				 board_ti_k3_is("AM62B-SKEVM"))
@@ -139,6 +140,9 @@ int board_late_init(void)
 #if defined(CONFIG_XPL_BUILD)
 void spl_board_init(void)
 {
+	if (IS_ENABLED(CONFIG_TI_K3_BOARD_LFOSC))
+		enable_32k_lfosc();
+
 	enable_caches();
 	if (IS_ENABLED(CONFIG_SPL_SPLASH_SCREEN) && IS_ENABLED(CONFIG_SPL_BMP))
 		splash_display();
configs/am62x_evm_r5_defconfig +2 -0
index dd3b4e58009..6d039f9acb6 100644
@@ -119,3 +119,5 @@ CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_TI_K3_BOARD_LFOSC=y
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/4 board: ti: am62ax: Enable 32k crystal on the board

In reply to Vishal Mahaveer

Enable 32k crystal on the board. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62ax/evm.c           | 7 +++++++
 configs/am62ax_evm_r5_defconfig | 2 ++
 2 files changed, 9 insertions(+)
board/ti/am62ax/evm.c +7 -0
index da6c31176cd..4916eec3b2b 100644
@@ -15,6 +15,7 @@
 #include <asm/arch/k3-ddr.h>
 
 #include "../common/fdt_ops.h"
+#include "../common/k3_32k_lfosc.h"
 
 #if defined(CONFIG_XPL_BUILD)
 void spl_perform_board_fixups(struct spl_image_info *spl_image)
@@ -26,6 +27,12 @@ void spl_perform_board_fixups(struct spl_image_info *spl_image)
 		fixup_memory_node(spl_image);
 	}
 }
+
+void spl_board_init(void)
+{
+	if (IS_ENABLED(CONFIG_TI_K3_BOARD_LFOSC))
+		enable_32k_lfosc();
+}
 #endif
 
 #ifdef CONFIG_BOARD_LATE_INIT
configs/am62ax_evm_r5_defconfig +2 -0
index 9336392a5ed..a94ae0cef1d 100644
@@ -102,3 +102,5 @@ CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_TI_K3_BOARD_LFOSC=y
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/4 board: ti: am62px: Enable 32k crystal on the board

In reply to Vishal Mahaveer

Enable 32k crystal on the board. If external 32k source is not used, 32k rc-osc comes into play, which is accurate to +-20%.

---
 board/ti/am62px/evm.c           | 4 ++++
 configs/am62px_evm_r5_defconfig | 2 ++
 2 files changed, 6 insertions(+)
board/ti/am62px/evm.c +4 -0
index 85c332b9339..8fde47fb1be 100644
@@ -16,6 +16,7 @@
 #include <spl.h>
 #include <asm/arch/k3-ddr.h>
 #include "../common/fdt_ops.h"
+#include "../common/k3_32k_lfosc.h"
 
 struct efi_fw_image fw_images[] = {
 	{
@@ -45,6 +46,9 @@ struct efi_capsule_update_info update_info = {
 #if IS_ENABLED(CONFIG_SPL_BUILD)
 void spl_board_init(void)
 {
+	if (IS_ENABLED(CONFIG_TI_K3_BOARD_LFOSC))
+		enable_32k_lfosc();
+
 	enable_caches();
 }
 #endif
configs/am62px_evm_r5_defconfig +2 -0
index 48ee2aad8f4..02f358d35de 100644
@@ -121,3 +121,5 @@ CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_LIB_RATIONAL=y
 CONFIG_SPL_LIB_RATIONAL=y
+CONFIG_SPL_BOARD_INIT=y
+CONFIG_TI_K3_BOARD_LFOSC=y
Signature · 1 line
2.34.1
Reviewed-by on the v2 series
#5 lore raw
In reply to Vishal Mahaveer

On January 8, 2026 thus sayeth Vishal Mahaveer:

Quoted 11 lines

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

Changes for v2:
- Created a common API which can be called from individual board files
- Squashed defconfig and board file changes into single commits

Vishal Mahaveer (4):
board: ti: common: Add function for initialization of 32k crystal
board: ti: am62x: Enable 32k crystal on the board
board: ti: am62ax: Enable 32k crystal on the board
board: ti: am62px: Enable 32k crystal on the board

Thanks Vishal!

~Bryan

#6 lore raw
In reply to Vishal Mahaveer
Quoted 11 lines · Vishal Mahaveer

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

Changes for v2:
- Created a common API which can be called from individual board files
- Squashed defconfig and board file changes into single commits

Vishal Mahaveer (4):
board: ti: common: Add function for initialization of 32k crystal
board: ti: am62x: Enable 32k crystal on the board
board: ti: am62ax: Enable 32k crystal on the board
board: ti: am62px: Enable 32k crystal on the board

This breaks building of am62dx_evm_r5 on current master, please rebase, thanks.

Signature · 1 line
Tom