Skip to contentSkip to conversation

board: beagle: Enable 32k and debounce configuration

PATCH Superseded Nishanth Menon 2 participants 7 messages Feb 12, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover board: beagle: Enable 32k and debounce configuration

Hi,

This is a follow up from [1] - Without the 32k crystal configuration, wlan does'nt work. Debounce is needed for HDMI hpd gpio interrupt.

At least the 32k configuration has been done for toradex and phytec boards, follow similar model of programming.

This series is based on master commit e8f2404e093d + the findfdt series[2].

Nishanth Menon (4):
board: beagle: beagleplay: Enable 32k crystal
configs: am62x_beagleplay_r5_defconfig: Enable SPL_BOARD_INIT
arm: mach-k3: am62: Add Debounce configuration register definitions
board: beagle: beagleplay: Configure debounce registers

 arch/arm/mach-k3/include/mach/am62_hardware.h |  3 +
 board/beagle/beagleplay/beagleplay.c          | 61 +++++++++++++++++++
 configs/am62x_beagleplay_r5_defconfig         |  1 +
 3 files changed, 65 insertions(+)

[1] https://lore.kernel.org/u-boot/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 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.

---
 board/beagle/beagleplay/beagleplay.c | 37 ++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
board/beagle/beagleplay/beagleplay.c +37 -0
index 20819ecf45b4..a75b3145fa37 100644
@@ -11,6 +11,8 @@
 #include <fdt_support.h>
 #include <spl.h>
 
+#include <asm/arch/hardware.h>
+
 DECLARE_GLOBAL_DATA_PTR;
 
 int board_init(void)
@@ -28,6 +30,41 @@ 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
+
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
Signature · 1 line
2.43.0
Tested-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] board: beagle: beagleplay: Enable 32k crystal

Quoted 8 lines · Nishanth Menon

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.

Yay, WiFi (wl18xx) now works on the BeaglePay with these 4 patches on top of v2024.01-rc1

debian@BeaglePlay-57:~$ dmesg | grep wl
[    1.892839] wlan_en: supplied by vdd_3v3
[    8.437425] systemd[1]: Expecting device
sys-subsystem-net-devices-wlan0.device -
/sys/subsystem/net/devices/wlan0...
[   13.241739] wlcore: wl18xx HW: 183x or 180x, PG 2.2 (ROM 0x11)
[   13.246116] wlcore: WARNING Detected unconfigured mac address in
nvs, derive from fuse instead.
[   13.246155] wlcore: WARNING This default nvs file can be removed
from the file system
[   13.253088] wlcore: loaded
[   13.788451] wlcore: using inverted interrupt logic: 2
[   13.842464] wlcore: PHY firmware version: Rev 8.2.0.0.243
[   13.938371] wlcore: firmware booted (Rev 8.9.0.0.83)

Regards,

Signature · 2 lines
Robert Nelson
https://rcn-ee.com/
#3 lore raw

PATCH 2/4 configs: am62x_beagleplay_r5_defconfig: Enable SPL_BOARD_INIT

In reply to Nishanth Menon

Enable CONFIG_SPL_BOARD_INIT to configure the 32k crystal.

---
 configs/am62x_beagleplay_r5_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am62x_beagleplay_r5_defconfig +1 -0
index 2f3264b7ede6..9413c859870f 100644
@@ -36,6 +36,7 @@ CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
 CONFIG_SPL_BSS_START_ADDR=0x43c3b000
 CONFIG_SPL_BSS_MAX_SIZE=0x3000
 CONFIG_SPL_SYS_REPORT_STACK_F_USAGE=y
+CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_SYS_MALLOC_SIMPLE=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_SEPARATE_BSS=y
Signature · 1 line
2.43.0
#4 lore raw

PATCH 3/4 arm: mach-k3: am62: Add Debounce configuration register definitions

In reply to Nishanth Menon

Add the Debounce configuration registers that need to be configured one time for the platform for the entire SoC.

---
 arch/arm/mach-k3/include/mach/am62_hardware.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-k3/include/mach/am62_hardware.h +3 -0
index 54380f36e161..06fcab01a5b7 100644
@@ -75,6 +75,9 @@
 
 #define CTRLMMR_MCU_RST_CTRL			(MCU_CTRL_MMR0_BASE + 0x18170)
 
+/* Debounce register configuration */
+#define CTRLMMR_DBOUNCE_CFG(index)		(MCU_CTRL_MMR0_BASE + 4080 + (index * 4))
+
 #define ROM_EXTENDED_BOOT_DATA_INFO		0x43c3f1e0
 
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	0x43c30000
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 3/4] arm: mach-k3: am62: Add Debounce configuration register definitions

Quoted 13 lines · Nishanth Menon

Add the Debounce configuration registers that need to be configured one time for the platform for the entire SoC.

---
 arch/arm/mach-k3/include/mach/am62_hardware.h | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/mach-k3/include/mach/am62_hardware.h +0 -0
index 54380f36e161..06fcab01a5b7 100644

arch/arm/mach-k3/include/mach/am62_hardware.h line 79

Quoted 5 lines
arch/arm/mach-k3/include/mach/am62_hardware.h +2 -0
@@ -75,6 +75,9 @@
 
 #define CTRLMMR_MCU_RST_CTRL			(MCU_CTRL_MMR0_BASE + 0x18170)
 
+/* Debounce register configuration */
+#define CTRLMMR_DBOUNCE_CFG(index)		(MCU_CTRL_MMR0_BASE + 4080 + (index * 4))

Grrr.. missed the fixup for 0x4080 here. will wait a couple of days for any other review comments.

Quoted 7 lines
arch/arm/mach-k3/include/mach/am62_hardware.h +1 -0
+
 #define ROM_EXTENDED_BOOT_DATA_INFO		0x43c3f1e0
 
 #define TI_SRAM_SCRATCH_BOARD_EEPROM_START	0x43c30000
Signature · 1 line
2.43.0
Signature · 3 lines
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 849D 1736 249D
#6 lore raw

PATCH 4/4 board: beagle: beagleplay: Configure debounce registers

In reply to Nishanth Menon

Configure the debounce configuration that makes sense for BeaglePlay usage model.

---
 board/beagle/beagleplay/beagleplay.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
board/beagle/beagleplay/beagleplay.c +24 -0
index a75b3145fa37..5640fdf41ed3 100644
@@ -59,9 +59,33 @@ static void crystal_32k_enable(void)
 	}
 }
 
+static void debounce_configure(void)
+{
+	/* Configure debounce one time from R5 */
+	if (IS_ENABLED(CONFIG_CPU_V7R)) {
+		/*
+		 * Setup debounce time registers.
+		 * arbitrary values. Times are approx
+		 */
+		/* 1.9ms debounce @ 32k */
+		writel(0x1, CTRLMMR_DBOUNCE_CFG(1));
+		/* 5ms debounce @ 32k */
+		writel(0x5, CTRLMMR_DBOUNCE_CFG(2));
+		/* 20ms debounce @ 32k */
+		writel(0x14, CTRLMMR_DBOUNCE_CFG(3));
+		/* 46ms debounce @ 32k */
+		writel(0x18, CTRLMMR_DBOUNCE_CFG(4));
+		/* 100ms debounce @ 32k */
+		writel(0x1c, CTRLMMR_DBOUNCE_CFG(5));
+		/* 156ms debounce @ 32k */
+		writel(0x1f, CTRLMMR_DBOUNCE_CFG(6));
+	}
+}
+
 void spl_board_init(void)
 {
 	crystal_32k_enable();
+	debounce_configure();
 }
 #endif
 
Signature · 1 line
2.43.0