New module to add NCT6692D watchdog funtionality
PATCH 1/1 New module to add NCT6692D watchdog funtionality
The new module adds in the basic functionality of the NCT6692D watchdog driver. This functionality is added to support the Lenovo SE30 device
--- drivers/watchdog/Kconfig | 12 + drivers/watchdog/Makefile | 1 + drivers/watchdog/nct6692_wdt.c | 690 +++++++++++++++++++++++++++++++++ 3 files changed, 703 insertions(+) create mode 100644 drivers/watchdog/nct6692_wdt.c
drivers/watchdog/Kconfig +12 -0
@@ -1672,6 +1672,18 @@ config SIEMENS_SIMATIC_IPC_WDT To compile this driver as a module, choose M here: the module will be called simatic-ipc-wdt. +config NCT6692_WDT + tristate "Nuvoton NCT6692D Watchdog" + depends on !PPC + depends on ACPI + select WATCHDOG_CORE + help + If you say yes here you get support for the hardware watchdog + functionality of the Nuvoton NCT6692D eSIO chip. + + This driver can also be built as a module. If so, the module + will be called nct6692_wdt. + # M68K Architecture config M54xx_WATCHDOG
drivers/watchdog/Makefile +1 -0
@@ -151,6 +151,7 @@ obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o obj-$(CONFIG_MLX_WDT) += mlx_wdt.o obj-$(CONFIG_KEEMBAY_WATCHDOG) += keembay_wdt.o obj-$(CONFIG_SIEMENS_SIMATIC_IPC_WDT) += simatic-ipc-wdt.o +obj-$(CONFIG_NCT6692D_WDT) += nct6692_wdt.o # M68K Architecture obj-$(CONFIG_M54xx_WATCHDOG) += m54xx_wdt.o
drivers/watchdog/nct6692_wdt.c new file +690 -0
690 lines not on this page · raw message
Signature · 1 line
2.34.1
Le 02/06/2023 à 18:30, David Ober a écrit :
Quoted 12 lines
The new module adds in the basic functionality of the NCT6692D watchdog driver. This functionality is added to support the Lenovo SE30 device
Signed-off-by David Ober <[email protected]>--- drivers/watchdog/Kconfig | 12 + drivers/watchdog/Makefile | 1 + drivers/watchdog/nct6692_wdt.c | 690 +++++++++++++++++++++++++++++++++ 3 files changed, 703 insertions(+)create mode 100644
drivers/watchdog/nct6692_wdt.c
[...]
drivers/watchdog/nct6692_wdt.c line 486
Quoted 11 lines
drivers/watchdog/nct6692_wdt.c new file +11
-0+static int nct6692_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct nct6692_data_t *data =NULL ; +struct nct6692_sio_data *sio_data = dev->platform_data; +struct resource *res; + +pr_info ("Probe NCT6692 called\n" ); + res =platform_get_resource (pdev,IORESOURCE_IO ,0 ); + + data =kzalloc (sizeof (struct nct6692_data_t ),GFP_KERNEL );
Is it released somewhere?
Should this be devm_kzalloc()?
drivers/watchdog/nct6692_wdt.c line 492
Quoted 6 lines
drivers/watchdog/nct6692_wdt.c new file +6
-0+if (!data) +return -ENOMEM ; + +// init value + data->shm.base_addr =0 ; + data->shm.report_addr =0 ;
Harmless, but useless (kzalloc() above)
Quoted 15 lines
drivers/watchdog/nct6692_wdt.c new file +15
-0+ + data->shm.base_phys = sio_data->base_phys; + data->shm.base_addr = (u_char *)ioremap_cache (data->shm.base_phys,256 ); + + data->shm.offset_mod =SHM_WIN_MOD_OFFSET ; + data->shm.offset_cmd =SHM_WIN_CMD_OFFSET ; + data->shm.offset_sel =SHM_WIN_SEL_OFFSET ; + data->shm.offset_ctl =SHM_WIN_CTL_OFFSET ; + data->shm.offset_id =SHM_WIN_ID_OFFSET ; + data->shm.offset_dat =SHM_WIN_DAT_OFFSET ; + +// Base for REPORT Channel + data->shm.report_phys = sio_data->report_phys; + data->shm.report_addr = (u_char *)ioremap_cache (data->shm.report_phys,256 ); +
drivers/watchdog/nct6692_wdt.c line 517
Quoted 10 lines
drivers/watchdog/nct6692_wdt.c new file +10
-0+ data->cfg.channel =NCT6692_CHANNEL_DEFAULT ; + data->cfg.mod =0x10 ; + data->cfg.cmd =0 ; + data->cfg.sel =0 ; + data->cfg.idx =0x15 ; + data->cnt.channel =NCT6692_CHANNEL_DEFAULT ; + data->cnt.mod =0x10 ; + data->cnt.cmd =0 ; + data->cnt.sel =0 ; + data->cnt.idx =0x16 ;
All these "= 0" are harmless, but useless (kzalloc() above). Maybe it makes sense to keep them.
Quoted 17 lines
drivers/watchdog/nct6692_wdt.c new file +17
-0+ + data->wdt.ops = &nct6692_wdt_ops; + data->wdt.info = &nct6692_wdt_info; + + data->wdt.timeout =WATCHDOG_TIMEOUT ;/* Set default timeout */ + data->wdt.min_timeout =MIN_TIMEOUT ; + data->wdt.max_timeout =MAX_TIMEOUT ; + data->wdt.parent = &pdev->dev; + +watchdog_init_timeout (&data->wdt, timeout, &pdev->dev); +watchdog_set_nowayout (&data->wdt, nowayout); +watchdog_set_drvdata (&data->wdt, data); + +watchdog_stop_on_unregister (&data->wdt); + +return devm_watchdog_register_device (dev, &data->wdt); +}
[...]
Quoted 15 lines
drivers/watchdog/nct6692_wdt.c new file +15
-0+static int __init nct6692_init (void ) +{ +struct nct6692_sio_data sio_data; +int sioaddr[2 ] = {0x2e ,0x4e }; +struct resource res; +int err; +int address; +bool found = false; +u_long base_phys =0 ; +u_long report_phys =0 ; + +platform_driver_register (&nct6692_driver); + +/* +* initialize sio_data->kind and sio_data->sioreg.
drivers/watchdog/nct6692_wdt.c line 624
Quoted 10 lines
drivers/watchdog/nct6692_wdt.c new file +10
-0+* +* when Super-I/O functions move to a separate file, the Super-I/O +* driver will probe 0x2e and 0x4e and auto-detect the presence of a +* nct6692 hardware monitor, and call probe() +*/ + err =nct6692_find (sioaddr[0 ], &base_phys, &report_phys); +if (err) { + err =nct6692_find (sioaddr[1 ], &base_phys, &report_phys); +if (err) +return -ENODEV ;
goto exit_unregister; ?
Quoted 5 lines
drivers/watchdog/nct6692_wdt.c new file +5
-0+ } + found = true; + sio_data.base_phys = base_phys; + sio_data.report_phys = report_phys; +
[...]