linux-watchdog.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions
@ 2019-11-11 12:13 Eugen.Hristev
  2019-11-11 12:13 ` [PATCH v3 2/3] dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible Eugen.Hristev
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Eugen.Hristev @ 2019-11-11 12:13 UTC (permalink / raw)
  To: robh+dt, linux, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel
  Cc: Eugen.Hristev

From: Eugen Hristev <eugen.hristev@microchip.com>

Cleanup the macro definitions to use BIT and align with two spaces.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v3:
- new patch as requested from review on ML

 drivers/watchdog/at91sam9_wdt.h | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index 390941c..2ca5fc5 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -14,23 +14,23 @@
 #define AT91_WDT_H
 
 #define AT91_WDT_CR		0x00			/* Watchdog Control Register */
-#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */
-#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
+#define  AT91_WDT_WDRSTT	BIT(0)			/* Restart */
+#define  AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
 
 #define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
-#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
-#define			AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
-#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */
-#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */
-#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */
-#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */
-#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
-#define			AT91_WDT_SET_WDD(x)	(((x) << 16) & AT91_WDT_WDD)
-#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */
-#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */
+#define  AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
+#define  AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
+#define  AT91_WDT_WDFIEN	BIT(12)		/* Fault Interrupt Enable */
+#define  AT91_WDT_WDRSTEN	BIT(13)		/* Reset Processor */
+#define  AT91_WDT_WDRPROC	BIT(14)		/* Timer Restart */
+#define  AT91_WDT_WDDIS		BIT(15)		/* Watchdog Disable */
+#define  AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
+#define  AT91_WDT_SET_WDD(x)	(((x) << 16) & AT91_WDT_WDD)
+#define  AT91_WDT_WDDBGHLT	BIT(28)		/* Debug Halt */
+#define  AT91_WDT_WDIDLEHLT	BIT(29)		/* Idle Halt */
 
-#define AT91_WDT_SR		0x08			/* Watchdog Status Register */
-#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */
-#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */
+#define AT91_WDT_SR		0x08		/* Watchdog Status Register */
+#define  AT91_WDT_WDUNF		BIT(0)		/* Watchdog Underflow */
+#define  AT91_WDT_WDERR		BIT(1)		/* Watchdog Error */
 
 #endif
-- 
2.7.4


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

* [PATCH v3 2/3] dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible
  2019-11-11 12:13 [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Eugen.Hristev
@ 2019-11-11 12:13 ` Eugen.Hristev
  2019-11-11 12:13 ` [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog Eugen.Hristev
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Eugen.Hristev @ 2019-11-11 12:13 UTC (permalink / raw)
  To: robh+dt, linux, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel
  Cc: Eugen.Hristev

From: Eugen Hristev <eugen.hristev@microchip.com>

The Atmel sama5d4_wdt needs to be compatible with microchip,sam9x60-wdt
The sama5d4_wdt driver is updated to work with both hardware blocks
(sama5d4/sama5d2 and sam9x60 based blocks)

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
 Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
index 4fec1e3..44727fc 100644
--- a/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/atmel-sama5d4-wdt.txt
@@ -1,7 +1,7 @@
 * Atmel SAMA5D4 Watchdog Timer (WDT) Controller
 
 Required properties:
-- compatible: "atmel,sama5d4-wdt"
+- compatible: "atmel,sama5d4-wdt" or "microchip,sam9x60-wdt"
 - reg: base physical address and length of memory mapped region.
 
 Optional properties:
-- 
2.7.4


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

* [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog
  2019-11-11 12:13 [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Eugen.Hristev
  2019-11-11 12:13 ` [PATCH v3 2/3] dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible Eugen.Hristev
@ 2019-11-11 12:13 ` Eugen.Hristev
  2019-11-12 14:01   ` Guenter Roeck
  2019-11-12 13:47 ` [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Guenter Roeck
  2019-11-12 21:24 ` kbuild test robot
  3 siblings, 1 reply; 8+ messages in thread
From: Eugen.Hristev @ 2019-11-11 12:13 UTC (permalink / raw)
  To: robh+dt, linux, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel
  Cc: Eugen.Hristev

From: Eugen Hristev <eugen.hristev@microchip.com>

Add support for SAM9X60 WDT into sama5d4_wdt.
This means that this driver gets a flag inside the data struct
that represents the sam9x60 support.
This flag differentiates between the two hardware blocks, and is set
according to the compatible of the driver instantiation.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
---
Changes in v3:
- changed need_irq to bool, instead of a single bit variable.
- the platform data config struct is gone now, changed to a pointer to a bool
to have the sam9x60_support as 'true', pointing to a static bool with true value.
Can have a better solution than this ?
- the specific sam9x60_support flag is assigned at probe time, corresponding
to the flag value in .data


 drivers/watchdog/at91sam9_wdt.h |  14 +++++
 drivers/watchdog/sama5d4_wdt.c  | 120 ++++++++++++++++++++++++++++++----------
 2 files changed, 105 insertions(+), 29 deletions(-)

diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
index 2ca5fc5..2a85135 100644
--- a/drivers/watchdog/at91sam9_wdt.h
+++ b/drivers/watchdog/at91sam9_wdt.h
@@ -20,7 +20,10 @@
 #define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
 #define  AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
 #define  AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
+#define  AT91_SAM9X60_PERIODRST	BIT(4)		/* Period Reset */
+#define  AT91_SAM9X60_RPTHRST	BIT(5)		/* Minimum Restart Period */
 #define  AT91_WDT_WDFIEN	BIT(12)		/* Fault Interrupt Enable */
+#define  AT91_SAM9X60_WDDIS	BIT(12)		/* Watchdog Disable */
 #define  AT91_WDT_WDRSTEN	BIT(13)		/* Reset Processor */
 #define  AT91_WDT_WDRPROC	BIT(14)		/* Timer Restart */
 #define  AT91_WDT_WDDIS		BIT(15)		/* Watchdog Disable */
