public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches
@ 2013-04-23 13:33 Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 1/4] microblaze: Fix reset function Michal Simek
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Michal Simek @ 2013-04-23 13:33 UTC (permalink / raw)
  To: u-boot

Here are some patches I have in my private repo for
a long time. Let's upstream them.

Thanks,
Michal

Changes in v2:
- Remove trailing 1 for configurations
- Remove \; from nc variable
- Fix define macros not to use trailing 1
- define watchdog_base as static variable
- label init and disable function as extern in header
- Add record to xparameters.h to get it compiled by default

Michal Simek (4):
  microblaze: Fix reset function
  microblaze: Enable netconsole
  microblaze: Disable all cpu features before reset
  watchdog: Add support for Xilinx Microblaze watchdog

 arch/microblaze/include/asm/processor.h            |  4 +
 arch/microblaze/lib/board.c                        |  3 +
 .../xilinx/microblaze-generic/microblaze-generic.c | 11 ++-
 board/xilinx/microblaze-generic/xparameters.h      |  4 +
 doc/README.watchdog                                |  3 +
 drivers/watchdog/Makefile                          |  1 +
 drivers/watchdog/xilinx_tb_wdt.c                   | 87 ++++++++++++++++++++++
 include/configs/microblaze-generic.h               | 17 ++++-
 8 files changed, 126 insertions(+), 4 deletions(-)
 create mode 100644 drivers/watchdog/xilinx_tb_wdt.c

--
1.8.2.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/8c176ea2/attachment.pgp>

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

* [U-Boot] [PATCH v2 1/4] microblaze: Fix reset function
  2013-04-23 13:33 [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches Michal Simek
@ 2013-04-23 13:33 ` Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole Michal Simek
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2013-04-23 13:33 UTC (permalink / raw)
  To: u-boot

From: Michal Simek <monstr@monstr.eu>

Remove CONFIG_SYS_RESET_ADDRESS macro.
It was there from historical point of view
when soft reset was just jump to u-boot text start
(not used right now).

Signed-off-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2: None

 board/xilinx/microblaze-generic/microblaze-generic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 70f94c1..8ba99f9 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -38,10 +38,10 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	*((unsigned long *)(CONFIG_SYS_GPIO_0_ADDR)) =
 	    ++(*((unsigned long *)(CONFIG_SYS_GPIO_0_ADDR)));
 #endif
-#ifdef CONFIG_SYS_RESET_ADDRESS
+
 	puts ("Reseting board\n");
 	asm ("bra r0");
-#endif
+
 	return 0;
 }

--
1.8.2.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/d01b35cc/attachment.pgp>

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

* [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole
  2013-04-23 13:33 [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 1/4] microblaze: Fix reset function Michal Simek
@ 2013-04-23 13:33 ` Michal Simek
  2013-04-23 18:47   ` Tom Rini
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 3/4] microblaze: Disable all cpu features before reset Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog Michal Simek
  3 siblings, 1 reply; 7+ messages in thread
From: Michal Simek @ 2013-04-23 13:33 UTC (permalink / raw)
  To: u-boot

From: Michal Simek <monstr@monstr.eu>

Setup environment and enable netconsole.

Signed-off-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2:
- Remove trailing 1 for configurations
- Remove \; from nc variable

 include/configs/microblaze-generic.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index d172e56..8c0353a 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -414,10 +414,17 @@
 					"nor0=flash-0\0"\
 					"mtdparts=mtdparts=flash-0:"\
 					"256k(u-boot),256k(env),3m(kernel),"\
-					"1m(romfs),1m(cramfs),-(jffs2)\0"
+					"1m(romfs),1m(cramfs),-(jffs2)\0"\
+					"nc=setenv stdout nc;"\
+					"setenv stdin nc\0" \
+					"serial=setenv stdout serial;"\
+					"setenv stdin serial\0"

 #define CONFIG_CMDLINE_EDITING

+#define CONFIG_NETCONSOLE
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV
+
 /* Use the HUSH parser */
 #define CONFIG_SYS_HUSH_PARSER

--
1.8.2.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/ca02e9fe/attachment.pgp>

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

* [U-Boot] [PATCH v2 3/4] microblaze: Disable all cpu features before reset
  2013-04-23 13:33 [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 1/4] microblaze: Fix reset function Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole Michal Simek
@ 2013-04-23 13:33 ` Michal Simek
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog Michal Simek
  3 siblings, 0 replies; 7+ messages in thread
From: Michal Simek @ 2013-04-23 13:33 UTC (permalink / raw)
  To: u-boot

From: Michal Simek <monstr@monstr.eu>

Fix microblaze soft reset function and disable
all cpu features. Especially disable caches because
IRQs were off by disable_interrupts().

Reported-by: John Williams <john.williams@xilinx.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2: None

 board/xilinx/microblaze-generic/microblaze-generic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 8ba99f9..1af0b86 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -40,7 +40,8 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 #endif

 	puts ("Reseting board\n");
-	asm ("bra r0");
+	__asm__ __volatile__ ("	mts rmsr, r0;" \
+				"bra r0");

 	return 0;
 }
