summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChin-Ting Kuo <chin-ting_kuo@aspeedtech.com>2025-10-10 16:03:14 +0800
committerWim Van Sebroeck <wim@linux-watchdog.org>2025-11-15 15:19:52 +0100
commit0eb54296dc784de757724055983d32b03c9e2df1 (patch)
tree7fe0cd09c1cfa5f4c145fed648df4b9e578556f8
parentb3bc229b54e780fe02a41ec65a0cb06acf7ac1d9 (diff)
watchdog: aspeed: Support variable number of reset mask registers
Starting from the AST2600 platform, the SoC design has become more complex, with an increased number of reset mask registers. To support this, introduce a new field 'num_reset_masks' in the 'aspeed_wdt_config' structure to specify the number of reset mask registers per platform. This change removes the need for hardcoded platform-specific logic and improves scalability for future SoCs. Signed-off-by: Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
-rw-r--r--drivers/watchdog/aspeed_wdt.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c
index 837e15701c0e..d23e565f30a8 100644
--- a/drivers/watchdog/aspeed_wdt.c
+++ b/drivers/watchdog/aspeed_wdt.c
@@ -35,6 +35,7 @@ struct aspeed_wdt_config {
u32 irq_shift;
u32 irq_mask;
struct aspeed_wdt_scu scu;
+ u32 num_reset_masks;
};
struct aspeed_wdt {
@@ -66,6 +67,7 @@ static const struct aspeed_wdt_config ast2500_config = {
.wdt_reset_mask = 0x1,
.wdt_reset_mask_shift = 2,
},
+ .num_reset_masks = 1,
};
static const struct aspeed_wdt_config ast2600_config = {
@@ -78,6 +80,7 @@ static const struct aspeed_wdt_config ast2600_config = {
.wdt_reset_mask = 0xf,
.wdt_reset_mask_shift = 16,
},
+ .num_reset_masks = 2,
};
static const struct of_device_id aspeed_wdt_of_table[] = {
@@ -479,11 +482,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
}
- if ((of_device_is_compatible(np, "aspeed,ast2500-wdt")) ||
- (of_device_is_compatible(np, "aspeed,ast2600-wdt"))) {
+ if (!of_device_is_compatible(np, "aspeed,ast2400-wdt")) {
u32 reset_mask[2];
- size_t nrstmask = of_device_is_compatible(np, "aspeed,ast2600-wdt") ? 2 : 1;
+ size_t nrstmask = wdt->cfg->num_reset_masks;
u32 reg = readl(wdt->base + WDT_RESET_WIDTH);
+ int i;
reg &= wdt->cfg->ext_pulse_width_mask;
if (of_property_read_bool(np, "aspeed,ext-active-high"))
@@ -503,9 +506,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
ret = of_property_read_u32_array(np, "aspeed,reset-mask", reset_mask, nrstmask);
if (!ret) {
- writel(reset_mask[0], wdt->base + WDT_RESET_MASK1);
- if (nrstmask > 1)
- writel(reset_mask[1], wdt->base + WDT_RESET_MASK2);
+ for (i = 0; i < nrstmask; i++)
+ writel(reset_mask[i], wdt->base + WDT_RESET_MASK1 + i * 4);
}
}