@@ -33,4 +36,15 @@
 #define  AT91_WDT_WDUNF		BIT(0)		/* Watchdog Underflow */
 #define  AT91_WDT_WDERR		BIT(1)		/* Watchdog Error */
 
+#define AT91_SAM9X60_VR		0x08			/* Watchdog Timer Value Register */
+
+#define AT91_SAM9X60_WLR		0x0c
+#define  AT91_SAM9X60_COUNTER	(0xfff << 0)		/* Watchdog Period Value */
+#define  AT91_SAM9X60_SET_COUNTER(x)	((x) & AT91_SAM9X60_COUNTER)
+
+#define AT91_SAM9X60_IER		0x14		/* Interrupt Enable Register */
+#define  AT91_SAM9X60_PERINT		BIT(0)		/* Period Interrupt Enable */
+#define AT91_SAM9X60_IDR		0x18		/* Interrupt Disable Register */
+#define AT91_SAM9X60_ISR		0x1c		/* Interrupt Status Register */
+
 #endif
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index d193a60..cf53354 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -2,7 +2,7 @@
 /*
  * Driver for Atmel SAMA5D4 Watchdog Timer
  *
- * Copyright (C) 2015 Atmel Corporation
+ * Copyright (C) 2015-2019 Microchip Technology Inc. and its subsidiaries
  */
 
 #include <linux/delay.h>
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
@@ -26,10 +27,13 @@
 #define WDT_SEC2TICKS(s)	((s) ? (((s) << 8) - 1) : 0)
 
 struct sama5d4_wdt {
-	struct watchdog_device	wdd;
-	void __iomem		*reg_base;
-	u32			mr;
-	unsigned long		last_ping;
+	struct watchdog_device		wdd;
+	void __iomem			*reg_base;
+	u32				mr;
+	u32				ir;
+	unsigned long			last_ping;
+	bool				need_irq;
+	bool				sam9x60_support;
 };
 
 static int wdt_timeout;
@@ -78,7 +82,12 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd)
 {
 	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
 
-	wdt->mr &= ~AT91_WDT_WDDIS;
+	if (wdt->sam9x60_support) {
+		writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IER);
+		wdt->mr &= ~AT91_SAM9X60_WDDIS;
+	} else {
+		wdt->mr &= ~AT91_WDT_WDDIS;
+	}
 	wdt_write(wdt, AT91_WDT_MR, wdt->mr);
 
 	return 0;
@@ -88,7 +97,12 @@ static int sama5d4_wdt_stop(struct watchdog_device *wdd)
 {
 	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
 
-	wdt->mr |= AT91_WDT_WDDIS;
+	if (wdt->sam9x60_support) {
+		writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IDR);
+		wdt->mr |= AT91_SAM9X60_WDDIS;
+	} else {
+		wdt->mr |= AT91_WDT_WDDIS;
+	}
 	wdt_write(wdt, AT91_WDT_MR, wdt->mr);
 
 	return 0;
@@ -109,6 +123,14 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd,
 	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
 	u32 value = WDT_SEC2TICKS(timeout);
 
+	if (wdt->sam9x60_support) {
+		wdt_write(wdt, AT91_SAM9X60_WLR,
+			  AT91_SAM9X60_SET_COUNTER(value));
+
+		wdd->timeout = timeout;
+		return 0;
+	}
+
 	wdt->mr &= ~AT91_WDT_WDV;
 	wdt->mr |= AT91_WDT_SET_WDV(value);
 
@@ -143,8 +165,14 @@ static const struct watchdog_ops sama5d4_wdt_ops = {
 static irqreturn_t sama5d4_wdt_irq_handler(int irq, void *dev_id)
 {
 	struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id);
+	u32 reg;
 
-	if (wdt_read(wdt, AT91_WDT_SR)) {
+	if (wdt->sam9x60_support)
+		reg = wdt_read(wdt, AT91_SAM9X60_ISR);
+	else
+		reg = wdt_read(wdt, AT91_WDT_SR);
+
+	if (reg) {
 		pr_crit("Atmel Watchdog Software Reset\n");
 		emergency_restart();
 		pr_crit("Reboot didn't succeed\n");
@@ -157,13 +185,14 @@ static int of_sama5d4_wdt_init(struct device_node *np, struct sama5d4_wdt *wdt)
 {
 	const char *tmp;
 
-	wdt->mr = AT91_WDT_WDDIS;
+	if (wdt->sam9x60_support)
+		wdt->mr = AT91_SAM9X60_WDDIS;
+	else
+		wdt->mr = AT91_WDT_WDDIS;
 
 	if (!of_property_read_string(np, "atmel,watchdog-type", &tmp) &&
 	    !strcmp(tmp, "software"))
-		wdt->mr |= AT91_WDT_WDFIEN;
-	else
-		wdt->mr |= AT91_WDT_WDRSTEN;
+		wdt->need_irq = true;
 
 	if (of_property_read_bool(np, "atmel,idle-halt"))
 		wdt->mr |= AT91_WDT_WDIDLEHLT;
@@ -176,21 +205,46 @@ static int of_sama5d4_wdt_init(struct device_node *np, struct sama5d4_wdt *wdt)
 
 static int sama5d4_wdt_init(struct sama5d4_wdt *wdt)
 {
-	u32 reg;
+	u32 reg, val;
+
+	val = WDT_SEC2TICKS(WDT_DEFAULT_TIMEOUT);
 	/*
 	 * When booting and resuming, the bootloader may have changed the
 	 * watchdog configuration.
 	 * If the watchdog is already running, we can safely update it.
 	 * Else, we have to disable it properly.
 	 */
-	if (wdt_enabled) {
-		wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
-	} else {
+	if (!wdt_enabled) {
 		reg = wdt_read(wdt, AT91_WDT_MR);
-		if (!(reg & AT91_WDT_WDDIS))
+		if (wdt->sam9x60_support && (!(reg & AT91_SAM9X60_WDDIS)))
+			wdt_write_nosleep(wdt, AT91_WDT_MR,
+					  reg | AT91_SAM9X60_WDDIS);
+		else if (!wdt->sam9x60_support &&
+			 (!(reg & AT91_WDT_WDDIS)))
 			wdt_write_nosleep(wdt, AT91_WDT_MR,
 					  reg | AT91_WDT_WDDIS);
 	}
+
+	if (wdt->sam9x60_support) {
+		if (wdt->need_irq)
+			wdt->ir = AT91_SAM9X60_PERINT;
+		else
+			wdt->mr |= AT91_SAM9X60_PERIODRST;
+
+		wdt_write(wdt, AT91_SAM9X60_IER, wdt->ir);
+		wdt_write(wdt, AT91_SAM9X60_WLR, AT91_SAM9X60_SET_COUNTER(val));
+	} else {
+		wdt->mr |= AT91_WDT_SET_WDD(WDT_SEC2TICKS(MAX_WDT_TIMEOUT));
+		wdt->mr |= AT91_WDT_SET_WDV(val);
+
+		if (wdt->need_irq)
+			wdt->mr |= AT91_WDT_WDFIEN;
+		else
+			wdt->mr |= AT91_WDT_WDRSTEN;
+	}
+
+	wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
+
 	return 0;
 }
 
@@ -200,14 +254,16 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 	struct watchdog_device *wdd;
 	struct sama5d4_wdt *wdt;
 	void __iomem *regs;
+	const void *data;
 	u32 irq = 0;
-	u32 timeout;
 	int ret;
 
 	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
 	if (!wdt)
 		return -ENOMEM;
 
+	data = of_device_get_match_data(&pdev->dev);
+
 	wdd = &wdt->wdd;
 	wdd->timeout = WDT_DEFAULT_TIMEOUT;
 	wdd->info = &sama5d4_wdt_info;
@@ -215,6 +271,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 	wdd->min_timeout = MIN_WDT_TIMEOUT;
 	wdd->max_timeout = MAX_WDT_TIMEOUT;
 	wdt->last_ping = jiffies;
+	wdt->sam9x60_support = data ? *(bool *)data : false;
 
 	watchdog_set_drvdata(wdd, wdt);
 
@@ -224,15 +281,17 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 
 	wdt->reg_base = regs;
 
-	irq = irq_of_parse_and_map(dev->of_node, 0);
-	if (!irq)
-		dev_warn(dev, "failed to get IRQ from DT\n");
-
 	ret = of_sama5d4_wdt_init(dev->of_node, wdt);
 	if (ret)
 		return ret;
 
-	if ((wdt->mr & AT91_WDT_WDFIEN) && irq) {
+	irq = irq_of_parse_and_map(dev->of_node, 0);
+	if (!irq) {
+		dev_warn(dev, "failed to get IRQ from DT\n");
+		wdt->need_irq = false;
+	}
+
+	if (wdt->need_irq) {
 		ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler,
 				       IRQF_SHARED | IRQF_IRQPOLL |
 				       IRQF_NO_SUSPEND, pdev->name, pdev);
@@ -244,11 +303,6 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 
 	watchdog_init_timeout(wdd, wdt_timeout, dev);
 
-	timeout = WDT_SEC2TICKS(wdd->timeout);
-
-	wdt->mr |= AT91_WDT_SET_WDD(WDT_SEC2TICKS(MAX_WDT_TIMEOUT));
-	wdt->mr |= AT91_WDT_SET_WDV(timeout);
-
 	ret = sama5d4_wdt_init(wdt);
 	if (ret)
 		return ret;
@@ -268,8 +322,16 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 	return 0;
 }
 
+static bool sam9x60_config = true;
+
 static const struct of_device_id sama5d4_wdt_of_match[] = {
-	{ .compatible = "atmel,sama5d4-wdt", },
+	{
+		.compatible = "atmel,sama5d4-wdt",
+	},
+	{
+		.compatible = "microchip,sam9x60-wdt",
+		.data = &sam9x60_config,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, sama5d4_wdt_of_match);
-- 
2.7.4


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

* Re: [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions
  2019-11-11 12:13 [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Eugen.Hristev
  2019-11-11 12:13 ` [PATCH v3 2/3] dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible Eugen.Hristev
  2019-11-11 12:13 ` [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog Eugen.Hristev
@ 2019-11-12 13:47 ` Guenter Roeck
  2019-11-14 11:34   ` Eugen.Hristev
  2019-11-12 21:24 ` kbuild test robot
  3 siblings, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2019-11-12 13:47 UTC (permalink / raw)
  To: Eugen.Hristev, robh+dt, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel

On 11/11/19 4:13 AM, Eugen.Hristev@microchip.com wrote:
> From: Eugen Hristev <eugen.hristev@microchip.com>
> 
> Cleanup the macro definitions to use BIT and align with two spaces.
> 
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
> ---
> Changes in v3:
> - new patch as requested from review on ML
> 
>   drivers/watchdog/at91sam9_wdt.h | 30 +++++++++++++++---------------
>   1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
> index 390941c..2ca5fc5 100644
> --- a/drivers/watchdog/at91sam9_wdt.h
> +++ b/drivers/watchdog/at91sam9_wdt.h
> @@ -14,23 +14,23 @@
>   #define AT91_WDT_H
>   
>   #define AT91_WDT_CR		0x00			/* Watchdog Control Register */
> -#define		AT91_WDT_WDRSTT		(1    << 0)		/* Restart */
> -#define		AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
> +#define  AT91_WDT_WDRSTT	BIT(0)			/* Restart */

Using BIT() requires including linux/bits.h.

> +#define  AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
>   
>   #define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
> -#define		AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
> -#define			AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
> -#define		AT91_WDT_WDFIEN		(1     << 12)		/* Fault Interrupt Enable */
> -#define		AT91_WDT_WDRSTEN	(1     << 13)		/* Reset Processor */
> -#define		AT91_WDT_WDRPROC	(1     << 14)		/* Timer Restart */
> -#define		AT91_WDT_WDDIS		(1     << 15)		/* Watchdog Disable */
> -#define		AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
> -#define			AT91_WDT_SET_WDD(x)	(((x) << 16) & AT91_WDT_WDD)
> -#define		AT91_WDT_WDDBGHLT	(1     << 28)		/* Debug Halt */
> -#define		AT91_WDT_WDIDLEHLT	(1     << 29)		/* Idle Halt */
> +#define  AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
> +#define  AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
> +#define  AT91_WDT_WDFIEN	BIT(12)		/* Fault Interrupt Enable */
> +#define  AT91_WDT_WDRSTEN	BIT(13)		/* Reset Processor */
> +#define  AT91_WDT_WDRPROC	BIT(14)		/* Timer Restart */
> +#define  AT91_WDT_WDDIS		BIT(15)		/* Watchdog Disable */
> +#define  AT91_WDT_WDD		(0xfff << 16)		/* Delta Value */
> +#define  AT91_WDT_SET_WDD(x)	(((x) << 16) & AT91_WDT_WDD)
> +#define  AT91_WDT_WDDBGHLT	BIT(28)		/* Debug Halt */
> +#define  AT91_WDT_WDIDLEHLT	BIT(29)		/* Idle Halt */
>   
> -#define AT91_WDT_SR		0x08			/* Watchdog Status Register */
> -#define		AT91_WDT_WDUNF		(1 << 0)		/* Watchdog Underflow */
> -#define		AT91_WDT_WDERR		(1 << 1)		/* Watchdog Error */
> +#define AT91_WDT_SR		0x08		/* Watchdog Status Register */
> +#define  AT91_WDT_WDUNF		BIT(0)		/* Watchdog Underflow */
> +#define  AT91_WDT_WDERR		BIT(1)		/* Watchdog Error */
>   
>   #endif
> 


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

* Re: [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog
  2019-11-11 12:13 ` [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog Eugen.Hristev
@ 2019-11-12 14:01   ` Guenter Roeck
  0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2019-11-12 14:01 UTC (permalink / raw)
  To: Eugen.Hristev, robh+dt, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel

On 11/11/19 4:13 AM, Eugen.Hristev@microchip.com wrote:
> From: Eugen Hristev <eugen.hristev@microchip.com>
> 
> Add support for SAM9X60 WDT into sama5d4_wdt.
> This means that this driver gets a flag inside the data struct
> that represents the sam9x60 support.
> This flag differentiates between the two hardware blocks, and is set
> according to the compatible of the driver instantiation.
> 
> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
> ---
> Changes in v3:
> - changed need_irq to bool, instead of a single bit variable.
> - the platform data config struct is gone now, changed to a pointer to a bool
> to have the sam9x60_support as 'true', pointing to a static bool with true value.
> Can have a better solution than this ?
> - the specific sam9x60_support flag is assigned at probe time, corresponding
> to the flag value in .data
> 
> 
>   drivers/watchdog/at91sam9_wdt.h |  14 +++++
>   drivers/watchdog/sama5d4_wdt.c  | 120 ++++++++++++++++++++++++++++++----------
>   2 files changed, 105 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/watchdog/at91sam9_wdt.h b/drivers/watchdog/at91sam9_wdt.h
> index 2ca5fc5..2a85135 100644
> --- a/drivers/watchdog/at91sam9_wdt.h
> +++ b/drivers/watchdog/at91sam9_wdt.h
> @@ -20,7 +20,10 @@
>   #define AT91_WDT_MR		0x04			/* Watchdog Mode Register */
>   #define  AT91_WDT_WDV		(0xfff << 0)		/* Counter Value */
>   #define  AT91_WDT_SET_WDV(x)	((x) & AT91_WDT_WDV)
> +#define  AT91_SAM9X60_PERIODRST	BIT(4)		/* Period Reset */
> +#define  AT91_SAM9X60_RPTHRST	BIT(5)		/* Minimum Restart Period */
>   #define  AT91_WDT_WDFIEN	BIT(12)		/* Fault Interrupt Enable */
> +#define  AT91_SAM9X60_WDDIS	BIT(12)		/* Watchdog Disable */
>   #define  AT91_WDT_WDRSTEN	BIT(13)		/* Reset Processor */
>   #define  AT91_WDT_WDRPROC	BIT(14)		/* Timer Restart */
>   #define  AT91_WDT_WDDIS		BIT(15)		/* Watchdog Disable */
> @@ -33,4 +36,15 @@
>   #define  AT91_WDT_WDUNF		BIT(0)		/* Watchdog Underflow */
>   #define  AT91_WDT_WDERR		BIT(1)		/* Watchdog Error */
>   
> +#define AT91_SAM9X60_VR		0x08			/* Watchdog Timer Value Register */
> +
> +#define AT91_SAM9X60_WLR		0x0c
> +#define  AT91_SAM9X60_COUNTER	(0xfff << 0)		/* Watchdog Period Value */
> +#define  AT91_SAM9X60_SET_COUNTER(x)	((x) & AT91_SAM9X60_COUNTER)
> +
> +#define AT91_SAM9X60_IER		0x14		/* Interrupt Enable Register */
> +#define  AT91_SAM9X60_PERINT		BIT(0)		/* Period Interrupt Enable */
> +#define AT91_SAM9X60_IDR		0x18		/* Interrupt Disable Register */
> +#define AT91_SAM9X60_ISR		0x1c		/* Interrupt Status Register */
> +
>   #endif
> diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
> index d193a60..cf53354 100644
> --- a/drivers/watchdog/sama5d4_wdt.c
> +++ b/drivers/watchdog/sama5d4_wdt.c
> @@ -2,7 +2,7 @@
>   /*
>    * Driver for Atmel SAMA5D4 Watchdog Timer
>    *
> - * Copyright (C) 2015 Atmel Corporation
> + * Copyright (C) 2015-2019 Microchip Technology Inc. and its subsidiaries
>    */
>   
>   #include <linux/delay.h>
> @@ -11,6 +11,7 @@
>   #include <linux/kernel.h>
>   #include <linux/module.h>
>   #include <linux/of.h>
> +#include <linux/of_device.h>
>   #include <linux/of_irq.h>
>   #include <linux/platform_device.h>
>   #include <linux/reboot.h>
> @@ -26,10 +27,13 @@
>   #define WDT_SEC2TICKS(s)	((s) ? (((s) << 8) - 1) : 0)
>   
>   struct sama5d4_wdt {
> -	struct watchdog_device	wdd;
> -	void __iomem		*reg_base;
> -	u32			mr;
> -	unsigned long		last_ping;
> +	struct watchdog_device		wdd;

Why add another tab here ? That seems excessive.

> +	void __iomem			*reg_base;
> +	u32				mr;
> +	u32				ir;
> +	unsigned long			last_ping;
> +	bool				need_irq;
> +	bool				sam9x60_support;
>   };
>   
>   static int wdt_timeout;
> @@ -78,7 +82,12 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd)
>   {
>   	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
>   
> -	wdt->mr &= ~AT91_WDT_WDDIS;
> +	if (wdt->sam9x60_support) {
> +		writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IER);
> +		wdt->mr &= ~AT91_SAM9X60_WDDIS;
> +	} else {
> +		wdt->mr &= ~AT91_WDT_WDDIS;
> +	}
>   	wdt_write(wdt, AT91_WDT_MR, wdt->mr);
>   
>   	return 0;
> @@ -88,7 +97,12 @@ static int sama5d4_wdt_stop(struct watchdog_device *wdd)
>   {
>   	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
>   
> -	wdt->mr |= AT91_WDT_WDDIS;
> +	if (wdt->sam9x60_support) {
> +		writel_relaxed(wdt->ir, wdt->reg_base + AT91_SAM9X60_IDR);
> +		wdt->mr |= AT91_SAM9X60_WDDIS;
> +	} else {
> +		wdt->mr |= AT91_WDT_WDDIS;
> +	}
>   	wdt_write(wdt, AT91_WDT_MR, wdt->mr);
>   
>   	return 0;
> @@ -109,6 +123,14 @@ static int sama5d4_wdt_set_timeout(struct watchdog_device *wdd,
>   	struct sama5d4_wdt *wdt = watchdog_get_drvdata(wdd);
>   	u32 value = WDT_SEC2TICKS(timeout);
>   
> +	if (wdt->sam9x60_support) {
> +		wdt_write(wdt, AT91_SAM9X60_WLR,
> +			  AT91_SAM9X60_SET_COUNTER(value));
> +
> +		wdd->timeout = timeout;
> +		return 0;
> +	}
> +
>   	wdt->mr &= ~AT91_WDT_WDV;
>   	wdt->mr |= AT91_WDT_SET_WDV(value);
>   
> @@ -143,8 +165,14 @@ static const struct watchdog_ops sama5d4_wdt_ops = {
>   static irqreturn_t sama5d4_wdt_irq_handler(int irq, void *dev_id)
>   {
>   	struct sama5d4_wdt *wdt = platform_get_drvdata(dev_id);
> +	u32 reg;
>   
> -	if (wdt_read(wdt, AT91_WDT_SR)) {
> +	if (wdt->sam9x60_support)
> +		reg = wdt_read(wdt, AT91_SAM9X60_ISR);
> +	else
> +		reg = wdt_read(wdt, AT91_WDT_SR);
> +
> +	if (reg) {
>   		pr_crit("Atmel Watchdog Software Reset\n");
>   		emergency_restart();
>   		pr_crit("Reboot didn't succeed\n");
> @@ -157,13 +185,14 @@ static int of_sama5d4_wdt_init(struct device_node *np, struct sama5d4_wdt *wdt)
>   {
>   	const char *tmp;
>   
> -	wdt->mr = AT91_WDT_WDDIS;
> +	if (wdt->sam9x60_support)
> +		wdt->mr = AT91_SAM9X60_WDDIS;
> +	else
> +		wdt->mr = AT91_WDT_WDDIS;
>   
>   	if (!of_property_read_string(np, "atmel,watchdog-type", &tmp) &&
>   	    !strcmp(tmp, "software"))
> -		wdt->mr |= AT91_WDT_WDFIEN;
> -	else
> -		wdt->mr |= AT91_WDT_WDRSTEN;
> +		wdt->need_irq = true;
>   
>   	if (of_property_read_bool(np, "atmel,idle-halt"))
>   		wdt->mr |= AT91_WDT_WDIDLEHLT;
> @@ -176,21 +205,46 @@ static int of_sama5d4_wdt_init(struct device_node *np, struct sama5d4_wdt *wdt)
>   
>   static int sama5d4_wdt_init(struct sama5d4_wdt *wdt)
>   {
> -	u32 reg;
> +	u32 reg, val;
> +
> +	val = WDT_SEC2TICKS(WDT_DEFAULT_TIMEOUT);
>   	/*
>   	 * When booting and resuming, the bootloader may have changed the
>   	 * watchdog configuration.
>   	 * If the watchdog is already running, we can safely update it.
>   	 * Else, we have to disable it properly.
>   	 */
> -	if (wdt_enabled) {
> -		wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
> -	} else {
> +	if (!wdt_enabled) {
>   		reg = wdt_read(wdt, AT91_WDT_MR);
> -		if (!(reg & AT91_WDT_WDDIS))
> +		if (wdt->sam9x60_support && (!(reg & AT91_SAM9X60_WDDIS)))
> +			wdt_write_nosleep(wdt, AT91_WDT_MR,
> +					  reg | AT91_SAM9X60_WDDIS);
> +		else if (!wdt->sam9x60_support &&
> +			 (!(reg & AT91_WDT_WDDIS)))
>   			wdt_write_nosleep(wdt, AT91_WDT_MR,
>   					  reg | AT91_WDT_WDDIS);
>   	}
> +
> +	if (wdt->sam9x60_support) {
> +		if (wdt->need_irq)
> +			wdt->ir = AT91_SAM9X60_PERINT;
> +		else
> +			wdt->mr |= AT91_SAM9X60_PERIODRST;
> +
> +		wdt_write(wdt, AT91_SAM9X60_IER, wdt->ir);
> +		wdt_write(wdt, AT91_SAM9X60_WLR, AT91_SAM9X60_SET_COUNTER(val));
> +	} else {
> +		wdt->mr |= AT91_WDT_SET_WDD(WDT_SEC2TICKS(MAX_WDT_TIMEOUT));
> +		wdt->mr |= AT91_WDT_SET_WDV(val);
> +
> +		if (wdt->need_irq)
> +			wdt->mr |= AT91_WDT_WDFIEN;
> +		else
> +			wdt->mr |= AT91_WDT_WDRSTEN;
> +	}
> +
> +	wdt_write_nosleep(wdt, AT91_WDT_MR, wdt->mr);
> +
>   	return 0;
>   }
>   
> @@ -200,14 +254,16 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>   	struct watchdog_device *wdd;
>   	struct sama5d4_wdt *wdt;
>   	void __iomem *regs;
> +	const void *data;
>   	u32 irq = 0;
> -	u32 timeout;
>   	int ret;
>   
>   	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
>   	if (!wdt)
>   		return -ENOMEM;
>   
> +	data = of_device_get_match_data(&pdev->dev);
> +
>   	wdd = &wdt->wdd;
>   	wdd->timeout = WDT_DEFAULT_TIMEOUT;
>   	wdd->info = &sama5d4_wdt_info;
> @@ -215,6 +271,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>   	wdd->min_timeout = MIN_WDT_TIMEOUT;
>   	wdd->max_timeout = MAX_WDT_TIMEOUT;
>   	wdt->last_ping = jiffies;
> +	wdt->sam9x60_support = data ? *(bool *)data : false;

	wdt->sam9x60_support = of_device_is_compatible(dev, "microchip,sam9x60-wdt");

should do.

>   
>   	watchdog_set_drvdata(wdd, wdt);
>   
> @@ -224,15 +281,17 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>   
>   	wdt->reg_base = regs;
>   
> -	irq = irq_of_parse_and_map(dev->of_node, 0);
> -	if (!irq)
> -		dev_warn(dev, "failed to get IRQ from DT\n");
> -
>   	ret = of_sama5d4_wdt_init(dev->of_node, wdt);
>   	if (ret)
>   		return ret;
>   
> -	if ((wdt->mr & AT91_WDT_WDFIEN) && irq) {
> +	irq = irq_of_parse_and_map(dev->of_node, 0);
> +	if (!irq) {

Why call irq_of_parse_and_map() in the first place if need_irq is false ?
Doesn't this generate an unnecessary warning if need_irq is false and
if there is no interrupt node ?

> +		dev_warn(dev, "failed to get IRQ from DT\n");
> +		wdt->need_irq = false;
> +	}
> +
> +	if (wdt->need_irq) {
>   		ret = devm_request_irq(dev, irq, sama5d4_wdt_irq_handler,
>   				       IRQF_SHARED | IRQF_IRQPOLL |
>   				       IRQF_NO_SUSPEND, pdev->name, pdev);
> @@ -244,11 +303,6 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>   
>   	watchdog_init_timeout(wdd, wdt_timeout, dev);
>   
> -	timeout = WDT_SEC2TICKS(wdd->timeout);
> -
> -	wdt->mr |= AT91_WDT_SET_WDD(WDT_SEC2TICKS(MAX_WDT_TIMEOUT));
> -	wdt->mr |= AT91_WDT_SET_WDV(timeout);
> -
>   	ret = sama5d4_wdt_init(wdt);
>   	if (ret)
>   		return ret;
> @@ -268,8 +322,16 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>   	return 0;
>   }
>   
> +static bool sam9x60_config = true;
> +
>   static const struct of_device_id sama5d4_wdt_of_match[] = {
> -	{ .compatible = "atmel,sama5d4-wdt", },
> +	{
> +		.compatible = "atmel,sama5d4-wdt",
> +	},
> +	{
> +		.compatible = "microchip,sam9x60-wdt",
> +		.data = &sam9x60_config,
> +	},
>   	{ }
>   };
>   MODULE_DEVICE_TABLE(of, sama5d4_wdt_of_match);
> 


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

* Re: [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions
  2019-11-11 12:13 [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Eugen.Hristev
                   ` (2 preceding siblings ...)
  2019-11-12 13:47 ` [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Guenter Roeck
@ 2019-11-12 21:24 ` kbuild test robot
  3 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-11-12 21:24 UTC (permalink / raw)
  To: Eugen.Hristev
  Cc: kbuild-all, robh+dt, linux, wim, Nicolas.Ferre,
	alexandre.belloni, linux-watchdog, devicetree, linux-arm-kernel,
	linux-kernel, Eugen.Hristev

[-- Attachment #1: Type: text/plain, Size: 3197 bytes --]

Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on v5.4-rc7 next-20191112]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Eugen-Hristev-microchip-com/watchdog-sama5d4_wdt-cleanup-the-bit-definitions/20191113-023558
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/watchdog/at91sam9_wdt.c: In function 'at91_wdt_reset':
>> drivers/watchdog/at91sam9_wdt.c:43:17: warning: large integer implicitly truncated to unsigned type [-Woverflow]
     writel_relaxed((val), (wdt)->base + (field))
                    ^
>> drivers/watchdog/at91sam9_wdt.c:114:2: note: in expansion of macro 'wdt_write'
     wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
     ^~~~~~~~~
--
   In file included from drivers/watchdog/sama5d4_wdt.c:19:0:
   drivers/watchdog/sama5d4_wdt.c: In function 'sama5d4_wdt_ping':
>> drivers/watchdog/at91sam9_wdt.h:18:24: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define  AT91_WDT_KEY  (0xa5 << 24)  /* KEY Password */
                           ^
>> drivers/watchdog/sama5d4_wdt.c:101:30: note: in expansion of macro 'AT91_WDT_KEY'
     wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT);
                                 ^~~~~~~~~~~~

vim +18 drivers/watchdog/at91sam9_wdt.h

eaa595cb881bba include/asm-arm/arch-at91rm9200/at91_wdt.h Andrew Victor                    2006-11-30  15  
c1c30a29df7e47 drivers/watchdog/at91sam9_wdt.h            Jean-Christophe PLAGNIOL-VILLARD 2011-11-02  16  #define AT91_WDT_CR		0x00			/* Watchdog Control Register */
70008fc3a14154 drivers/watchdog/at91sam9_wdt.h            Eugen Hristev                    2019-11-11  17  #define  AT91_WDT_WDRSTT	BIT(0)			/* Restart */
0e5f82dda5e60a include/asm-arm/arch-at91/at91_wdt.h       Andrew Victor                    2007-05-31 @18  #define  AT91_WDT_KEY		(0xa5 << 24)		/* KEY Password */
eaa595cb881bba include/asm-arm/arch-at91rm9200/at91_wdt.h Andrew Victor                    2006-11-30  19  

:::::: The code at line 18 was first introduced by commit
:::::: 0e5f82dda5e60a21cf8ba4f77334d60290277d2c [ARM] 4421/1: AT91: Value of _KEY fields.

:::::: TO: Andrew Victor <andrew@sanpeople.com>
:::::: CC: Russell King <rmk+kernel@arm.linux.org.uk>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54928 bytes --]

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

* Re: [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions
  2019-11-12 13:47 ` [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Guenter Roeck
@ 2019-11-14 11:34   ` Eugen.Hristev
  2019-11-14 16:08     ` Guenter Roeck
  0 siblings, 1 reply; 8+ messages in thread
From: Eugen.Hristev @ 2019-11-14 11:34 UTC (permalink / raw)
  To: linux, robh+dt, wim, Nicolas.Ferre, alexandre.belloni,
	linux-watchdog, devicetree, linux-arm-kernel, linux-kernel



On 12.11.2019 15:47, Guenter Roeck wrote:

> 
> On 11/11/19 4:13 AM, Eugen.Hristev@microchip.com wrote:
>> From: Eugen Hristev <eugen.hristev@microchip.com>
>>
>> Cleanup the macro definitions to use BIT and align with two spaces.
>>
>> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
>> ---
>> Changes in v3:
>> - new patch as requested from review on ML
>>
>>   drivers/watchdog/at91sam9_wdt.h | 30 +++++++++++++++---------------
>>   1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/watchdog/at91sam9_wdt.h 
>> b/drivers/watchdog/at91sam9_wdt.h
>> index 390941c..2ca5fc5 100644
>> --- a/drivers/watchdog/at91sam9_wdt.h
>> +++ b/drivers/watchdog/at91sam9_wdt.h
>> @@ -14,23 +14,23 @@
>>   #define AT91_WDT_H
>>   #define AT91_WDT_CR        0x00            /* Watchdog Control 
>> Register */
>> -#define        AT91_WDT_WDRSTT        (1    << 0)        /* Restart */
>> -#define        AT91_WDT_KEY        (0xa5 << 24)        /* KEY 
>> Password */
>> +#define  AT91_WDT_WDRSTT    BIT(0)            /* Restart */
> 
> Using BIT() requires including linux/bits.h.


Hi Guenter,

The C files include/will include the bits.h as the drivers use this 
definition header, or, you have something else in mind ?

Thanks,
Eugen

> 
>> +#define  AT91_WDT_KEY        (0xa5 << 24)        /* KEY Password */
>>   #define AT91_WDT_MR        0x04            /* Watchdog Mode Register */
>> -#define        AT91_WDT_WDV        (0xfff << 0)        /* Counter 
>> Value */
>> -#define            AT91_WDT_SET_WDV(x)    ((x) & AT91_WDT_WDV)
>> -#define        AT91_WDT_WDFIEN        (1     << 12)        /* Fault 
>> Interrupt Enable */
>> -#define        AT91_WDT_WDRSTEN    (1     << 13)        /* Reset 
>> Processor */
>> -#define        AT91_WDT_WDRPROC    (1     << 14)        /* Timer 
>> Restart */
>> -#define        AT91_WDT_WDDIS        (1     << 15)        /* Watchdog 
>> Disable */
>> -#define        AT91_WDT_WDD        (0xfff << 16)        /* Delta 
>> Value */
>> -#define            AT91_WDT_SET_WDD(x)    (((x) << 16) & AT91_WDT_WDD)
>> -#define        AT91_WDT_WDDBGHLT    (1     << 28)        /* Debug 
>> Halt */
>> -#define        AT91_WDT_WDIDLEHLT    (1     << 29)        /* Idle 
>> Halt */
>> +#define  AT91_WDT_WDV        (0xfff << 0)        /* Counter Value */
>> +#define  AT91_WDT_SET_WDV(x)    ((x) & AT91_WDT_WDV)
>> +#define  AT91_WDT_WDFIEN    BIT(12)        /* Fault Interrupt Enable */
>> +#define  AT91_WDT_WDRSTEN    BIT(13)        /* Reset Processor */
>> +#define  AT91_WDT_WDRPROC    BIT(14)        /* Timer Restart */
>> +#define  AT91_WDT_WDDIS        BIT(15)        /* Watchdog Disable */
>> +#define  AT91_WDT_WDD        (0xfff << 16)        /* Delta Value */
>> +#define  AT91_WDT_SET_WDD(x)    (((x) << 16) & AT91_WDT_WDD)
>> +#define  AT91_WDT_WDDBGHLT    BIT(28)        /* Debug Halt */
>> +#define  AT91_WDT_WDIDLEHLT    BIT(29)        /* Idle Halt */
>> -#define AT91_WDT_SR        0x08            /* Watchdog Status 
>> Register */
>> -#define        AT91_WDT_WDUNF        (1 << 0)        /* Watchdog 
>> Underflow */
>> -#define        AT91_WDT_WDERR        (1 << 1)        /* Watchdog 
>> Error */
>> +#define AT91_WDT_SR        0x08        /* Watchdog Status Register */
>> +#define  AT91_WDT_WDUNF        BIT(0)        /* Watchdog Underflow */
>> +#define  AT91_WDT_WDERR        BIT(1)        /* Watchdog Error */
>>   #endif
>>
> 

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

* Re: [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions
  2019-11-14 11:34   ` Eugen.Hristev
@ 2019-11-14 16:08     ` Guenter Roeck
  0 siblings, 0 replies; 8+ messages in thread
From: Guenter Roeck @ 2019-11-14 16:08 UTC (permalink / raw)
  To: Eugen.Hristev
  Cc: robh+dt, wim, Nicolas.Ferre, alexandre.belloni, linux-watchdog,
	devicetree, linux-arm-kernel, linux-kernel

On Thu, Nov 14, 2019 at 11:34:31AM +0000, Eugen.Hristev@microchip.com wrote:
> 
> 
> On 12.11.2019 15:47, Guenter Roeck wrote:
> 
> > 
> > On 11/11/19 4:13 AM, Eugen.Hristev@microchip.com wrote:
> >> From: Eugen Hristev <eugen.hristev@microchip.com>
> >>
> >> Cleanup the macro definitions to use BIT and align with two spaces.
> >>
> >> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
> >> ---
> >> Changes in v3:
> >> - new patch as requested from review on ML
> >>
> >>   drivers/watchdog/at91sam9_wdt.h | 30 +++++++++++++++---------------
> >>   1 file changed, 15 insertions(+), 15 deletions(-)
> >>
> >> diff --git a/drivers/watchdog/at91sam9_wdt.h 
> >> b/drivers/watchdog/at91sam9_wdt.h
> >> index 390941c..2ca5fc5 100644
> >> --- a/drivers/watchdog/at91sam9_wdt.h
> >> +++ b/drivers/watchdog/at91sam9_wdt.h
> >> @@ -14,23 +14,23 @@
> >>   #define AT91_WDT_H
> >>   #define AT91_WDT_CR        0x00            /* Watchdog Control 
> >> Register */
> >> -#define        AT91_WDT_WDRSTT        (1    << 0)        /* Restart */
> >> -#define        AT91_WDT_KEY        (0xa5 << 24)        /* KEY 
> >> Password */
> >> +#define  AT91_WDT_WDRSTT    BIT(0)            /* Restart */
> > 
> > Using BIT() requires including linux/bits.h.
> 
> 
> Hi Guenter,
> 
> The C files include/will include the bits.h as the drivers use this 
> definition header, or, you have something else in mind ?
> 
You are supposed to include the file where it is used. If the C file
uses it again, it will need to include it again.

Guenter

> Thanks,
> Eugen
> 
> > 
> >> +#define  AT91_WDT_KEY        (0xa5 << 24)        /* KEY Password */
> >>   #define AT91_WDT_MR        0x04            /* Watchdog Mode Register */
> >> -#define        AT91_WDT_WDV        (0xfff << 0)        /* Counter 
> >> Value */
> >> -#define            AT91_WDT_SET_WDV(x)    ((x) & AT91_WDT_WDV)
> >> -#define        AT91_WDT_WDFIEN        (1     << 12)        /* Fault 
> >> Interrupt Enable */
> >> -#define        AT91_WDT_WDRSTEN    (1     << 13)        /* Reset 
> >> Processor */
> >> -#define        AT91_WDT_WDRPROC    (1     << 14)        /* Timer 
> >> Restart */
> >> -#define        AT91_WDT_WDDIS        (1     << 15)        /* Watchdog 
> >> Disable */
> >> -#define        AT91_WDT_WDD        (0xfff << 16)        /* Delta 
> >> Value */
> >> -#define            AT91_WDT_SET_WDD(x)    (((x) << 16) & AT91_WDT_WDD)
> >> -#define        AT91_WDT_WDDBGHLT    (1     << 28)        /* Debug 
> >> Halt */
> >> -#define        AT91_WDT_WDIDLEHLT    (1     << 29)        /* Idle 
> >> Halt */
> >> +#define  AT91_WDT_WDV        (0xfff << 0)        /* Counter Value */
> >> +#define  AT91_WDT_SET_WDV(x)    ((x) & AT91_WDT_WDV)
> >> +#define  AT91_WDT_WDFIEN    BIT(12)        /* Fault Interrupt Enable */
> >> +#define  AT91_WDT_WDRSTEN    BIT(13)        /* Reset Processor */
> >> +#define  AT91_WDT_WDRPROC    BIT(14)        /* Timer Restart */
> >> +#define  AT91_WDT_WDDIS        BIT(15)        /* Watchdog Disable */
> >> +#define  AT91_WDT_WDD        (0xfff << 16)        /* Delta Value */
> >> +#define  AT91_WDT_SET_WDD(x)    (((x) << 16) & AT91_WDT_WDD)
> >> +#define  AT91_WDT_WDDBGHLT    BIT(28)        /* Debug Halt */
> >> +#define  AT91_WDT_WDIDLEHLT    BIT(29)        /* Idle Halt */
> >> -#define AT91_WDT_SR        0x08            /* Watchdog Status 
> >> Register */
> >> -#define        AT91_WDT_WDUNF        (1 << 0)        /* Watchdog 
> >> Underflow */
> >> -#define        AT91_WDT_WDERR        (1 << 1)        /* Watchdog 
> >> Error */
> >> +#define AT91_WDT_SR        0x08        /* Watchdog Status Register */
> >> +#define  AT91_WDT_WDUNF        BIT(0)        /* Watchdog Underflow */
> >> +#define  AT91_WDT_WDERR        BIT(1)        /* Watchdog Error */
> >>   #endif
> >>
> > 

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

end of thread, other threads:[~2019-11-14 16:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 12:13 [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Eugen.Hristev
2019-11-11 12:13 ` [PATCH v3 2/3] dt-bindings: watchdog: sama5d4_wdt: add microchip,sam9x60-wdt compatible Eugen.Hristev
2019-11-11 12:13 ` [PATCH v3 3/3] watchdog: sama5d4_wdt: addition of sam9x60 compatible watchdog Eugen.Hristev
2019-11-12 14:01   ` Guenter Roeck
2019-11-12 13:47 ` [PATCH v3 1/3] watchdog: sama5d4_wdt: cleanup the bit definitions Guenter Roeck
2019-11-14 11:34   ` Eugen.Hristev
2019-11-14 16:08     ` Guenter Roeck
2019-11-12 21:24 ` kbuild test robot

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).