Skip to content

Commit 6584cd3

Browse files
petegriffinkrzk
authored andcommitted
watchdog: s3c2410_wdt: Add support for WTCON register DBGACK_MASK bit
The WDT uses the CPU core signal DBGACK to determine whether the SoC is running in debug mode or not. If the DBGACK signal is asserted and DBGACK_MASK bit is enabled, then WDT output and interrupt is masked (disabled). Presence of the DBGACK_MASK bit is determined by adding a new QUIRK_HAS_DBGACK_BIT quirk. Also update to use BIT macro to avoid checkpatch --strict warnings. Tested-by: Will McVicker <willmcvicker@google.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Peter Griffin <peter.griffin@linaro.org> Link: https://lore.kernel.org/r/20231211162331.435900-11-peter.griffin@linaro.org Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
1 parent c95f5b2 commit 6584cd3

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

drivers/watchdog/s3c2410_wdt.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* (c) Copyright 1996 Alan Cox <alan@lxorguk.ukuu.org.uk>
1010
*/
1111

12+
#include <linux/bits.h>
1213
#include <linux/module.h>
1314
#include <linux/moduleparam.h>
1415
#include <linux/types.h>
@@ -34,9 +35,10 @@
3435

3536
#define S3C2410_WTCNT_MAXCNT 0xffff
3637

37-
#define S3C2410_WTCON_RSTEN (1 << 0)
38-
#define S3C2410_WTCON_INTEN (1 << 2)
39-
#define S3C2410_WTCON_ENABLE (1 << 5)
38+
#define S3C2410_WTCON_RSTEN BIT(0)
39+
#define S3C2410_WTCON_INTEN BIT(2)
40+
#define S3C2410_WTCON_ENABLE BIT(5)
41+
#define S3C2410_WTCON_DBGACK_MASK BIT(16)
4042

4143
#define S3C2410_WTCON_DIV16 (0 << 3)
4244
#define S3C2410_WTCON_DIV32 (1 << 3)
@@ -100,12 +102,17 @@
100102
* %QUIRK_HAS_PMU_CNT_EN: PMU block has some register (e.g. CLUSTERx_NONCPU_OUT)
101103
* with "watchdog counter enable" bit. That bit should be set to make watchdog
102104
* counter running.
105+
*
106+
* %QUIRK_HAS_DBGACK_BIT: WTCON register has DBGACK_MASK bit. Setting the
107+
* DBGACK_MASK bit disables the watchdog outputs when the SoC is in debug mode.
108+
* Debug mode is determined by the DBGACK CPU signal.
103109
*/
104110
#define QUIRK_HAS_WTCLRINT_REG (1 << 0)
105111
#define QUIRK_HAS_PMU_MASK_RESET (1 << 1)
106112
#define QUIRK_HAS_PMU_RST_STAT (1 << 2)
107113
#define QUIRK_HAS_PMU_AUTO_DISABLE (1 << 3)
108114
#define QUIRK_HAS_PMU_CNT_EN (1 << 4)
115+
#define QUIRK_HAS_DBGACK_BIT BIT(5)
109116

110117
/* These quirks require that we have a PMU register map */
111118
#define QUIRKS_HAVE_PMUREG \
@@ -375,6 +382,19 @@ static int s3c2410wdt_enable(struct s3c2410_wdt *wdt, bool en)
375382
return 0;
376383
}
377384

385+
/* Disable watchdog outputs if CPU is in debug mode */
386+
static void s3c2410wdt_mask_dbgack(struct s3c2410_wdt *wdt)
387+
{
388+
unsigned long wtcon;
389+
390+
if (!(wdt->drv_data->quirks & QUIRK_HAS_DBGACK_BIT))
391+
return;
392+
393+
wtcon = readl(wdt->reg_base + S3C2410_WTCON);
394+
wtcon |= S3C2410_WTCON_DBGACK_MASK;
395+
writel(wtcon, wdt->reg_base + S3C2410_WTCON);
396+
}
397+
378398
static int s3c2410wdt_keepalive(struct watchdog_device *wdd)
379399
{
380400
struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
@@ -700,6 +720,8 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
700720
wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
701721
wdt->wdt_device.parent = dev;
702722

723+
s3c2410wdt_mask_dbgack(wdt);
724+
703725
/*
704726
* If "tmr_atboot" param is non-zero, start the watchdog right now. Also
705727
* set WDOG_HW_RUNNING bit, so that watchdog core can kick the watchdog.

0 commit comments

Comments
 (0)