blob: 3a523ae71ca1b90dd7a53edfeec3173d77e4f88d [file]
From d85a46553fb6b149fe116b8d8294d68a3ccbb0f1 Mon Sep 17 00:00:00 2001
From: Alan Hung <yung-sheng.huang@fii-na.corp-partner.google.com>
Date: Wed, 25 Feb 2026 11:08:49 +0800
Subject: [PATCH] SGPIO: Make default output values persist reboot
Summary:
Following an AC cycle, the SGPIO default values are set. The unit
will function as expected. However following a reboot, the SGPIO
controller will still be operating. The SGPIO values will be zeroed out
for a short amount of time, and undefined behavior will occur.
Make the SGPIO output values persist reboot, and only set the default
SGPIO output values if not previously set.
Google-Bug-Id: 458611169, 471067239
Change-Id: Ifc3edb7384faf2c29f5714b289903c7d2b1fe83b
Signed-off-by: Kyle Nieman <kyle.nieman@fii-na.corp-partner.google.com>
Signed-off-by: Alan Hung <yung-sheng.huang@fii-na.corp-partner.google.com>
---
drivers/gpio/gpio-aspeed-sgpio.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-aspeed-sgpio.c b/drivers/gpio/gpio-aspeed-sgpio.c
index 6a928a182b19..a0104052fafb 100644
--- a/drivers/gpio/gpio-aspeed-sgpio.c
+++ b/drivers/gpio/gpio-aspeed-sgpio.c
@@ -874,11 +874,23 @@ static int aspeed_sgpio_probe(struct platform_device *pdev)
ast_write_bits(addr, SGPIO_G7_SERIAL_OUT_SEL,
SELECT_FROM_CSR);
- if (has_default) {
+ /*
+ * By default, GPIO values set in user space will
+ * automatically be set to be retained across BMC
+ * reboot. Apply this for initially set values of SGPIO
+ * as well. Only set the default value if the value is
+ * not set to persist BMC reboot. This is so that
+ * if the values were changed from the default defined,
+ * we aren't accidently overwritting them.
+ */
+ int has_persistent_output = field_get(SGPIO_G7_RST_TOLERANCE, ioread32(addr));
+ if (has_default && !has_persistent_output) {
const int byte_index = i / 8;
const int bit_index = i % 8;
initial_val = (byte_configs[byte_index] >> bit_index) & 1;
ast_write_bits(addr, SGPIO_G7_OUT_DATA, initial_val);
+ // Retain set values across BMC reboots
+ ast_write_bits(addr, SGPIO_G7_RST_TOLERANCE, 1);
}
}
--
2.34.1