summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-05-14 12:17:46 -0400
committerMike Frysinger <vapier@gentoo.org>2011-09-29 16:38:05 -0400
commit90a75b050b8a23a6e8f558cc9a76658d8443509d (patch)
tree621d53f9b20c8c72913b634436b419b1eaba7415 /arch
parent22f45ce48a53b19da2347efa9fc33c3ff6a06bf6 (diff)
downloadu-boot-imx-90a75b050b8a23a6e8f558cc9a76658d8443509d.zip
u-boot-imx-90a75b050b8a23a6e8f558cc9a76658d8443509d.tar.gz
u-boot-imx-90a75b050b8a23a6e8f558cc9a76658d8443509d.tar.bz2
Blackfin: uart: implement loop callback for post
This allows the Blackfin UART driver to be tested via post. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/blackfin/cpu/serial.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/arch/blackfin/cpu/serial.c b/arch/blackfin/cpu/serial.c
index 030160f..6603dc0 100644
--- a/arch/blackfin/cpu/serial.c
+++ b/arch/blackfin/cpu/serial.c
@@ -38,6 +38,7 @@
*/
#include <common.h>
+#include <post.h>
#include <watchdog.h>
#include <serial.h>
#include <linux/compiler.h>
@@ -153,6 +154,30 @@ static int uart_getc(uint32_t uart_base)
return uart_rbr_val;
}
+#if CONFIG_POST & CONFIG_SYS_POST_UART
+# define LOOP(x) x
+#else
+# define LOOP(x)
+#endif
+
+LOOP(
+static void uart_loop(uint32_t uart_base, int state)
+{
+ u16 mcr;
+
+ /* Drain the TX fifo first so bytes don't come back */
+ while (!(uart_lsr_read(uart_base) & TEMT))
+ continue;
+
+ mcr = bfin_read(&pUART->mcr);
+ if (state)
+ mcr |= LOOP_ENA | MRTS;
+ else
+ mcr &= ~(LOOP_ENA | MRTS);
+ bfin_write(&pUART->mcr, mcr);
+}
+)
+
#ifdef CONFIG_SYS_BFIN_UART
static void uart_puts(uint32_t uart_base, const char *s)
@@ -202,6 +227,13 @@ static void uart##n##_puts(const char *s) \
uart_puts(MMR_UART(n), s); \
} \
\
+LOOP( \
+static void uart##n##_loop(int state) \
+{ \
+ uart_loop(MMR_UART(n), state); \
+} \
+) \
+\
struct serial_device bfin_serial##n##_device = { \
.name = "bfin_uart"#n, \
.init = uart##n##_init, \
@@ -211,6 +243,7 @@ struct serial_device bfin_serial##n##_device = { \
.tstc = uart##n##_tstc, \
.putc = uart##n##_putc, \
.puts = uart##n##_puts, \
+ LOOP(.loop = uart##n##_loop) \
};
#ifdef UART0_DLL
@@ -307,6 +340,13 @@ void serial_puts(const char *s)
serial_putc(*s++);
}
+LOOP(
+void serial_loop(int state)
+{
+ uart_loop(UART_DLL, state);
+}
+)
+
#endif
#endif