From d0305aac8e83caf24aaf44f1134335b405bbb075 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Thu, 23 Sep 2021 01:09:46 +0200 Subject: watchdog: db8500_wdt: Rename driver This driver is named after the ambition to support more SoCs than the DB8500. Those were never produced, so cut down the scope and rename the driver accordingly. Since the Kconfig for the watchdog defaults to y this will still be built by default. Signed-off-by: Linus Walleij Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20210922230947.1864357-2-linus.walleij@linaro.org Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck --- drivers/watchdog/Kconfig | 8 +-- drivers/watchdog/Makefile | 2 +- drivers/watchdog/db8500_wdt.c | 152 ++++++++++++++++++++++++++++++++++++++++++ drivers/watchdog/ux500_wdt.c | 152 ------------------------------------------ 4 files changed, 157 insertions(+), 157 deletions(-) create mode 100644 drivers/watchdog/db8500_wdt.c delete mode 100644 drivers/watchdog/ux500_wdt.c (limited to 'drivers/watchdog') diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 0fab8230b663..9d222ba17ec6 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -729,17 +729,17 @@ config IMX7ULP_WDT To compile this driver as a module, choose M here: the module will be called imx7ulp_wdt. -config UX500_WATCHDOG - tristate "ST-Ericsson Ux500 watchdog" +config DB500_WATCHDOG + tristate "ST-Ericsson DB800 watchdog" depends on MFD_DB8500_PRCMU select WATCHDOG_CORE default y help Say Y here to include Watchdog timer support for the watchdog - existing in the prcmu of ST-Ericsson Ux500 series platforms. + existing in the prcmu of ST-Ericsson DB8500 platform. To compile this driver as a module, choose M here: the - module will be called ux500_wdt. + module will be called db500_wdt. config RETU_WATCHDOG tristate "Retu watchdog" diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 74127ced3c23..2ee97064145b 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -68,7 +68,7 @@ obj-$(CONFIG_TS72XX_WATCHDOG) += ts72xx_wdt.o obj-$(CONFIG_IMX2_WDT) += imx2_wdt.o obj-$(CONFIG_IMX_SC_WDT) += imx_sc_wdt.o obj-$(CONFIG_IMX7ULP_WDT) += imx7ulp_wdt.o -obj-$(CONFIG_UX500_WATCHDOG) += ux500_wdt.o +obj-$(CONFIG_DB500_WATCHDOG) += db8500_wdt.o obj-$(CONFIG_RETU_WATCHDOG) += retu_wdt.o obj-$(CONFIG_BCM2835_WDT) += bcm2835_wdt.o obj-$(CONFIG_MOXART_WDT) += moxart_wdt.o diff --git a/drivers/watchdog/db8500_wdt.c b/drivers/watchdog/db8500_wdt.c new file mode 100644 index 000000000000..40f8cf1cb234 --- /dev/null +++ b/drivers/watchdog/db8500_wdt.c @@ -0,0 +1,152 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) ST-Ericsson SA 2011-2013 + * + * Author: Mathieu Poirier for ST-Ericsson + * Author: Jonas Aaberg for ST-Ericsson + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define WATCHDOG_TIMEOUT 600 /* 10 minutes */ + +#define WATCHDOG_MIN 0 +#define WATCHDOG_MAX28 268435 /* 28 bit resolution in ms == 268435.455 s */ + +static unsigned int timeout = WATCHDOG_TIMEOUT; +module_param(timeout, uint, 0); +MODULE_PARM_DESC(timeout, + "Watchdog timeout in seconds. default=" + __MODULE_STRING(WATCHDOG_TIMEOUT) "."); + +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) ")"); + +static int ux500_wdt_start(struct watchdog_device *wdd) +{ + return prcmu_enable_a9wdog(PRCMU_WDOG_ALL); +} + +static int ux500_wdt_stop(struct watchdog_device *wdd) +{ + return prcmu_disable_a9wdog(PRCMU_WDOG_ALL); +} + +static int ux500_wdt_keepalive(struct watchdog_device *wdd) +{ + return prcmu_kick_a9wdog(PRCMU_WDOG_ALL); +} + +static int ux500_wdt_set_timeout(struct watchdog_device *wdd, + unsigned int timeout) +{ + ux500_wdt_stop(wdd); + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); + ux500_wdt_start(wdd); + + return 0; +} + +static const struct watchdog_info ux500_wdt_info = { + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .identity = "Ux500 WDT", + .firmware_version = 1, +}; + +static const struct watchdog_ops ux500_wdt_ops = { + .owner = THIS_MODULE, + .start = ux500_wdt_start, + .stop = ux500_wdt_stop, + .ping = ux500_wdt_keepalive, + .set_timeout = ux500_wdt_set_timeout, +}; + +static struct watchdog_device ux500_wdt = { + .info = &ux500_wdt_info, + .ops = &ux500_wdt_ops, + .min_timeout = WATCHDOG_MIN, + .max_timeout = WATCHDOG_MAX28, +}; + +static int ux500_wdt_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + int ret; + + timeout = 600; /* Default to 10 minutes */ + ux500_wdt.parent = dev; + watchdog_set_nowayout(&ux500_wdt, nowayout); + + /* disable auto off on sleep */ + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); + + /* set HW initial value */ + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); + + ret = devm_watchdog_register_device(dev, &ux500_wdt); + if (ret) + return ret; + + dev_info(dev, "initialized\n"); + + return 0; +} + +#ifdef CONFIG_PM +static int ux500_wdt_suspend(struct platform_device *pdev, + pm_message_t state) +{ + if (watchdog_active(&ux500_wdt)) { + ux500_wdt_stop(&ux500_wdt); + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, true); + + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); + ux500_wdt_start(&ux500_wdt); + } + return 0; +} + +static int ux500_wdt_resume(struct platform_device *pdev) +{ + if (watchdog_active(&ux500_wdt)) { + ux500_wdt_stop(&ux500_wdt); + prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); + + prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); + ux500_wdt_start(&ux500_wdt); + } + return 0; +} +#else +#define ux500_wdt_suspend NULL +#define ux500_wdt_resume NULL +#endif + +static struct platform_driver ux500_wdt_driver = { + .probe = ux500_wdt_probe, + .suspend = ux500_wdt_suspend, + .resume = ux500_wdt_resume, + .driver = { + .name = "ux500_wdt", + }, +}; + +module_platform_driver(ux500_wdt_driver); + +MODULE_AUTHOR("Jonas Aaberg "); +MODULE_DESCRIPTION("Ux500 Watchdog Driver"); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:ux500_wdt"); diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c deleted file mode 100644 index 40f8cf1cb234..000000000000 --- a/drivers/watchdog/ux500_wdt.c +++ /dev/null @@ -1,152 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (C) ST-Ericsson SA 2011-2013 - * - * Author: Mathieu Poirier for ST-Ericsson - * Author: Jonas Aaberg for ST-Ericsson - */ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include - -#include - -#define WATCHDOG_TIMEOUT 600 /* 10 minutes */ - -#define WATCHDOG_MIN 0 -#define WATCHDOG_MAX28 268435 /* 28 bit resolution in ms == 268435.455 s */ - -static unsigned int timeout = WATCHDOG_TIMEOUT; -module_param(timeout, uint, 0); -MODULE_PARM_DESC(timeout, - "Watchdog timeout in seconds. default=" - __MODULE_STRING(WATCHDOG_TIMEOUT) "."); - -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) ")"); - -static int ux500_wdt_start(struct watchdog_device *wdd) -{ - return prcmu_enable_a9wdog(PRCMU_WDOG_ALL); -} - -static int ux500_wdt_stop(struct watchdog_device *wdd) -{ - return prcmu_disable_a9wdog(PRCMU_WDOG_ALL); -} - -static int ux500_wdt_keepalive(struct watchdog_device *wdd) -{ - return prcmu_kick_a9wdog(PRCMU_WDOG_ALL); -} - -static int ux500_wdt_set_timeout(struct watchdog_device *wdd, - unsigned int timeout) -{ - ux500_wdt_stop(wdd); - prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - ux500_wdt_start(wdd); - - return 0; -} - -static const struct watchdog_info ux500_wdt_info = { - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, - .identity = "Ux500 WDT", - .firmware_version = 1, -}; - -static const struct watchdog_ops ux500_wdt_ops = { - .owner = THIS_MODULE, - .start = ux500_wdt_start, - .stop = ux500_wdt_stop, - .ping = ux500_wdt_keepalive, - .set_timeout = ux500_wdt_set_timeout, -}; - -static struct watchdog_device ux500_wdt = { - .info = &ux500_wdt_info, - .ops = &ux500_wdt_ops, - .min_timeout = WATCHDOG_MIN, - .max_timeout = WATCHDOG_MAX28, -}; - -static int ux500_wdt_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - int ret; - - timeout = 600; /* Default to 10 minutes */ - ux500_wdt.parent = dev; - watchdog_set_nowayout(&ux500_wdt, nowayout); - - /* disable auto off on sleep */ - prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); - - /* set HW initial value */ - prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - - ret = devm_watchdog_register_device(dev, &ux500_wdt); - if (ret) - return ret; - - dev_info(dev, "initialized\n"); - - return 0; -} - -#ifdef CONFIG_PM -static int ux500_wdt_suspend(struct platform_device *pdev, - pm_message_t state) -{ - if (watchdog_active(&ux500_wdt)) { - ux500_wdt_stop(&ux500_wdt); - prcmu_config_a9wdog(PRCMU_WDOG_CPU1, true); - - prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - ux500_wdt_start(&ux500_wdt); - } - return 0; -} - -static int ux500_wdt_resume(struct platform_device *pdev) -{ - if (watchdog_active(&ux500_wdt)) { - ux500_wdt_stop(&ux500_wdt); - prcmu_config_a9wdog(PRCMU_WDOG_CPU1, false); - - prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - ux500_wdt_start(&ux500_wdt); - } - return 0; -} -#else -#define ux500_wdt_suspend NULL -#define ux500_wdt_resume NULL -#endif - -static struct platform_driver ux500_wdt_driver = { - .probe = ux500_wdt_probe, - .suspend = ux500_wdt_suspend, - .resume = ux500_wdt_resume, - .driver = { - .name = "ux500_wdt", - }, -}; - -module_platform_driver(ux500_wdt_driver); - -MODULE_AUTHOR("Jonas Aaberg "); -MODULE_DESCRIPTION("Ux500 Watchdog Driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:ux500_wdt"); -- cgit v1.2.3-58-ga151