2021-10-31 12:24:25

by Sam Protsenko

[permalink] [raw]
Subject: [PATCH v2 00/12] watchdog: s3c2410: Add Exynos850 support

Exynos850 WDT IP-core differs a bit from existing platforms:
- Another set of PMU registers
- Separate WDT instance for each CPU cluster, having different PMU
registers/bits
- Source clock is different from PCLK

Implement all missing features above and enable Exynos850 WDT support.
While at it, do a bit of cleaning up.

Changes in v2:
- Added patch to fail probe if no valid timeout was found, as
suggested by Guenter Roeck (03/12)
- Extracted code for separating disable/mask functions into separate
patch (06/12)
- Added patch for inverting mask register value (07/12)
- Extracted PMU cleanup code to separate patch, to ease the review and
porting (09/12)
- Added patch for removing not needed 'err' label in probe function (11/12)
- Addressed all outstanding review comments on mailing list

Sam Protsenko (12):
dt-bindings: watchdog: Require samsung,syscon-phandle for Exynos7
dt-bindings: watchdog: Document Exynos850 watchdog bindings
watchdog: s3c2410: Fail probe if can't find valid timeout
watchdog: s3c2410: Let kernel kick watchdog
watchdog: s3c2410: Make reset disable register optional
watchdog: s3c2410: Extract disable and mask code into separate
functions
watchdog: s3c2410: Implement a way to invert mask reg value
watchdog: s3c2410: Add support for WDT counter enable register
watchdog: s3c2410: Cleanup PMU related code
watchdog: s3c2410: Support separate source clock
watchdog: s3c2410: Remove superfluous err label
watchdog: s3c2410: Add Exynos850 support

.../bindings/watchdog/samsung-wdt.yaml | 47 ++-
drivers/watchdog/s3c2410_wdt.c | 289 +++++++++++++-----
2 files changed, 254 insertions(+), 82 deletions(-)

--
2.30.2


2021-10-31 12:24:51

by Sam Protsenko

[permalink] [raw]
Subject: [PATCH v2 11/12] watchdog: s3c2410: Remove superfluous err label

'err' label in probe function is not really need, it just returns.
Remove it and replace all 'goto' statements with actual returns in
place.

No functional change here, just a cleanup patch.

Signed-off-by: Sam Protsenko <[email protected]>
---
Changes in v2:
- (none): it's a new patch

drivers/watchdog/s3c2410_wdt.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index c733917c5470..8fdda2ede1c3 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -588,22 +588,18 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
wdt_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (wdt_irq == NULL) {
dev_err(dev, "no irq resource specified\n");
- ret = -ENOENT;
- goto err;
+ return -ENOENT;
}

/* get the memory region for the watchdog timer */
wdt->reg_base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(wdt->reg_base)) {
- ret = PTR_ERR(wdt->reg_base);
- goto err;
- }
+ if (IS_ERR(wdt->reg_base))
+ return PTR_ERR(wdt->reg_base);

wdt->bus_clk = devm_clk_get(dev, "watchdog");
if (IS_ERR(wdt->bus_clk)) {
dev_err(dev, "failed to find bus clock\n");
- ret = PTR_ERR(wdt->bus_clk);
- goto err;
+ return PTR_ERR(wdt->bus_clk);
}

ret = clk_prepare_enable(wdt->bus_clk);
@@ -720,7 +716,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
err_bus_clk:
clk_disable_unprepare(wdt->bus_clk);

- err:
return ret;
}

--
2.30.2

2021-10-31 12:24:51

by Sam Protsenko

[permalink] [raw]
Subject: [PATCH v2 04/12] watchdog: s3c2410: Let kernel kick watchdog

When "tmr_atboot" module param is set, the watchdog is started in
driver's probe. In that case, also set WDOG_HW_RUNNING bit to let
watchdog core driver know it's running. This way watchdog core can kick
the watchdog for us (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED option is
enabled), until user space takes control.

WDOG_HW_RUNNING bit must be set before registering the watchdog. So the
"tmr_atboot" handling code is moved before watchdog registration, to
avoid performing the same check twice. This is also logical because
WDOG_HW_RUNNING bit makes WDT core expect actually running watchdog.

Signed-off-by: Sam Protsenko <[email protected]>
---
Changes in v2:
- Added explanation on moving the code block to commit message
- [PATCH 03/12] handles the case when tmr_atboot is present but valid
timeout wasn't found

drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index 00421cf22556..0845c05034a1 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -604,6 +604,21 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
wdt->wdt_device.parent = dev;

+ /*
+ * If "tmr_atboot" param is non-zero, start the watchdog right now. Also
+ * set WDOG_HW_RUNNING bit, so that watchdog core can kick the watchdog.
+ *
+ * If we're not enabling the watchdog, then ensure it is disabled if it
+ * has been left running from the bootloader or other source.
+ */
+ if (tmr_atboot) {
+ dev_info(dev, "starting watchdog timer\n");
+ s3c2410wdt_start(&wdt->wdt_device);
+ set_bit(WDOG_HW_RUNNING, &wdt->wdt_device.status);
+ } else {
+ s3c2410wdt_stop(&wdt->wdt_device);
+ }
+
ret = watchdog_register_device(&wdt->wdt_device);
if (ret)
goto err_cpufreq;
@@ -612,17 +627,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
if (ret < 0)
goto err_unregister;

- if (tmr_atboot) {
- dev_info(dev, "starting watchdog timer\n");
- s3c2410wdt_start(&wdt->wdt_device);
- } else {
- /* if we're not enabling the watchdog, then ensure it is
- * disabled if it has been left running from the bootloader
- * or other source */
-
- s3c2410wdt_stop(&wdt->wdt_device);
- }
-
platform_set_drvdata(pdev, wdt);

/* print out a statement of readiness */
--
2.30.2

2021-11-02 09:51:58

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 04/12] watchdog: s3c2410: Let kernel kick watchdog

On 31/10/2021 13:22, Sam Protsenko wrote:
> When "tmr_atboot" module param is set, the watchdog is started in
> driver's probe. In that case, also set WDOG_HW_RUNNING bit to let
> watchdog core driver know it's running. This way watchdog core can kick
> the watchdog for us (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED option is
> enabled), until user space takes control.
>
> WDOG_HW_RUNNING bit must be set before registering the watchdog. So the
> "tmr_atboot" handling code is moved before watchdog registration, to
> avoid performing the same check twice. This is also logical because
> WDOG_HW_RUNNING bit makes WDT core expect actually running watchdog.
>
> Signed-off-by: Sam Protsenko <[email protected]>
> ---
> Changes in v2:
> - Added explanation on moving the code block to commit message
> - [PATCH 03/12] handles the case when tmr_atboot is present but valid
> timeout wasn't found
>
> drivers/watchdog/s3c2410_wdt.c | 26 +++++++++++++++-----------
> 1 file changed, 15 insertions(+), 11 deletions(-)
>


Reviewed-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof

2021-11-02 10:19:14

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 11/12] watchdog: s3c2410: Remove superfluous err label

On 31/10/2021 13:22, Sam Protsenko wrote:
> 'err' label in probe function is not really need, it just returns.
> Remove it and replace all 'goto' statements with actual returns in
> place.
>
> No functional change here, just a cleanup patch.
>
> Signed-off-by: Sam Protsenko <[email protected]>
> ---
> Changes in v2:
> - (none): it's a new patch
>
> drivers/watchdog/s3c2410_wdt.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>


Reviewed-by: Krzysztof Kozlowski <[email protected]>


Best regards,
Krzysztof