summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2024-02-20 12:39:48 -0600
committerTom Rini <trini@konsulko.com>2024-03-04 11:49:23 -0500
commit5aa46d0807d8827eeffdecdd87094a13c4e0fa71 (patch)
tree48048aae8b3e24b2b454c4fecb5a9cc416fdb128
parent3e6f2a94bfc25f1782ce2d45db27f47ec781feb1 (diff)
board: beagle: beagleplay: Enable 32k crystal
Enable the external 32k crystal similar to that found on other production AM62X board. The trim settings for the crystal is board dependent, so the sequences tend to be board specific. Since this is a configuration that needs to be done prior to DM managing the system and all other muxes get set, do the same from R5 context. Tested-by: Robert Nelson <robertcnelson@gmail.com> Signed-off-by: Nishanth Menon <nm@ti.com>
-rw-r--r--board/beagle/beagleplay/beagleplay.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/board/beagle/beagleplay/beagleplay.c b/board/beagle/beagleplay/beagleplay.c
index 1c376dea372..2adb2517ef0 100644
--- a/board/beagle/beagleplay/beagleplay.c
+++ b/board/beagle/beagleplay/beagleplay.c
@@ -11,6 +11,8 @@
#include <fdt_support.h>
#include <spl.h>
+#include <asm/arch/hardware.h>
+
DECLARE_GLOBAL_DATA_PTR;
int board_init(void)
@@ -27,3 +29,38 @@ int dram_init_banksize(void)
{
return fdtdec_setup_memory_banksize();
}
+
+#ifdef CONFIG_SPL_BOARD_INIT
+
+/*
+ * Enable the 32k Crystal: needed for accurate 32k clock
+ * and external clock sources such as wlan 32k input clock
+ * supplied from the SoC to the wlan chip.
+ *
+ * The trim setup can be very highly board type specific choice of the crystal
+ * So this is done in the board file, though, in this case, no specific trim
+ * is necessary.
+ */
+static void crystal_32k_enable(void)
+{
+ /* Only mess with 32k at the start of boot from R5 */
+ if (IS_ENABLED(CONFIG_CPU_V7R)) {
+ /*
+ * We have external 32k crystal, so lets enable it (0x0)
+ * and disable bypass (0x0)
+ */
+ writel(0x0, MCU_CTRL_LFXOSC_CTRL);
+
+ /* Add any crystal specific TRIM needed here.. */
+
+ /* Make sure to mux the SoC 32k from the crystal */
+ writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL,
+ MCU_CTRL_DEVICE_CLKOUT_32K_CTRL);
+ }
+}
+
+void spl_board_init(void)
+{
+ crystal_32k_enable();
+}
+#endif