* [PATCH 04/16] watchdog: remove ks8695 driver [not found] <20190809202749.742267-1-arnd@arndb.de> @ 2019-08-09 20:27 ` Arnd Bergmann 2019-08-09 20:42 ` Guenter Roeck 2019-08-09 20:27 ` [PATCH 06/16] watchdog: remove w90x900 driver Arnd Bergmann 1 sibling, 1 reply; 6+ messages in thread From: Arnd Bergmann @ 2019-08-09 20:27 UTC (permalink / raw) To: soc Cc: Arnd Bergmann, Wim Van Sebroeck, Guenter Roeck, Jonathan Corbet, linux-watchdog, linux-doc, linux-kernel The platform is getting removed, so there are no remaining users of this driver. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- .../watchdog/watchdog-parameters.rst | 9 - drivers/watchdog/Kconfig | 7 - drivers/watchdog/Makefile | 1 - drivers/watchdog/ks8695_wdt.c | 319 ------------------ 4 files changed, 336 deletions(-) delete mode 100644 drivers/watchdog/ks8695_wdt.c diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst index a3985cc5aeda..226aba56f704 100644 --- a/Documentation/watchdog/watchdog-parameters.rst +++ b/Documentation/watchdog/watchdog-parameters.rst @@ -301,15 +301,6 @@ ixp4xx_wdt: ------------------------------------------------- -ks8695_wdt: - wdt_time: - Watchdog time in seconds. (default=5) - nowayout: - Watchdog cannot be stopped once started - (default=kernel config parameter) - -------------------------------------------------- - machzwd: nowayout: Watchdog cannot be stopped once started diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 8188963a405b..e631f1ae303a 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -477,13 +477,6 @@ config IXP4XX_WATCHDOG Say N if you are unsure. -config KS8695_WATCHDOG - tristate "KS8695 watchdog" - depends on ARCH_KS8695 - help - Watchdog timer embedded into KS8695 processor. This will reboot your - system when the timeout is reached. - config HAVE_S3C2410_WATCHDOG bool help diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 7caa920e7e60..85f55ec76f8d 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -49,7 +49,6 @@ obj-$(CONFIG_21285_WATCHDOG) += wdt285.o obj-$(CONFIG_977_WATCHDOG) += wdt977.o obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o -obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c deleted file mode 100644 index 1550ce3c5702..000000000000 --- a/drivers/watchdog/ks8695_wdt.c +++ /dev/null @@ -1,319 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Watchdog driver for Kendin/Micrel KS8695. - * - * (C) 2007 Andrew Victor - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include <linux/bitops.h> -#include <linux/errno.h> -#include <linux/fs.h> -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/miscdevice.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/platform_device.h> -#include <linux/types.h> -#include <linux/watchdog.h> -#include <linux/io.h> -#include <linux/uaccess.h> -#include <mach/hardware.h> - -#define KS8695_TMR_OFFSET (0xF0000 + 0xE400) -#define KS8695_TMR_VA (KS8695_IO_VA + KS8695_TMR_OFFSET) - -/* - * Timer registers - */ -#define KS8695_TMCON (0x00) /* Timer Control Register */ -#define KS8695_T0TC (0x08) /* Timer 0 Timeout Count Register */ -#define TMCON_T0EN (1 << 0) /* Timer 0 Enable */ - -/* Timer0 Timeout Counter Register */ -#define T0TC_WATCHDOG (0xff) /* Enable watchdog mode */ - -#define WDT_DEFAULT_TIME 5 /* seconds */ -#define WDT_MAX_TIME 171 /* seconds */ - -static int wdt_time = WDT_DEFAULT_TIME; -static bool nowayout = WATCHDOG_NOWAYOUT; - -module_param(wdt_time, int, 0); -MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" - __MODULE_STRING(WDT_DEFAULT_TIME) ")"); - -#ifdef CONFIG_WATCHDOG_NOWAYOUT -module_param(nowayout, bool, 0); -MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); -#endif - - -static unsigned long ks8695wdt_busy; -static DEFINE_SPINLOCK(ks8695_lock); - -/* ......................................................................... */ - -/* - * Disable the watchdog. - */ -static inline void ks8695_wdt_stop(void) -{ - unsigned long tmcon; - - spin_lock(&ks8695_lock); - /* disable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - spin_unlock(&ks8695_lock); -} - -/* - * Enable and reset the watchdog. - */ -static inline void ks8695_wdt_start(void) -{ - unsigned long tmcon; - unsigned long tval = wdt_time * KS8695_CLOCK_RATE; - - spin_lock(&ks8695_lock); - /* disable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - - /* program timer0 */ - __raw_writel(tval | T0TC_WATCHDOG, KS8695_TMR_VA + KS8695_T0TC); - - /* re-enable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - spin_unlock(&ks8695_lock); -} - -/* - * Reload the watchdog timer. (ie, pat the watchdog) - */ -static inline void ks8695_wdt_reload(void) -{ - unsigned long tmcon; - - spin_lock(&ks8695_lock); - /* disable, then re-enable timer0 */ - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); - spin_unlock(&ks8695_lock); -} - -/* - * Change the watchdog time interval. - */ -static int ks8695_wdt_settimeout(int new_time) -{ - /* - * All counting occurs at KS8695_CLOCK_RATE / 128 = 0.256 Hz - * - * Since WDV is a 16-bit counter, the maximum period is - * 65536 / 0.256 = 256 seconds. - */ - if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) - return -EINVAL; - - /* Set new watchdog time. It will be used when - ks8695_wdt_start() is called. */ - wdt_time = new_time; - return 0; -} - -/* ......................................................................... */ - -/* - * Watchdog device is opened, and watchdog starts running. - */ -static int ks8695_wdt_open(struct inode *inode, struct file *file) -{ - if (test_and_set_bit(0, &ks8695wdt_busy)) - return -EBUSY; - - ks8695_wdt_start(); - return stream_open(inode, file); -} - -/* - * Close the watchdog device. - * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also - * disabled. - */ -static int ks8695_wdt_close(struct inode *inode, struct file *file) -{ - /* Disable the watchdog when file is closed */ - if (!nowayout) - ks8695_wdt_stop(); - clear_bit(0, &ks8695wdt_busy); - return 0; -} - -static const struct watchdog_info ks8695_wdt_info = { - .identity = "ks8695 watchdog", - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, -}; - -/* - * Handle commands from user-space. - */ -static long ks8695_wdt_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - void __user *argp = (void __user *)arg; - int __user *p = argp; - int new_value; - - switch (cmd) { - case WDIOC_GETSUPPORT: - return copy_to_user(argp, &ks8695_wdt_info, - sizeof(ks8695_wdt_info)) ? -EFAULT : 0; - case WDIOC_GETSTATUS: - case WDIOC_GETBOOTSTATUS: - return put_user(0, p); - case WDIOC_SETOPTIONS: - if (get_user(new_value, p)) - return -EFAULT; - if (new_value & WDIOS_DISABLECARD) - ks8695_wdt_stop(); - if (new_value & WDIOS_ENABLECARD) - ks8695_wdt_start(); - return 0; - case WDIOC_KEEPALIVE: - ks8695_wdt_reload(); /* pat the watchdog */ - return 0; - case WDIOC_SETTIMEOUT: - if (get_user(new_value, p)) - return -EFAULT; - if (ks8695_wdt_settimeout(new_value)) - return -EINVAL; - /* Enable new time value */ - ks8695_wdt_start(); - /* Return current value */ - return put_user(wdt_time, p); - case WDIOC_GETTIMEOUT: - return put_user(wdt_time, p); - default: - return -ENOTTY; - } -} - -/* - * Pat the watchdog whenever device is written to. - */ -static ssize_t ks8695_wdt_write(struct file *file, const char *data, - size_t len, loff_t *ppos) -{ - ks8695_wdt_reload(); /* pat the watchdog */ - return len; -} - -/* ......................................................................... */ - -static const struct file_operations ks8695wdt_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .unlocked_ioctl = ks8695_wdt_ioctl, - .open = ks8695_wdt_open, - .release = ks8695_wdt_close, - .write = ks8695_wdt_write, -}; - -static struct miscdevice ks8695wdt_miscdev = { - .minor = WATCHDOG_MINOR, - .name = "watchdog", - .fops = &ks8695wdt_fops, -}; - -static int ks8695wdt_probe(struct platform_device *pdev) -{ - int res; - - if (ks8695wdt_miscdev.parent) - return -EBUSY; - ks8695wdt_miscdev.parent = &pdev->dev; - - res = misc_register(&ks8695wdt_miscdev); - if (res) - return res; - - pr_info("KS8695 Watchdog Timer enabled (%d seconds%s)\n", - wdt_time, nowayout ? ", nowayout" : ""); - return 0; -} - -static int ks8695wdt_remove(struct platform_device *pdev) -{ - misc_deregister(&ks8695wdt_miscdev); - ks8695wdt_miscdev.parent = NULL; - - return 0; -} - -static void ks8695wdt_shutdown(struct platform_device *pdev) -{ - ks8695_wdt_stop(); -} - -#ifdef CONFIG_PM - -static int ks8695wdt_suspend(struct platform_device *pdev, pm_message_t message) -{ - ks8695_wdt_stop(); - return 0; -} - -static int ks8695wdt_resume(struct platform_device *pdev) -{ - if (ks8695wdt_busy) - ks8695_wdt_start(); - return 0; -} - -#else -#define ks8695wdt_suspend NULL -#define ks8695wdt_resume NULL -#endif - -static struct platform_driver ks8695wdt_driver = { - .probe = ks8695wdt_probe, - .remove = ks8695wdt_remove, - .shutdown = ks8695wdt_shutdown, - .suspend = ks8695wdt_suspend, - .resume = ks8695wdt_resume, - .driver = { - .name = "ks8695_wdt", - }, -}; - -static int __init ks8695_wdt_init(void) -{ - /* Check that the heartbeat value is within range; - if not reset to the default */ - if (ks8695_wdt_settimeout(wdt_time)) { - ks8695_wdt_settimeout(WDT_DEFAULT_TIME); - pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i" - ", using %d\n", wdt_time, WDT_MAX_TIME); - } - return platform_driver_register(&ks8695wdt_driver); -} - -static void __exit ks8695_wdt_exit(void) -{ - platform_driver_unregister(&ks8695wdt_driver); -} - -module_init(ks8695_wdt_init); -module_exit(ks8695_wdt_exit); - -MODULE_AUTHOR("Andrew Victor"); -MODULE_DESCRIPTION("Watchdog driver for KS8695"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:ks8695_wdt"); -- 2.20.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 04/16] watchdog: remove ks8695 driver 2019-08-09 20:27 ` [PATCH 04/16] watchdog: remove ks8695 driver Arnd Bergmann @ 2019-08-09 20:42 ` Guenter Roeck 2019-08-10 8:37 ` Arnd Bergmann 0 siblings, 1 reply; 6+ messages in thread From: Guenter Roeck @ 2019-08-09 20:42 UTC (permalink / raw) To: Arnd Bergmann Cc: soc, Wim Van Sebroeck, Jonathan Corbet, linux-watchdog, linux-doc, linux-kernel On Fri, Aug 09, 2019 at 10:27:32PM +0200, Arnd Bergmann wrote: > The platform is getting removed, so there are no remaining > users of this driver. > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Guenter Roeck <linux@roeck-us.net> Please let me know if this should be applied through the watchdog tree. For now I'll assume it will be applied together with the rest of the series. > --- > .../watchdog/watchdog-parameters.rst | 9 - > drivers/watchdog/Kconfig | 7 - > drivers/watchdog/Makefile | 1 - > drivers/watchdog/ks8695_wdt.c | 319 ------------------ > 4 files changed, 336 deletions(-) > delete mode 100644 drivers/watchdog/ks8695_wdt.c > > diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst > index a3985cc5aeda..226aba56f704 100644 > --- a/Documentation/watchdog/watchdog-parameters.rst > +++ b/Documentation/watchdog/watchdog-parameters.rst > @@ -301,15 +301,6 @@ ixp4xx_wdt: > > ------------------------------------------------- > > -ks8695_wdt: > - wdt_time: > - Watchdog time in seconds. (default=5) > - nowayout: > - Watchdog cannot be stopped once started > - (default=kernel config parameter) > - > -------------------------------------------------- > - > machzwd: > nowayout: > Watchdog cannot be stopped once started > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig > index 8188963a405b..e631f1ae303a 100644 > --- a/drivers/watchdog/Kconfig > +++ b/drivers/watchdog/Kconfig > @@ -477,13 +477,6 @@ config IXP4XX_WATCHDOG > > Say N if you are unsure. > > -config KS8695_WATCHDOG > - tristate "KS8695 watchdog" > - depends on ARCH_KS8695 > - help > - Watchdog timer embedded into KS8695 processor. This will reboot your > - system when the timeout is reached. > - > config HAVE_S3C2410_WATCHDOG > bool > help > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile > index 7caa920e7e60..85f55ec76f8d 100644 > --- a/drivers/watchdog/Makefile > +++ b/drivers/watchdog/Makefile > @@ -49,7 +49,6 @@ obj-$(CONFIG_21285_WATCHDOG) += wdt285.o > obj-$(CONFIG_977_WATCHDOG) += wdt977.o > obj-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o > obj-$(CONFIG_IXP4XX_WATCHDOG) += ixp4xx_wdt.o > -obj-$(CONFIG_KS8695_WATCHDOG) += ks8695_wdt.o > obj-$(CONFIG_S3C2410_WATCHDOG) += s3c2410_wdt.o > obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o > obj-$(CONFIG_SAMA5D4_WATCHDOG) += sama5d4_wdt.o > diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c > deleted file mode 100644 > index 1550ce3c5702..000000000000 > --- a/drivers/watchdog/ks8695_wdt.c > +++ /dev/null > @@ -1,319 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/* > - * Watchdog driver for Kendin/Micrel KS8695. > - * > - * (C) 2007 Andrew Victor > - */ > - > -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > - > -#include <linux/bitops.h> > -#include <linux/errno.h> > -#include <linux/fs.h> > -#include <linux/init.h> > -#include <linux/kernel.h> > -#include <linux/miscdevice.h> > -#include <linux/module.h> > -#include <linux/moduleparam.h> > -#include <linux/platform_device.h> > -#include <linux/types.h> > -#include <linux/watchdog.h> > -#include <linux/io.h> > -#include <linux/uaccess.h> > -#include <mach/hardware.h> > - > -#define KS8695_TMR_OFFSET (0xF0000 + 0xE400) > -#define KS8695_TMR_VA (KS8695_IO_VA + KS8695_TMR_OFFSET) > - > -/* > - * Timer registers > - */ > -#define KS8695_TMCON (0x00) /* Timer Control Register */ > -#define KS8695_T0TC (0x08) /* Timer 0 Timeout Count Register */ > -#define TMCON_T0EN (1 << 0) /* Timer 0 Enable */ > - > -/* Timer0 Timeout Counter Register */ > -#define T0TC_WATCHDOG (0xff) /* Enable watchdog mode */ > - > -#define WDT_DEFAULT_TIME 5 /* seconds */ > -#define WDT_MAX_TIME 171 /* seconds */ > - > -static int wdt_time = WDT_DEFAULT_TIME; > -static bool nowayout = WATCHDOG_NOWAYOUT; > - > -module_param(wdt_time, int, 0); > -MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default=" > - __MODULE_STRING(WDT_DEFAULT_TIME) ")"); > - > -#ifdef CONFIG_WATCHDOG_NOWAYOUT > -module_param(nowayout, bool, 0); > -MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" > - __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); > -#endif > - > - > -static unsigned long ks8695wdt_busy; > -static DEFINE_SPINLOCK(ks8695_lock); > - > -/* ......................................................................... */ > - > -/* > - * Disable the watchdog. > - */ > -static inline void ks8695_wdt_stop(void) > -{ > - unsigned long tmcon; > - > - spin_lock(&ks8695_lock); > - /* disable timer0 */ > - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); > - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); > - spin_unlock(&ks8695_lock); > -} > - > -/* > - * Enable and reset the watchdog. > - */ > -static inline void ks8695_wdt_start(void) > -{ > - unsigned long tmcon; > - unsigned long tval = wdt_time * KS8695_CLOCK_RATE; > - > - spin_lock(&ks8695_lock); > - /* disable timer0 */ > - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); > - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); > - > - /* program timer0 */ > - __raw_writel(tval | T0TC_WATCHDOG, KS8695_TMR_VA + KS8695_T0TC); > - > - /* re-enable timer0 */ > - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); > - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); > - spin_unlock(&ks8695_lock); > -} > - > -/* > - * Reload the watchdog timer. (ie, pat the watchdog) > - */ > -static inline void ks8695_wdt_reload(void) > -{ > - unsigned long tmcon; > - > - spin_lock(&ks8695_lock); > - /* disable, then re-enable timer0 */ > - tmcon = __raw_readl(KS8695_TMR_VA + KS8695_TMCON); > - __raw_writel(tmcon & ~TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); > - __raw_writel(tmcon | TMCON_T0EN, KS8695_TMR_VA + KS8695_TMCON); > - spin_unlock(&ks8695_lock); > -} > - > -/* > - * Change the watchdog time interval. > - */ > -static int ks8695_wdt_settimeout(int new_time) > -{ > - /* > - * All counting occurs at KS8695_CLOCK_RATE / 128 = 0.256 Hz > - * > - * Since WDV is a 16-bit counter, the maximum period is > - * 65536 / 0.256 = 256 seconds. > - */ > - if ((new_time <= 0) || (new_time > WDT_MAX_TIME)) > - return -EINVAL; > - > - /* Set new watchdog time. It will be used when > - ks8695_wdt_start() is called. */ > - wdt_time = new_time; > - return 0; > -} > - > -/* ......................................................................... */ > - > -/* > - * Watchdog device is opened, and watchdog starts running. > - */ > -static int ks8695_wdt_open(struct inode *inode, struct file *file) > -{ > - if (test_and_set_bit(0, &ks8695wdt_busy)) > - return -EBUSY; > - > - ks8695_wdt_start(); > - return stream_open(inode, file); > -} > - > -/* > - * Close the watchdog device. > - * If CONFIG_WATCHDOG_NOWAYOUT is NOT defined then the watchdog is also > - * disabled. > - */ > -static int ks8695_wdt_close(struct inode *inode, struct file *file) > -{ > - /* Disable the watchdog when file is closed */ > - if (!nowayout) > - ks8695_wdt_stop(); > - clear_bit(0, &ks8695wdt_busy); > - return 0; > -} > - > -static const struct watchdog_info ks8695_wdt_info = { > - .identity = "ks8695 watchdog", > - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, > -}; > - > -/* > - * Handle commands from user-space. > - */ > -static long ks8695_wdt_ioctl(struct file *file, unsigned int cmd, > - unsigned long arg) > -{ > - void __user *argp = (void __user *)arg; > - int __user *p = argp; > - int new_value; > - > - switch (cmd) { > - case WDIOC_GETSUPPORT: > - return copy_to_user(argp, &ks8695_wdt_info, > - sizeof(ks8695_wdt_info)) ? -EFAULT : 0; > - case WDIOC_GETSTATUS: > - case WDIOC_GETBOOTSTATUS: > - return put_user(0, p); > - case WDIOC_SETOPTIONS: > - if (get_user(new_value, p)) > - return -EFAULT; > - if (new_value & WDIOS_DISABLECARD) > - ks8695_wdt_stop(); > - if (new_value & WDIOS_ENABLECARD) > - ks8695_wdt_start(); > - return 0; > - case WDIOC_KEEPALIVE: > - ks8695_wdt_reload(); /* pat the watchdog */ > - return 0; > - case WDIOC_SETTIMEOUT: > - if (get_user(new_value, p)) > - return -EFAULT; > - if (ks8695_wdt_settimeout(new_value)) > - return -EINVAL; > - /* Enable new time value */ > - ks8695_wdt_start(); > - /* Return current value */ > - return put_user(wdt_time, p); > - case WDIOC_GETTIMEOUT: > - return put_user(wdt_time, p); > - default: > - return -ENOTTY; > - } > -} > - > -/* > - * Pat the watchdog whenever device is written to. > - */ > -static ssize_t ks8695_wdt_write(struct file *file, const char *data, > - size_t len, loff_t *ppos) > -{ > - ks8695_wdt_reload(); /* pat the watchdog */ > - return len; > -} > - > -/* ......................................................................... */ > - > -static const struct file_operations ks8695wdt_fops = { > - .owner = THIS_MODULE, > - .llseek = no_llseek, > - .unlocked_ioctl = ks8695_wdt_ioctl, > - .open = ks8695_wdt_open, > - .release = ks8695_wdt_close, > - .write = ks8695_wdt_write, > -}; > - > -static struct miscdevice ks8695wdt_miscdev = { > - .minor = WATCHDOG_MINOR, > - .name = "watchdog", > - .fops = &ks8695wdt_fops, > -}; > - > -static int ks8695wdt_probe(struct platform_device *pdev) > -{ > - int res; > - > - if (ks8695wdt_miscdev.parent) > - return -EBUSY; > - ks8695wdt_miscdev.parent = &pdev->dev; > - > - res = misc_register(&ks8695wdt_miscdev); > - if (res) > - return res; > - > - pr_info("KS8695 Watchdog Timer enabled (%d seconds%s)\n", > - wdt_time, nowayout ? ", nowayout" : ""); > - return 0; > -} > - > -static int ks8695wdt_remove(struct platform_device *pdev) > -{ > - misc_deregister(&ks8695wdt_miscdev); > - ks8695wdt_miscdev.parent = NULL; > - > - return 0; > -} > - > -static void ks8695wdt_shutdown(struct platform_device *pdev) > -{ > - ks8695_wdt_stop(); > -} > - > -#ifdef CONFIG_PM > - > -static int ks8695wdt_suspend(struct platform_device *pdev, pm_message_t message) > -{ > - ks8695_wdt_stop(); > - return 0; > -} > - > -static int ks8695wdt_resume(struct platform_device *pdev) > -{ > - if (ks8695wdt_busy) > - ks8695_wdt_start(); > - return 0; > -} > - > -#else > -#define ks8695wdt_suspend NULL > -#define ks8695wdt_resume NULL > -#endif > - > -static struct platform_driver ks8695wdt_driver = { > - .probe = ks8695wdt_probe, > - .remove = ks8695wdt_remove, > - .shutdown = ks8695wdt_shutdown, > - .suspend = ks8695wdt_suspend, > - .resume = ks8695wdt_resume, > - .driver = { > - .name = "ks8695_wdt", > - }, > -}; > - > -static int __init ks8695_wdt_init(void) > -{ > - /* Check that the heartbeat value is within range; > - if not reset to the default */ > - if (ks8695_wdt_settimeout(wdt_time)) { > - ks8695_wdt_settimeout(WDT_DEFAULT_TIME); > - pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i" > - ", using %d\n", wdt_time, WDT_MAX_TIME); > - } > - return platform_driver_register(&ks8695wdt_driver); > -} > - > -static void __exit ks8695_wdt_exit(void) > -{ > - platform_driver_unregister(&ks8695wdt_driver); > -} > - > -module_init(ks8695_wdt_init); > -module_exit(ks8695_wdt_exit); > - > -MODULE_AUTHOR("Andrew Victor"); > -MODULE_DESCRIPTION("Watchdog driver for KS8695"); > -MODULE_LICENSE("GPL"); > -MODULE_ALIAS("platform:ks8695_wdt"); > -- > 2.20.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 04/16] watchdog: remove ks8695 driver 2019-08-09 20:42 ` Guenter Roeck @ 2019-08-10 8:37 ` Arnd Bergmann 2019-08-10 12:56 ` Guenter Roeck 0 siblings, 1 reply; 6+ messages in thread From: Arnd Bergmann @ 2019-08-10 8:37 UTC (permalink / raw) To: Guenter Roeck Cc: soc, Wim Van Sebroeck, Jonathan Corbet, LINUXWATCHDOG, open list:DOCUMENTATION, Linux Kernel Mailing List On Fri, Aug 9, 2019 at 10:42 PM Guenter Roeck <linux@roeck-us.net> wrote: > > On Fri, Aug 09, 2019 at 10:27:32PM +0200, Arnd Bergmann wrote: > > The platform is getting removed, so there are no remaining > > users of this driver. > > > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > Acked-by: Guenter Roeck <linux@roeck-us.net> > > Please let me know if this should be applied through the watchdog tree. > For now I'll assume it will be applied together with the rest of the > series. For this series, my preference is that you apply the patches through the subsystem tree as there are no dependencies. Thanks, Arnd ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 04/16] watchdog: remove ks8695 driver 2019-08-10 8:37 ` Arnd Bergmann @ 2019-08-10 12:56 ` Guenter Roeck 0 siblings, 0 replies; 6+ messages in thread From: Guenter Roeck @ 2019-08-10 12:56 UTC (permalink / raw) To: Arnd Bergmann Cc: soc, Wim Van Sebroeck, Jonathan Corbet, LINUXWATCHDOG, open list:DOCUMENTATION, Linux Kernel Mailing List On Sat, Aug 10, 2019 at 10:37:14AM +0200, Arnd Bergmann wrote: > On Fri, Aug 9, 2019 at 10:42 PM Guenter Roeck <linux@roeck-us.net> wrote: > > > > On Fri, Aug 09, 2019 at 10:27:32PM +0200, Arnd Bergmann wrote: > > > The platform is getting removed, so there are no remaining > > > users of this driver. > > > > > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > > > Acked-by: Guenter Roeck <linux@roeck-us.net> > > > > Please let me know if this should be applied through the watchdog tree. > > For now I'll assume it will be applied together with the rest of the > > series. > > For this series, my preference is that you apply the patches through > the subsystem tree as there are no dependencies. > Ok, I added both patches to my tree. Thanks, Guenter ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 06/16] watchdog: remove w90x900 driver [not found] <20190809202749.742267-1-arnd@arndb.de> 2019-08-09 20:27 ` [PATCH 04/16] watchdog: remove ks8695 driver Arnd Bergmann @ 2019-08-09 20:27 ` Arnd Bergmann 2019-08-09 20:42 ` Guenter Roeck 1 sibling, 1 reply; 6+ messages in thread From: Arnd Bergmann @ 2019-08-09 20:27 UTC (permalink / raw) To: soc Cc: Arnd Bergmann, Wim Van Sebroeck, Guenter Roeck, Jonathan Corbet, linux-watchdog, linux-doc, linux-kernel The ARM w90x900 platform is getting removed, so this driver is obsolete Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- .../watchdog/watchdog-parameters.rst | 10 - drivers/watchdog/Kconfig | 9 - drivers/watchdog/Makefile | 1 - drivers/watchdog/nuc900_wdt.c | 302 ------------------ 4 files changed, 322 deletions(-) delete mode 100644 drivers/watchdog/nuc900_wdt.c diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst index 226aba56f704..223c99361a30 100644 --- a/Documentation/watchdog/watchdog-parameters.rst +++ b/Documentation/watchdog/watchdog-parameters.rst @@ -366,16 +366,6 @@ nic7018_wdt: ------------------------------------------------- -nuc900_wdt: - heartbeat: - Watchdog heartbeats in seconds. - (default = 15) - nowayout: - Watchdog cannot be stopped once started - (default=kernel config parameter) - -------------------------------------------------- - omap_wdt: timer_margin: initial watchdog timeout (in seconds) diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index e631f1ae303a..0e64f501ef30 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -655,15 +655,6 @@ config STMP3XXX_RTC_WATCHDOG To compile this driver as a module, choose M here: the module will be called stmp3xxx_rtc_wdt. -config NUC900_WATCHDOG - tristate "Nuvoton NUC900 watchdog" - depends on ARCH_W90X900 || COMPILE_TEST - help - Say Y here if to include support for the watchdog timer - for the Nuvoton NUC900 series SoCs. - To compile this driver as a module, choose M here: the - module will be called nuc900_wdt. - config TS4800_WATCHDOG tristate "TS-4800 Watchdog" depends on HAS_IOMEM && OF diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 85f55ec76f8d..b5a0aed537af 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -63,7 +63,6 @@ obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o obj-$(CONFIG_NPCM7XX_WATCHDOG) += npcm_wdt.o obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o -obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c deleted file mode 100644 index db124cebe838..000000000000 --- a/drivers/watchdog/nuc900_wdt.c +++ /dev/null @@ -1,302 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (c) 2009 Nuvoton technology corporation. - * - * Wan ZongShun <mcuos.com@gmail.com> - */ - -#include <linux/bitops.h> -#include <linux/errno.h> -#include <linux/fs.h> -#include <linux/io.h> -#include <linux/clk.h> -#include <linux/kernel.h> -#include <linux/miscdevice.h> -#include <linux/module.h> -#include <linux/moduleparam.h> -#include <linux/platform_device.h> -#include <linux/slab.h> -#include <linux/interrupt.h> -#include <linux/types.h> -#include <linux/watchdog.h> -#include <linux/uaccess.h> - -#define REG_WTCR 0x1c -#define WTCLK (0x01 << 10) -#define WTE (0x01 << 7) /*wdt enable*/ -#define WTIS (0x03 << 4) -#define WTIF (0x01 << 3) -#define WTRF (0x01 << 2) -#define WTRE (0x01 << 1) -#define WTR (0x01 << 0) -/* - * The watchdog time interval can be calculated via following formula: - * WTIS real time interval (formula) - * 0x00 ((2^ 14 ) * ((external crystal freq) / 256))seconds - * 0x01 ((2^ 16 ) * ((external crystal freq) / 256))seconds - * 0x02 ((2^ 18 ) * ((external crystal freq) / 256))seconds - * 0x03 ((2^ 20 ) * ((external crystal freq) / 256))seconds - * - * The external crystal freq is 15Mhz in the nuc900 evaluation board. - * So 0x00 = +-0.28 seconds, 0x01 = +-1.12 seconds, 0x02 = +-4.48 seconds, - * 0x03 = +- 16.92 seconds.. - */ -#define WDT_HW_TIMEOUT 0x02 -#define WDT_TIMEOUT (HZ/2) -#define WDT_HEARTBEAT 15 - -static int heartbeat = WDT_HEARTBEAT; -module_param(heartbeat, int, 0); -MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. " - "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")"); - -static bool nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, bool, 0); -MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " - "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); - -struct nuc900_wdt { - struct clk *wdt_clock; - struct platform_device *pdev; - void __iomem *wdt_base; - char expect_close; - struct timer_list timer; - spinlock_t wdt_lock; - unsigned long next_heartbeat; -}; - -static unsigned long nuc900wdt_busy; -static struct nuc900_wdt *nuc900_wdt; - -static inline void nuc900_wdt_keepalive(void) -{ - unsigned int val; - - spin_lock(&nuc900_wdt->wdt_lock); - - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); - val |= (WTR | WTIF); - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); - - spin_unlock(&nuc900_wdt->wdt_lock); -} - -static inline void nuc900_wdt_start(void) -{ - unsigned int val; - - spin_lock(&nuc900_wdt->wdt_lock); - - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); - val |= (WTRE | WTE | WTR | WTCLK | WTIF); - val &= ~WTIS; - val |= (WDT_HW_TIMEOUT << 0x04); - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); - - spin_unlock(&nuc900_wdt->wdt_lock); - - nuc900_wdt->next_heartbeat = jiffies + heartbeat * HZ; - mod_timer(&nuc900_wdt->timer, jiffies + WDT_TIMEOUT); -} - -static inline void nuc900_wdt_stop(void) -{ - unsigned int val; - - del_timer(&nuc900_wdt->timer); - - spin_lock(&nuc900_wdt->wdt_lock); - - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); - val &= ~WTE; - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); - - spin_unlock(&nuc900_wdt->wdt_lock); -} - -static inline void nuc900_wdt_ping(void) -{ - nuc900_wdt->next_heartbeat = jiffies + heartbeat * HZ; -} - -static int nuc900_wdt_open(struct inode *inode, struct file *file) -{ - - if (test_and_set_bit(0, &nuc900wdt_busy)) - return -EBUSY; - - nuc900_wdt_start(); - - return stream_open(inode, file); -} - -static int nuc900_wdt_close(struct inode *inode, struct file *file) -{ - if (nuc900_wdt->expect_close == 42) - nuc900_wdt_stop(); - else { - dev_crit(&nuc900_wdt->pdev->dev, - "Unexpected close, not stopping watchdog!\n"); - nuc900_wdt_ping(); - } - - nuc900_wdt->expect_close = 0; - clear_bit(0, &nuc900wdt_busy); - return 0; -} - -static const struct watchdog_info nuc900_wdt_info = { - .identity = "nuc900 watchdog", - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | - WDIOF_MAGICCLOSE, -}; - -static long nuc900_wdt_ioctl(struct file *file, - unsigned int cmd, unsigned long arg) -{ - void __user *argp = (void __user *)arg; - int __user *p = argp; - int new_value; - - switch (cmd) { - case WDIOC_GETSUPPORT: - return copy_to_user(argp, &nuc900_wdt_info, - sizeof(nuc900_wdt_info)) ? -EFAULT : 0; - case WDIOC_GETSTATUS: - case WDIOC_GETBOOTSTATUS: - return put_user(0, p); - - case WDIOC_KEEPALIVE: - nuc900_wdt_ping(); - return 0; - - case WDIOC_SETTIMEOUT: - if (get_user(new_value, p)) - return -EFAULT; - - heartbeat = new_value; - nuc900_wdt_ping(); - - return put_user(new_value, p); - case WDIOC_GETTIMEOUT: - return put_user(heartbeat, p); - default: - return -ENOTTY; - } -} - -static ssize_t nuc900_wdt_write(struct file *file, const char __user *data, - size_t len, loff_t *ppos) -{ - if (!len) - return 0; - - /* Scan for magic character */ - if (!nowayout) { - size_t i; - - nuc900_wdt->expect_close = 0; - - for (i = 0; i < len; i++) { - char c; - if (get_user(c, data + i)) - return -EFAULT; - if (c == 'V') { - nuc900_wdt->expect_close = 42; - break; - } - } - } - - nuc900_wdt_ping(); - return len; -} - -static void nuc900_wdt_timer_ping(struct timer_list *unused) -{ - if (time_before(jiffies, nuc900_wdt->next_heartbeat)) { - nuc900_wdt_keepalive(); - mod_timer(&nuc900_wdt->timer, jiffies + WDT_TIMEOUT); - } else - dev_warn(&nuc900_wdt->pdev->dev, "Will reset the machine !\n"); -} - -static const struct file_operations nuc900wdt_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .unlocked_ioctl = nuc900_wdt_ioctl, - .open = nuc900_wdt_open, - .release = nuc900_wdt_close, - .write = nuc900_wdt_write, -}; - -static struct miscdevice nuc900wdt_miscdev = { - .minor = WATCHDOG_MINOR, - .name = "watchdog", - .fops = &nuc900wdt_fops, -}; - -static int nuc900wdt_probe(struct platform_device *pdev) -{ - int ret = 0; - - nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), - GFP_KERNEL); - if (!nuc900_wdt) - return -ENOMEM; - - nuc900_wdt->pdev = pdev; - - spin_lock_init(&nuc900_wdt->wdt_lock); - - nuc900_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(nuc900_wdt->wdt_base)) - return PTR_ERR(nuc900_wdt->wdt_base); - - nuc900_wdt->wdt_clock = devm_clk_get(&pdev->dev, NULL); - if (IS_ERR(nuc900_wdt->wdt_clock)) { - dev_err(&pdev->dev, "failed to find watchdog clock source\n"); - return PTR_ERR(nuc900_wdt->wdt_clock); - } - - clk_enable(nuc900_wdt->wdt_clock); - - timer_setup(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0); - - ret = misc_register(&nuc900wdt_miscdev); - if (ret) { - dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n", - WATCHDOG_MINOR, ret); - goto err_clk; - } - - return 0; - -err_clk: - clk_disable(nuc900_wdt->wdt_clock); - return ret; -} - -static int nuc900wdt_remove(struct platform_device *pdev) -{ - misc_deregister(&nuc900wdt_miscdev); - - clk_disable(nuc900_wdt->wdt_clock); - - return 0; -} - -static struct platform_driver nuc900wdt_driver = { - .probe = nuc900wdt_probe, - .remove = nuc900wdt_remove, - .driver = { - .name = "nuc900-wdt", - }, -}; - -module_platform_driver(nuc900wdt_driver); - -MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); -MODULE_DESCRIPTION("Watchdog driver for NUC900"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:nuc900-wdt"); -- 2.20.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 06/16] watchdog: remove w90x900 driver 2019-08-09 20:27 ` [PATCH 06/16] watchdog: remove w90x900 driver Arnd Bergmann @ 2019-08-09 20:42 ` Guenter Roeck 0 siblings, 0 replies; 6+ messages in thread From: Guenter Roeck @ 2019-08-09 20:42 UTC (permalink / raw) To: Arnd Bergmann Cc: soc, Wim Van Sebroeck, Jonathan Corbet, linux-watchdog, linux-doc, linux-kernel On Fri, Aug 09, 2019 at 10:27:34PM +0200, Arnd Bergmann wrote: > The ARM w90x900 platform is getting removed, so this driver is obsolete > > Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Guenter Roeck <linux@roeck-us.net> > --- > .../watchdog/watchdog-parameters.rst | 10 - > drivers/watchdog/Kconfig | 9 - > drivers/watchdog/Makefile | 1 - > drivers/watchdog/nuc900_wdt.c | 302 ------------------ > 4 files changed, 322 deletions(-) > delete mode 100644 drivers/watchdog/nuc900_wdt.c > > diff --git a/Documentation/watchdog/watchdog-parameters.rst b/Documentation/watchdog/watchdog-parameters.rst > index 226aba56f704..223c99361a30 100644 > --- a/Documentation/watchdog/watchdog-parameters.rst > +++ b/Documentation/watchdog/watchdog-parameters.rst > @@ -366,16 +366,6 @@ nic7018_wdt: > > ------------------------------------------------- > > -nuc900_wdt: > - heartbeat: > - Watchdog heartbeats in seconds. > - (default = 15) > - nowayout: > - Watchdog cannot be stopped once started > - (default=kernel config parameter) > - > -------------------------------------------------- > - > omap_wdt: > timer_margin: > initial watchdog timeout (in seconds) > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig > index e631f1ae303a..0e64f501ef30 100644 > --- a/drivers/watchdog/Kconfig > +++ b/drivers/watchdog/Kconfig > @@ -655,15 +655,6 @@ config STMP3XXX_RTC_WATCHDOG > To compile this driver as a module, choose M here: the > module will be called stmp3xxx_rtc_wdt. > > -config NUC900_WATCHDOG > - tristate "Nuvoton NUC900 watchdog" > - depends on ARCH_W90X900 || COMPILE_TEST > - help > - Say Y here if to include support for the watchdog timer > - for the Nuvoton NUC900 series SoCs. > - To compile this driver as a module, choose M here: the > - module will be called nuc900_wdt. > - > config TS4800_WATCHDOG > tristate "TS-4800 Watchdog" > depends on HAS_IOMEM && OF > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile > index 85f55ec76f8d..b5a0aed537af 100644 > --- a/drivers/watchdog/Makefile > +++ b/drivers/watchdog/Makefile > @@ -63,7 +63,6 @@ obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o > obj-$(CONFIG_COH901327_WATCHDOG) += coh901327_wdt.o > obj-$(CONFIG_NPCM7XX_WATCHDOG) += npcm_wdt.o > obj-$(CONFIG_STMP3XXX_RTC_WATCHDOG) += stmp3xxx_rtc_wdt.o > -obj-$(CONFIG_NUC900_WATCHDOG) += nuc900_wdt.o > obj-$(CONFIG_TS4800_WATCHDOG) += ts4800_wdt.o > obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o > obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o > diff --git a/drivers/watchdog/nuc900_wdt.c b/drivers/watchdog/nuc900_wdt.c > deleted file mode 100644 > index db124cebe838..000000000000 > --- a/drivers/watchdog/nuc900_wdt.c > +++ /dev/null > @@ -1,302 +0,0 @@ > -// SPDX-License-Identifier: GPL-2.0-only > -/* > - * Copyright (c) 2009 Nuvoton technology corporation. > - * > - * Wan ZongShun <mcuos.com@gmail.com> > - */ > - > -#include <linux/bitops.h> > -#include <linux/errno.h> > -#include <linux/fs.h> > -#include <linux/io.h> > -#include <linux/clk.h> > -#include <linux/kernel.h> > -#include <linux/miscdevice.h> > -#include <linux/module.h> > -#include <linux/moduleparam.h> > -#include <linux/platform_device.h> > -#include <linux/slab.h> > -#include <linux/interrupt.h> > -#include <linux/types.h> > -#include <linux/watchdog.h> > -#include <linux/uaccess.h> > - > -#define REG_WTCR 0x1c > -#define WTCLK (0x01 << 10) > -#define WTE (0x01 << 7) /*wdt enable*/ > -#define WTIS (0x03 << 4) > -#define WTIF (0x01 << 3) > -#define WTRF (0x01 << 2) > -#define WTRE (0x01 << 1) > -#define WTR (0x01 << 0) > -/* > - * The watchdog time interval can be calculated via following formula: > - * WTIS real time interval (formula) > - * 0x00 ((2^ 14 ) * ((external crystal freq) / 256))seconds > - * 0x01 ((2^ 16 ) * ((external crystal freq) / 256))seconds > - * 0x02 ((2^ 18 ) * ((external crystal freq) / 256))seconds > - * 0x03 ((2^ 20 ) * ((external crystal freq) / 256))seconds > - * > - * The external crystal freq is 15Mhz in the nuc900 evaluation board. > - * So 0x00 = +-0.28 seconds, 0x01 = +-1.12 seconds, 0x02 = +-4.48 seconds, > - * 0x03 = +- 16.92 seconds.. > - */ > -#define WDT_HW_TIMEOUT 0x02 > -#define WDT_TIMEOUT (HZ/2) > -#define WDT_HEARTBEAT 15 > - > -static int heartbeat = WDT_HEARTBEAT; > -module_param(heartbeat, int, 0); > -MODULE_PARM_DESC(heartbeat, "Watchdog heartbeats in seconds. " > - "(default = " __MODULE_STRING(WDT_HEARTBEAT) ")"); > - > -static bool nowayout = WATCHDOG_NOWAYOUT; > -module_param(nowayout, bool, 0); > -MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " > - "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); > - > -struct nuc900_wdt { > - struct clk *wdt_clock; > - struct platform_device *pdev; > - void __iomem *wdt_base; > - char expect_close; > - struct timer_list timer; > - spinlock_t wdt_lock; > - unsigned long next_heartbeat; > -}; > - > -static unsigned long nuc900wdt_busy; > -static struct nuc900_wdt *nuc900_wdt; > - > -static inline void nuc900_wdt_keepalive(void) > -{ > - unsigned int val; > - > - spin_lock(&nuc900_wdt->wdt_lock); > - > - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); > - val |= (WTR | WTIF); > - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); > - > - spin_unlock(&nuc900_wdt->wdt_lock); > -} > - > -static inline void nuc900_wdt_start(void) > -{ > - unsigned int val; > - > - spin_lock(&nuc900_wdt->wdt_lock); > - > - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); > - val |= (WTRE | WTE | WTR | WTCLK | WTIF); > - val &= ~WTIS; > - val |= (WDT_HW_TIMEOUT << 0x04); > - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); > - > - spin_unlock(&nuc900_wdt->wdt_lock); > - > - nuc900_wdt->next_heartbeat = jiffies + heartbeat * HZ; > - mod_timer(&nuc900_wdt->timer, jiffies + WDT_TIMEOUT); > -} > - > -static inline void nuc900_wdt_stop(void) > -{ > - unsigned int val; > - > - del_timer(&nuc900_wdt->timer); > - > - spin_lock(&nuc900_wdt->wdt_lock); > - > - val = __raw_readl(nuc900_wdt->wdt_base + REG_WTCR); > - val &= ~WTE; > - __raw_writel(val, nuc900_wdt->wdt_base + REG_WTCR); > - > - spin_unlock(&nuc900_wdt->wdt_lock); > -} > - > -static inline void nuc900_wdt_ping(void) > -{ > - nuc900_wdt->next_heartbeat = jiffies + heartbeat * HZ; > -} > - > -static int nuc900_wdt_open(struct inode *inode, struct file *file) > -{ > - > - if (test_and_set_bit(0, &nuc900wdt_busy)) > - return -EBUSY; > - > - nuc900_wdt_start(); > - > - return stream_open(inode, file); > -} > - > -static int nuc900_wdt_close(struct inode *inode, struct file *file) > -{ > - if (nuc900_wdt->expect_close == 42) > - nuc900_wdt_stop(); > - else { > - dev_crit(&nuc900_wdt->pdev->dev, > - "Unexpected close, not stopping watchdog!\n"); > - nuc900_wdt_ping(); > - } > - > - nuc900_wdt->expect_close = 0; > - clear_bit(0, &nuc900wdt_busy); > - return 0; > -} > - > -static const struct watchdog_info nuc900_wdt_info = { > - .identity = "nuc900 watchdog", > - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | > - WDIOF_MAGICCLOSE, > -}; > - > -static long nuc900_wdt_ioctl(struct file *file, > - unsigned int cmd, unsigned long arg) > -{ > - void __user *argp = (void __user *)arg; > - int __user *p = argp; > - int new_value; > - > - switch (cmd) { > - case WDIOC_GETSUPPORT: > - return copy_to_user(argp, &nuc900_wdt_info, > - sizeof(nuc900_wdt_info)) ? -EFAULT : 0; > - case WDIOC_GETSTATUS: > - case WDIOC_GETBOOTSTATUS: > - return put_user(0, p); > - > - case WDIOC_KEEPALIVE: > - nuc900_wdt_ping(); > - return 0; > - > - case WDIOC_SETTIMEOUT: > - if (get_user(new_value, p)) > - return -EFAULT; > - > - heartbeat = new_value; > - nuc900_wdt_ping(); > - > - return put_user(new_value, p); > - case WDIOC_GETTIMEOUT: > - return put_user(heartbeat, p); > - default: > - return -ENOTTY; > - } > -} > - > -static ssize_t nuc900_wdt_write(struct file *file, const char __user *data, > - size_t len, loff_t *ppos) > -{ > - if (!len) > - return 0; > - > - /* Scan for magic character */ > - if (!nowayout) { > - size_t i; > - > - nuc900_wdt->expect_close = 0; > - > - for (i = 0; i < len; i++) { > - char c; > - if (get_user(c, data + i)) > - return -EFAULT; > - if (c == 'V') { > - nuc900_wdt->expect_close = 42; > - break; > - } > - } > - } > - > - nuc900_wdt_ping(); > - return len; > -} > - > -static void nuc900_wdt_timer_ping(struct timer_list *unused) > -{ > - if (time_before(jiffies, nuc900_wdt->next_heartbeat)) { > - nuc900_wdt_keepalive(); > - mod_timer(&nuc900_wdt->timer, jiffies + WDT_TIMEOUT); > - } else > - dev_warn(&nuc900_wdt->pdev->dev, "Will reset the machine !\n"); > -} > - > -static const struct file_operations nuc900wdt_fops = { > - .owner = THIS_MODULE, > - .llseek = no_llseek, > - .unlocked_ioctl = nuc900_wdt_ioctl, > - .open = nuc900_wdt_open, > - .release = nuc900_wdt_close, > - .write = nuc900_wdt_write, > -}; > - > -static struct miscdevice nuc900wdt_miscdev = { > - .minor = WATCHDOG_MINOR, > - .name = "watchdog", > - .fops = &nuc900wdt_fops, > -}; > - > -static int nuc900wdt_probe(struct platform_device *pdev) > -{ > - int ret = 0; > - > - nuc900_wdt = devm_kzalloc(&pdev->dev, sizeof(*nuc900_wdt), > - GFP_KERNEL); > - if (!nuc900_wdt) > - return -ENOMEM; > - > - nuc900_wdt->pdev = pdev; > - > - spin_lock_init(&nuc900_wdt->wdt_lock); > - > - nuc900_wdt->wdt_base = devm_platform_ioremap_resource(pdev, 0); > - if (IS_ERR(nuc900_wdt->wdt_base)) > - return PTR_ERR(nuc900_wdt->wdt_base); > - > - nuc900_wdt->wdt_clock = devm_clk_get(&pdev->dev, NULL); > - if (IS_ERR(nuc900_wdt->wdt_clock)) { > - dev_err(&pdev->dev, "failed to find watchdog clock source\n"); > - return PTR_ERR(nuc900_wdt->wdt_clock); > - } > - > - clk_enable(nuc900_wdt->wdt_clock); > - > - timer_setup(&nuc900_wdt->timer, nuc900_wdt_timer_ping, 0); > - > - ret = misc_register(&nuc900wdt_miscdev); > - if (ret) { > - dev_err(&pdev->dev, "err register miscdev on minor=%d (%d)\n", > - WATCHDOG_MINOR, ret); > - goto err_clk; > - } > - > - return 0; > - > -err_clk: > - clk_disable(nuc900_wdt->wdt_clock); > - return ret; > -} > - > -static int nuc900wdt_remove(struct platform_device *pdev) > -{ > - misc_deregister(&nuc900wdt_miscdev); > - > - clk_disable(nuc900_wdt->wdt_clock); > - > - return 0; > -} > - > -static struct platform_driver nuc900wdt_driver = { > - .probe = nuc900wdt_probe, > - .remove = nuc900wdt_remove, > - .driver = { > - .name = "nuc900-wdt", > - }, > -}; > - > -module_platform_driver(nuc900wdt_driver); > - > -MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); > -MODULE_DESCRIPTION("Watchdog driver for NUC900"); > -MODULE_LICENSE("GPL"); > -MODULE_ALIAS("platform:nuc900-wdt"); > -- > 2.20.0 > ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-08-10 12:56 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <20190809202749.742267-1-arnd@arndb.de> 2019-08-09 20:27 ` [PATCH 04/16] watchdog: remove ks8695 driver Arnd Bergmann 2019-08-09 20:42 ` Guenter Roeck 2019-08-10 8:37 ` Arnd Bergmann 2019-08-10 12:56 ` Guenter Roeck 2019-08-09 20:27 ` [PATCH 06/16] watchdog: remove w90x900 driver Arnd Bergmann 2019-08-09 20:42 ` Guenter Roeck
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).