linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings
@ 2021-07-14 15:33 Linus Walleij
  2021-07-14 15:33 ` [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Linus Walleij @ 2021-07-14 15:33 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, Linus Walleij, devicetree, Marc Zyngier

This adds devicetree bindings for the Maxim MAX63xx watchdog
timers.

Cc: devicetree@vger.kernel.org
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 .../bindings/watchdog/maxim,max63xx.yaml      | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml

diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
new file mode 100644
index 000000000000..f2105eedac2c
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/watchdog/maxim,max63xx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Maxim 63xx Watchdog Timers
+
+allOf:
+  - $ref: "watchdog.yaml#"
+
+maintainers:
+  - Marc Zyngier <maz@kernel.org>
+  - Linus Walleij <linus.walleij@linaro.org>
+
+properties:
+  compatible:
+    oneOf:
+      - const: maxim,max6369
+      - const: maxim,max6370
+      - const: maxim,max6371
+      - const: maxim,max6372
+      - const: maxim,max6373
+      - const: maxim,max6374
+
+  reg:
+    description: This is a 1-byte memory-mapped address
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    wdt: watchdog@50000000 {
+        compatible = "maxim,max6369";
+        reg = <0x50000000 0x1>;
+        timeout-sec = <10>;
+    };
+
+...
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing
  2021-07-14 15:33 [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Linus Walleij
@ 2021-07-14 15:33 ` Linus Walleij
  2021-07-17 14:08   ` Guenter Roeck
  2021-07-16 19:27 ` [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Rob Herring
  2021-07-17 14:08 ` Guenter Roeck
  2 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2021-07-14 15:33 UTC (permalink / raw)
  To: Wim Van Sebroeck, Guenter Roeck
  Cc: linux-watchdog, Linus Walleij, Marc Zyngier

This adds device tree probing to the MAX63xx driver so it can be
instantiated from the device tree. We use the generic fwnode-based
method to get to the match data and clean up by constifying the
functions as the match is indeed a const.

Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
index 3a899628a834..9e1541cfae0d 100644
--- a/drivers/watchdog/max63xx_wdt.c
+++ b/drivers/watchdog/max63xx_wdt.c
@@ -26,6 +26,7 @@
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/slab.h>
+#include <linux/property.h>
 
 #define DEFAULT_HEARTBEAT 60
 #define MAX_HEARTBEAT     60
@@ -99,8 +100,8 @@ static const struct max63xx_timeout max6373_table[] = {
 	{ },
 };
 
-static struct max63xx_timeout *
-max63xx_select_timeout(struct max63xx_timeout *table, int value)
+static const struct max63xx_timeout *
+max63xx_select_timeout(const struct max63xx_timeout *table, int value)
 {
 	while (table->twd) {
 		if (value <= table->twd) {
@@ -202,14 +203,17 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct max63xx_wdt *wdt;
-	struct max63xx_timeout *table;
+	const struct max63xx_timeout *table;
 	int err;
 
 	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
 	if (!wdt)
 		return -ENOMEM;
 
-	table = (struct max63xx_timeout *)pdev->id_entry->driver_data;
+	/* Attempt to use fwnode first */
+	table = device_get_match_data(dev);
+	if (!table)
+		table = (struct max63xx_timeout *)pdev->id_entry->driver_data;
 
 	if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
 		heartbeat = DEFAULT_HEARTBEAT;
@@ -255,11 +259,23 @@ static const struct platform_device_id max63xx_id_table[] = {
 };
 MODULE_DEVICE_TABLE(platform, max63xx_id_table);
 
+static const struct of_device_id max63xx_dt_id_table[] = {
+	{ .compatible = "maxim,max6369", .data = max6369_table, },
+	{ .compatible = "maxim,max6370", .data = max6369_table, },
+	{ .compatible = "maxim,max6371", .data = max6371_table, },
+	{ .compatible = "maxim,max6372", .data = max6371_table, },
+	{ .compatible = "maxim,max6373", .data = max6373_table, },
+	{ .compatible = "maxim,max6374", .data = max6373_table, },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, max63xx_dt_id_table);
+
 static struct platform_driver max63xx_wdt_driver = {
 	.probe		= max63xx_wdt_probe,
 	.id_table	= max63xx_id_table,
 	.driver		= {
 		.name	= "max63xx_wdt",
+		.of_match_table = max63xx_dt_id_table,
 	},
 };
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings
  2021-07-14 15:33 [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Linus Walleij
  2021-07-14 15:33 ` [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Linus Walleij
@ 2021-07-16 19:27 ` Rob Herring
  2021-07-17 14:08 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Rob Herring @ 2021-07-16 19:27 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Marc Zyngier, Wim Van Sebroeck, devicetree, Guenter Roeck,
	linux-watchdog

On Wed, 14 Jul 2021 17:33:13 +0200, Linus Walleij wrote:
> This adds devicetree bindings for the Maxim MAX63xx watchdog
> timers.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  .../bindings/watchdog/maxim,max63xx.yaml      | 44 +++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
> 

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings
  2021-07-14 15:33 [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Linus Walleij
  2021-07-14 15:33 ` [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Linus Walleij
  2021-07-16 19:27 ` [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Rob Herring
@ 2021-07-17 14:08 ` Guenter Roeck
  2 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-07-17 14:08 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Wim Van Sebroeck, linux-watchdog, devicetree, Marc Zyngier

On Wed, Jul 14, 2021 at 05:33:13PM +0200, Linus Walleij wrote:
> This adds devicetree bindings for the Maxim MAX63xx watchdog
> timers.
> 
> Cc: devicetree@vger.kernel.org
> Cc: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  .../bindings/watchdog/maxim,max63xx.yaml      | 44 +++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
> new file mode 100644
> index 000000000000..f2105eedac2c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/maxim,max63xx.yaml
> @@ -0,0 +1,44 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/watchdog/maxim,max63xx.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Maxim 63xx Watchdog Timers
> +
> +allOf:
> +  - $ref: "watchdog.yaml#"
> +
> +maintainers:
> +  - Marc Zyngier <maz@kernel.org>
> +  - Linus Walleij <linus.walleij@linaro.org>
> +
> +properties:
> +  compatible:
> +    oneOf:
> +      - const: maxim,max6369
> +      - const: maxim,max6370
> +      - const: maxim,max6371
> +      - const: maxim,max6372
> +      - const: maxim,max6373
> +      - const: maxim,max6374
> +
> +  reg:
> +    description: This is a 1-byte memory-mapped address
> +    maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    wdt: watchdog@50000000 {
> +        compatible = "maxim,max6369";
> +        reg = <0x50000000 0x1>;
> +        timeout-sec = <10>;
> +    };
> +
> +...
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing
  2021-07-14 15:33 ` [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Linus Walleij
@ 2021-07-17 14:08   ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-07-17 14:08 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Wim Van Sebroeck, linux-watchdog, Marc Zyngier

On Wed, Jul 14, 2021 at 05:33:14PM +0200, Linus Walleij wrote:
> This adds device tree probing to the MAX63xx driver so it can be
> instantiated from the device tree. We use the generic fwnode-based
> method to get to the match data and clean up by constifying the
> functions as the match is indeed a const.
> 
> Cc: Marc Zyngier <maz@kernel.org>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/max63xx_wdt.c | 24 ++++++++++++++++++++----
>  1 file changed, 20 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c
> index 3a899628a834..9e1541cfae0d 100644
> --- a/drivers/watchdog/max63xx_wdt.c
> +++ b/drivers/watchdog/max63xx_wdt.c
> @@ -26,6 +26,7 @@
>  #include <linux/spinlock.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/property.h>
>  
>  #define DEFAULT_HEARTBEAT 60
>  #define MAX_HEARTBEAT     60
> @@ -99,8 +100,8 @@ static const struct max63xx_timeout max6373_table[] = {
>  	{ },
>  };
>  
> -static struct max63xx_timeout *
> -max63xx_select_timeout(struct max63xx_timeout *table, int value)
> +static const struct max63xx_timeout *
> +max63xx_select_timeout(const struct max63xx_timeout *table, int value)
>  {
>  	while (table->twd) {
>  		if (value <= table->twd) {
> @@ -202,14 +203,17 @@ static int max63xx_wdt_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct max63xx_wdt *wdt;
> -	struct max63xx_timeout *table;
> +	const struct max63xx_timeout *table;
>  	int err;
>  
>  	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
>  	if (!wdt)
>  		return -ENOMEM;
>  
> -	table = (struct max63xx_timeout *)pdev->id_entry->driver_data;
> +	/* Attempt to use fwnode first */
> +	table = device_get_match_data(dev);
> +	if (!table)
> +		table = (struct max63xx_timeout *)pdev->id_entry->driver_data;
>  
>  	if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT)
>  		heartbeat = DEFAULT_HEARTBEAT;
> @@ -255,11 +259,23 @@ static const struct platform_device_id max63xx_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(platform, max63xx_id_table);
>  
> +static const struct of_device_id max63xx_dt_id_table[] = {
> +	{ .compatible = "maxim,max6369", .data = max6369_table, },
> +	{ .compatible = "maxim,max6370", .data = max6369_table, },
> +	{ .compatible = "maxim,max6371", .data = max6371_table, },
> +	{ .compatible = "maxim,max6372", .data = max6371_table, },
> +	{ .compatible = "maxim,max6373", .data = max6373_table, },
> +	{ .compatible = "maxim,max6374", .data = max6373_table, },
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(of, max63xx_dt_id_table);
> +
>  static struct platform_driver max63xx_wdt_driver = {
>  	.probe		= max63xx_wdt_probe,
>  	.id_table	= max63xx_id_table,
>  	.driver		= {
>  		.name	= "max63xx_wdt",
> +		.of_match_table = max63xx_dt_id_table,
>  	},
>  };
>  
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-07-17 14:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 15:33 [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Linus Walleij
2021-07-14 15:33 ` [PATCH 2/2] watchdog: max63xx_wdt: Add device tree probing Linus Walleij
2021-07-17 14:08   ` Guenter Roeck
2021-07-16 19:27 ` [PATCH 1/2] dt-bindings: watchdog: Add Maxim MAX63xx bindings Rob Herring
2021-07-17 14:08 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).