ftwdt010_wdt: support faraday ftwdt010 watchdog
PATCH v6 1/1 ftwdt010_wdt: support faraday ftwdt010 watchdog
Faraday ftwdt010 watchdog is an architecture independant watchdog. It is usaually used in SoC chip design.
---
Changes for v2:
- Fix the wrong title of ftwdt010_wdt patch.
Changes for v3:
- Patch v2 was encoded in utf-8. Fixed to ASCII.
Changes for v4:
- Replace the copyright statement "origin: Linux kernel" because the
Linux
- driver haven't commit into kernel yet.
Changes for v5:
- Put header file of this driver into "faraday/ftwdt010_wdt.h".
- Add function declaration.
Changes for v6:
- Fix declaration of function ftwdt010_wdt_settimeout().
drivers/watchdog/Makefile | 1 + drivers/watchdog/ftwdt010_wdt.c | 104 ++++++++++++++++++++++++++++++++++++++ include/faraday/ftwdt010_wdt.h | 106 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 211 insertions(+), 0 deletions(-) create mode 100644 drivers/watchdog/ftwdt010_wdt.c create mode 100644 include/faraday/ftwdt010_wdt.h
drivers/watchdog/Makefile +1 -0
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libwatchdog.o COBJS-$(CONFIG_AT91SAM9_WATCHDOG) += at91sam9_wdt.o +COBJS-$(CONFIG_FTWDT010_WATCHDOG) += ftwdt010_wdt.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
(quoted diff) +0 -0
b/drivers/watchdog/ftwdt010_wdt.c
new file mode 100644
index 0000000..3c88ce6
drivers/watchdog/ftwdt010_wdt.c new file +104 -0
104 lines not on this page · raw message
(quoted diff) +0 -0
b/include/faraday/ftwdt010_wdt.h
new file mode 100644
index 0000000..abe2a9c
include/faraday/ftwdt010_wdt.h new file +45 -0
45 lines not on this page · raw message
is
+ * one second.
+ */
+#define FTWDT010_WDLOAD(x) ((x) & 0xffffffff)
+
+/*
+ * WDRESTART - Watch Dog Timer Counter Restart Register
+ * If writing 0x5AB9 to WDRESTART register, Watch Dog timer will
+ * automatically reload WDLOAD to WDCOUNTER and restart counting.
+ */
+#define FTWDT010_WDRESTART_MAGIC 0x5AB9
+
+/* WDCR - Watch Dog Timer Control Register */
+#define FTWDT010_WDCR_ENABLE (1 << 0)
+#define FTWDT010_WDCR_RST (1 << 1)
+#define FTWDT010_WDCR_INTR (1 << 2)
+/* FTWDT010_WDCR_EXT bit: Watch Dog Timer External Signal Enable */
+#define FTWDT010_WDCR_EXT (1 << 3)
+/* FTWDT010_WDCR_CLOCK bit: Clock Source: 0: PCLK, 1: EXTCLK.
+ * The clock source PCLK cannot be gated when system sleeps, even if
+ * WDCLOCK bit is turned on.
+ *
+ * Faraday's Watch Dog timer can be driven by an external clock. The
+ * programmer just needs to write one to WdCR[WdClock] bit.
+ *
+ * Note: There is a limitation between EXTCLK and PCLK: + * EXTCLK cycle time / PCLK cycle time > 2. + * If the system does not need an external clock, + * just keep WdCR[WdClock] bit in its default value.
+ */
+#define FTWDT010_WDCR_CLOCK (1 << 4)
+
+/*
+ * WDSTATUS - Watch Dog Timer Status Register
+ * This bit is set when the counter reaches Zero
+ */
+#define FTWDT010_WDSTATUS(x) ((x) & 0x1)
+
+/*
+ * WDCLEAR - Watch Dog Timer Clear Register
+ * Writing one to this register will clear WDSTATUS.
+ */
+#define FTWDT010_WDCLEAR (1 << 0)
+
+/*
+ * WDINTRLEN - Watch Dog Timer Interrupt Length
+ * This register controls the duration length of wd_rst, wd_intr andwd_ext.
+ * The default value is 0xFF.
+ */
+#define FTWDT010_WDINTRLEN(x) ((x) & 0xff)
+
+/*
+ * Variable timeout should be set in ms.
+ * (CONFIG_SYS_CLK_FREQ/1000) equals 1 ms.
+ * WDLOAD = timeout * TIMEOUT_FACTOR.
+ */
+#define FTWDT010_TIMEOUT_FACTOR (CONFIG_SYS_CLK_FREQ / 1000) /* 1 ms
*/
+
+void ftwdt010_wdt_reset(void);
+void ftwdt010_wdt_disable(void);
+
+#endif /* __FTWDT010_H */
Signature · 16 lines
1.7.3.5 CONFIDENTIALITY NOTICE: This e-mail (and its attachments) may contain confidential and legally privileged information or information protected from disclosure. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein is strictly prohibited. In this case, please immediately notify the sender by return e-mail, delete the message (and any accompanying documents) and destroy all printed hard copies. Thank you for your cooperation. Copyright ANDES TECHNOLOGY CORPORATION - All Rights Reserved.