[PATCH 5/6] watchdog: RN568: rename to rn5t618
Lucas Stach <[email protected]> Thu, 11 Jun 2026 13:21:14 +0200
| Newsgroups | org.infradead.lists.barebox |
|---|---|
| Message-ID | <[email protected]> |
Align driver name with the Linux driver. Signed-off-by: Lucas Stach <[email protected]> --- drivers/watchdog/Kconfig | 4 +- drivers/watchdog/Makefile | 2 +- drivers/watchdog/rn5t568_wdt.c | 147 --------------------------------- drivers/watchdog/rn5t618_wdt.c | 140 +++++++++++++++++++++++++++++++ include/mfd/rn5t618.h | 6 ++ 5 files changed, 149 insertions(+), 150 deletions(-) delete mode 100644 drivers/watchdog/rn5t568_wdt.c create mode 100644 drivers/watchdog/rn5t618_wdt.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 97a305c164dc..14fdb7cf68f3 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -126,8 +126,8 @@ config STPMIC1_WATCHDOG help Enable to support configuration of the stpmic1's built-in watchdog. -config RN568_WATCHDOG - bool "Ricoh RN5t568 PMIC based Watchdog" +config RN5T618_WATCHDOG + bool "Ricoh RN5T618/567 PMIC based Watchdog" depends on MFD_RN5T618 help Enable to support system control via the PMIC based watchdog. diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 187ab247ddcf..c49d090f8d7c 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -17,7 +17,7 @@ obj-$(CONFIG_ARCH_BCM283X) += bcm2835_wdt.o obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o obj-$(CONFIG_STM32_IWDG_WATCHDOG) += stm32_iwdg.o obj-$(CONFIG_STPMIC1_WATCHDOG) += stpmic1_wdt.o -obj-$(CONFIG_RN568_WATCHDOG) += rn5t568_wdt.o +obj-$(CONFIG_RN5T618_WATCHDOG) += rn5t618_wdt.o obj-$(CONFIG_F71808E_WDT) += f71808e_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_ITCO_WDT) += itco_wdt.o diff --git a/drivers/watchdog/rn5t568_wdt.c b/drivers/watchdog/rn5t568_wdt.c deleted file mode 100644 index 8c3e4175f9c0..000000000000 --- a/drivers/watchdog/rn5t568_wdt.c +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Watchdog driver for Ricoh RN5T618 PMIC - * - * Copyright (C) 2014 Beniamino Galvani <[email protected]> - */ - -#include <common.h> -#include <init.h> -#include <watchdog.h> -#include <linux/regmap.h> -#include <of.h> - -#define RN5T568_WATCHDOG 0x0b -# define RN5T568_WATCHDOG_WDPWROFFEN BIT(2) -# define RN5T568_WATCHDOG_WDOGTIM_M (BIT(0) | BIT(1)) -#define RN5T568_PWRIREN 0x12 -# define RN5T568_PWRIREN_EN_WDOG BIT(6) -#define RN5T568_PWRIRQ 0x13 -# define RN5T568_PWRIRQ_IR_WDOG BIT(6) - -struct rn5t568_wdt { - struct watchdog wdd; - struct regmap *regmap; - unsigned int timeout; -}; - -struct rn5t568_wdt_tim { - u8 reg_val; - u8 time; -}; - -static const struct rn5t568_wdt_tim rn5t568_wdt_timeout[] = { - { .reg_val = 0, .time = 1, }, - { .reg_val = 1, .time = 8, }, - { .reg_val = 2, .time = 32, }, - { .reg_val = 3, .time = 128, }, -}; - -#define PMIC_WDT_MAX_TIMEOUT 128 - -static int rn5t568_wdt_start(struct regmap *regmap, int idx) -{ - int ret; - - ret = regmap_update_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDOGTIM_M, - rn5t568_wdt_timeout[idx].reg_val); - if (ret) - return ret; - - regmap_clear_bits(regmap, RN5T568_PWRIRQ, RN5T568_PWRIRQ_IR_WDOG); - regmap_set_bits(regmap, RN5T568_PWRIREN, RN5T568_PWRIREN_EN_WDOG); - - pr_debug("RN5t: Starting the watchdog with %u seconds\n", rn5t568_wdt_timeout[idx].time); - - return regmap_set_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDPWROFFEN); -} - -static int rn5t568_wdt_stop(struct regmap *regmap) -{ - int ret; - - ret = regmap_clear_bits(regmap, RN5T568_PWRIREN, RN5T568_PWRIREN_EN_WDOG); - if (ret) - return ret; - - return regmap_clear_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDPWROFFEN); -} - -static int rn5t568_wdt_ping(struct regmap *regmap) -{ - unsigned int val; - int ret; - - ret = regmap_read(regmap, RN5T568_WATCHDOG, &val); - if (ret) - return ret; - - return regmap_write(regmap, RN5T568_WATCHDOG, val); -} - -static int rn5t568_wdt_set_timeout(struct watchdog *wdd, unsigned int timeout) -{ - struct rn5t568_wdt *wdt = container_of(wdd, struct rn5t568_wdt, wdd); - int ret, i; - - if (!timeout) - return rn5t568_wdt_stop(wdt->regmap); - - for (i = 0; i < ARRAY_SIZE(rn5t568_wdt_timeout); i++) { - if (timeout < rn5t568_wdt_timeout[i].time) - break; - } - - if (i == ARRAY_SIZE(rn5t568_wdt_timeout)) - return -EINVAL; - - if (wdt->timeout == timeout) - return rn5t568_wdt_ping(wdt->regmap); - - ret = rn5t568_wdt_start(wdt->regmap, i); - if (ret) - return ret; - - wdt->timeout = rn5t568_wdt_timeout[i].time; - - return ret; -} - -static int rn5t568_wdt_probe(struct device *dev) -{ - struct rn5t568_wdt *wdt; - struct watchdog *wdd; - unsigned int val; - int ret; - - wdt = xzalloc(sizeof(*wdt)); - - wdt->regmap = dev_get_regmap(dev->parent, NULL); - if (!wdt->regmap) - return -ENOENT; - - wdd = &wdt->wdd; - wdd->hwdev = dev; - wdd->set_timeout = rn5t568_wdt_set_timeout; - wdd->timeout_max = PMIC_WDT_MAX_TIMEOUT; - - ret = regmap_read(wdt->regmap, RN5T568_WATCHDOG, &val); - if (ret == 0) - wdd->running = val & RN5T568_WATCHDOG_WDPWROFFEN ? - WDOG_HW_RUNNING : WDOG_HW_NOT_RUNNING; - - return watchdog_register(wdd); -} - -static __maybe_unused const struct of_device_id rn5t568_wdt_of_match[] = { - { .compatible = "ricoh,rn5t568-wdt" }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, rn5t568_wdt_of_match); - -static struct driver rn5t568_wdt_driver = { - .name = "rn5t568-wdt", - .probe = rn5t568_wdt_probe, - .of_compatible = DRV_OF_COMPAT(rn5t568_wdt_of_match), -}; -device_platform_driver(rn5t568_wdt_driver); diff --git a/drivers/watchdog/rn5t618_wdt.c b/drivers/watchdog/rn5t618_wdt.c new file mode 100644 index 000000000000..95089ac7c885 --- /dev/null +++ b/drivers/watchdog/rn5t618_wdt.c @@ -0,0 +1,140 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Watchdog driver for Ricoh RN5T618 PMIC + * + * Copyright (C) 2014 Beniamino Galvani <[email protected]> + */ + +#include <common.h> +#include <init.h> +#include <watchdog.h> +#include <linux/regmap.h> +#include <of.h> +#include <mfd/rn5t618.h> + +struct rn5t618_wdt { + struct watchdog wdd; + struct regmap *regmap; + unsigned int timeout; +}; + +struct rn5t618_wdt_tim { + u8 reg_val; + u8 time; +}; + +static const struct rn5t618_wdt_tim rn5t618_wdt_timeout[] = { + { .reg_val = 0, .time = 1, }, + { .reg_val = 1, .time = 8, }, + { .reg_val = 2, .time = 32, }, + { .reg_val = 3, .time = 128, }, +}; + +#define PMIC_WDT_MAX_TIMEOUT 128 + +static int rn5t618_wdt_start(struct regmap *regmap, int idx) +{ + int ret; + + ret = regmap_update_bits(regmap, RN5T618_WATCHDOG, RN5T618_WATCHDOG_WDOGTIM_M, + rn5t618_wdt_timeout[idx].reg_val); + if (ret) + return ret; + + regmap_clear_bits(regmap, RN5T618_PWRIRQ, RN5T618_PWRIRQ_IR_WDOG); + regmap_set_bits(regmap, RN5T618_PWRIREN, RN5T618_PWRIREN_EN_WDOG); + + pr_debug("RN5t: Starting the watchdog with %u seconds\n", rn5t618_wdt_timeout[idx].time); + + return regmap_set_bits(regmap, RN5T618_WATCHDOG, RN5T618_WATCHDOG_WDPWROFFEN); +} + +static int rn5t618_wdt_stop(struct regmap *regmap) +{ + int ret; + + ret = regmap_clear_bits(regmap, RN5T618_PWRIREN, RN5T618_PWRIREN_EN_WDOG); + if (ret) + return ret; + + return regmap_clear_bits(regmap, RN5T618_WATCHDOG, RN5T618_WATCHDOG_WDPWROFFEN); +} + +static int rn5t618_wdt_ping(struct regmap *regmap) +{ + unsigned int val; + int ret; + + ret = regmap_read(regmap, RN5T618_WATCHDOG, &val); + if (ret) + return ret; + + return regmap_write(regmap, RN5T618_WATCHDOG, val); +} + +static int rn5t618_wdt_set_timeout(struct watchdog *wdd, unsigned int timeout) +{ + struct rn5t618_wdt *wdt = container_of(wdd, struct rn5t618_wdt, wdd); + int ret, i; + + if (!timeout) + return rn5t618_wdt_stop(wdt->regmap); + + for (i = 0; i < ARRAY_SIZE(rn5t618_wdt_timeout); i++) { + if (timeout < rn5t618_wdt_timeout[i].time) + break; + } + + if (i == ARRAY_SIZE(rn5t618_wdt_timeout)) + return -EINVAL; + + if (wdt->timeout == timeout) + return rn5t618_wdt_ping(wdt->regmap); + + ret = rn5t618_wdt_start(wdt->regmap, i); + if (ret) + return ret; + + wdt->timeout = rn5t618_wdt_timeout[i].time; + + return ret; +} + +static int rn5t618_wdt_probe(struct device *dev) +{ + struct rn5t618_wdt *wdt; + struct watchdog *wdd; + unsigned int val; + int ret; + + wdt = xzalloc(sizeof(*wdt)); + + wdt->regmap = dev_get_regmap(dev->parent, NULL); + if (!wdt->regmap) + return -ENOENT; + + wdd = &wdt->wdd; + wdd->hwdev = dev; + wdd->set_timeout = rn5t618_wdt_set_timeout; + wdd->timeout_max = PMIC_WDT_MAX_TIMEOUT; + + ret = regmap_read(wdt->regmap, RN5T618_WATCHDOG, &val); + if (ret == 0) + wdd->running = val & RN5T618_WATCHDOG_WDPWROFFEN ? + WDOG_HW_RUNNING : WDOG_HW_NOT_RUNNING; + + return watchdog_register(wdd); +} + +static __maybe_unused const struct of_device_id rn5t618_wdt_of_match[] = { + { .compatible = "ricoh,rn5t568-wdt" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, rn5t618_wdt_of_match); + +static struct driver rn5t618_wdt_driver = { + .name = "rn5t618-wdt", + .probe = rn5t618_wdt_probe, + .of_compatible = DRV_OF_COMPAT(rn5t618_wdt_of_match), +}; +device_platform_driver(rn5t618_wdt_driver); diff --git a/include/mfd/rn5t618.h b/include/mfd/rn5t618.h index 196ae00fb5b1..0bf1417d98d3 100644 --- a/include/mfd/rn5t618.h +++ b/include/mfd/rn5t618.h @@ -131,4 +131,10 @@ enum { #define RN5T618_REPCNT_OFF_REPWRTIM_1000MS 0x06 #define RN5T618_REPCNT_OFF_REPWRON BIT(0) +#define RN5T618_WATCHDOG_WDPWROFFEN BIT(2) +#define RN5T618_WATCHDOG_WDOGTIM_M (BIT(0) | BIT(1)) + +#define RN5T618_PWRIREN_EN_WDOG BIT(6) +#define RN5T618_PWRIRQ_IR_WDOG BIT(6) + #endif -- 2.47.3