Skip to contentSkip to conversation

watchdog: add minimal jz4740 driver

PATCH New Antony Pavlov 1 participant 2 messages Jul 31, 2014

Subsystems (3)
lore
Share & tools
lore
#1 lore raw

PATCH v2 2/2 watchdog: i.MX: check requested mem region in imx_wd_probe()

In reply to Antony Pavlov
---
 drivers/watchdog/imxwd.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/watchdog/imxwd.c +4 -0
index 63c5605..31c3d0d 100644
@@ -159,6 +159,10 @@ static int imx_wd_probe(struct device_d *dev)
 
 	priv = xzalloc(sizeof(struct imx_wd));
 	priv->base = dev_request_mem_region(dev, 0);
+	if (!priv->base) {
+		dev_err(dev, "could not get memory region\n");
+		return -ENODEV;
+	}
 	priv->set_timeout = fn;
 	priv->wd.set_timeout = imx_watchdog_set_timeout;
 	priv->dev = dev;
Signature · 7 lines
2.0.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#0 lore raw

PATCH v2 1/2 watchdog: add minimal jz4740 driver

Also move reset_cpu() for jz4755 SoC from platform code into the new driver code.

At the moment mach-xburst lacks clk support so jz4740 watchdog driver looks like a template. We can improve jz4740 watchdog driver later after adding clk support.

---
 arch/mips/dts/jz4755.dtsi                         |   5 ++
 arch/mips/mach-xburst/Kconfig                     |   2 +
 arch/mips/mach-xburst/include/mach/jz4750d_regs.h |  22 -----
 arch/mips/mach-xburst/reset-jz4750.c              |  18 ----
 drivers/watchdog/Kconfig                          |   7 ++
 drivers/watchdog/Makefile                         |   1 +
 drivers/watchdog/jz4740.c                         | 102 ++++++++++++++++++++++
 7 files changed, 117 insertions(+), 40 deletions(-)
arch/mips/dts/jz4755.dtsi +5 -0
index 0e655b6..7184635 100644
@@ -8,6 +8,11 @@
 		#size-cells = <1>;
 		ranges;
 
+		wdt: wdt@b0002000 {
+			compatible = "ingenic,jz4740-wdt";
+			reg = <0xb0002000 0x10>;
+		};
+
 		serial0: serial@b0030000 {
 			compatible = "ingenic,jz4740-uart";
 			reg = <0xb0030000 0x20>;
arch/mips/mach-xburst/Kconfig +2 -0
index 706d592..f7b8470 100644
@@ -6,6 +6,8 @@ config ARCH_TEXT_BASE
 
 config CPU_JZ4755
 	bool
+	select WATCHDOG
+	select WATCHDOG_JZ4740
 
 choice
 	prompt "Board type"
arch/mips/mach-xburst/include/mach/jz4750d_regs.h +0 -22
index 7a3daad..396c823 100644
@@ -59,28 +59,6 @@
 #define TCU_OSTCSR_PCK_EN		(1 << 0) /* select pclk as the timer clock input */
 
 /*************************************************************************
- * WDT (WatchDog Timer)
- *************************************************************************/
-#define WDT_TDR		(WDT_BASE + 0x00)
-#define WDT_TCER	(WDT_BASE + 0x04)
-#define WDT_TCNT	(WDT_BASE + 0x08)
-#define WDT_TCSR	(WDT_BASE + 0x0c)
-
-#define WDT_TCSR_PRESCALE_BIT	3
-#define WDT_TCSR_PRESCALE_MASK	(0x7 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE1	(0x0 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE4	(0x1 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE16	(0x2 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE64	(0x3 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE256	(0x4 << WDT_TCSR_PRESCALE_BIT)
- #define WDT_TCSR_PRESCALE1024	(0x5 << WDT_TCSR_PRESCALE_BIT)
-#define WDT_TCSR_EXT_EN		(1 << 2)
-#define WDT_TCSR_RTC_EN		(1 << 1)
-#define WDT_TCSR_PCK_EN		(1 << 0)
-
-#define WDT_TCER_TCEN		(1 << 0)
-
-/*************************************************************************
  * RTC
  *************************************************************************/
 #define RTC_RCR		(RTC_BASE + 0x00) /* RTC Control Register */
arch/mips/mach-xburst/reset-jz4750.c +0 -18
index 8f33672..25830f1 100644
@@ -24,8 +24,6 @@
 #include <io.h>
 #include <mach/jz4750d_regs.h>
 
-#define JZ_EXTAL 24000000
-
 static void __noreturn jz4750d_halt(void)
 {
 	while (1) {
@@ -39,22 +37,6 @@ static void __noreturn jz4750d_halt(void)
 	unreachable();
 }
 
-void __noreturn reset_cpu(ulong addr)
-{
-	__raw_writew(WDT_TCSR_PRESCALE4 | WDT_TCSR_EXT_EN, (u16 *)WDT_TCSR);
-	__raw_writew(0, (u16 *)WDT_TCNT);
-
-	/* reset after 4ms */
-	__raw_writew(JZ_EXTAL / 1000, (u16 *)WDT_TDR);
-	/* enable wdt clock */
-	__raw_writel(TCU_TSCR_WDTSC, (u32 *)TCU_TSCR);
-	/* start wdt */
-	__raw_writeb(WDT_TCER_TCEN, (u8 *)WDT_TCER);
-
-	unreachable();
-}
-EXPORT_SYMBOL(reset_cpu);
-
 void __noreturn poweroff()
 {
 	u32 ctrl;
drivers/watchdog/Kconfig +7 -0
index 2e2900c..7f7b02e 100644
@@ -21,4 +21,11 @@ config WATCHDOG_IMX
 	depends on ARCH_IMX
 	help
 	  Add support for watchdog found on Freescale i.MX SoCs.
+
+config WATCHDOG_JZ4740
+	bool "Ingenic jz4740 SoC hardware watchdog"
+	depends on MACH_MIPS_XBURST
+	help
+	  Hardware driver for the built-in watchdog timer on Ingenic jz4740 SoCs.
+
 endif
drivers/watchdog/Makefile +1 -0
index f522b88..865fc47 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_WATCHDOG) += wd_core.o
 obj-$(CONFIG_WATCHDOG_MXS28) += im28wd.o
+obj-$(CONFIG_WATCHDOG_JZ4740) += jz4740.o
 obj-$(CONFIG_WATCHDOG_IMX_RESET_SOURCE) += imxwd.o
drivers/watchdog/jz4740.c new file +102 -0

102 lines not on this page · raw message

Signature · 7 lines
2.0.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox