Skip to contentSkip to conversation

arm: aspeed: ast2600: Add B650D4U THRU handover

PATCH In review Prasanth Kumar Padarthi 2 participants 3 messages Nov 10 – Nov 23

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: aspeed: ast2600: Add B650D4U THRU handover

The ASRock Rack B650D4U uses AST2600 GPIOP signals for host power and reset control.

Add a board-specific initialization sequence to prepare the THRU pin selections and release the relevant strap overrides before handing control to the operating system.

The initialization is restricted to the B650D4U and checks the resulting strap state.

Tested on ASRock Rack B650D4U with a custom OpenBMC image:
- U-Boot and OpenBMC boot successfully
- Software-initiated host power-on
- Physical power-button host power-on

---
 arch/arm/mach-aspeed/ast2600/board_common.c | 55 +++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/arm/mach-aspeed/ast2600/board_common.c +55 -0
index 4c0b705ea88..3d8df6a9977 100644
@@ -13,6 +13,8 @@
 #include <dm/uclass.h>
 #include <asm/arch/scu_ast2600.h>
 #include <asm/global_data.h>
+#include <dm/ofnode.h>
+
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -49,11 +51,64 @@ int dram_init(void)
 	return 0;
 }
 
+
+/*
+ * B650D4U-specific AST2600 THRU handover.
+ * Prepare the THRU pin selections before releasing the strap overrides.
+ */
+static int b650d4u_thru_init(void)
+{
+	const uintptr_t scu = 0x1e6e2000;
+	u32 strap2, strap3, local;
+
+	if (!ofnode_device_is_compatible(ofnode_root(),
+					 "asrock,b650d4u-bmc"))
+		return 0;
+
+	strap2 = readl(scu + 0x510);
+	strap3 = readl(scu + 0x51c);
+
+	if (!(strap2 & BIT(28)) &&
+	    ((strap2 & BIT(30)) || !(strap3 & BIT(9))))
+		return 0;
+
+	/* Prepare local THRU0, THRU1 and THRU2 selections. */
+	local = readl(scu + 0x4bc);
+	writel(local | GENMASK(29, 24), scu + 0x4bc);
+
+	local = readl(scu + 0x4bc);
+	if ((local & GENMASK(29, 24)) != GENMASK(29, 24))
+		return -EPERM;
+
+	if (!(strap2 & BIT(30)) && (strap3 & BIT(9))) {
+		local = readl(scu + 0x51c);
+		writel(local & ~BIT(9), scu + 0x51c);
+	}
+
+	if (strap2 & BIT(28))
+		writel(BIT(28), scu + 0x514);
+
+	strap2 = readl(scu + 0x510);
+	strap3 = readl(scu + 0x51c);
+
+	if ((strap2 & BIT(28)) ||
+	    (!(strap2 & BIT(30)) && (strap3 & BIT(9))))
+		return -EPERM;
+
+	return 0;
+}
+
 int board_init(void)
 {
 	int i = 0, rc;
 	struct udevice *dev;
 
+	rc = b650d4u_thru_init();
+	if (rc) {
+		printf("B650D4U: THRU handover failed: %d\n", rc);
+		return rc;
+	}
+
 	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
 
 	while (1) {
Signature · 1 line
2.47.3
#1 lore raw
Quoted 8 lines · Prasanth Kumar Padarthi

The ASRock Rack B650D4U uses AST2600 GPIOP signals for host power and reset control.

Add a board-specific initialization sequence to prepare the THRU pin selections and release the relevant strap overrides before handing control to the operating system.

[...]

Applied to u-boot/next, thanks!

[1/1] arm: aspeed: ast2600: Add B650D4U THRU handover

      commit: ff6834c4ab49b837a3710f8afae03325e6a60839
Signature · 1 line
Tom
author
#2 lore raw

Thanks for applying the patch, Tom.
Prasanth

Quoted 20 lines · Tom Rini
Quoted 8 lines · Prasanth Kumar Padarthi

The ASRock Rack B650D4U uses AST2600 GPIOP signals for host power and reset control.

Add a board-specific initialization sequence to prepare the THRU pin selections and release the relevant strap overrides before handing control to the operating system.

[...]

Applied to u-boot/next, thanks!

[1/1] arm: aspeed: ast2600: Add B650D4U THRU handover

      commit: ff6834c4ab49b837a3710f8afae03325e6a60839

--
Tom