Re: [RESEND PATCH v4 6/6] watchdog: ahc1ec0-wdt: Add sub-device watchdog for Advantech embedded controller
On Wed, Nov 25, 2020 at 03:07:44PM +0800, Shihlun Lin wrote: > This is one of sub-device driver for Advantech embedded controller > AHC1EC0. This driver provide watchdog functionality for Advantech > related applications to restart the system. > > Signed-off-by: Shihlun Lin New watchdog drivers must use the watchdog API to register the watchdog device. > --- > drivers/watchdog/Kconfig | 8 + > drivers/watchdog/Makefile | 1 + > drivers/watchdog/ahc1ec0-wdt.c | 489 + > 3 files changed, 498 insertions(+) > create mode 100644 drivers/watchdog/ahc1ec0-wdt.c > > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig > index fd7968635e6d..82084e5af35e 100644 > --- a/drivers/watchdog/Kconfig > +++ b/drivers/watchdog/Kconfig > @@ -1634,6 +1634,14 @@ config NIC7018_WDT > To compile this driver as a module, choose M here: the module will be > called nic7018_wdt. > > +config AHC1EC0_WDT > + tristate "Advantech EC Watchdog Function" > + depends on MFD_AHC1EC0 > + help > + This is sub-device for Advantech embedded controller AHC1EC0. This > + driver provide watchdog functionality for Advantech related > + applications to restart the system. > + > # M68K Architecture > > config M54xx_WATCHDOG > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile > index 071a2e50be98..93d15eed1f7c 100644 > --- a/drivers/watchdog/Makefile > +++ b/drivers/watchdog/Makefile > @@ -145,6 +145,7 @@ obj-$(CONFIG_INTEL_MID_WATCHDOG) += intel-mid_wdt.o > obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o > obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o > obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o > +obj-$(CONFIG_AHC1EC0_WDT) += ahc1ec0-wdt.o > obj-$(CONFIG_MLX_WDT) += mlx_wdt.o > > # M68K Architecture > diff --git a/drivers/watchdog/ahc1ec0-wdt.c b/drivers/watchdog/ahc1ec0-wdt.c > new file mode 100644 > index ..3799b99f6423 > --- /dev/null > +++ b/drivers/watchdog/ahc1ec0-wdt.c > @@ -0,0 +1,489 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Watchdog Driver for Advantech controlling EC chip AHC1EC0 > + * > + * Copyright (C) 2020, Advantech Automation Corp. > + * > + * Change Log: > + * Version 1.00 <10/10/2014> Sun.Lang > + *- Initial version > + * Version 1.01 <12/30/2015> Jiangwei.Zhu > + *- Modify adv_watchdog_init function to install the driver to > + *- the support devices. > + * Version 1.02 <03/04/2016> Jiangwei.Zhu > + *- Support UNO-1372G-E3AE, TPC-1782H-433AE, APAX-5580-433AE > + * Version 1.03 <05/09/2016> Ji.Xu > + *- Support EC watchdog mini-board on UNO-3083G/3085G-D44E/D64E > + *- APAX-5580-473AE/4C3AE. > + *- Modify the timeout unit to 1 second. > + *- Modify the device name check method to fuzzy matching. > + * Version 1.04 <06/28/2017> Ji.Xu > + *- Support EC UNO-2271G-E2xAE. > + *- Support EC UNO-2271G-E02xAE. > + *- Support EC UNO-2473G-JxAE. > + *- Support proc filesystem. > + * Version 1.05 <09/20/2017> Ji.Xu > + *- Support EC UNO-2484G-633xAE. > + *- Support EC UNO-2484G-653xAE. > + *- Support EC UNO-2484G-673xAE. > + *- Support EC UNO-2484G-733xAE. > + *- Support EC UNO-2484G-753xAE. > + *- Support EC UNO-2484G-773xAE. > + * Version 1.06 <10/26/2017> Ji.Xu > + *- Support EC UNO-3283G-674AE > + *- Support EC UNO-3285G-674AE > + * Version 1.07 <11/16/2017> Zhang.Yang > + *- Support EC UNO-1372G-J021AE/J031AE > + *- Support EC UNO-2372G > + * Version 1.08 <02/02/2018> Ji.Xu > + *- Support EC TPC-B500-6??AE > + *- Support EC TPC-5???T-6??AE > + *- Support EC TPC-5???W-6??AE > + * Version 1.09 <03/20/2018> Ji.Xu > + *- Support for compiling in kernel-4.10 and below. > + * Version 1.10 <02/20/2019> Ji.Xu > + *- Support EC UNO-420 > + *- Support EC TPC-B200-???AE > + *- Support EC TPC-2???T-???AE > + *- Support EC TPC-2???W-???AE > + * Version 1.11 <08/30/2019> Yao.Kang > + * - Support 32-bit programs on 64-bit kernel > + * Version 1.12 <12/03/2019> Jianfeng.dai > + * - Support support UNO-2372G watchdog > + * Version 1.13 <04/24/2020> Yao.Kang > + * - Support support UNO-2473G > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include I don't think this large list of include files is needed. > + > +#define ADVANTECH_EC_WDT_VER"1.12" > +#define ADVANTECH_EC_WDT_DATE "04/24/2020" > + > +#define PROCFS_MAX_SIZE 128 > + > +static char adv_expect_close; > +static unsigned long advwdt_is_open; > +static unsigned
[RESEND PATCH v4 6/6] watchdog: ahc1ec0-wdt: Add sub-device watchdog for Advantech embedded controller
This is one of sub-device driver for Advantech embedded controller AHC1EC0. This driver provide watchdog functionality for Advantech related applications to restart the system. Signed-off-by: Shihlun Lin --- drivers/watchdog/Kconfig | 8 + drivers/watchdog/Makefile | 1 + drivers/watchdog/ahc1ec0-wdt.c | 489 + 3 files changed, 498 insertions(+) create mode 100644 drivers/watchdog/ahc1ec0-wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index fd7968635e6d..82084e5af35e 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1634,6 +1634,14 @@ config NIC7018_WDT To compile this driver as a module, choose M here: the module will be called nic7018_wdt. +config AHC1EC0_WDT + tristate "Advantech EC Watchdog Function" + depends on MFD_AHC1EC0 + help + This is sub-device for Advantech embedded controller AHC1EC0. This + driver provide watchdog functionality for Advantech related + applications to restart the system. + # M68K Architecture config M54xx_WATCHDOG diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 071a2e50be98..93d15eed1f7c 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -145,6 +145,7 @@ obj-$(CONFIG_INTEL_MID_WATCHDOG) += intel-mid_wdt.o obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o +obj-$(CONFIG_AHC1EC0_WDT) += ahc1ec0-wdt.o obj-$(CONFIG_MLX_WDT) += mlx_wdt.o # M68K Architecture diff --git a/drivers/watchdog/ahc1ec0-wdt.c b/drivers/watchdog/ahc1ec0-wdt.c new file mode 100644 index ..3799b99f6423 --- /dev/null +++ b/drivers/watchdog/ahc1ec0-wdt.c @@ -0,0 +1,489 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Watchdog Driver for Advantech controlling EC chip AHC1EC0 + * + * Copyright (C) 2020, Advantech Automation Corp. + * + * Change Log: + * Version 1.00 <10/10/2014> Sun.Lang + *- Initial version + * Version 1.01 <12/30/2015> Jiangwei.Zhu + *- Modify adv_watchdog_init function to install the driver to + *- the support devices. + * Version 1.02 <03/04/2016> Jiangwei.Zhu + *- Support UNO-1372G-E3AE, TPC-1782H-433AE, APAX-5580-433AE + * Version 1.03 <05/09/2016> Ji.Xu + *- Support EC watchdog mini-board on UNO-3083G/3085G-D44E/D64E + *- APAX-5580-473AE/4C3AE. + *- Modify the timeout unit to 1 second. + *- Modify the device name check method to fuzzy matching. + * Version 1.04 <06/28/2017> Ji.Xu + *- Support EC UNO-2271G-E2xAE. + *- Support EC UNO-2271G-E02xAE. + *- Support EC UNO-2473G-JxAE. + *- Support proc filesystem. + * Version 1.05 <09/20/2017> Ji.Xu + *- Support EC UNO-2484G-633xAE. + *- Support EC UNO-2484G-653xAE. + *- Support EC UNO-2484G-673xAE. + *- Support EC UNO-2484G-733xAE. + *- Support EC UNO-2484G-753xAE. + *- Support EC UNO-2484G-773xAE. + * Version 1.06 <10/26/2017> Ji.Xu + *- Support EC UNO-3283G-674AE + *- Support EC UNO-3285G-674AE + * Version 1.07 <11/16/2017> Zhang.Yang + *- Support EC UNO-1372G-J021AE/J031AE + *- Support EC UNO-2372G + * Version 1.08 <02/02/2018> Ji.Xu + *- Support EC TPC-B500-6??AE + *- Support EC TPC-5???T-6??AE + *- Support EC TPC-5???W-6??AE + * Version 1.09 <03/20/2018> Ji.Xu + *- Support for compiling in kernel-4.10 and below. + * Version 1.10 <02/20/2019> Ji.Xu + *- Support EC UNO-420 + *- Support EC TPC-B200-???AE + *- Support EC TPC-2???T-???AE + *- Support EC TPC-2???W-???AE + * Version 1.11 <08/30/2019> Yao.Kang + * - Support 32-bit programs on 64-bit kernel + * Version 1.12 <12/03/2019> Jianfeng.dai + * - Support support UNO-2372G watchdog + * Version 1.13 <04/24/2020> Yao.Kang + * - Support support UNO-2473G + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ADVANTECH_EC_WDT_VER"1.12" +#define ADVANTECH_EC_WDT_DATE "04/24/2020" + +#define PROCFS_MAX_SIZE 128 + +static char adv_expect_close; +static unsigned long advwdt_is_open; +static unsigned short timeout = 450; +static unsigned int major; +struct mutex lock_ioctl; + +struct adv_wdt_info { + unsigned char chip_name[32]; + unsigned char is_enable[8]; + unsigned long current_timeout; +}; + +static struct adv_wdt_info wdt_data = { + .chip_name = "Advantech Embedded Controller", + .is_enable = "No", + .current_timeout = 45, +}; + +static int wdt_proc_read(struct seq_file *m, void *p); + +static void