Skip to content

Commit 0eb5429

Browse files
chintingkuoWim Van Sebroeck
authored andcommitted
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>
1 parent b3bc229 commit 0eb5429

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/watchdog/aspeed_wdt.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct aspeed_wdt_config {
3535
u32 irq_shift;
3636
u32 irq_mask;
3737
struct aspeed_wdt_scu scu;
38+
u32 num_reset_masks;
3839
};
3940

4041
struct aspeed_wdt {
@@ -66,6 +67,7 @@ static const struct aspeed_wdt_config ast2500_config = {
6667
.wdt_reset_mask = 0x1,
6768
.wdt_reset_mask_shift = 2,
6869
},
70+
.num_reset_masks = 1,
6971
};
7072

7173
static const struct aspeed_wdt_config ast2600_config = {
@@ -78,6 +80,7 @@ static const struct aspeed_wdt_config ast2600_config = {
7880
.wdt_reset_mask = 0xf,
7981
.wdt_reset_mask_shift = 16,
8082
},
83+
.num_reset_masks = 2,
8184
};
8285

8386
static const struct of_device_id aspeed_wdt_of_table[] = {
@@ -479,11 +482,11 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
479482
set_bit(WDOG_HW_RUNNING, &wdt->wdd.status);
480483
}
481484

482-
if ((of_device_is_compatible(np, "aspeed,ast2500-wdt")) ||
483-
(of_device_is_compatible(np, "aspeed,ast2600-wdt"))) {
485+
if (!of_device_is_compatible(np, "aspeed,ast2400-wdt")) {
484486
u32 reset_mask[2];
485-
size_t nrstmask = of_device_is_compatible(np, "aspeed,ast2600-wdt") ? 2 : 1;
487+
size_t nrstmask = wdt->cfg->num_reset_masks;
486488
u32 reg = readl(wdt->base + WDT_RESET_WIDTH);
489+
int i;
487490

488491
reg &= wdt->cfg->ext_pulse_width_mask;
489492
if (of_property_read_bool(np, "aspeed,ext-active-high"))
@@ -503,9 +506,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev)
503506

504507
ret = of_property_read_u32_array(np, "aspeed,reset-mask", reset_mask, nrstmask);
505508
if (!ret) {
506-
writel(reset_mask[0], wdt->base + WDT_RESET_MASK1);
507-
if (nrstmask > 1)
508-
writel(reset_mask[1], wdt->base + WDT_RESET_MASK2);
509+
for (i = 0; i < nrstmask; i++)
510+
writel(reset_mask[i], wdt->base + WDT_RESET_MASK1 + i * 4);
509511
}
510512
}
511513

0 commit comments

Comments
 (0)