mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Borleis <jbe@pengutronix.de>
To: Sascha Hauer <sha@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 2/2] Add Ricoh RN5T568 PMIC based watchdog
Date: Tue, 18 Jan 2022 09:17:52 +0100	[thread overview]
Message-ID: <2adde69877fb4d49178b2c02fb26926b6ca3bc26.camel@pengutronix.de> (raw)
In-Reply-To: <20220117114627.GJ1121@pengutronix.de>

Hi Sascha,

Am Montag, dem 17.01.2022 um 12:46 +0100 schrieb Sascha Hauer:
> > ---
> >  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
> > 
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index d605e62..61a096b 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -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
> > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> > index dbb76a5..84fd2bf 100644
> > --- a/drivers/watchdog/Makefile
> > +++ b/drivers/watchdog/Makefile
> > @@ -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
> > diff --git a/drivers/watchdog/rn5t568_wdt.c b/drivers/watchdog/rn5t568_wdt.c
> > new file mode 100644
> > index 0000000..f6e7234
> > --- /dev/null
> > +++ b/drivers/watchdog/rn5t568_wdt.c
> > @@ -0,0 +1,140 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Watchdog driver for Ricoh RN5T618 PMIC
> > + *
> > + * Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.com>
> > + */
> > +
> > +#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);
> > +}
> > +
> > +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.

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

Will send a V2 soon.

jb

-- 
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2022-01-18  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  8:59 Add core driver for PMIC rn5t568 Juergen Borleis
2022-01-17  8:59 ` [PATCH 1/2] Add the base Ricoh RN5T568 PMIC driver Juergen Borleis
2022-01-17 10:23   ` Sascha Hauer
2022-01-17  8:59 ` [PATCH 2/2] Add Ricoh RN5T568 PMIC based watchdog Juergen Borleis
2022-01-17 11:46   ` Sascha Hauer
2022-01-18  8:17     ` Juergen Borleis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2adde69877fb4d49178b2c02fb26926b6ca3bc26.camel@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox