* [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding @ 2022-07-05 0:10 Pali Rohár 2022-07-05 0:10 ` [PATCH v3 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Pali Rohár 2022-07-06 15:07 ` [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Rob Herring 0 siblings, 2 replies; 5+ messages in thread From: Pali Rohár @ 2022-07-05 0:10 UTC (permalink / raw) To: Wim Van Sebroeck, Guenter Roeck, Rob Herring Cc: linux-watchdog, devicetree, linux-kernel GPIO is optional and used for WDI logic. Signed-off-by: Pali Rohár <pali@kernel.org> --- Changes in v3: * Extend description --- Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml index ab9641e845db..a0cf9e6c371d 100644 --- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml @@ -27,6 +27,10 @@ properties: description: This is a 1-byte memory-mapped address maxItems: 1 + gpios: + description: Optional GPIO used for controlling WDI (watchdog input) when WDI bit is not mapped to memory + maxItems: 1 + required: - compatible - reg -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO 2022-07-05 0:10 [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Pali Rohár @ 2022-07-05 0:10 ` Pali Rohár 2022-07-06 15:07 ` [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Rob Herring 1 sibling, 0 replies; 5+ messages in thread From: Pali Rohár @ 2022-07-05 0:10 UTC (permalink / raw) To: Wim Van Sebroeck, Guenter Roeck, Rob Herring Cc: linux-watchdog, devicetree, linux-kernel On some boards is WDI logic of max6370 chip connected via GPIO. So extend max63xx_wdt driver to allow specifying WDI logic via GPIO. Signed-off-by: Pali Rohár <pali@kernel.org> --- Changes in v3: * Use gpiod_set_value() Changes in v2: * Usage of dev_err_probe() * Fixing assignment of wdt->ping * Remove clearing of wdt->gpio_wdi * Move YAML change to separate patch --- drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 9e1541cfae0d..4718695837f6 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -27,6 +27,7 @@ #include <linux/io.h> #include <linux/slab.h> #include <linux/property.h> +#include <linux/gpio/consumer.h> #define DEFAULT_HEARTBEAT 60 #define MAX_HEARTBEAT 60 @@ -53,6 +54,9 @@ struct max63xx_wdt { void __iomem *base; spinlock_t lock; + /* GPIOs */ + struct gpio_desc *gpio_wdi; + /* WDI and WSET bits write access routines */ void (*ping)(struct max63xx_wdt *wdt); void (*set)(struct max63xx_wdt *wdt, u8 set); @@ -158,6 +162,17 @@ static const struct watchdog_info max63xx_wdt_info = { .identity = "max63xx Watchdog", }; +static void max63xx_gpio_ping(struct max63xx_wdt *wdt) +{ + spin_lock(&wdt->lock); + + gpiod_set_value(wdt->gpio_wdi, 1); + udelay(1); + gpiod_set_value(wdt->gpio_wdi, 0); + + spin_unlock(&wdt->lock); +} + static void max63xx_mmap_ping(struct max63xx_wdt *wdt) { u8 val; @@ -225,10 +240,19 @@ static int max63xx_wdt_probe(struct platform_device *pdev) return -EINVAL; } + wdt->gpio_wdi = devm_gpiod_get(dev, NULL, GPIOD_FLAGS_BIT_DIR_OUT); + if (IS_ERR(wdt->gpio_wdi) && PTR_ERR(wdt->gpio_wdi) != -ENOENT) + return dev_err_probe(dev, PTR_ERR(wdt->gpio_wdi), + "unable to request gpio: %ld\n", + PTR_ERR(wdt->gpio_wdi)); + err = max63xx_mmap_init(pdev, wdt); if (err) return err; + if (!IS_ERR(wdt->gpio_wdi)) + wdt->ping = max63xx_gpio_ping; + platform_set_drvdata(pdev, &wdt->wdd); watchdog_set_drvdata(&wdt->wdd, wdt); -- 2.20.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding 2022-07-05 0:10 [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Pali Rohár 2022-07-05 0:10 ` [PATCH v3 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Pali Rohár @ 2022-07-06 15:07 ` Rob Herring 2022-07-07 12:27 ` Pali Rohár 1 sibling, 1 reply; 5+ messages in thread From: Rob Herring @ 2022-07-06 15:07 UTC (permalink / raw) To: Pali Rohár Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog, devicetree, linux-kernel On Tue, Jul 05, 2022 at 02:10:22AM +0200, Pali Rohár wrote: > GPIO is optional and used for WDI logic. > > Signed-off-by: Pali Rohár <pali@kernel.org> > --- > Changes in v3: > * Extend description > --- > Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > index ab9641e845db..a0cf9e6c371d 100644 > --- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > @@ -27,6 +27,10 @@ properties: > description: This is a 1-byte memory-mapped address > maxItems: 1 > > + gpios: As I said before, add a name prefix: wdi-gpios > + description: Optional GPIO used for controlling WDI (watchdog input) when WDI bit is not mapped to memory Wrap lines at 80 unless wrapping at 100 provides some benefit. yamllint is set to 110 because I don't want to fix everyone's line wrap, not because that's the standard. > + maxItems: 1 > + > required: > - compatible > - reg > -- > 2.20.1 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding 2022-07-06 15:07 ` [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Rob Herring @ 2022-07-07 12:27 ` Pali Rohár 2022-07-12 18:28 ` Rob Herring 0 siblings, 1 reply; 5+ messages in thread From: Pali Rohár @ 2022-07-07 12:27 UTC (permalink / raw) To: Rob Herring Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog, devicetree, linux-kernel, kabel On Wednesday 06 July 2022 09:07:26 Rob Herring wrote: > On Tue, Jul 05, 2022 at 02:10:22AM +0200, Pali Rohár wrote: > > GPIO is optional and used for WDI logic. > > > > Signed-off-by: Pali Rohár <pali@kernel.org> > > --- > > Changes in v3: > > * Extend description > > --- > > Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > index ab9641e845db..a0cf9e6c371d 100644 > > --- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > @@ -27,6 +27,10 @@ properties: > > description: This is a 1-byte memory-mapped address > > maxItems: 1 > > > > + gpios: > > As I said before, add a name prefix: wdi-gpios So gpio with output direction should be really named that is input? I really do not understand this kind of thinking and making every device tree description totally illogical and inconsistent with all other. > > + description: Optional GPIO used for controlling WDI (watchdog input) when WDI bit is not mapped to memory > > Wrap lines at 80 unless wrapping at 100 provides some benefit. > > yamllint is set to 110 because I don't want to fix everyone's line wrap, > not because that's the standard. > > > > + maxItems: 1 > > + > > required: > > - compatible > > - reg > > -- > > 2.20.1 > > > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding 2022-07-07 12:27 ` Pali Rohár @ 2022-07-12 18:28 ` Rob Herring 0 siblings, 0 replies; 5+ messages in thread From: Rob Herring @ 2022-07-12 18:28 UTC (permalink / raw) To: Pali Rohár Cc: Wim Van Sebroeck, Guenter Roeck, linux-watchdog, devicetree, linux-kernel, kabel On Thu, Jul 07, 2022 at 02:27:30PM +0200, Pali Rohár wrote: > On Wednesday 06 July 2022 09:07:26 Rob Herring wrote: > > On Tue, Jul 05, 2022 at 02:10:22AM +0200, Pali Rohár wrote: > > > GPIO is optional and used for WDI logic. > > > > > > Signed-off-by: Pali Rohár <pali@kernel.org> > > > --- > > > Changes in v3: > > > * Extend description > > > --- > > > Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > > index ab9641e845db..a0cf9e6c371d 100644 > > > --- a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > > +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml > > > @@ -27,6 +27,10 @@ properties: > > > description: This is a 1-byte memory-mapped address > > > maxItems: 1 > > > > > > + gpios: > > > > As I said before, add a name prefix: wdi-gpios > > So gpio with output direction should be really named that is input? Names are based on the pins they connect to, so yes. The flags cell will make it clear it is a GPIO output. > I really do not understand this kind of thinking and making every device > tree description totally illogical and inconsistent with all other. I don't understand what you mean. When there is a 2nd GPIO used for this binding, what do we call it? 'gpios' doesn't scale. > > > + description: Optional GPIO used for controlling WDI (watchdog input) when WDI bit is not mapped to memory Look at it this way, why do I have to find and read the description here to know what 'gpios' is for when instead, it can be self-describing when I look at the datasheet and the DT to see this is the GPIO connection to WDI signal. Rob ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-07-12 18:28 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-07-05 0:10 [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Pali Rohár 2022-07-05 0:10 ` [PATCH v3 2/2] watchdog: max63xx_wdt: Add support for specifying WDI logic via GPIO Pali Rohár 2022-07-06 15:07 ` [PATCH v3 1/2] dt-bindings: watchdog: max63xx: Add GPIO binding Rob Herring 2022-07-07 12:27 ` Pali Rohár 2022-07-12 18:28 ` Rob Herring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox