arm: at91: wdt: Remove unused at91_wdt struct
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/7 arm: at91: wdt: Remove unused at91_wdt struct
at91_wdt struct is not used by anyone, let's remove it.
--- arch/arm/mach-at91/include/mach/at91_wdt.h | 6 ------ 1 file changed, 6 deletions(-)
arch/arm/mach-at91/include/mach/at91_wdt.h +0 -6
@@ -19,12 +19,6 @@ #else -typedef struct at91_wdt { - u32 cr; - u32 mr; - u32 sr; -} at91_wdt_t; - struct at91_wdt_priv { void __iomem *regs; u32 regval;
Signature · 1 line
2.49.0
cover watchdog: at91sam9_wdt driver enhancement
It looks like cover letter was missing...
This patch series includes some code refactor and adds new device support for at91sam9_wdt driver.
Instead of add a new driver like Linux kernel, at91sam9_wdt driver is extended as new watchdog variant is similar to existing one, especially for the function subset used by u-boot.
1. Remove unused typedef and rename variables for readability.
2. Add SAMA5D4 compatible, it has the same watchdog as SAM9260 except a new lockout feature is added. Currently this feature is unimplemented.
3. SAM9X60, SAM9X7 and SAMA7 series have a new watchdog variant, some bitfields bof MR register shifted their position, a new register is added for timer value.
4. Add DT node to SAM9X60-Currently board
It has been tested on SAM9X60-Currently board:
- Start & stop
- Set timeout from DT node
- Reset kick in with a while(1) loop
Zixun LI (7):
arm: at91: wdt: Remove unused at91_wdt struct
arm: at91: wdt: Rename regval in priv data to mr
watchdog: at91sam9_wdt: Rename priv to wdt
arm: at91: wdt: Add SAM9X60 register definition
watchdog: at91sam9_wdt: Add SAM9X60 support
ARM: dts: sam9x60: Add watchdog DT node.
ARM: dts: at91: sam9x60-curiosity: Enable watchdog node
arch/arm/dts/at91-sam9x60_curiosity.dts | 5 ++ arch/arm/dts/sam9x60.dtsi | 7 +++ arch/arm/mach-at91/include/mach/at91_wdt.h | 25 ++++++---- drivers/watchdog/at91sam9_wdt.c | 55 +++++++++++++++------- 4 files changed, 68 insertions(+), 24 deletions(-)
--
2.49.0
Quoted 14 lines · Zixun LI
at91_wdtstruct is not used by anyone, let's remove it.Signed-off-by Zixun LI <[email protected]>--- arch/arm/mach-at91/include/mach/at91_wdt.h | 6 ------ 1 file changed, 6 deletions(-)arch/arm/mach-at91/include/mach/at91_wdt.h +0
-0@@ -19,12 +19,6 @@#else
arch/arm/mach-at91/include/mach/at91_wdt.h line 24
Quoted 10 lines
arch/arm/mach-at91/include/mach/at91_wdt.h +0
-6-typedef struct at91_wdt { -u32 cr; -u32 mr; -u32 sr; -}at91_wdt_t ; -struct at91_wdt_priv {void __iomem *regs;u32 regval;
This breaks sama5d2_xplained_mmc_defconfig for example.
In file included from arch/arm/mach-at91/spl.c:8:arch/arm/mach-at91/spl.c: In function ‘at91_disable_wdt’:arch/arm/mach-at91/spl.c:19:39: error: invalid use of undefined type ‘struct at91_wdt’
19 | writel(AT91_WDT_MR_WDDIS, &wdt->mr);
| ^~./arch/arm/include/asm/io.h:31:69: note: in definition of macro ‘__arch_putl’
31 | #define __arch_putl(v,a) (*(volatile unsigned int
*)(a) = (v))
|
^
arch/arm/mach-at91/spl.c:19:9: note: in expansion of macro ‘writel’
19 | writel(AT91_WDT_MR_WDDIS, &wdt->mr);
| ^~~~~~Quoted 13 lines · Eugen Hristev
This breaks
sama5d2_xplained_mmc_defconfigfor example.In file included from
arch/arm/mach-at91/spl.c:8:arch/arm/mach-at91/spl.c: In function ‘at91_disable_wdt’:arch/arm/mach-at91/spl.c:19:39: error: invalid use of undefined type ‘struct at91_wdt’
19 |writel(AT91_WDT_MR_WDDIS, &wdt->mr);
| ^~./arch/arm/include/asm/io.h:31:69: note: in definition of macro ‘__arch_putl’
31 | #define__arch_putl(v,a)(*(volatile unsigned int
*)(a) = (v))
Quoted 6 lines
|
^
arch/arm/mach-at91/spl.c:19:9: note: in expansion of macro ‘writel’
19 | writel(AT91_WDT_MR_WDDIS, &wdt->mr);
| ^~~~~~Thank you for the spot. I can add a patch like this:
#if !defined(CONFIG_WDT_AT91)
void at91_disable_wdt(void)
{
- struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT;
-
- writel(AT91_WDT_MR_WDDIS, &wdt->mr);
+#if defined(CONFIG_SAM9X60)
+ writel(AT91_SAM9X60_MR_WDDIS, ATMEL_BASE_WDT + AT91_WDT_MR);
+#else
+ writel(AT91_WDT_MR_WDDIS, ATMEL_BASE_WDT + AT91_WDT_MR);
+#endif
}
#endif
Zixun
PATCH 2/7 arm: at91: wdt: Rename regval in priv data to mr
In reply to a message not in the archiveUse the name "mr" since we are referring to timer mode register.
--- arch/arm/mach-at91/include/mach/at91_wdt.h | 2 +- drivers/watchdog/at91sam9_wdt.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/mach-at91/include/mach/at91_wdt.h +1 -1
@@ -21,7 +21,7 @@struct at91_wdt_priv {void __iomem *regs; -u32 regval; +u32 mr; };#endif
drivers/watchdog/at91sam9_wdt.c +4 -4
@@ -60,11 +60,11 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)* Since WDV is a 12-bit counter, the maximum period is * 4096 / 256 = 16 seconds. */ - priv->regval =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ + priv->mr =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ |AT91_WDT_MR_WDDBGHLT /* disabled in debug mode */ |AT91_WDT_MR_WDD (0xfff )/* restart at any time */ |AT91_WDT_MR_WDV (ticks);/* timer value */ -writel (priv->regval, priv->regs +AT91_WDT_MR ); +writel (priv->mr, priv->regs +AT91_WDT_MR );return 0 ; }
@@ -74,8 +74,8 @@ static int at91_wdt_stop(struct udevice *dev)struct at91_wdt_priv *priv =dev_get_priv (dev);/* Disable Watchdog Timer */ - priv->regval |=AT91_WDT_MR_WDDIS ; -writel (priv->regval, priv->regs +AT91_WDT_MR ); + priv->mr |=AT91_WDT_MR_WDDIS ; +writel (priv->mr, priv->regs +AT91_WDT_MR );return 0 ; }
Signature · 1 line
2.49.0
PATCH 3/7 watchdog: at91sam9_wdt: Rename priv to wdt
In reply to a message not in the archive"wdt" is a better name for watchdog rather than generic "priv".
--- drivers/watchdog/at91sam9_wdt.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/watchdog/at91sam9_wdt.c +12 -12
@@ -38,7 +38,7 @@ DECLARE_GLOBAL_DATA_PTR;*/ static int at91_wdt_start (struct udevice *dev,u64 timeout_ms,ulong flags) { -struct at91_wdt_priv *priv =dev_get_priv (dev); +struct at91_wdt_priv *wdt =dev_get_priv (dev);u64 timeout;u32 ticks;
@@ -49,7 +49,7 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) ticks =WDT_SEC2TICKS (timeout);/* Check if disabled */ -if (readl (priv->regs +AT91_WDT_MR ) &AT91_WDT_MR_WDDIS ) { +if (readl (wdt->regs +AT91_WDT_MR ) &AT91_WDT_MR_WDDIS ) {printf ("sorry, watchdog is disabled\n" );return -1 ; }
@@ -60,31 +60,31 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)* Since WDV is a 12-bit counter, the maximum period is * 4096 / 256 = 16 seconds. */ - priv->mr =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ + wdt->mr =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ |AT91_WDT_MR_WDDBGHLT /* disabled in debug mode */ |AT91_WDT_MR_WDD (0xfff )/* restart at any time */ |AT91_WDT_MR_WDV (ticks);/* timer value */ -writel (priv->mr, priv->regs +AT91_WDT_MR ); +writel (wdt->mr, wdt->regs +AT91_WDT_MR );return 0 ; }static int at91_wdt_stop (struct udevice *dev) { -struct at91_wdt_priv *priv =dev_get_priv (dev); +struct at91_wdt_priv *wdt =dev_get_priv (dev);/* Disable Watchdog Timer */ - priv->mr |=AT91_WDT_MR_WDDIS ; -writel (priv->mr, priv->regs +AT91_WDT_MR ); + wdt->mr |=AT91_WDT_MR_WDDIS ; +writel (wdt->mr, wdt->regs +AT91_WDT_MR );return 0 ; }static int at91_wdt_reset (struct udevice *dev) { -struct at91_wdt_priv *priv =dev_get_priv (dev); +struct at91_wdt_priv *wdt =dev_get_priv (dev); -writel (AT91_WDT_CR_WDRSTT |AT91_WDT_CR_KEY , priv->regs +AT91_WDT_CR ); +writel (AT91_WDT_CR_WDRSTT |AT91_WDT_CR_KEY , wdt->regs +AT91_WDT_CR );return 0 ; }
@@ -102,10 +102,10 @@ static const struct udevice_id at91_wdt_ids[] = {static int at91_wdt_probe (struct udevice *dev) { -struct at91_wdt_priv *priv =dev_get_priv (dev); +struct at91_wdt_priv *wdt =dev_get_priv (dev); - priv->regs =dev_remap_addr (dev); -if (!priv->regs) + wdt->regs =dev_remap_addr (dev); +if (!wdt->regs)return -EINVAL ;debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));
Signature · 1 line
2.49.0
PATCH 4/7 arm: at91: wdt: Add SAM9X60 register definition
In reply to a message not in the archiveSAM9X60 has different watchdog register definition.
--- arch/arm/mach-at91/include/mach/at91_wdt.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
arch/arm/mach-at91/include/mach/at91_wdt.h +10 -2
@@ -33,14 +33,22 @@ struct at91_wdt_priv {/* Watchdog Mode Register*/ #define AT91_WDT_MR 0X04 -#define AT91_WDT_MR_WDV (x) (x & 0xfff) +#define AT91_WDT_MR_WDV (x) ((x) & 0xfff) +#define AT91_SAM9X60_MR_PERIODRST 0x00000010#define AT91_WDT_MR_WDFIEN 0x00001000 +#define AT91_SAM9X60_MR_WDDIS 0x00001000#define AT91_WDT_MR_WDRSTEN 0x00002000#define AT91_WDT_MR_WDRPROC 0x00004000#define AT91_WDT_MR_WDDIS 0x00008000 -#define AT91_WDT_MR_WDD (x) ((x & 0xfff) << 16) +#define AT91_WDT_MR_WDD (x) (((x) & 0xfff) << 16)#define AT91_WDT_MR_WDDBGHLT 0x10000000 +#define AT91_SAM9X60_MR_WDIDLEHLT 0x10000000#define AT91_WDT_MR_WDIDLEHLT 0x20000000 +#define AT91_SAM9X60_MR_WDDBGHLT 0x20000000 + +/* Watchdog Window Level Register */ +#define AT91_SAM9X60_WLR 0x0c +#define AT91_SAM9X60_WLR_COUNTER (x) ((x) & 0xfff)/* Hardware timeout in seconds */ #define WDT_MAX_TIMEOUT 16
Signature · 1 line
2.49.0
PATCH 5/7 watchdog: at91sam9_wdt: Add SAM9X60 support
In reply to a message not in the archiveSAM9X60 has a slightly different watchdog implementation:
- Timer value moved into a new register WLR
- Some MR register fields have their position changed
This patch add SAM9X60 support, also adds a compatible for SAMA5D4 who is the same as existing SAM9260.
--- arch/arm/mach-at91/include/mach/at91_wdt.h | 7 ++++ drivers/watchdog/at91sam9_wdt.c | 39 +++++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-)
arch/arm/mach-at91/include/mach/at91_wdt.h +7 -0
@@ -19,9 +19,16 @@#else +enum { +AT91_WDT_MODE_SAM9260 =0 , +AT91_WDT_MODE_SAM9X60 =1 +}; +struct at91_wdt_priv {void __iomem *regs;u32 mr; +u32 wddis; +u8 mode; };#endif
drivers/watchdog/at91sam9_wdt.c +31 -8
@@ -49,7 +49,7 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags) ticks =WDT_SEC2TICKS (timeout);/* Check if disabled */ -if (readl (wdt->regs +AT91_WDT_MR ) &AT91_WDT_MR_WDDIS ) { +if (readl (wdt->regs +AT91_WDT_MR ) & wdt->wddis) {printf ("sorry, watchdog is disabled\n" );return -1 ; }
@@ -60,11 +60,21 @@ static int at91_wdt_start(struct udevice *dev, u64 timeout_ms, ulong flags)* Since WDV is a 12-bit counter, the maximum period is * 4096 / 256 = 16 seconds. */ - wdt->mr =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ - |AT91_WDT_MR_WDDBGHLT /* disabled in debug mode */ - |AT91_WDT_MR_WDD (0xfff )/* restart at any time */ - |AT91_WDT_MR_WDV (ticks);/* timer value */ -writel (wdt->mr, wdt->regs +AT91_WDT_MR ); + +if (wdt->mode ==AT91_WDT_MODE_SAM9260 ) { + wdt->mr =AT91_WDT_MR_WDRSTEN /* causes watchdog reset */ + |AT91_WDT_MR_WDDBGHLT /* disabled in debug mode */ + |AT91_WDT_MR_WDD (0xfff )/* restart at any time */ + |AT91_WDT_MR_WDV (ticks);/* timer value */ +writel (wdt->mr, wdt->regs +AT91_WDT_MR ); + }else if (wdt->mode ==AT91_WDT_MODE_SAM9X60 ) { +writel (AT91_SAM9X60_WLR_COUNTER (ticks),/* timer value */ + wdt->regs +AT91_SAM9X60_WLR ); + + wdt->mr =AT91_SAM9X60_MR_PERIODRST /* causes watchdog reset */ + |AT91_SAM9X60_MR_WDDBGHLT ;/* disabled in debug mode */ +writel (wdt->mr, wdt->regs +AT91_WDT_MR ); + }return 0 ; }
@@ -74,7 +84,7 @@ static int at91_wdt_stop(struct udevice *dev)struct at91_wdt_priv *wdt =dev_get_priv (dev);/* Disable Watchdog Timer */ - wdt->mr |=AT91_WDT_MR_WDDIS ; + wdt->mr |= wdt->wddis;writel (wdt->mr, wdt->regs +AT91_WDT_MR );return 0 ;
@@ -96,7 +106,14 @@ static const struct wdt_ops at91_wdt_ops = { };static const struct udevice_id at91_wdt_ids[] = { - { .compatible ="atmel,at91sam9260-wdt" }, + { .compatible ="atmel,at91sam9260-wdt" , + .data =AT91_WDT_MODE_SAM9260 }, + { .compatible ="atmel,sama5d4-wdt" , + .data =AT91_WDT_MODE_SAM9260 }, + { .compatible ="microchip,sam9x60-wdt" , + .data =AT91_WDT_MODE_SAM9X60 }, + { .compatible ="microchip,sama7g5-wdt" , + .data =AT91_WDT_MODE_SAM9X60 }, {} };
@@ -108,6 +125,12 @@ static int at91_wdt_probe(struct udevice *dev)if (!wdt->regs)return -EINVAL ; + wdt->mode =dev_get_driver_data (dev); +if (wdt->mode ==AT91_WDT_MODE_SAM9260 ) + wdt->wddis =AT91_WDT_MR_WDDIS ; +else if (wdt->mode ==AT91_WDT_MODE_SAM9X60 ) + wdt->wddis =AT91_SAM9X60_MR_WDDIS ; +debug ("%s: Probing wdt%u\n" , __func__,dev_seq (dev));return 0 ;
Signature · 1 line
2.49.0
PATCH 6/7 ARM: dts: sam9x60: Add watchdog DT node.
In reply to a message not in the archiveAdd the watchdog timer node for the sam9x60 SoC's.
--- arch/arm/dts/sam9x60.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/dts/sam9x60.dtsi +7 -0
@@ -333,6 +333,13 @@ clocks = <&slow_rc_osc>, <&slow_xtal>; #clock-cells = <1>; }; + + watchdog: watchdog@ffffff80 { + compatible = "microchip,sam9x60-wdt"; + reg = <0xffffff80 0x24>; + clocks = <&clk32 0>; + status = "disabled"; + }; }; };
Signature · 1 line
2.49.0
PATCH 7/7 ARM: dts: at91: sam9x60-curiosity: Enable watchdog node
In reply to a message not in the archiveEnable watchdog node on SAM9X60-Curiosity board.
--- arch/arm/dts/at91-sam9x60_curiosity.dts | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm/dts/at91-sam9x60_curiosity.dts +5 -0
@@ -248,6 +248,11 @@ }; }; +&watchdog { + status = "okay"; + timeout-sec = <16>; +}; + &usb1 { num-ports = <3>; atmel,vbus-gpio = <0
Signature · 1 line
2.49.0