Skip to contentSkip to conversation

Add core driver for PMIC rn5t568

PATCH Superseded Juergen Borleis 2 participants 6 messages Jan 17, 2022 – Jan 18, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#3 lore raw

PATCH 2/2 Add Ricoh RN5T568 PMIC based watchdog

In reply to Juergen Borleis
---
 drivers/watchdog/Kconfig       |   6 ++
 drivers/watchdog/Makefile      |   1 +
 drivers/watchdog/rn5t568_wdt.c | 140 +++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
 create mode 100644 drivers/watchdog/rn5t568_wdt.c
drivers/watchdog/Kconfig +6 -0
index d605e62..61a096b 100644
@@ -109,6 +109,12 @@ config STPMIC1_WATCHDOG
 	help
 	  Enable to support configuration of the stpmic1's built-in watchdog.
 
+config RN568_WATCHDOG
+	bool "Ricoh RN5t568 PMIC based Watchdog"
+	depends on MFD_RN568PMIC
+	help
+	  Enable to support system control via the PMIC based watchdog.
+
 config F71808E_WDT
 	bool "Fintek F718xx, F818xx Super I/O Watchdog"
 	depends on X86
drivers/watchdog/Makefile +1 -0
index dbb76a5..84fd2bf 100644
@@ -16,6 +16,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_F71808E_WDT) += f71808e_wdt.o
 obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o
 obj-$(CONFIG_ITCO_WDT) += itco_wdt.o
drivers/watchdog/rn5t568_wdt.c new file +140 -0

140 lines not on this page · raw message

Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/2 Add the base Ricoh RN5T568 PMIC driver

---
 drivers/mfd/Kconfig   |   6 ++
 drivers/mfd/Makefile  |   1 +
 drivers/mfd/rn5t568.c | 165 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/mfd/rn5t568.c
drivers/mfd/Kconfig +6 -0
index 8468a2d..1602480 100644
@@ -68,6 +68,12 @@ config MFD_STPMIC1
 	help
 	  Select this to support communication with the STPMIC1.
 
+config MFD_RN568PMIC
+	depends on I2C
+	bool "Ricoh RN5T568 MFD driver"
+	help
+	  Select this to support communication with the Ricoh RN5T568 PMIC.
+
 config MFD_SUPERIO
 	bool
 
drivers/mfd/Makefile +1 -0
index 2bcf900..50f54cf 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_MFD_TWL4030)	+= twl4030.o
 obj-$(CONFIG_MFD_TWL6030)	+= twl6030.o
 obj-$(CONFIG_RAVE_SP_CORE)	+= rave-sp.o
 obj-$(CONFIG_MFD_STPMIC1)	+= stpmic1.o
+obj-$(CONFIG_MFD_RN568PMIC)	+= rn5t568.o
 obj-$(CONFIG_MFD_SUPERIO)	+= superio.o
 obj-$(CONFIG_FINTEK_SUPERIO)	+= fintek-superio.o
 obj-$(CONFIG_SMSC_SUPERIO)	+= smsc-superio.o
drivers/mfd/rn5t568.c new file +165 -0

165 lines not on this page · raw message

Signature · 7 lines
2.30.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [PATCH 1/2] Add the base Ricoh RN5T568 PMIC driver

Quoted 80 lines · Juergen Borleis
---
 drivers/mfd/Kconfig   |   6 ++
 drivers/mfd/Makefile  |   1 +
 drivers/mfd/rn5t568.c | 165 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+)
 create mode 100644 drivers/mfd/rn5t568.c
drivers/mfd/Kconfig +6 -0
index 8468a2d..1602480 100644
@@ -68,6 +68,12 @@ config MFD_STPMIC1
 	help
 	  Select this to support communication with the STPMIC1.
 
+config MFD_RN568PMIC
+	depends on I2C
+	bool "Ricoh RN5T568 MFD driver"
+	help
+	  Select this to support communication with the Ricoh RN5T568 PMIC.
+
 config MFD_SUPERIO
 	bool
 
drivers/mfd/Makefile +1 -0
index 2bcf900..50f54cf 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_MFD_TWL4030)	+= twl4030.o
 obj-$(CONFIG_MFD_TWL6030)	+= twl6030.o
 obj-$(CONFIG_RAVE_SP_CORE)	+= rave-sp.o
 obj-$(CONFIG_MFD_STPMIC1)	+= stpmic1.o
+obj-$(CONFIG_MFD_RN568PMIC)	+= rn5t568.o
 obj-$(CONFIG_MFD_SUPERIO)	+= superio.o
 obj-$(CONFIG_FINTEK_SUPERIO)	+= fintek-superio.o
 obj-$(CONFIG_SMSC_SUPERIO)	+= smsc-superio.o
drivers/mfd/rn5t568.c new file +38 -0
new file mode 100644
index 0000000..ad53d7b
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * MFD core driver for Ricoh RN5T618 PMIC
+ * Note: Manufacturer is now Nisshinbo Micro Devices Inc.
+ *
+ * Copyright (C) 2014 Beniamino Galvani <[email protected]>
+ * Copyright (C) 2016 Toradex AG
+ */
+
+#include <common.h>
+#include <driver.h>
+#include <errno.h>
+#include <i2c/i2c.h>
+#include <init.h>
+#include <of.h>
+#include <regmap.h>
+#include <reset_source.h>
+#include <restart.h>
+
+#define RN5T568_LSIVER 0x00
+#define RN5T568_OTPVER 0x01
+#define RN5T568_PONHIS 0x09
+# define RN5T568_PONHIS_ON_EXTINPON BIT(3)
+# define RN5T568_PONHIS_ON_REPWRPON BIT(1)
+# define RN5T568_PONHIS_ON_PWRONPON BIT(0)
+#define RN5T568_POFFHIS 0x0a
+# define RN5T568_POFFHIS_N_OEPOFF BIT(7)
+# define RN5T568_POFFHIS_DCLIMPOFF BIT(6)
+# define RN5T568_POFFHIS_WDGPOFF BIT(5)
+# define RN5T568_POFFHIS_CPUPOFF BIT(4)
+# define RN5T568_POFFHIS_IODETPOFF BIT(3)
+# define RN5T568_POFFHIS_VINDETPOFF BIT(2)
+# define RN5T568_POFFHIS_TSHUTPOFF BIT(1)
+# define RN5T568_POFFHIS_PWRONPOFF BIT(0)
+#define RN5T568_SLPCNT 0x0e
+# define RN5T568_SLPCNT_SWPPWROFF BIT(0)
+#define RN5T568_REPCNT 0x0f
+# define RN5T568_REPCNT_OFF_RESETO_16MS 0x30

drivers/mfd/rn5t568.c line 48

Quoted 10 lines
drivers/mfd/rn5t568.c new file +10 -0
+# define RN5T568_REPCNT_OFF_REPWRTIM_1000MS 0x06
+# define RN5T568_REPCNT_OFF_REPWRON BIT(0)
+#define RN5T568_MAX_REG 0xbc
+
+struct rn5t568 {
+	struct restart_handler restart;
+	struct regmap *regmap;
+};
+
+static struct rn5t568 single_pmic;

Please do not artificially limit the driver to a single instance only.

Quoted 60 lines
drivers/mfd/rn5t568.c new file +60 -0
+
+static void rn5t568_restart(struct restart_handler *rst)
+{
+	struct rn5t568 *rn5t568 = container_of(rst, struct rn5t568, restart);
+
+	regmap_write(rn5t568->regmap, RN5T568_SLPCNT, RN5T568_SLPCNT_SWPPWROFF);
+}
+
+static int rn5t568_reset_reason_detect(struct device_d *dev, struct regmap *regmap)
+{
+	unsigned int reg;
+	int ret;
+
+	ret = regmap_read(regmap, RN5T568_PONHIS, &reg);
+	if (ret)
+		return ret;
+
+	dev_dbg(dev, "Power-on history: %x\n", reg);
+
+	if (reg == 0) {
+		dev_info(dev, "No power-on reason available\n");
+		return 0;
+	}
+
+	if (reg & RN5T568_PONHIS_ON_EXTINPON) {
+		reset_source_set_device(dev, RESET_POR);
+		return 0;
+	} else if (reg & RN5T568_PONHIS_ON_PWRONPON) {
+		reset_source_set_device(dev, RESET_POR);
+		return 0;
+	} else if (!(reg & RN5T568_PONHIS_ON_REPWRPON))
+		return -EINVAL;
+
+	ret = regmap_read(regmap, RN5T568_POFFHIS, &reg);
+	if (ret)
+		return ret;
+
+	dev_dbg(dev, "Power-off history: %x\n", reg);
+
+	if (reg & RN5T568_POFFHIS_PWRONPOFF)
+		reset_source_set_device(dev, RESET_POR);
+	else if (reg & RN5T568_POFFHIS_TSHUTPOFF)
+		reset_source_set_device(dev, RESET_THERM);
+	else if (reg & RN5T568_POFFHIS_VINDETPOFF)
+		reset_source_set_device(dev, RESET_BROWNOUT);
+	else if (reg & RN5T568_POFFHIS_IODETPOFF)
+		reset_source_set_device(dev, RESET_UKWN);
+	else if (reg & RN5T568_POFFHIS_CPUPOFF)
+		reset_source_set_device(dev, RESET_RST);
+	else if (reg & RN5T568_POFFHIS_WDGPOFF)
+		reset_source_set_device(dev, RESET_WDG);
+	else if (reg & RN5T568_POFFHIS_DCLIMPOFF)
+		reset_source_set_device(dev, RESET_BROWNOUT);
+	else if (reg & RN5T568_POFFHIS_N_OEPOFF)
+		reset_source_set_device(dev, RESET_EXT);
+	else
+		return -EINVAL;
+
+	return 0;
+}

drivers/mfd/rn5t568.c line 118

Quoted 10 lines
drivers/mfd/rn5t568.c new file +10 -0
+
+static const struct regmap_config rn5t568_regmap_config = {
+	.reg_bits	= 8,
+	.val_bits	= 8,
+	.max_register	= RN5T568_MAX_REG,
+};
+
+static int __init rn5t568_i2c_probe(struct device_d *dev)
+{
+	static const unsigned int val = RN5T568_REPCNT_OFF_RESETO_16MS | RN5T568_REPCNT_OFF_REPWRTIM_1000MS | RN5T568_REPCNT_OFF_REPWRON;

val is used only once. Maybe drop the variable and use the value directly?

drivers/mfd/rn5t568.c line 119

Quoted 1 line
drivers/mfd/rn5t568.c new file +1 -0
+	unsigned char reg[4];

reg[2] should be enough. This doesn't matter much but might be a bit confusing otherwise.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

Re: [PATCH 2/2] Add Ricoh RN5T568 PMIC based watchdog

In reply to Juergen Borleis
Quoted 96 lines · Juergen Borleis
---
 drivers/watchdog/Kconfig       |   6 ++
 drivers/watchdog/Makefile      |   1 +
 drivers/watchdog/rn5t568_wdt.c | 140 +++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
 create mode 100644 drivers/watchdog/rn5t568_wdt.c
drivers/watchdog/Kconfig +6 -0
index d605e62..61a096b 100644
@@ -109,6 +109,12 @@ config STPMIC1_WATCHDOG
 	help
 	  Enable to support configuration of the stpmic1's built-in watchdog.
 
+config RN568_WATCHDOG
+	bool "Ricoh RN5t568 PMIC based Watchdog"
+	depends on MFD_RN568PMIC
+	help
+	  Enable to support system control via the PMIC based watchdog.
+
 config F71808E_WDT
 	bool "Fintek F718xx, F818xx Super I/O Watchdog"
 	depends on X86
drivers/watchdog/Makefile +1 -0
index dbb76a5..84fd2bf 100644
@@ -16,6 +16,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_F71808E_WDT) += f71808e_wdt.o
 obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o
 obj-$(CONFIG_ITCO_WDT) += itco_wdt.o
drivers/watchdog/rn5t568_wdt.c new file +54 -0
new file mode 100644
index 0000000..f6e7234
@@ -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 <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_update_bits(regmap, RN5T568_PWRIRQ, RN5T568_PWRIRQ_IR_WDOG, 0x00);
+	regmap_update_bits(regmap, RN5T568_PWRIREN, RN5T568_PWRIREN_EN_WDOG, RN5T568_PWRIREN_EN_WDOG);
+
+	pr_debug("RN5t: Starting the watchdog with %u seconds\n", rn5t568_wdt_timeout[idx].time);

drivers/watchdog/rn5t568_wdt.c line 64

Quoted 10 lines
drivers/watchdog/rn5t568_wdt.c new file +10 -0
+
+	return regmap_update_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDPWROFFEN,
+				 RN5T568_WATCHDOG_WDPWROFFEN);
+}
+
+static int rn5t568_wdt_stop(struct regmap *regmap)
+{
+	int ret;
+
+	ret  = regmap_update_bits(regmap, RN5T568_PWRIREN, RN5T568_PWRIREN_EN_WDOG, 0);

You could use regmap_[clear|set]_bits() here and elsewhere in the driver.

Quoted 17 lines
drivers/watchdog/rn5t568_wdt.c new file +17 -0
+	if (ret)
+		return ret;
+	return regmap_update_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDPWROFFEN, 0);
+}
+
+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);
+}
+

drivers/watchdog/rn5t568_wdt.c line 91

Quoted 10 lines
drivers/watchdog/rn5t568_wdt.c new file +10 -0
+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 (rn5t568_wdt_timeout[i].time + 1 >= timeout)

I don't understand the + 1 here. When I want to have a timeout of 9s the driver uses 8s instead which doesn't seem to be correct.

Quoted 25 lines
drivers/watchdog/rn5t568_wdt.c new file +25 -0
+			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_d *dev)
+{
+	struct rn5t568_wdt *wdt;
+	struct watchdog *wdd;
+
+	wdt = xzalloc(sizeof(*wdt));
+

drivers/watchdog/rn5t568_wdt.c line 126

Quoted 10 lines
drivers/watchdog/rn5t568_wdt.c new file +10 -0
+	wdt->regmap = dev_get_regmap(dev->parent, NULL);
+	if (IS_ERR(wdt->regmap))
+		return PTR_ERR(wdt->regmap);
+
+	wdd = &wdt->wdd;
+	wdd->hwdev = dev;
+	wdd->set_timeout = rn5t568_wdt_set_timeout;
+	wdd->timeout_max = PMIC_WDT_MAX_TIMEOUT;
+
+	regmap_write(wdt->regmap, RN5T568_WATCHDOG, 0x03);

Why is anything written here to the register?

It seems this clears BIT(2) which disables the watchdog, right? If so, that's not a good idea as it might be disabled on purpose by earlier boot stages.

You could read the hardware status to provide the
WDOG_HW_RUNNING/WDOG_HW_NOT_RUNNING flag.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

Re: [PATCH 2/2] Add Ricoh RN5T568 PMIC based watchdog

Hi Sascha,

Am Montag, dem 17.01.2022 um 12:46 +0100 schrieb Sascha Hauer:

Quoted 108 lines
Quoted 108 lines

---
 drivers/watchdog/Kconfig       |   6 ++ drivers/watchdog/Makefile      |   1 + drivers/watchdog/rn5t568_wdt.c | 140 +++++++++++++++++++++++++++++++++

 3 files changed, 147 insertions(+)

 create mode 100644 drivers/watchdog/rn5t568_wdt.c

drivers/watchdog/Kconfig +0 -0
index d605e62..61a096b 100644
@@ -109,6 +109,12 @@ config STPMIC1_WATCHDOG

        help
          Enable to support configuration of the stpmic1's built-in watchdog.

drivers/watchdog/Kconfig +6 -0
+config RN568_WATCHDOG
+       bool "Ricoh RN5t568 PMIC based Watchdog"
+       depends on MFD_RN568PMIC
+       help
+         Enable to support system control via the PMIC based watchdog.
+

 config F71808E_WDT
        bool "Fintek F718xx, F818xx Super I/O Watchdog" depends on X86

drivers/watchdog/Makefile +0 -0
index dbb76a5..84fd2bf 100644
@@ -16,6 +16,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_F71808E_WDT) += f71808e_wdt.o obj-$(CONFIG_GPIO_WATCHDOG) += gpio_wdt.o obj-$(CONFIG_ITCO_WDT) += itco_wdt.o

drivers/watchdog/rn5t568_wdt.c new file +46 -0
new file mode 100644
index 0000000..f6e7234
@@ -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 <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_update_bits(regmap, RN5T568_PWRIRQ, RN5T568_PWRIRQ_IR_WDOG, 0x00);
+       regmap_update_bits(regmap, RN5T568_PWRIREN, RN5T568_PWRIREN_EN_WDOG, RN5T568_PWRIREN_EN_WDOG);
+
+       pr_debug("RN5t: Starting the watchdog with %u seconds\n", rn5t568_wdt_timeout[idx].time);
+
+       return regmap_update_bits(regmap, RN5T568_WATCHDOG, RN5T568_WATCHDOG_WDPWROFFEN,
+                                RN5T568_WATCHDOG_WDPWROFFEN);

drivers/watchdog/rn5t568_wdt.c new file +3 -0
+}
+
+static int rn5t568_wdt_stop(struct regmap *regmap)
Quoted 8 lines
Quoted 5 lines
drivers/watchdog/rn5t568_wdt.c new file +4 -0
+{
+       int ret;
+
+       ret  = regmap_update_bits(regmap, RN5T568_PWRIREN,

RN5T568_PWRIREN_EN_WDOG, 0);

You could use regmap_[clear|set]_bits() here and elsewhere in the driver.

Hmmm, seems a Linux kernel feature, I didn't found such functions in barebox.

Will send a V2 soon.

jb

Signature · 11 lines
Pengutronix e.K.                       | Juergen Borleis             |
Steuerwalder Str. 21                   | https://www.pengutronix.de/ |
31137 Hildesheim, Germany              | Phone: +49-5121-206917-128  |
Amtsgericht Hildesheim, HRA 2686       | Fax:   +49-5121-206917-9    |



_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox