@@ -3,12 +3,17 @@ LDFLAGS=-static -nostdlib
GCC=$(CROSS_COMPILE)gcc
OBJCOPY=$(CROSS_COMPILE)objcopy
LD=$(CROSS_COMPILE)ld
-LOADADDR=0xa0008000
+LOADADDR=0x10008000
BINFMT=elf32-littlearm
MFG=raumfeld
+UART=8250
+UART_BASE=0xf1012000
+
+CFLAGS+=-DUART_BASE=$(UART_BASE)
BOARD_OBJ = board-$(MFG).o
+UART_OBJ = serial-$(UART).o
COMMON_OBJS = \
main.o \
@@ -38,7 +43,7 @@ zimage.o: input/zImage
%.o: %.c
$(GCC) $(CFLAGS) -c $^
-matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(INPUT_OBJS)
+matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(UART_OBJ) $(INPUT_OBJS)
$(LD) $(LDFLAGS) -T matcher.lds -o $@ $^
matcher.bin: matcher
@@ -1,5 +1,5 @@
SECTIONS {
- . = 0xa0008000;
+ . = 0x10008000;
.text : { * (.text); }
.data : { * (.data); }
.rodata : { * (.rodata); }
@@ -1,5 +1,6 @@
#include "types.h"
#include "print.h"
+#include "serial.h"
static inline void nop(int n)
{
@@ -7,12 +8,6 @@ static inline void nop(int n)
asm("nop");
}
-static void __putch(char c)
-{
- *(volatile __u32 *) 0x40100000 = c;
- nop(100);
-}
-
void putch(char c)
{
__putch(c);
@@ -39,4 +34,3 @@ void putstr(const char *s)
while (*s)
putch(*s++);
}
-
new file mode 100644
@@ -0,0 +1,21 @@
+#include "types.h"
+#include "register.h"
+#include "serial.h"
+
+/*
+ * Whole heartedly copied from barebox's mach-mvebu debug code. Thanks to
+ * Thomas Petazzoni for the original code.
+ */
+void __putch(char c)
+{
+ /* Wait until there is space in the FIFO */
+ while (!(readl(UART_BASE + UART_LSR) & LSR_THRE))
+ ;
+
+ /* Send the character */
+ writel(c, UART_BASE + UART_THR);
+
+ /* Wait to make sure it hits the line */
+ while (!(readl(UART_BASE + UART_LSR) & LSR_THRE))
+ ;
+}
new file mode 100644
@@ -0,0 +1,10 @@
+#ifndef _SERIAL_H
+#define _SERIAL_H
+
+#define BIT(nr) (1UL << (nr))
+#define UART_THR 0x00
+#define UART_LSR 0x14
+#define LSR_THRE BIT(5)
+
+void __putch(char);
+#endif
Signed-off-by: Jason Cooper <jason@lakedaemon.net> --- Makefile | 9 +++++++-- matcher.lds | 2 +- print.c | 8 +------- serial-8250.c | 21 +++++++++++++++++++++ serial.h | 10 ++++++++++ 5 files changed, 40 insertions(+), 10 deletions(-) create mode 100644 serial-8250.c create mode 100644 serial.h