The external 32k crystal is optional and by default LFOSC0 is sourced by a RC oscillator. This adds a function to be called by board code when the 32k crystal is present and shall be used to source LFOSC0 from the crystal. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- arch/arm/mach-k3/common.c | 20 ++++++++++++++++++++ include/mach/k3/common.h | 1 + 2 files changed, 21 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index 3922a0ff19..c779e873c9 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -170,6 +170,26 @@ static void of_delete_node_path(struct device_node *root, const char *path) of_delete_node(np); } +#define MCU_CTRL_MMR0_BASE 0x04500000 +#define MCU_CTRL_LFXOSC_CTRL (MCU_CTRL_MMR0_BASE + 0x8038) +#define MCU_CTRL_LFXOSC_32K_DISABLE_VAL BIT(7) +#define MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL (0x3) +#define MCU_CTRL_DEVICE_CLKOUT_32K_CTRL (MCU_CTRL_MMR0_BASE + 0x8058) + +void am625_enable_32k_crystal(void) +{ + u32 val; + + /* Enable 32k crystal */ + val = readl(MCU_CTRL_LFXOSC_CTRL); + val &= ~(MCU_CTRL_LFXOSC_32K_DISABLE_VAL); + writel(val, MCU_CTRL_LFXOSC_CTRL); + + /* select 32k clock from LFOSC0 */ + writel(MCU_CTRL_DEVICE_CLKOUT_LFOSC_SELECT_VAL, + MCU_CTRL_DEVICE_CLKOUT_32K_CTRL); +} + #define CTRLMMR_WKUP_JTAG_DEVICE_ID (AM625_WKUP_CTRL_MMR0_BASE + 0x18) #define JTAG_DEV_CORE_NR GENMASK(21, 19) diff --git a/include/mach/k3/common.h b/include/mach/k3/common.h index d7ceea51d7..3377dc8895 100644 --- a/include/mach/k3/common.h +++ b/include/mach/k3/common.h @@ -6,5 +6,6 @@ void am625_get_bootsource(enum bootsource *src, int *instance); u64 am625_sdram_size(void); void am625_register_dram(void); +void am625_enable_32k_crystal(void); #endif /* __MACH_K3_COMMON_H */ -- 2.39.5