summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-socfpga/include/mach/debug_ll.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-09-11 12:06:39 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-23 08:40:32 +0200
commit5b5f6ab6bfdd369bd2e3f968a868569c4399c374 (patch)
tree7fad81cb9b711a3ff46a153436dcda4bd27177d7 /arch/arm/mach-socfpga/include/mach/debug_ll.h
parent947d79651e433eeea1d0265f0965dc6c511edfc6 (diff)
downloadbarebox-5b5f6ab6bfdd369bd2e3f968a868569c4399c374.tar.gz
barebox-5b5f6ab6bfdd369bd2e3f968a868569c4399c374.tar.xz
ARM: Add Altera SoCFPGA support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-socfpga/include/mach/debug_ll.h')
-rw-r--r--arch/arm/mach-socfpga/include/mach/debug_ll.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/mach-socfpga/include/mach/debug_ll.h b/arch/arm/mach-socfpga/include/mach/debug_ll.h
new file mode 100644
index 0000000000..f378435970
--- /dev/null
+++ b/arch/arm/mach-socfpga/include/mach/debug_ll.h
@@ -0,0 +1,55 @@
+#ifndef __MACH_DEBUG_LL_H__
+#define __MACH_DEBUG_LL_H__
+
+#include <io.h>
+
+#define UART_BASE 0xffc02000
+
+#define LSR_THRE 0x20 /* Xmit holding register empty */
+#define LSR (5 << 2)
+#define THR (0 << 2)
+
+#define LCR_BKSE 0x80 /* Bank select enable */
+#define LSR (5 << 2)
+#define THR (0 << 2)
+#define DLL (0 << 2)
+#define IER (1 << 2)
+#define DLM (1 << 2)
+#define FCR (2 << 2)
+#define LCR (3 << 2)
+#define MCR (4 << 2)
+#define MDR (8 << 2)
+
+static inline unsigned int ns16550_calc_divisor(unsigned int clk,
+ unsigned int baudrate)
+{
+ return (clk / 16 / baudrate);
+}
+
+static inline void INIT_LL(void)
+{
+ unsigned int clk = 100000000;
+ unsigned int divisor = clk / 16 / 115200;
+
+ writeb(0x00, UART_BASE + LCR);
+ writeb(0x00, UART_BASE + IER);
+ writeb(0x07, UART_BASE + MDR);
+ writeb(LCR_BKSE, UART_BASE + LCR);
+ writeb(divisor & 0xff, UART_BASE + DLL);
+ writeb(divisor >> 8, UART_BASE + DLM);
+ writeb(0x03, UART_BASE + LCR);
+ writeb(0x03, UART_BASE + MCR);
+ writeb(0x07, UART_BASE + FCR);
+ writeb(0x00, UART_BASE + MDR);
+}
+
+static inline void PUTC_LL(char c)
+{
+ /* Wait until there is space in the FIFO */
+ while ((readb(UART_BASE + LSR) & LSR_THRE) == 0);
+ /* Send the character */
+ writeb(c, UART_BASE + THR);
+ /* Wait to make sure it hits the line, in case we die too soon. */
+ while ((readb(UART_BASE + LSR) & LSR_THRE) == 0);
+}
+#endif