Skip to contentSkip to conversation

watchdog: add in watchdog for nct6686

PATCH Superseded David Ober 2 participants 2 messages Sep 7, 2023 – Sep 8, 2023 Watchdog device drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

David Ober

author
#0 lore raw

PATCH 1/1 watchdog: add in watchdog for nct6686

This change adds in the watchdog timer support for the nct6686 chip so that it can be used on the Lenovo m90n IOT device

---
 drivers/watchdog/Kconfig       |  11 +
 drivers/watchdog/Makefile      |   1 +
 drivers/watchdog/nct6686_wdt.c | 492 +++++++++++++++++++++++++++++++++
 3 files changed, 504 insertions(+)
 create mode 100644 drivers/watchdog/nct6686_wdt.c
drivers/watchdog/Kconfig +11 -0
index 751458959411..64494f13e864 100644
@@ -341,6 +341,17 @@ config RAVE_SP_WATCHDOG
 	help
 	  Support for the watchdog on RAVE SP device.
 
+config NCT6686_WDT
+	tristate "NCT6686 Watchdog Timer"
+	depends on I2C
+	select WATCHDOG_CORE
+	help
+	  Watchdog driver for the Nuvoton 6686 Watchdog
+	  Processor.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called nct6686_wdt.
+
 config MLX_WDT
 	tristate "Mellanox Watchdog"
 	depends on MELLANOX_PLATFORM || COMPILE_TEST
drivers/watchdog/Makefile +1 -0
index 7eab9de311cb..6bcaedd5fc87 100644
@@ -150,6 +150,7 @@ obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o
 obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o
 obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o
 obj-$(CONFIG_MLX_WDT) += mlx_wdt.o
+obj-$(CONFIG_NCT6686_WDT) += nct6686_wdt.o
 obj-$(CONFIG_KEEMBAY_WATCHDOG) += keembay_wdt.o
 obj-$(CONFIG_SIEMENS_SIMATIC_IPC_WDT) += simatic-ipc-wdt.o
 
drivers/watchdog/nct6686_wdt.c new file +492 -0

492 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw
kernel test robot noticed the following build warnings:

Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v6.5 next-20230908]
[cannot apply to groeck-staging/hwmon-next]
[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/David-Ober/watchdog-add-in-watchdog-for-nct6686/20230907-235048
base:   linus/master
patch link:    https://lore.kernel.org/r/20230907113517.31147-1-dober6023%40gmail.com
patch subject: [PATCH] watchdog: add in watchdog for nct6686
config: powerpc64-allyesconfig (https://download.01.org/0day-ci/archive/20230908/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230908/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/watchdog/nct6686_wdt.c:352:3: warning: variable 'wdt' is uninitialized when used here [-Wuninitialized]
     352 |                 wdt->timeout, nowayout);
         |                 ^~~
   include/linux/dev_printk.h:155:39: note: expanded from macro 'dev_dbg'
     155 |         dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                              ^~~~~~~~~~~
   include/linux/dynamic_debug.h:274:19: note: expanded from macro 'dynamic_dev_dbg'
     274 |                            dev, fmt, ##__VA_ARGS__)
         |                                        ^~~~~~~~~~~
   include/linux/dynamic_debug.h:250:59: note: expanded from macro '_dynamic_func_call'
     250 |         _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__)
         |                                                                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:248:65: note: expanded from macro '_dynamic_func_call_cls'
     248 |         __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__)
         |                                                                        ^~~~~~~~~~~
   include/linux/dynamic_debug.h:224:15: note: expanded from macro '__dynamic_func_call_cls'
     224 |                 func(&id, ##__VA_ARGS__);                       \
         |                             ^~~~~~~~~~~
   drivers/watchdog/nct6686_wdt.c:309:29: note: initialize the variable 'wdt' to silence this warning
     309 |         struct watchdog_device *wdt;
         |                                    ^
         |                                     = NULL

1 warning generated.

vim +/wdt +352 drivers/watchdog/nct6686_wdt.c

305
306 static int nct6686_probe(struct platform_device *pdev)
307 {
308 struct device *dev = &pdev->dev;
309 struct watchdog_device *wdt;
310 struct resource *res;
311 struct nct6686_data *data;
312 struct nct6686_sio_data *sio_data = dev->platform_data;
313 int ret;
314 u_char reg;
315
316 dev_dbg(&pdev->dev, "Probe NCT6686 called\n");
317 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
318 if (!devm_request_region(dev, res->start, IOREGION_LENGTH, DRVNAME))
319 return -EBUSY;
320
321 data = devm_kzalloc(dev, sizeof(struct nct6686_data), GFP_KERNEL);
322 if (!data)
323 return -ENOMEM;
324
325 data->sio_data.sioreg = sio_data->sioreg;
326 data->addr = res->start;
327 mutex_init(&data->update_lock);
328 platform_set_drvdata(pdev, data);
329
330 /* Watchdog initialization */
331 data->wdt.ops = &nct6686_wdt_ops;
332 data->wdt.info = &nct6686_wdt_info;
333
334 data->wdt.timeout = WATCHDOG_TIMEOUT; /* Set default timeout */
335 data->wdt.min_timeout = MIN_TIMEOUT;
336 data->wdt.max_timeout = MAX_TIMEOUT;
337 data->wdt.parent = &pdev->dev;
338
339 watchdog_init_timeout(&data->wdt, timeout, &pdev->dev);
340 watchdog_set_nowayout(&data->wdt, nowayout);
341 watchdog_set_drvdata(&data->wdt, data);
342
343 /* reset trigger status */
344 reg = nct6686_read(data, WDT_STS);
345 nct6686_write(data, WDT_STS, reg & ~WDT_STS_EVT_MSK);
346
347 watchdog_stop_on_unregister(&data->wdt);
348
349 ret = devm_watchdog_register_device(dev, &data->wdt);
350
351 dev_dbg(&pdev->dev, "initialized. timeout=%d sec (nowayout=%d)\n",

 > 352			wdt->timeout, nowayout);

353
354 return ret;
355 }
356

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