mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/3] debug_ll: Let architectures define PUTC_LL directly
@ 2012-11-26 10:13 Sascha Hauer
  2012-11-26 10:13 ` [PATCH 2/3] debug_ll: Add some usage comments Sascha Hauer
  2012-11-26 10:13 ` [PATCH 3/3] i.MX debug_ll support Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-11-26 10:13 UTC (permalink / raw)
  To: barebox

putc already is a regular barebox function. To avoid conflicts and
confusions just let architectures define PUTC_LL directly instead
of going through this addiotional redirection.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/mach-omap/include/mach/debug_ll.h      |    2 +-
 arch/arm/mach-tegra/include/mach/debug_ll.h     |    2 +-
 arch/arm/mach-versatile/include/mach/debug_ll.h |    2 +-
 arch/mips/include/debug_ll_ns16550.h            |    2 +-
 arch/mips/mach-bcm47xx/include/mach/debug_ll.h  |    2 +-
 include/debug_ll.h                              |    1 -
 6 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-omap/include/mach/debug_ll.h b/arch/arm/mach-omap/include/mach/debug_ll.h
index c1fcc9d..b2714c5 100644
--- a/arch/arm/mach-omap/include/mach/debug_ll.h
+++ b/arch/arm/mach-omap/include/mach/debug_ll.h
@@ -39,7 +39,7 @@
 #define LSR		(5 << 2)
 #define THR		(0 << 2)
 
-static inline void putc(char c)
+static inline void PUTC_LL(char c)
 {
 	/* Wait until there is space in the FIFO */
 	while ((readb(UART_BASE + LSR) & LSR_THRE) == 0);
diff --git a/arch/arm/mach-tegra/include/mach/debug_ll.h b/arch/arm/mach-tegra/include/mach/debug_ll.h
index 18024eb..290ad58 100644
--- a/arch/arm/mach-tegra/include/mach/debug_ll.h
+++ b/arch/arm/mach-tegra/include/mach/debug_ll.h
@@ -31,7 +31,7 @@
 #define lsr		(5 << DEBUG_LL_UART_RSHFT)
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static inline void putc(char ch)
+static inline void PUTC_LL(char ch)
 {
 	while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE))
 		;
diff --git a/arch/arm/mach-versatile/include/mach/debug_ll.h b/arch/arm/mach-versatile/include/mach/debug_ll.h
index 20fbc7c..f91812b 100644
--- a/arch/arm/mach-versatile/include/mach/debug_ll.h
+++ b/arch/arm/mach-versatile/include/mach/debug_ll.h
@@ -19,7 +19,7 @@
 #include <linux/amba/serial.h>
 #include <io.h>
 
-static inline void putc(char c)
+static inline void PUTC_LL(char c)
 {
 	/* Wait until there is space in the FIFO */
 	while (readl(0x101F1000 + UART01x_FR) & UART01x_FR_TXFF);
diff --git a/arch/mips/include/debug_ll_ns16550.h b/arch/mips/include/debug_ll_ns16550.h
index a8b74d2..e9c7ecf 100644
--- a/arch/mips/include/debug_ll_ns16550.h
+++ b/arch/mips/include/debug_ll_ns16550.h
@@ -28,7 +28,7 @@
 
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static __inline__ void putc(char ch)
+static __inline__ void PUTC_LL(char ch)
 {
 	while (!(__raw_readb((u8 *)DEBUG_LL_UART_ADDR + lsr) & LSR_THRE));
 	__raw_writeb(ch, (u8 *)DEBUG_LL_UART_ADDR + rbr);
diff --git a/arch/mips/mach-bcm47xx/include/mach/debug_ll.h b/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
index 4bf1817..0703bb0 100644
--- a/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
+++ b/arch/mips/mach-bcm47xx/include/mach/debug_ll.h
@@ -28,7 +28,7 @@
 #define lsr		5
 #define LSR_THRE	0x20	/* Xmit holding register empty */
 
-static __inline__ void putc(char ch)
+static __inline__ void PUTC_LL(char ch)
 {
 	while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE));
 	__raw_writeb(ch, DEBUG_LL_UART_ADDR + rbr);
diff --git a/include/debug_ll.h b/include/debug_ll.h
index c744573..c5f2df4 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -22,7 +22,6 @@
 #if defined (CONFIG_DEBUG_LL)
 # include <mach/debug_ll.h>
 
-#define PUTC_LL(x) putc(x)
 # define PUTHEX_LL(value)  ({ unsigned long v = (unsigned long) (value); \
 			     int i; unsigned char ch; \
 			     for (i = 8; i--; ) {\
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/3] debug_ll: Add some usage comments
  2012-11-26 10:13 [PATCH 1/3] debug_ll: Let architectures define PUTC_LL directly Sascha Hauer
@ 2012-11-26 10:13 ` Sascha Hauer
  2012-11-26 10:13 ` [PATCH 3/3] i.MX debug_ll support Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-11-26 10:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/Kconfig     |    2 ++
 include/debug_ll.h |   16 +++++++++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index d60db80..57119dc 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -667,6 +667,8 @@ config DEBUG_LL
 	prompt "low level debug messages"
 	help
 	  Enable this to get low level debug messages during barebox initialization.
+	  This requires SoC specific support. Most SoCs require the debug UART to be
+	  initialized by a debugger or first stage bootloader.
 
 endmenu
 
diff --git a/include/debug_ll.h b/include/debug_ll.h
index c5f2df4..f0034ba 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -1,4 +1,5 @@
-/* debug_ll.h
+/*
+ * debug_ll.h
  *
  *  written by Marc Singer
  *  12 Feb 2005
@@ -20,6 +21,14 @@
 #define   __INCLUDE_DEBUG_LL_H__
 
 #if defined (CONFIG_DEBUG_LL)
+
+/*
+ * mach/debug_ll.h should implement PUTC_LL. This can be a macro or a static
+ * inline function. Note that several SoCs expect the UART to be initialized
+ * by a debugger or a first stage bootloader. You won't see anything without
+ * this initialization. Depending on the PUTC_LL implementation the board might
+ * also hang in PUTC_LL without proper initialization.
+ */
 # include <mach/debug_ll.h>
 
 # define PUTHEX_LL(value)  ({ unsigned long v = (unsigned long) (value); \
@@ -29,6 +38,11 @@
 			     ch += (ch >= 10) ? 'a' - 10 : '0';\
 			     PUTC_LL (ch); }})
 
+/*
+ * Be careful with PUTS_LL, it only works if the binary is running at the
+ * link address which often is not the case during early startup. If in doubt
+ * don't use it.
+ */
 static __inline__ void PUTS_LL(const char * str)
 {
 	while (*str) {
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/3] i.MX debug_ll support
  2012-11-26 10:13 [PATCH 1/3] debug_ll: Let architectures define PUTC_LL directly Sascha Hauer
  2012-11-26 10:13 ` [PATCH 2/3] debug_ll: Add some usage comments Sascha Hauer
@ 2012-11-26 10:13 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2012-11-26 10:13 UTC (permalink / raw)
  To: barebox

This adds lowlevel debug functions for i.MX. As we have a great variety
of different UARTs on i.MX currently no Kconfig support for chosing the
correct one is added. Instead we expect the user to add the correct
define and issue a compiler warning if he hasn't.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/Kconfig                          |    1 +
 arch/arm/mach-imx/include/mach/debug_ll.h |   46 +++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)
 create mode 100644 arch/arm/mach-imx/include/mach/debug_ll.h

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 3afd885..cdb5081 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -57,6 +57,7 @@ config ARCH_IMX
 	select COMMON_CLK
 	select CLKDEV_LOOKUP
 	select WATCHDOG_IMX_RESET_SOURCE
+	select HAS_DEBUG_LL
 
 config ARCH_MXS
 	bool "Freescale i.MX23/28 (mxs) based"
diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
new file mode 100644
index 0000000..cb6dd03
--- /dev/null
+++ b/arch/arm/mach-imx/include/mach/debug_ll.h
@@ -0,0 +1,46 @@
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <io.h>
+#include <config.h>
+#include <mach/imx1-regs.h>
+#include <mach/imx21-regs.h>
+#include <mach/imx25-regs.h>
+#include <mach/imx27-regs.h>
+#include <mach/imx31-regs.h>
+#include <mach/imx35-regs.h>
+#include <mach/imx51-regs.h>
+#include <mach/imx53-regs.h>
+#include <mach/imx6-regs.h>
+
+/* #define IMX_DEBUG_LL_UART_BASE MXxy_UARTx_BASE_ADDR */
+
+#ifndef IMX_DEBUG_LL_UART_BASE
+#warning define IMX_DEBUG_LL_UART_BASE properly for debug_ll
+#define IMX_DEBUG_LL_UART_BASE 0
+#endif
+
+#define URTX0		0x40		/* Transmitter Register */
+
+#define UCR1		0x80		/* Control Register 1 */
+#define UCR1_UARTEN	(1 << 0)	/* UART enabled */
+
+#define USR2		0x98		/* Status Register 2 */
+#define USR2_TXDC	(1 << 3)	/* Transmitter complete */
+
+static inline void PUTC_LL(int c)
+{
+	void __iomem *base = (void *)IMX_DEBUG_LL_UART_BASE;
+
+	if (!base)
+		return;
+
+	if (!(readl(base + UCR1) & UCR1_UARTEN))
+		return;
+
+	while (!(readl(base + USR2) & USR2_TXDC));
+
+	writel(c, base + URTX0);
+}
+
+#endif /* __MACH_DEBUG_LL_H__ */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2012-11-26 10:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 10:13 [PATCH 1/3] debug_ll: Let architectures define PUTC_LL directly Sascha Hauer
2012-11-26 10:13 ` [PATCH 2/3] debug_ll: Add some usage comments Sascha Hauer
2012-11-26 10:13 ` [PATCH 3/3] i.MX debug_ll support Sascha Hauer

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