public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Maxim Sloyko <maxims@google.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 02/12] aspeed: Add support for Watchdot Timer
Date: Wed,  4 Jan 2017 11:46:46 -0800	[thread overview]
Message-ID: <20170104194656.124368-3-maxims@google.com> (raw)
In-Reply-To: <20170104194656.124368-1-maxims@google.com>

The driver is compatible with AST2400 and AST2500 watchdogs.
There is no uclass for Watchdog yet, so the driver does not follow
the driver model. It also uses fixed clock, so no clock driver
is needed.

# Conflicts:
#	arch/arm/mach-aspeed/Makefile

Signed-off-by: Maxim Sloyko <maxims@google.com>
---

 arch/arm/include/asm/arch-aspeed/wdt.h | 89 ++++++++++++++++++++++++++++++++++
 arch/arm/mach-aspeed/Makefile          |  3 +-
 arch/arm/mach-aspeed/ast_wdt.c         | 44 +++++++++++++++++
 3 files changed, 134 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-aspeed/wdt.h
 create mode 100644 arch/arm/mach-aspeed/ast_wdt.c

diff --git a/arch/arm/include/asm/arch-aspeed/wdt.h b/arch/arm/include/asm/arch-aspeed/wdt.h
new file mode 100644
index 0000000000..32774b1a70
--- /dev/null
+++ b/arch/arm/include/asm/arch-aspeed/wdt.h
@@ -0,0 +1,89 @@
+/*
+ * (C) Copyright 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#ifndef _ASM_ARCH_WDT_H
+#define _ASM_ARCH_WDT_H
+
+#define WDT_BASE			0x1e785000
+
+/*
+ * Special value that needs to be written to counter_restart register to
+ * (re)start the timer
+ */
+#define WDT_COUNTER_RESTART_VAL		0x4755
+
+/* Control register */
+#define WDT_CTRL_RESET_MODE_SHIFT	5
+#define WDT_CTRL_RESET_MODE_MASK	3
+
+#define WDT_CTRL_EN			(1 << 0)
+#define WDT_CTRL_RESET			(1 << 1)
+#define WDT_CTRL_CLK1MHZ		(1 << 4)
+#define WDT_CTRL_2ND_BOOT		(1 << 7)
+
+/* Values for Reset Mode */
+#define WDT_CTRL_RESET_SOC		0
+#define WDT_CTRL_RESET_CHIP		1
+#define WDT_CTRL_RESET_CPU		2
+#define WDT_CTRL_RESET_MASK		3
+
+/* Reset Mask register */
+#define WDT_RESET_ARM			(1 << 0)
+#define WDT_RESET_COPROC		(1 << 1)
+#define WDT_RESET_SDRAM			(1 << 2)
+#define WDT_RESET_AHB			(1 << 3)
+#define WDT_RESET_I2C			(1 << 4)
+#define WDT_RESET_MAC1			(1 << 5)
+#define WDT_RESET_MAC2			(1 << 6)
+#define WDT_RESET_GCRT			(1 << 7)
+#define WDT_RESET_USB20			(1 << 8)
+#define WDT_RESET_USB11_HOST		(1 << 9)
+#define WDT_RESET_USB11_EHCI2		(1 << 10)
+#define WDT_RESET_VIDEO			(1 << 11)
+#define WDT_RESET_HAC			(1 << 12)
+#define WDT_RESET_LPC			(1 << 13)
+#define WDT_RESET_SDSDIO		(1 << 14)
+#define WDT_RESET_MIC			(1 << 15)
+#define WDT_RESET_CRT2C			(1 << 16)
+#define WDT_RESET_PWM			(1 << 17)
+#define WDT_RESET_PECI			(1 << 18)
+#define WDT_RESET_JTAG			(1 << 19)
+#define WDT_RESET_ADC			(1 << 20)
+#define WDT_RESET_GPIO			(1 << 21)
+#define WDT_RESET_MCTP			(1 << 22)
+#define WDT_RESET_XDMA			(1 << 23)
+#define WDT_RESET_SPI			(1 << 24)
+#define WDT_RESET_MISC			(1 << 25)
+
+#ifndef __ASSEMBLY__
+struct ast_wdt {
+	u32 counter_status;
+	u32 counter_reload_val;
+	u32 counter_restart;
+	u32 ctrl;
+	u32 timeout_status;
+	u32 clr_timeout_status;
+	u32 reset_width;
+#ifdef CONFIG_ASPEED_AST2500
+	u32 reset_mask;
+#else
+	u32 reserved0;
+#endif
+};
+
+void wdt_stop(struct ast_wdt *wdt);
+void wdt_start(struct ast_wdt *wdt, u32 timeout);
+
+/**
+ * ast_get_wdt() - get a pointer to watchdog registers
+ *
+ * @wdt_number: 0-based WDT peripheral number
+ * @return pointer to registers or -ve error on error
+ */
+struct ast_wdt *ast_get_wdt(u8 wdt_number);
+#endif  /* __ASSEMBLY__ */
+
+#endif /* _ASM_ARCH_WDT_H */
diff --git a/arch/arm/mach-aspeed/Makefile b/arch/arm/mach-aspeed/Makefile
index 8e276b4a9f..a14b8f751d 100644
--- a/arch/arm/mach-aspeed/Makefile
+++ b/arch/arm/mach-aspeed/Makefile
@@ -1,8 +1,7 @@
 #
-# Copyright (c) 2014 Google, Inc
+# Copyright (c) 2016 Google, Inc
 #
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
 obj-$(CONFIG_ARCH_ASPEED) += ast_wdt.o
-obj-$(CONFIG_ASPEED_AST2500) += ast2500/ ast2500-board.o
diff --git a/arch/arm/mach-aspeed/ast_wdt.c b/arch/arm/mach-aspeed/ast_wdt.c
new file mode 100644
index 0000000000..0b62abc455
--- /dev/null
+++ b/arch/arm/mach-aspeed/ast_wdt.c
@@ -0,0 +1,44 @@
+/*
+ * (C) Copyright 2016 Google, Inc
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/arch/wdt.h>
+#include <asm/io.h>
+#include <linux/err.h>
+
+/* Number of available watchdog timers */
+#ifdef CONFIG_ASPEED_AST2500
+#define WDT_MAX_NUM			2
+#else
+#define WDT_MAX_NUM			1
+#endif
+
+void wdt_stop(struct ast_wdt *wdt)
+{
+	clrbits_le32(&wdt->ctrl, WDT_CTRL_EN);
+}
+
+void wdt_start(struct ast_wdt *wdt, u32 timeout)
+{
+	writel(timeout, &wdt->counter_reload_val);
+	writel(WDT_COUNTER_RESTART_VAL, &wdt->counter_restart);
+	/*
+	 * Setting CLK1MHZ bit is just for compatibility with ast2400 part.
+	 * On ast2500 watchdog timer clock is fixed at 1MHz and the bit is
+	 * read-only
+	 */
+	setbits_le32(&wdt->ctrl,
+		     WDT_CTRL_EN | WDT_CTRL_RESET | WDT_CTRL_CLK1MHZ);
+}
+
+struct ast_wdt *ast_get_wdt(u8 wdt_number)
+{
+	if (wdt_number > WDT_MAX_NUM)
+		return ERR_PTR(-EINVAL);
+
+	return (struct ast_wdt *)(WDT_BASE +
+				  sizeof(struct ast_wdt) * wdt_number);
+}
-- 
2.11.0.390.gc69c2f50cf-goog

  parent reply	other threads:[~2017-01-04 19:46 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-04 19:46 [U-Boot] [PATCH 00/12] arm: aspeed: Basic support for Aspeed AST2500 part and eval board Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 01/12] aspeed: Add mach-aspeed directory and basic Kconfig Maxim Sloyko
2017-01-04 19:58   ` Rick Altherr
2017-01-04 20:23     ` Tom Rini
2017-01-14 17:13   ` Simon Glass
2017-01-18  0:15     ` Maxim Sloyko
2017-01-04 19:46 ` Maxim Sloyko [this message]
2017-01-04 20:58   ` [U-Boot] [PATCH 02/12] aspeed: Add support for Watchdot Timer Tom Rini
2017-01-14 17:13   ` Simon Glass
2017-01-04 19:46 ` [U-Boot] [PATCH 03/12] aspeed: Add Timer Support Maxim Sloyko
2017-01-04 20:58   ` Tom Rini
2017-01-14 17:13   ` Simon Glass
2017-01-17 17:57     ` Maxim Sloyko
2017-01-17 21:37       ` Simon Glass
2017-01-17 23:59     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 04/12] aspeed: Add sysreset driver Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-04 19:46 ` [U-Boot] [PATCH 05/12] aspeed/ast2500: Device Tree and bindings for some of the clocks Maxim Sloyko
2017-01-04 20:58   ` Tom Rini
2017-01-05  1:18     ` Maxim Sloyko
2017-01-05  3:26       ` Tom Rini
2017-01-05 22:20         ` Maxim Sloyko
2017-01-14 17:13           ` Simon Glass
2017-01-17 23:27             ` Maxim Sloyko
2017-01-21  3:52               ` Simon Glass
2017-01-23 17:52                 ` Maxim Sloyko
2017-01-23 19:51                   ` Simon Glass
2017-01-04 19:46 ` [U-Boot] [PATCH 06/12] aspeed/ast2500: Add Clock Driver Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 23:18     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 07/12] aspeed/ast2500: Helper function to get access to SCU Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 22:27     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 08/12] aspeed/ast2500: Add SDRAM MC driver Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-18 20:16     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 09/12] aspeed/ast2500: Common board init functions for ast2500 based boards Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 20:17     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 10/12] aspeed: Common configuration parameters for aspeed boards Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 20:02     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 11/12] aspeed: Device Tree for ast2500 Eval Board Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 19:51     ` Maxim Sloyko
2017-01-04 19:46 ` [U-Boot] [PATCH 12/12] aspeed: Configuration for ast2500 eval board Maxim Sloyko
2017-01-14 17:14   ` Simon Glass
2017-01-17 19:46     ` Maxim Sloyko
2017-01-21  3:51       ` Simon Glass
2017-01-04 20:26 ` [U-Boot] [PATCH 00/12] arm: aspeed: Basic support for Aspeed AST2500 part and " Tom Rini
2017-01-04 22:47   ` Maxim Sloyko
2017-01-04 20:58 ` Tom Rini
2017-01-05 22:42 ` [U-Boot] [PATCH v1 0/4] " Maxim Sloyko
2017-01-05 22:42   ` [U-Boot] [PATCH v1 1/4] aspeed: Add drivers common to all Aspeed SoCs Maxim Sloyko
2017-01-05 22:42   ` [U-Boot] [PATCH v1 2/4] aspeed: Add basic ast2500 specific drivers and configuration Maxim Sloyko
2017-01-05 22:42   ` [U-Boot] [PATCH v1 3/4] aspeed: Board init functions and common configs for ast2500 based boards Maxim Sloyko
2017-01-05 22:42   ` [U-Boot] [PATCH v1 4/4] aspeed: Support for ast2500 Eval Board Maxim Sloyko
2017-01-10  1:50   ` [U-Boot] [PATCH v2 0/4] arm: aspeed: Basic support for Aspeed AST2500 part and eval board Maxim Sloyko
2017-01-10  1:50     ` [U-Boot] [PATCH v2 1/4] aspeed: Add drivers common to all Aspeed SoCs Maxim Sloyko
2017-01-11  3:20       ` Tom Rini
2017-01-10  1:50     ` [U-Boot] [PATCH v2 2/4] aspeed: Add basic ast2500 specific drivers and configuration Maxim Sloyko
2017-01-11  3:20       ` Tom Rini
2017-01-10  1:50     ` [U-Boot] [PATCH v2 3/4] aspeed: Board init functions and common configs for ast2500 based boards Maxim Sloyko
2017-01-11  3:20       ` Tom Rini
2017-01-11 23:40         ` Maxim Sloyko
2017-01-10  1:50     ` [U-Boot] [PATCH v2 4/4] aspeed: Support for ast2500 Eval Board Maxim Sloyko
2017-01-11  3:20       ` Tom Rini
2017-01-11 23:45     ` [U-Boot] [PATCH v3 0/4] arm: aspeed: Basic support for Aspeed AST2500 part and eval board Maxim Sloyko
2017-01-11 23:45       ` [U-Boot] [PATCH v3 1/4] aspeed: Add drivers common to all Aspeed SoCs Maxim Sloyko
2017-01-13  0:51         ` Tom Rini
2017-01-11 23:45       ` [U-Boot] [PATCH v3 2/4] aspeed: Add basic ast2500 specific drivers and configuration Maxim Sloyko
2017-01-11 23:45       ` [U-Boot] [PATCH v3 3/4] aspeed: Board init functions and common configs for ast2500 based boards Maxim Sloyko
2017-01-13  0:51         ` Tom Rini
2017-01-11 23:45       ` [U-Boot] [PATCH v3 4/4] aspeed: Support for ast2500 Eval Board Maxim Sloyko
2017-01-13  0:51         ` Tom Rini
2017-01-18 21:44       ` [U-Boot] [PATCH v4 0/4] arm: aspeed: Basic support for Aspeed AST2500 part and eval board Maxim Sloyko
2017-01-18 21:44         ` [U-Boot] [PATCH v4 1/4] aspeed: Add drivers common to all Aspeed SoCs Maxim Sloyko
2017-01-26 14:23           ` Simon Glass
2017-01-26 18:31             ` Maxim Sloyko
2017-01-28 22:44           ` [U-Boot] [U-Boot, v4, " Tom Rini
2017-01-18 21:44         ` [U-Boot] [PATCH v4 2/4] aspeed: Add basic ast2500-specific drivers and configuration Maxim Sloyko
2017-01-26 14:23           ` Simon Glass
2017-01-26 18:02             ` Maxim Sloyko
2017-01-28 22:44           ` [U-Boot] [U-Boot, v4, " Tom Rini
2017-01-18 21:44         ` [U-Boot] [PATCH v4 3/4] aspeed: Board init functions and common configs for ast2500 based boards Maxim Sloyko
2017-01-26 14:23           ` Simon Glass
2017-01-28 22:44           ` [U-Boot] [U-Boot, v4, " Tom Rini
2017-01-18 21:44         ` [U-Boot] [PATCH v4 4/4] aspeed: Support for ast2500 Eval Board Maxim Sloyko
2017-01-26 14:23           ` Simon Glass
2017-01-28 22:44           ` [U-Boot] [U-Boot, v4, " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170104194656.124368-3-maxims@google.com \
    --to=maxims@google.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox