Skip to contentSkip to conversation

wdt/aspeed: Support software reset mode for AST2600

PATCH New Jamin Lin via 4 participants 6 messages Jan 23, 2025 – Jan 24, 2025 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

cover wdt/aspeed: Support software reset mode for AST2600

v1:
Support software reset mode for AST2600

Jamin Lin (2):
aspeed/wdt: Fix coding style
aspeed/wdt: Support software reset mode for AST2600

 hw/watchdog/wdt_aspeed.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 aspeed/wdt: Fix coding style

Fix coding style issues from checkpatch.pl.

---
 hw/watchdog/wdt_aspeed.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +2 -1
index 81f5c5189a..22e94e7b9c 100644
@@ -278,7 +278,8 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
 
     s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev);
 
-    /* FIXME: This setting should be derived from the SCU hw strapping
+    /*
+     * FIXME: This setting should be derived from the SCU hw strapping
      * register SCU70
      */
     s->pclk_freq = PCLK_HZ;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] aspeed/wdt: Fix coding style

Quoted 3 lines · Jamin Lin

Fix coding style issues from checkpatch.pl.

Thanks,

C.

Quoted 18 lines
---
  hw/watchdog/wdt_aspeed.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +2 -1
index 81f5c5189a..22e94e7b9c 100644
@@ -278,7 +278,8 @@ static void aspeed_wdt_realize(DeviceState *dev, Error **errp)
 
      s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, aspeed_wdt_timer_expired, dev);
 
-    /* FIXME: This setting should be derived from the SCU hw strapping
+    /*
+     * FIXME: This setting should be derived from the SCU hw strapping
       * register SCU70
       */
      s->pclk_freq = PCLK_HZ;
#3 lore raw

PATCH 2/2 aspeed/wdt: Support software reset mode for AST2600

In reply to Jamin Lin via

On the AST2400 and AST2500 platforms, the system can only be reset by enabling the WDT (Watchdog Timer) and waiting for the WDT timeout. However, starting from the AST2600 platform, the reset event can be triggered directly and intentionally by software, without relying on the WDT timeout.

This mechanism, referred to as "software restart", is implemented in hardware. When using the software restart mechanism, the WDT counter is not enabled.

To trigger a reset generation in software mode, write 0xAEEDF123 to register 0x24 and software mode reset only support SOC reset mode.

A new function, "aspeed_wdt_is_soc_reset_mode", is introduced to determine whether the SoC reset mode is active.

---
 hw/watchdog/wdt_aspeed.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +15 -1
index 22e94e7b9c..94fb643395 100644
@@ -51,11 +51,20 @@
 #define WDT_TIMEOUT_CLEAR               (0x14 / 4)
 
 #define WDT_RESTART_MAGIC               0x4755
+#define WDT_SW_RESET_ENABLE             0xAEEDF123
 
 #define AST2600_SCU_RESET_CONTROL1      (0x40 / 4)
 #define SCU_RESET_CONTROL1              (0x04 / 4)
 #define    SCU_RESET_SDRAM              BIT(0)
 
+static bool aspeed_wdt_is_soc_reset_mode(const AspeedWDTState *s)
+{
+    uint32_t mode;
+
+    mode = extract32(s->regs[WDT_CTRL], 5, 2);
+    return (mode == 0);
+}
+
 static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
 {
     return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
@@ -199,13 +208,18 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,
     case WDT_TIMEOUT_STATUS:
     case WDT_TIMEOUT_CLEAR:
     case WDT_RESET_MASK2:
-    case WDT_SW_RESET_CTRL:
     case WDT_SW_RESET_MASK1:
     case WDT_SW_RESET_MASK2:
         qemu_log_mask(LOG_UNIMP,
                       "%s: uninmplemented write at offset 0x%" HWADDR_PRIx "\n",
                       __func__, offset);
         break;
+    case WDT_SW_RESET_CTRL:
+        if (aspeed_wdt_is_soc_reset_mode(s) &&
+            (data == WDT_SW_RESET_ENABLE)) {
+            watchdog_perform_action();
+        }
+        break;
     default:
         qemu_log_mask(LOG_GUEST_ERROR,
                       "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx "\n",
Signature · 1 line
2.34.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] aspeed/wdt: Support software reset mode for AST2600

Quoted 28 lines · Jamin Lin

On the AST2400 and AST2500 platforms, the system can only be reset by enabling the WDT (Watchdog Timer) and waiting for the WDT timeout. However, starting from the AST2600 platform, the reset event can be triggered directly and intentionally by software, without relying on the WDT timeout.

This mechanism, referred to as "software restart", is implemented in hardware. When using the software restart mechanism, the WDT counter is not enabled.

To trigger a reset generation in software mode, write 0xAEEDF123 to register 0x24 and software mode reset only support SOC reset mode.

A new function, "aspeed_wdt_is_soc_reset_mode", is introduced to determine whether the SoC reset mode is active.

---
  hw/watchdog/wdt_aspeed.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c +1 -0
index 22e94e7b9c..94fb643395 100644
@@ -51,11 +51,20 @@
  #define WDT_TIMEOUT_CLEAR               (0x14 / 4)
 
  #define WDT_RESTART_MAGIC               0x4755
+#define WDT_SW_RESET_ENABLE             0xAEEDF123

hw/watchdog/wdt_aspeed.c line 64

Quoted 10 lines
hw/watchdog/wdt_aspeed.c +5 -0
 
  #define AST2600_SCU_RESET_CONTROL1      (0x40 / 4)
  #define SCU_RESET_CONTROL1              (0x04 / 4)
  #define    SCU_RESET_SDRAM              BIT(0)
 
+static bool aspeed_wdt_is_soc_reset_mode(const AspeedWDTState *s)
+{
+    uint32_t mode;
+
+    mode = extract32(s->regs[WDT_CTRL], 5, 2);

Could we test the extracted field against WDT_CTRL_RESET_MODE_SOC ?

With that,

Thanks,

C.

Quoted 26 lines
hw/watchdog/wdt_aspeed.c +9 -1
+    return (mode == 0);
+}
+
  static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
  {
      return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE;
@@ -199,13 +208,18 @@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t data,
      case WDT_TIMEOUT_STATUS:
      case WDT_TIMEOUT_CLEAR:
      case WDT_RESET_MASK2:
-    case WDT_SW_RESET_CTRL:
      case WDT_SW_RESET_MASK1:
      case WDT_SW_RESET_MASK2:
          qemu_log_mask(LOG_UNIMP,
                        "%s: uninmplemented write at offset 0x%" HWADDR_PRIx "\n",
                        __func__, offset);
          break;
+    case WDT_SW_RESET_CTRL:
+        if (aspeed_wdt_is_soc_reset_mode(s) &&
+            (data == WDT_SW_RESET_ENABLE)) {
+            watchdog_perform_action();
+        }
+        break;
      default:
          qemu_log_mask(LOG_GUEST_ERROR,
                        "%s: Out-of-bounds write at offset 0x%" HWADDR_PRIx "\n",
#5 lore raw

RE: [PATCH v1 2/2] aspeed/wdt: Support software reset mode for AST2600

Hi Cedric,

Quoted 51 lines

From: Cédric Le Goater <[email protected]>
Sent: Friday, January 24, 2025 2:45 AM
To: Jamin Lin <[email protected]>; Peter Maydell <[email protected]>; Steven Lee <[email protected]>; Troy Lee <[email protected]>; Andrew Jeffery <[email protected]>; Joel Stanley <[email protected]>; open list:ASPEED BMCs <[email protected]>; open list:All patches CC here <[email protected]>
Cc: Troy Lee <[email protected]>; Yunlin Tang <[email protected]>
Subject: Re: [PATCH v1 2/2] aspeed/wdt: Support software reset mode for AST2600

Quoted 4 lines · Jamin Lin

On the AST2400 and AST2500 platforms, the system can only be reset by enabling the WDT (Watchdog Timer) and waiting for the WDT timeout. However, starting from the AST2600 platform, the reset event can be triggered directly and intentionally by software, without relying on the WDT

timeout.

Quoted 2 lines

This mechanism, referred to as "software restart", is implemented in

hardware.

Quoted 1 line

When using the software restart mechanism, the WDT counter is not

enabled.

Quoted 27 lines

To trigger a reset generation in software mode, write 0xAEEDF123 to register
0x24 and software mode reset only support SOC reset mode.

A new function, "aspeed_wdt_is_soc_reset_mode", is introduced to determine whether the SoC reset mode is active.

---
  hw/watchdog/wdt_aspeed.c | 16 +++++++++++++++-
  1 file changed, 15 insertions(+), 1 deletion(-)
hw/watchdog/wdt_aspeed.c index renamed from hw/watchdog/wdt_aspeed.c +0 -0

22e94e7b9c..94fb643395 100644

hw/watchdog/wdt_aspeed.c +1 -0
@@ -51,11 +51,20 @@
  #define WDT_TIMEOUT_CLEAR               (0x14 / 4)
 
  #define WDT_RESTART_MAGIC               0x4755
+#define WDT_SW_RESET_ENABLE             0xAEEDF123
 
  #define AST2600_SCU_RESET_CONTROL1      (0x40 / 4)
  #define SCU_RESET_CONTROL1              (0x04 / 4)
  #define    SCU_RESET_SDRAM              BIT(0)
 
Quoted 7 lines

hw/watchdog/wdt_aspeed.c line 64

Quoted 4 lines
hw/watchdog/wdt_aspeed.c +4 -0
+static bool aspeed_wdt_is_soc_reset_mode(const AspeedWDTState *s) {
+    uint32_t mode;
+
+    mode = extract32(s->regs[WDT_CTRL], 5, 2);

Could we test the extracted field against WDT_CTRL_RESET_MODE_SOC ?

Will update it.

Thanks for review.
Jamin

Quoted 43 lines

With that,

Thanks,

C.

hw/watchdog/wdt_aspeed.c

Quoted 6 lines
hw/watchdog/wdt_aspeed.c +3 -0
+    return (mode == 0);
+}
+
  static bool aspeed_wdt_is_enabled(const AspeedWDTState *s)
  {
      return s->regs[WDT_CTRL] & WDT_CTRL_ENABLE; @@ -199,13

+208,18

Quoted 1 line

@@ static void aspeed_wdt_write(void *opaque, hwaddr offset, uint64_t

data,

Quoted 8 lines

case WDT_TIMEOUT_STATUS:
case WDT_TIMEOUT_CLEAR:
case WDT_RESET_MASK2:
- case WDT_SW_RESET_CTRL:

      case WDT_SW_RESET_MASK1:
      case WDT_SW_RESET_MASK2:
          qemu_log_mask(LOG_UNIMP,
                        "%s: uninmplemented write at offset 0x%"

HWADDR_PRIx "\n",

Quoted 12 lines
                        __func__, offset);
          break;
hw/watchdog/wdt_aspeed.c +6 -0
+    case WDT_SW_RESET_CTRL:
+        if (aspeed_wdt_is_soc_reset_mode(s) &&
+            (data == WDT_SW_RESET_ENABLE)) {
+            watchdog_perform_action();
+        }
+        break;
      default:
          qemu_log_mask(LOG_GUEST_ERROR,
                        "%s: Out-of-bounds write at offset 0x%"

HWADDR_PRIx "\n",