Skip to content

Commit 47c0080

Browse files
marcusfolkessonWim Van Sebroeck
authored andcommitted
watchdog: rn5t618: add support for read out bootstatus
The PMIC does store the power-off factor internally. Read it out and report it as bootstatus. Signed-off-by: Marcus Folkesson <[email protected]> Acked-by: Lee Jones <[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 758f46c commit 47c0080

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

drivers/watchdog/rn5t618_wdt.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ static int rn5t618_wdt_probe(struct platform_device *pdev)
144144
struct rn5t618 *rn5t618 = dev_get_drvdata(dev->parent);
145145
struct rn5t618_wdt *wdt;
146146
int min_timeout, max_timeout;
147+
int ret;
148+
unsigned int val;
147149

148150
wdt = devm_kzalloc(dev, sizeof(struct rn5t618_wdt), GFP_KERNEL);
149151
if (!wdt)
@@ -160,6 +162,16 @@ static int rn5t618_wdt_probe(struct platform_device *pdev)
160162
wdt->wdt_dev.timeout = max_timeout;
161163
wdt->wdt_dev.parent = dev;
162164

165+
/* Read out previous power-off factor */
166+
ret = regmap_read(wdt->rn5t618->regmap, RN5T618_POFFHIS, &val);
167+
if (ret)
168+
return ret;
169+
170+
if (val & RN5T618_POFFHIS_VINDET)
171+
wdt->wdt_dev.bootstatus = WDIOF_POWERUNDER;
172+
else if (val & RN5T618_POFFHIS_WDG)
173+
wdt->wdt_dev.bootstatus = WDIOF_CARDRESET;
174+
163175
watchdog_set_drvdata(&wdt->wdt_dev, wdt);
164176
watchdog_init_timeout(&wdt->wdt_dev, timeout, dev);
165177
watchdog_set_nowayout(&wdt->wdt_dev, nowayout);

include/linux/mfd/rn5t618.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@
227227
#define RN5T618_WATCHDOG_WDOGTIM_S 0
228228
#define RN5T618_PWRIRQ_IR_WDOG BIT(6)
229229

230+
#define RN5T618_POFFHIS_PWRON BIT(0)
231+
#define RN5T618_POFFHIS_TSHUT BIT(1)
232+
#define RN5T618_POFFHIS_VINDET BIT(2)
233+
#define RN5T618_POFFHIS_IODET BIT(3)
234+
#define RN5T618_POFFHIS_CPU BIT(4)
235+
#define RN5T618_POFFHIS_WDG BIT(5)
236+
#define RN5T618_POFFHIS_DCLIM BIT(6)
237+
#define RN5T618_POFFHIS_N_OE BIT(7)
238+
230239
enum {
231240
RN5T618_DCDC1,
232241
RN5T618_DCDC2,

0 commit comments

Comments
 (0)