public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Devicetree support for Loongson-1 watchdog
@ 2023-05-11 12:11 Keguang Zhang
  2023-05-11 12:11 ` [PATCH v2 1/2] dt-bindings: watchdog: Add " Keguang Zhang
  2023-05-11 12:11 ` [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support Keguang Zhang
  0 siblings, 2 replies; 6+ messages in thread
From: Keguang Zhang @ 2023-05-11 12:11 UTC (permalink / raw)
  To: linux-watchdog, devicetree, linux-mips, linux-kernel
  Cc: Wim Van Sebroeck, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
	Yang Ling, Keguang Zhang

Add DT support and dt-binding document for Loongson-1 watchdog.

Changelog
V1 -> V2: Replaced the wildcard compatible string with specific ones
          Use unevaluatedProperties instead of additionalProperties
          (suggested by Krzysztof Kozlowski)
          Use of_match_ptr() to aviod the build error when CONFIG_OF=n

Keguang Zhang (2):
  dt-bindings: watchdog: Add Loongson-1 watchdog
  watchdog: loongson1_wdt: Add DT support

 .../bindings/watchdog/loongson,ls1x-wdt.yaml  | 42 +++++++++++++++++++
 drivers/watchdog/loongson1_wdt.c              | 13 +++++-
 2 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml


base-commit: 10f67d1fd275528e62109de2ece26371833638e5
-- 
2.39.2


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

* [PATCH v2 1/2] dt-bindings: watchdog: Add Loongson-1 watchdog
  2023-05-11 12:11 [PATCH v2 0/2] Devicetree support for Loongson-1 watchdog Keguang Zhang
@ 2023-05-11 12:11 ` Keguang Zhang
  2023-05-11 14:52   ` Krzysztof Kozlowski
  2023-05-12 12:30   ` Guenter Roeck
  2023-05-11 12:11 ` [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support Keguang Zhang
  1 sibling, 2 replies; 6+ messages in thread
From: Keguang Zhang @ 2023-05-11 12:11 UTC (permalink / raw)
  To: linux-watchdog, devicetree, linux-mips, linux-kernel
  Cc: Wim Van Sebroeck, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
	Yang Ling, Keguang Zhang

Add devicetree binding document for Loongson-1 watchdog.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
V1 -> V2: Replaced the wildcard compatible string with specific ones
          Use unevaluatedProperties instead of additionalProperties
          (suggested by Krzysztof Kozlowski)
---
 .../bindings/watchdog/loongson,ls1x-wdt.yaml  | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml

diff --git a/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml b/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml
new file mode 100644
index 000000000000..81690d4b62a6
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml
@@ -0,0 +1,42 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/watchdog/loongson,ls1x-wdt.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Loongson-1 Watchdog Timer
+
+maintainers:
+  - Keguang Zhang <keguang.zhang@gmail.com>
+
+allOf:
+  - $ref: watchdog.yaml#
+
+properties:
+  compatible:
+    enum:
+      - loongson,ls1b-wdt
+      - loongson,ls1c-wdt
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - clocks
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/clock/loongson,ls1x-clk.h>
+    watchdog: watchdog@1fe5c060 {
+        compatible = "loongson,ls1b-wdt";
+        reg = <0x1fe5c060 0xc>;
+
+        clocks = <&clkc LS1X_CLKID_APB>;
+    };
-- 
2.39.2


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

* [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support
  2023-05-11 12:11 [PATCH v2 0/2] Devicetree support for Loongson-1 watchdog Keguang Zhang
  2023-05-11 12:11 ` [PATCH v2 1/2] dt-bindings: watchdog: Add " Keguang Zhang
@ 2023-05-11 12:11 ` Keguang Zhang
  2023-05-12 12:30   ` Guenter Roeck
  1 sibling, 1 reply; 6+ messages in thread
From: Keguang Zhang @ 2023-05-11 12:11 UTC (permalink / raw)
  To: linux-watchdog, devicetree, linux-mips, linux-kernel
  Cc: Wim Van Sebroeck, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
	Yang Ling, Keguang Zhang

This patch adds the of_match_table to enable DT support
of Loongson-1 watchdog driver.
And modify the parameter of devm_clk_get_enabled() accordingly.

Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
---
V1 -> V2: Change the wildcard compatible string to specific ones
          Use of_match_ptr() to aviod the build error when CONFIG_OF=n
---
 drivers/watchdog/loongson1_wdt.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c
index 3c651c50a98c..4ac7810a314d 100644
--- a/drivers/watchdog/loongson1_wdt.c
+++ b/drivers/watchdog/loongson1_wdt.c
@@ -5,6 +5,7 @@
 
 #include <linux/clk.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/watchdog.h>
 
@@ -112,7 +113,7 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
 	if (IS_ERR(drvdata->base))
 		return PTR_ERR(drvdata->base);
 
-	drvdata->clk = devm_clk_get_enabled(dev, pdev->name);
+	drvdata->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(drvdata->clk))
 		return PTR_ERR(drvdata->clk);
 
@@ -144,10 +145,20 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id ls1x_wdt_dt_ids[] = {
+	{ .compatible = "loongson,ls1b-wdt", },
+	{ .compatible = "loongson,ls1c-wdt", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, ls1x_wdt_dt_ids);
+#endif
+
 static struct platform_driver ls1x_wdt_driver = {
 	.probe = ls1x_wdt_probe,
 	.driver = {
 		.name = "ls1x-wdt",
+		.of_match_table = of_match_ptr(ls1x_wdt_dt_ids),
 	},
 };
 
-- 
2.39.2


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

* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add Loongson-1 watchdog
  2023-05-11 12:11 ` [PATCH v2 1/2] dt-bindings: watchdog: Add " Keguang Zhang
@ 2023-05-11 14:52   ` Krzysztof Kozlowski
  2023-05-12 12:30   ` Guenter Roeck
  1 sibling, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2023-05-11 14:52 UTC (permalink / raw)
  To: Keguang Zhang, linux-watchdog, devicetree, linux-mips,
	linux-kernel
  Cc: Wim Van Sebroeck, Guenter Roeck, Rob Herring, Krzysztof Kozlowski,
	Yang Ling

On 11/05/2023 14:11, Keguang Zhang wrote:
> Add devicetree binding document for Loongson-1 watchdog.
> 
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>
> ---
> V1 -> V2: Replaced the wildcard compatible string with specific ones
>           Use unevaluatedProperties instead of additionalProperties
>           (suggested by Krzysztof Kozlowski)
> ---

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof


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

* Re: [PATCH v2 1/2] dt-bindings: watchdog: Add Loongson-1 watchdog
  2023-05-11 12:11 ` [PATCH v2 1/2] dt-bindings: watchdog: Add " Keguang Zhang
  2023-05-11 14:52   ` Krzysztof Kozlowski
@ 2023-05-12 12:30   ` Guenter Roeck
  1 sibling, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-05-12 12:30 UTC (permalink / raw)
  To: Keguang Zhang
  Cc: linux-watchdog, devicetree, linux-mips, linux-kernel,
	Wim Van Sebroeck, Rob Herring, Krzysztof Kozlowski, Yang Ling

On Thu, May 11, 2023 at 08:11:58PM +0800, Keguang Zhang wrote:
> Add devicetree binding document for Loongson-1 watchdog.
> 
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>

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

> ---
> V1 -> V2: Replaced the wildcard compatible string with specific ones
>           Use unevaluatedProperties instead of additionalProperties
>           (suggested by Krzysztof Kozlowski)
> ---
>  .../bindings/watchdog/loongson,ls1x-wdt.yaml  | 42 +++++++++++++++++++
>  1 file changed, 42 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml
> 
> diff --git a/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml b/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml
> new file mode 100644
> index 000000000000..81690d4b62a6
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/watchdog/loongson,ls1x-wdt.yaml
> @@ -0,0 +1,42 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/watchdog/loongson,ls1x-wdt.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Loongson-1 Watchdog Timer
> +
> +maintainers:
> +  - Keguang Zhang <keguang.zhang@gmail.com>
> +
> +allOf:
> +  - $ref: watchdog.yaml#
> +
> +properties:
> +  compatible:
> +    enum:
> +      - loongson,ls1b-wdt
> +      - loongson,ls1c-wdt
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    maxItems: 1
> +
> +required:
> +  - compatible
> +  - reg
> +  - clocks
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/clock/loongson,ls1x-clk.h>
> +    watchdog: watchdog@1fe5c060 {
> +        compatible = "loongson,ls1b-wdt";
> +        reg = <0x1fe5c060 0xc>;
> +
> +        clocks = <&clkc LS1X_CLKID_APB>;
> +    };
> -- 
> 2.39.2
> 

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

* Re: [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support
  2023-05-11 12:11 ` [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support Keguang Zhang
@ 2023-05-12 12:30   ` Guenter Roeck
  0 siblings, 0 replies; 6+ messages in thread
From: Guenter Roeck @ 2023-05-12 12:30 UTC (permalink / raw)
  To: Keguang Zhang
  Cc: linux-watchdog, devicetree, linux-mips, linux-kernel,
	Wim Van Sebroeck, Rob Herring, Krzysztof Kozlowski, Yang Ling

On Thu, May 11, 2023 at 08:11:59PM +0800, Keguang Zhang wrote:
> This patch adds the of_match_table to enable DT support
> of Loongson-1 watchdog driver.
> And modify the parameter of devm_clk_get_enabled() accordingly.
> 
> Signed-off-by: Keguang Zhang <keguang.zhang@gmail.com>

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

> ---
> V1 -> V2: Change the wildcard compatible string to specific ones
>           Use of_match_ptr() to aviod the build error when CONFIG_OF=n
> ---
>  drivers/watchdog/loongson1_wdt.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/loongson1_wdt.c b/drivers/watchdog/loongson1_wdt.c
> index 3c651c50a98c..4ac7810a314d 100644
> --- a/drivers/watchdog/loongson1_wdt.c
> +++ b/drivers/watchdog/loongson1_wdt.c
> @@ -5,6 +5,7 @@
>  
>  #include <linux/clk.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/watchdog.h>
>  
> @@ -112,7 +113,7 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
>  	if (IS_ERR(drvdata->base))
>  		return PTR_ERR(drvdata->base);
>  
> -	drvdata->clk = devm_clk_get_enabled(dev, pdev->name);
> +	drvdata->clk = devm_clk_get_enabled(dev, NULL);
>  	if (IS_ERR(drvdata->clk))
>  		return PTR_ERR(drvdata->clk);
>  
> @@ -144,10 +145,20 @@ static int ls1x_wdt_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +#ifdef CONFIG_OF
> +static const struct of_device_id ls1x_wdt_dt_ids[] = {
> +	{ .compatible = "loongson,ls1b-wdt", },
> +	{ .compatible = "loongson,ls1c-wdt", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, ls1x_wdt_dt_ids);
> +#endif
> +
>  static struct platform_driver ls1x_wdt_driver = {
>  	.probe = ls1x_wdt_probe,
>  	.driver = {
>  		.name = "ls1x-wdt",
> +		.of_match_table = of_match_ptr(ls1x_wdt_dt_ids),
>  	},
>  };
>  
> -- 
> 2.39.2
> 

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

end of thread, other threads:[~2023-05-12 12:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-11 12:11 [PATCH v2 0/2] Devicetree support for Loongson-1 watchdog Keguang Zhang
2023-05-11 12:11 ` [PATCH v2 1/2] dt-bindings: watchdog: Add " Keguang Zhang
2023-05-11 14:52   ` Krzysztof Kozlowski
2023-05-12 12:30   ` Guenter Roeck
2023-05-11 12:11 ` [PATCH v2 2/2] watchdog: loongson1_wdt: Add DT support Keguang Zhang
2023-05-12 12:30   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox