summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-08-25 17:14:57 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-05 10:15:48 +0200
commit4960dc9db00fcf5058196dbcb94c2f139999bd2e (patch)
tree9d61a2eab6283efb10dc7fc57a8578d7189609ee
parentabd545d2f9b91268ed90879d929b0e5e055d574d (diff)
downloadbarebox-4960dc9db00fcf5058196dbcb94c2f139999bd2e.tar.gz
barebox-4960dc9db00fcf5058196dbcb94c2f139999bd2e.tar.xz
rework debug_ll
Convert to static inline functions and use lower case letters for function names. Also, include mach/debug_ll.h when an architecture provides support for debug_ll, not only when it's actually enabled. This allows architecures to put some UART initialization code into mach/debug_ll.h which is compiled out when debug_ll is disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/tqma6x/lowlevel.c4
-rw-r--r--arch/arm/mach-imx/include/mach/debug_ll.h4
-rw-r--r--arch/mips/boot/main_entry-pbl.c2
-rw-r--r--common/console.c8
-rw-r--r--common/console_simple.c2
-rw-r--r--include/debug_ll.h61
6 files changed, 54 insertions, 27 deletions
diff --git a/arch/arm/boards/tqma6x/lowlevel.c b/arch/arm/boards/tqma6x/lowlevel.c
index 8c8684123a..8a16abba3a 100644
--- a/arch/arm/boards/tqma6x/lowlevel.c
+++ b/arch/arm/boards/tqma6x/lowlevel.c
@@ -54,7 +54,7 @@ ENTRY_FUNCTION(start_imx6q_mba6x)(void)
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
writel(0x2, 0x020e0338);
setup_uart();
- PUTC_LL('a');
+ putc_ll('a');
}
arm_early_mmu_cache_invalidate();
@@ -77,7 +77,7 @@ ENTRY_FUNCTION(start_imx6dl_mba6x)(void)
if (IS_ENABLED(CONFIG_DEBUG_LL)) {
writel(0x2, 0x020e035c);
setup_uart();
- PUTC_LL('a');
+ putc_ll('a');
}
arm_early_mmu_cache_invalidate();
diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
index 0bb28ee6ea..f34eaa139f 100644
--- a/arch/arm/mach-imx/include/mach/debug_ll.h
+++ b/arch/arm/mach-imx/include/mach/debug_ll.h
@@ -13,6 +13,8 @@
#include <mach/imx53-regs.h>
#include <mach/imx6-regs.h>
+#ifdef CONFIG_DEBUG_LL
+
#ifdef CONFIG_DEBUG_IMX1_UART
#define IMX_DEBUG_SOC MX1
#elif defined CONFIG_DEBUG_IMX21_UART
@@ -61,5 +63,5 @@ static inline void PUTC_LL(int c)
writel(c, base + URTX0);
}
-
+#endif /* CONFIG_DEBUG_LL */
#endif /* __MACH_DEBUG_LL_H__ */
diff --git a/arch/mips/boot/main_entry-pbl.c b/arch/mips/boot/main_entry-pbl.c
index 820e1d5d1b..3a244a0c50 100644
--- a/arch/mips/boot/main_entry-pbl.c
+++ b/arch/mips/boot/main_entry-pbl.c
@@ -51,7 +51,7 @@ void __section(.text_entry) pbl_main_entry(void)
u32 pg_start, pg_end, pg_len;
void (*barebox)(void);
- PUTS_LL("pbl_main_entry()\n");
+ puts_ll("pbl_main_entry()\n");
/* clear bss */
memset(__bss_start, 0, __bss_stop - __bss_start);
diff --git a/common/console.c b/common/console.c
index 402dcf53ec..d196e6df2b 100644
--- a/common/console.c
+++ b/common/console.c
@@ -93,9 +93,9 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
if (initialized < CONSOLE_INIT_FULL) {
char ch;
initialized = CONSOLE_INIT_FULL;
- PUTS_LL("Switch to console [");
- PUTS_LL(dev_name(dev));
- PUTS_LL("]\n");
+ puts_ll("Switch to console [");
+ puts_ll(dev_name(dev));
+ puts_ll("]\n");
barebox_banner();
while (kfifo_getc(console_output_fifo, &ch) == 0)
console_putc(CONSOLE_STDOUT, ch);
@@ -282,7 +282,7 @@ void console_putc(unsigned int ch, char c)
case CONSOLE_INITIALIZED_BUFFER:
kfifo_putc(console_output_fifo, c);
- PUTC_LL(c);
+ putc_ll(c);
return;
case CONSOLE_INIT_FULL:
diff --git a/common/console_simple.c b/common/console_simple.c
index 1fe569ef9d..101064b69a 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -28,7 +28,7 @@ EXPORT_SYMBOL(console_puts);
void console_putc(unsigned int ch, char c)
{
if (!console) {
- PUTC_LL(c);
+ putc_ll(c);
return;
}
diff --git a/include/debug_ll.h b/include/debug_ll.h
index f0034ba06a..288aa256e5 100644
--- a/include/debug_ll.h
+++ b/include/debug_ll.h
@@ -20,8 +20,7 @@
#ifndef __INCLUDE_DEBUG_LL_H__
#define __INCLUDE_DEBUG_LL_H__
-#if defined (CONFIG_DEBUG_LL)
-
+#ifdef CONFIG_HAS_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
@@ -29,35 +28,61 @@
* this initialization. Depending on the PUTC_LL implementation the board might
* also hang in PUTC_LL without proper initialization.
*/
-# include <mach/debug_ll.h>
+#include <mach/debug_ll.h>
+#endif
-# define PUTHEX_LL(value) ({ unsigned long v = (unsigned long) (value); \
- int i; unsigned char ch; \
- for (i = 8; i--; ) {\
- ch = ((v >> (i*4)) & 0xf);\
- ch += (ch >= 10) ? 'a' - 10 : '0';\
- PUTC_LL (ch); }})
+#if defined (CONFIG_DEBUG_LL)
+
+static inline void putc_ll(unsigned char value)
+{
+ PUTC_LL(value);
+}
+
+static inline void puthex_ll(unsigned long value)
+{
+ int i; unsigned char ch;
+
+ for (i = 8; i--; ) {
+ ch = ((value >> (i * 4)) & 0xf);
+ ch += (ch >= 10) ? 'a' - 10 : '0';
+ putc_ll(ch);
+ }
+}
/*
- * Be careful with PUTS_LL, it only works if the binary is running at the
+ * 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)
+static inline void puts_ll(const char * str)
{
while (*str) {
- if (*str == '\n') {
- PUTC_LL('\r');
- }
- PUTC_LL(*str);
+ if (*str == '\n')
+ putc_ll('\r');
+
+ putc_ll(*str);
str++;
}
}
#else
-# define PUTC_LL(c) do {} while (0)
-# define PUTHEX_LL(v) do {} while (0)
-# define PUTS_LL(c) do {} while (0)
+
+static inline void putc_ll(unsigned char value)
+{
+}
+
+static inline void puthex_ll(unsigned long value)
+{
+}
+
+/*
+ * 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)
+{
+}
#endif