[PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset

Herve Codina (Schneider Electric) posted 5 patches 4 weeks ago
There is a newer version of this series
[PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset
Posted by Herve Codina (Schneider Electric) 4 weeks ago
The watchdog timeout is signaled using an interrupt and, on this
interrupt, a software initiated reset is performed.

The watchdog is able to control directly the hardware reset without
any operation done by the interrupt handler. This feature allows the
watchdog to not depend on the software to reset the system when the
watchdog timeout occurs.

The 'renesas,reset-line' device-tree property has been recently
introduced in order to describe the hardware reset line used by the
watchdog on its timeout.

Handle this property in the driver and add support for the related
direct hardware reset.

Signed-off-by: Herve Codina (Schneider Electric) <herve.codina@bootlin.com>
---
 drivers/watchdog/rzn1_wdt.c | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/watchdog/rzn1_wdt.c b/drivers/watchdog/rzn1_wdt.c
index 98978b5cc5b4..bf623ea31be1 100644
--- a/drivers/watchdog/rzn1_wdt.c
+++ b/drivers/watchdog/rzn1_wdt.c
@@ -17,7 +17,9 @@
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
+#include <linux/soc/renesas/r9a06g032-sysctrl.h>
 #include <linux/watchdog.h>
+#include <dt-bindings/watchdog/renesas,rzn1-wdt.h>
 
 #define DEFAULT_TIMEOUT		60
 
@@ -98,6 +100,41 @@ static const struct watchdog_ops rzn1_wdt_ops = {
 	.ping = rzn1_wdt_ping,
 };
 
+static int rzn1_wdt_setup_rst_line(struct device *dev)
+{
+	enum r9a06g032_sysctrl_rst_src rst_src;
+	u32 reset_line;
+	int ret;
+
+	ret = of_property_read_u32(dev->of_node, "renesas,reset-line", &reset_line);
+	if (ret) {
+		if (ret == -EINVAL)
+			return 0; /* Property not present -> Ok, nothing to do */
+
+		return dev_err_probe(dev, ret, "Read 'renesas,reset-line' failed\n");
+	}
+
+	switch (reset_line) {
+	case RZN1_WDT_A7_0:
+		rst_src = R9A06G032_RST_WATCHDOG_CA7_0;
+		break;
+	case RZN1_WDT_A7_1:
+		rst_src = R9A06G032_RST_WATCHDOG_CA7_1;
+		break;
+
+	default:
+		return dev_err_probe(dev, -EINVAL,
+				     "Invalid 'renesas,reset-line' (%u)\n",
+				     reset_line);
+	}
+
+	ret = r9a06g032_sysctrl_enable_rst(rst_src);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to enable reset\n");
+
+	return 0;
+}
+
 static int rzn1_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
@@ -116,6 +153,10 @@ static int rzn1_wdt_probe(struct platform_device *pdev)
 	if (IS_ERR(wdt->base))
 		return PTR_ERR(wdt->base);
 
+	ret = rzn1_wdt_setup_rst_line(dev);
+	if (ret)
+		return ret;
+
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;
-- 
2.53.0
Re: [PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset
Posted by kernel test robot 3 weeks, 6 days ago
Hi Herve,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on geert-renesas-drivers/renesas-clk geert-renesas-devel/next groeck-staging/hwmon-next linus/master v7.0-rc3 next-20260310]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herve-Codina-Schneider-Electric/watchdog-rzn1-Fix-reverse-xmas-tree-declaration/20260311-015157
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20260310173249.161354-6-herve.codina%40bootlin.com
patch subject: [PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset
config: x86_64-buildonly-randconfig-003-20260311 (https://download.01.org/0day-ci/archive/20260311/202603111437.eGpzXcOB-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260311/202603111437.eGpzXcOB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603111437.eGpzXcOB-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from drivers/watchdog/rzn1_wdt.c:20:
>> include/linux/soc/renesas/r9a06g032-sysctrl.h:17:53: warning: declaration of 'enum r9a06g032_sysctrl_rst_src' will not be visible outside of this function [-Wvisibility]
      17 | static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
         |                                                     ^
>> include/linux/soc/renesas/r9a06g032-sysctrl.h:17:79: error: variable has incomplete type 'enum r9a06g032_sysctrl_rst_src'
      17 | static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
         |                                                                               ^
   include/linux/soc/renesas/r9a06g032-sysctrl.h:17:53: note: forward declaration of 'enum r9a06g032_sysctrl_rst_src'
      17 | static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
         |                                                     ^
>> drivers/watchdog/rzn1_wdt.c:105:33: error: variable has incomplete type 'enum r9a06g032_sysctrl_rst_src'
     105 |         enum r9a06g032_sysctrl_rst_src rst_src;
         |                                        ^
   drivers/watchdog/rzn1_wdt.c:105:7: note: forward declaration of 'enum r9a06g032_sysctrl_rst_src'
     105 |         enum r9a06g032_sysctrl_rst_src rst_src;
         |              ^
>> drivers/watchdog/rzn1_wdt.c:119:13: error: use of undeclared identifier 'R9A06G032_RST_WATCHDOG_CA7_0'
     119 |                 rst_src = R9A06G032_RST_WATCHDOG_CA7_0;
         |                           ^
>> drivers/watchdog/rzn1_wdt.c:122:13: error: use of undeclared identifier 'R9A06G032_RST_WATCHDOG_CA7_1'
     122 |                 rst_src = R9A06G032_RST_WATCHDOG_CA7_1;
         |                           ^
   1 warning and 4 errors generated.


vim +17 include/linux/soc/renesas/r9a06g032-sysctrl.h

21c34edbcc67b0 Herve Codina (Schneider Electric  2026-03-10  14) 
885525c1e7e27e Miquel Raynal                     2022-04-27  15  #else
885525c1e7e27e Miquel Raynal                     2022-04-27  16  static inline int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
21c34edbcc67b0 Herve Codina (Schneider Electric  2026-03-10 @17) static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
21c34edbcc67b0 Herve Codina (Schneider Electric  2026-03-10  18) {
21c34edbcc67b0 Herve Codina (Schneider Electric  2026-03-10  19) 	return -ENODEV;
21c34edbcc67b0 Herve Codina (Schneider Electric  2026-03-10  20) }
885525c1e7e27e Miquel Raynal                     2022-04-27  21  #endif
885525c1e7e27e Miquel Raynal                     2022-04-27  22  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset
Posted by kernel test robot 4 weeks ago
Hi Herve,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on geert-renesas-drivers/renesas-clk geert-renesas-devel/next groeck-staging/hwmon-next linus/master v7.0-rc3 next-20260310]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Herve-Codina-Schneider-Electric/watchdog-rzn1-Fix-reverse-xmas-tree-declaration/20260311-015157
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20260310173249.161354-6-herve.codina%40bootlin.com
patch subject: [PATCH 5/5] watchdog: rzn1: Add support for direct hardware reset
config: arm-randconfig-002-20260311 (https://download.01.org/0day-ci/archive/20260311/202603111012.xhKbu8oc-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260311/202603111012.xhKbu8oc-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603111012.xhKbu8oc-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from drivers/watchdog/rzn1_wdt.c:20:
>> include/linux/soc/renesas/r9a06g032-sysctrl.h:17:53: warning: 'enum r9a06g032_sysctrl_rst_src' declared inside parameter list will not be visible outside of this definition or declaration
    static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/soc/renesas/r9a06g032-sysctrl.h:17:79: error: parameter 1 ('rst_src') has incomplete type
    static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
>> include/linux/soc/renesas/r9a06g032-sysctrl.h:17:19: error: function declaration isn't a prototype [-Werror=strict-prototypes]
    static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/watchdog/rzn1_wdt.c: In function 'rzn1_wdt_setup_rst_line':
>> drivers/watchdog/rzn1_wdt.c:105:33: error: storage size of 'rst_src' isn't known
     enum r9a06g032_sysctrl_rst_src rst_src;
                                    ^~~~~~~
>> drivers/watchdog/rzn1_wdt.c:119:13: error: 'R9A06G032_RST_WATCHDOG_CA7_0' undeclared (first use in this function)
      rst_src = R9A06G032_RST_WATCHDOG_CA7_0;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/watchdog/rzn1_wdt.c:119:13: note: each undeclared identifier is reported only once for each function it appears in
>> drivers/watchdog/rzn1_wdt.c:122:13: error: 'R9A06G032_RST_WATCHDOG_CA7_1' undeclared (first use in this function)
      rst_src = R9A06G032_RST_WATCHDOG_CA7_1;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/watchdog/rzn1_wdt.c:105:33: warning: unused variable 'rst_src' [-Wunused-variable]
     enum r9a06g032_sysctrl_rst_src rst_src;
                                    ^~~~~~~
   cc1: some warnings being treated as errors


vim +17 include/linux/soc/renesas/r9a06g032-sysctrl.h

21c34edbcc67b03 Herve Codina (Schneider Electric  2026-03-10  14) 
885525c1e7e27ea Miquel Raynal                     2022-04-27  15  #else
885525c1e7e27ea Miquel Raynal                     2022-04-27  16  static inline int r9a06g032_sysctrl_set_dmamux(u32 mask, u32 val) { return -ENODEV; }
21c34edbcc67b03 Herve Codina (Schneider Electric  2026-03-10 @17) static inline int r9a06g032_sysctrl_enable_rst(enum r9a06g032_sysctrl_rst_src rst_src)
21c34edbcc67b03 Herve Codina (Schneider Electric  2026-03-10  18) {
21c34edbcc67b03 Herve Codina (Schneider Electric  2026-03-10  19) 	return -ENODEV;
21c34edbcc67b03 Herve Codina (Schneider Electric  2026-03-10  20) }
885525c1e7e27ea Miquel Raynal                     2022-04-27  21  #endif
885525c1e7e27ea Miquel Raynal                     2022-04-27  22  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki