Skip to content

Commit ff8ec4a

Browse files
parakaWim Van Sebroeck
authored andcommitted
watchdog: mt7621-wdt: avoid ralink architecture dependent code
MT7621 SoC has a system controller node. Watchdog need to access to reset status register. Ralink architecture and related driver are old and from the beggining they are using some architecture dependent operations for accessing this shared registers through 'asm/mach-ralink/ralink_regs.h' header file. However this is not ideal from a driver perspective which can just access to the system controller registers in an arch independent way using regmap syscon APIs. Update Kconfig accordingly to select new added dependencies and allow driver to be compile tested. Signed-off-by: Sergio Paracuellos <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 783c7cb commit ff8ec4a

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

drivers/watchdog/Kconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,9 @@ config GXP_WATCHDOG
18721872
config MT7621_WDT
18731873
tristate "Mediatek SoC watchdog"
18741874
select WATCHDOG_CORE
1875-
depends on SOC_MT7620 || SOC_MT7621
1875+
select REGMAP_MMIO
1876+
select MFD_SYSCON
1877+
depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
18761878
help
18771879
Hardware driver for the Mediatek/Ralink MT7621/8 SoC Watchdog Timer.
18781880

drivers/watchdog/mt7621_wdt.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <linux/moduleparam.h>
1616
#include <linux/platform_device.h>
1717
#include <linux/mod_devicetable.h>
18-
19-
#include <asm/mach-ralink/ralink_regs.h>
18+
#include <linux/mfd/syscon.h>
19+
#include <linux/regmap.h>
2020

2121
#define SYSC_RSTSTAT 0x38
2222
#define WDT_RST_CAUSE BIT(1)
@@ -34,6 +34,7 @@
3434
struct mt7621_wdt_data {
3535
void __iomem *base;
3636
struct reset_control *rst;
37+
struct regmap *sysc;
3738
struct watchdog_device wdt;
3839
};
3940

@@ -104,9 +105,12 @@ static int mt7621_wdt_stop(struct watchdog_device *w)
104105
return 0;
105106
}
106107

107-
static int mt7621_wdt_bootcause(void)
108+
static int mt7621_wdt_bootcause(struct mt7621_wdt_data *d)
108109
{
109-
if (rt_sysc_r32(SYSC_RSTSTAT) & WDT_RST_CAUSE)
110+
u32 val;
111+
112+
regmap_read(d->sysc, SYSC_RSTSTAT, &val);
113+
if (val & WDT_RST_CAUSE)
110114
return WDIOF_CARDRESET;
111115

112116
return 0;
@@ -134,6 +138,7 @@ static const struct watchdog_ops mt7621_wdt_ops = {
134138

135139
static int mt7621_wdt_probe(struct platform_device *pdev)
136140
{
141+
struct device_node *np = pdev->dev.of_node;
137142
struct device *dev = &pdev->dev;
138143
struct watchdog_device *mt7621_wdt;
139144
struct mt7621_wdt_data *drvdata;
@@ -143,6 +148,13 @@ static int mt7621_wdt_probe(struct platform_device *pdev)
143148
if (!drvdata)
144149
return -ENOMEM;
145150

151+
drvdata->sysc = syscon_regmap_lookup_by_phandle(np, "mediatek,sysctl");
152+
if (IS_ERR(drvdata->sysc)) {
153+
drvdata->sysc = syscon_regmap_lookup_by_compatible("mediatek,mt7621-sysc");
154+
if (IS_ERR(drvdata->sysc))
155+
return PTR_ERR(drvdata->sysc);
156+
}
157+
146158
drvdata->base = devm_platform_ioremap_resource(pdev, 0);
147159
if (IS_ERR(drvdata->base))
148160
return PTR_ERR(drvdata->base);
@@ -158,7 +170,7 @@ static int mt7621_wdt_probe(struct platform_device *pdev)
158170
mt7621_wdt->max_timeout = 0xfffful / 1000;
159171
mt7621_wdt->parent = dev;
160172

161-
mt7621_wdt->bootstatus = mt7621_wdt_bootcause();
173+
mt7621_wdt->bootstatus = mt7621_wdt_bootcause(drvdata);
162174

163175
watchdog_init_timeout(mt7621_wdt, mt7621_wdt->max_timeout, dev);
164176
watchdog_set_nowayout(mt7621_wdt, nowayout);

0 commit comments

Comments
 (0)