From 4960dc9db00fcf5058196dbcb94c2f139999bd2e Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Sun, 25 Aug 2013 17:14:57 +0200 Subject: [PATCH] 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 --- arch/arm/boards/tqma6x/lowlevel.c | 4 +- arch/arm/mach-imx/include/mach/debug_ll.h | 4 +- arch/mips/boot/main_entry-pbl.c | 2 +- common/console.c | 8 +-- common/console_simple.c | 2 +- include/debug_ll.h | 61 ++++++++++++++++------- 6 files changed, 54 insertions(+), 27 deletions(-) diff --git a/arch/arm/boards/tqma6x/lowlevel.c b/arch/arm/boards/tqma6x/lowlevel.c index 8c8684123..8a16abba3 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 0bb28ee6e..f34eaa139 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 #include +#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 820e1d5d1..3a244a0c5 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 402dcf53e..d196e6df2 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 1fe569ef9..101064b69 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 f0034ba06..288aa256e 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 +#include +#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