--
1.8.2.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/350400f5/attachment.pgp>

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

* [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog
  2013-04-23 13:33 [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches Michal Simek
                   ` (2 preceding siblings ...)
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 3/4] microblaze: Disable all cpu features before reset Michal Simek
@ 2013-04-23 13:33 ` Michal Simek
  2013-04-23 18:47   ` Tom Rini
  3 siblings, 1 reply; 7+ messages in thread
From: Michal Simek @ 2013-04-23 13:33 UTC (permalink / raw)
  To: u-boot

Watchdog can be used on Microblaze, PPC and Zynq hw designs.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
Changes in v2:
- Fix define macros not to use trailing 1
- define watchdog_base as static variable
- label init and disable function as extern in header
- Add record to xparameters.h to get it compiled by default

 arch/microblaze/include/asm/processor.h            |  4 +
 arch/microblaze/lib/board.c                        |  3 +
 .../xilinx/microblaze-generic/microblaze-generic.c |  4 +
 board/xilinx/microblaze-generic/xparameters.h      |  4 +
 doc/README.watchdog                                |  3 +
 drivers/watchdog/Makefile                          |  1 +
 drivers/watchdog/xilinx_tb_wdt.c                   | 87 ++++++++++++++++++++++
 include/configs/microblaze-generic.h               |  8 ++
 8 files changed, 114 insertions(+)
 create mode 100644 drivers/watchdog/xilinx_tb_wdt.c

diff --git a/arch/microblaze/include/asm/processor.h b/arch/microblaze/include/asm/processor.h
index 2c4d5ff..d33faeb 100644
--- a/arch/microblaze/include/asm/processor.h
+++ b/arch/microblaze/include/asm/processor.h
@@ -31,4 +31,8 @@ extern char __text_start[];
 /* Microblaze board initialization function */
 void board_init(void);

+/* Watchdog functions */
+extern int hw_watchdog_init(void);
+extern void hw_watchdog_disable(void);
+
 #endif /* __ASM_MICROBLAZE_PROCESSOR_H */
diff --git a/arch/microblaze/lib/board.c b/arch/microblaze/lib/board.c
index a7c2f76..815fb5a 100644
--- a/arch/microblaze/lib/board.c
+++ b/arch/microblaze/lib/board.c
@@ -61,6 +61,9 @@ init_fnc_t *init_sequence[] = {
 	serial_init,
 	console_init_f,
 	interrupts_init,
+#ifdef CONFIG_XILINX_TB_WATCHDOG
+	hw_watchdog_init,
+#endif
 	timer_init,
 	NULL,
 };
diff --git a/board/xilinx/microblaze-generic/microblaze-generic.c b/board/xilinx/microblaze-generic/microblaze-generic.c
index 1af0b86..befbb3a 100644
--- a/board/xilinx/microblaze-generic/microblaze-generic.c
+++ b/board/xilinx/microblaze-generic/microblaze-generic.c
@@ -39,6 +39,10 @@ int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	    ++(*((unsigned long *)(CONFIG_SYS_GPIO_0_ADDR)));
 #endif

+#ifdef CONFIG_XILINX_TB_WATCHDOG
+	hw_watchdog_disable();
+#endif
+
 	puts ("Reseting board\n");
 	__asm__ __volatile__ ("	mts rmsr, r0;" \
 				"bra r0");
diff --git a/board/xilinx/microblaze-generic/xparameters.h b/board/xilinx/microblaze-generic/xparameters.h
index 50a82d9..c846f97 100644
--- a/board/xilinx/microblaze-generic/xparameters.h
+++ b/board/xilinx/microblaze-generic/xparameters.h
@@ -77,3 +77,7 @@
 #define XILINX_LLTEMAC_SDMA_CTRL_BASEADDR	0x42000180
 #define XILINX_LLTEMAC_BASEADDR1		0x44200000
 #define XILINX_LLTEMAC_FIFO_BASEADDR1		0x42100000
+
+/* Watchdog IP is wxi_timebase_wdt_0 */
+#define XILINX_WATCHDOG_BASEADDR	0x50000000
+#define XILINX_WATCHDOG_IRQ		1
diff --git a/doc/README.watchdog b/doc/README.watchdog
index ee65008..33f31c2 100644
--- a/doc/README.watchdog
+++ b/doc/README.watchdog
@@ -27,3 +27,6 @@ CONFIG_IMX_WATCHDOG
 	Available for i.mx31/35/5x/6x to service the watchdog. This is not
 	automatically set because some boards (vision2) still need to define
 	their own hw_watchdog_reset routine.
+
+CONFIG_XILINX_TB_WATCHDOG
+	Available for Xilinx Axi platforms to service timebase watchdog timer.
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index b1f4e0f..13e7c37 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -32,6 +32,7 @@ COBJS-y += imx_watchdog.o
 endif
 COBJS-$(CONFIG_TNETV107X_WATCHDOG) += tnetv107x_wdt.o
 COBJS-$(CONFIG_S5P)               += s5p_wdt.o
+COBJS-$(CONFIG_XILINX_TB_WATCHDOG) += xilinx_tb_wdt.o

 COBJS	:= $(COBJS-y)
 SRCS	:= $(COBJS:.o=.c)
diff --git a/drivers/watchdog/xilinx_tb_wdt.c b/drivers/watchdog/xilinx_tb_wdt.c
new file mode 100644
index 0000000..f7c722e
--- /dev/null
+++ b/drivers/watchdog/xilinx_tb_wdt.c
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011-2013 Xilinx Inc.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/microblaze_intc.h>
+#include <asm/processor.h>
+#include <watchdog.h>
+
+#define XWT_CSR0_WRS_MASK	0x00000008 /* Reset status Mask */
+#define XWT_CSR0_WDS_MASK	0x00000004 /* Timer state Mask */
+#define XWT_CSR0_EWDT1_MASK	0x00000002 /* Enable bit 1 Mask*/
+#define XWT_CSRX_EWDT2_MASK	0x00000001 /* Enable bit 2 Mask */
+
+struct watchdog_regs {
+	u32 twcsr0; /* 0x0 */
+	u32 twcsr1; /* 0x4 */
+	u32 tbr; /* 0x8 */
+};
+
+static struct watchdog_regs *watchdog_base =
+			(struct watchdog_regs *)CONFIG_WATCHDOG_BASEADDR;
+
+void hw_watchdog_reset(void)
+{
+	u32 reg;
+
+	/* Read the current contents of TCSR0 */
+	reg = readl(&watchdog_base->twcsr0);
+
+	/* Clear the watchdog WDS bit */
+	if (reg & (XWT_CSR0_EWDT1_MASK | XWT_CSRX_EWDT2_MASK))
+		writel(reg | XWT_CSR0_WDS_MASK, &watchdog_base->twcsr0);
+}
+
+void hw_watchdog_disable(void)
+{
+	u32 reg;
+
+	/* Read the current contents of TCSR0 */
+	reg = readl(&watchdog_base->twcsr0);
+
+	writel(reg & ~XWT_CSR0_EWDT1_MASK, &watchdog_base->twcsr0);
+	writel(~XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
+
+	puts("Watchdog disabled!\n");
+}
+
+static void hw_watchdog_isr(void *arg)
+{
+	hw_watchdog_reset();
+}
+
+int hw_watchdog_init(void)
+{
+	int ret;
+
+	writel((XWT_CSR0_WRS_MASK | XWT_CSR0_WDS_MASK | XWT_CSR0_EWDT1_MASK),
+	       &watchdog_base->twcsr0);
+	writel(XWT_CSRX_EWDT2_MASK, &watchdog_base->twcsr1);
+
+	ret = install_interrupt_handler(CONFIG_WATCHDOG_IRQ,
+						hw_watchdog_isr, NULL);
+	if (ret)
+		return 1;
+
+	return 0;
+}
diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h
index 8c0353a..0c4e719 100644
--- a/include/configs/microblaze-generic.h
+++ b/include/configs/microblaze-generic.h
@@ -120,6 +120,14 @@
 #  define CONFIG_SYS_TIMER_0_IRQ	XILINX_TIMER_IRQ
 #endif

+/* watchdog */
+#if defined(XILINX_WATCHDOG_BASEADDR) && defined(XILINX_WATCHDOG_IRQ)
+# define CONFIG_WATCHDOG_BASEADDR	XILINX_WATCHDOG_BASEADDR
+# define CONFIG_WATCHDOG_IRQ		XILINX_WATCHDOG_IRQ
+# define CONFIG_HW_WATCHDOG
+# define CONFIG_XILINX_TB_WATCHDOG
+#endif
+
 /*
  * memory layout - Example
  * CONFIG_SYS_TEXT_BASE = 0x1200_0000;	defined in config.mk
--
1.8.2.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/4b4ac696/attachment.pgp>

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

* [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog Michal Simek
@ 2013-04-23 18:47   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2013-04-23 18:47 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 23, 2013 at 03:33:39PM +0200, Michal Simek wrote:

> Watchdog can be used on Microblaze, PPC and Zynq hw designs.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Reviewed-by: Tom Rini <trini@ti.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/aaf65f97/attachment.pgp>

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

* [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole
  2013-04-23 13:33 ` [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole Michal Simek
@ 2013-04-23 18:47   ` Tom Rini
  0 siblings, 0 replies; 7+ messages in thread
From: Tom Rini @ 2013-04-23 18:47 UTC (permalink / raw)
  To: u-boot

On Tue, Apr 23, 2013 at 03:33:37PM +0200, Michal Simek wrote:

> From: Michal Simek <monstr@monstr.eu>
> 
> Setup environment and enable netconsole.
> 
> Signed-off-by: Michal Simek <monstr@monstr.eu>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Reviewed-by: Tom Rini <trini@ti.com>

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130423/b881425b/attachment.pgp>

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

end of thread, other threads:[~2013-04-23 18:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-23 13:33 [U-Boot] [PATCH v2 0/4] Xilinx Microblaze patches Michal Simek
2013-04-23 13:33 ` [U-Boot] [PATCH v2 1/4] microblaze: Fix reset function Michal Simek
2013-04-23 13:33 ` [U-Boot] [PATCH v2 2/4] microblaze: Enable netconsole Michal Simek
2013-04-23 18:47   ` Tom Rini
2013-04-23 13:33 ` [U-Boot] [PATCH v2 3/4] microblaze: Disable all cpu features before reset Michal Simek
2013-04-23 13:33 ` [U-Boot] [PATCH v2 4/4] watchdog: Add support for Xilinx Microblaze watchdog Michal Simek
2013-04-23 18:47   ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox