mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH v2 01/20] ARM: k3: Add function to enable 32k crystal
Date: Wed, 12 Feb 2025 15:09:14 +0100	[thread overview]
Message-ID: <20250212-k3-emmc-v2-1-8dd1bb0ce60a@pengutronix.de> (raw)
In-Reply-To: <20250212-k3-emmc-v2-0-8dd1bb0ce60a@pengutronix.de>

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@pengutronix.de>
---
 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




  reply	other threads:[~2025-02-12 14:10 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 14:09 [PATCH v2 00/20] ARM: K3 updates Sascha Hauer
2025-02-12 14:09 ` Sascha Hauer [this message]
2025-02-12 14:09 ` [PATCH v2 02/20] ARM: k3: add function to detect eMMC boot Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 03/20] ARM: k3: do not mount /boot when booting from eMMC Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 04/20] fip: drop typedefs Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 05/20] fip: use linux list implementation Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 06/20] fip: use uuid_equal() and uuid_is_null() Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 07/20] fiptool: do not typedef structs Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 08/20] fip: add fip_ prefix Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 09/20] fip: add fip_image_open() Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 10/20] ARM: k3: r5: add USB DFU and eMMC boot support Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 11/20] ARM: am625-sk: enable 32k crystal Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 12/20] mci: am654: parse generic mmc node properties Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 13/20] ARM: k3: limit eMMC frequency to 26MHz Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 14/20] ARM: k3: add eMMC barebox update handler Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 15/20] ARM: am625-sk: put environment on eMMC when booting from it Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 16/20] serial: omap: Use ttyS as Linux console name Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 17/20] ARM: k3: remove beagleplay FIT image Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 18/20] ARM: am625-sk: cleanup board entry Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 19/20] ARM: beagleplay: " Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 20/20] ARM: k3: Add k3-r5_defconfig Sascha Hauer
2025-02-17 11:14 ` [PATCH v2 00/20] ARM: K3 updates Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250212-k3-emmc-v2-1-8dd1bb0ce60a@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox