summaryrefslogtreecommitdiffstats
path: root/target/linux/realtek/files/arch/mips/rtl8196c/printf.c
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2012-09-13 00:40:35 +0300
committerRoman Yeryomin <roman@advem.lv>2012-12-03 00:13:21 +0200
commit5deb3317cb51ac52de922bb55f8492624018906d (patch)
treec2fbe6346699d9bb0f2100490c3029519bb8fde8 /target/linux/realtek/files/arch/mips/rtl8196c/printf.c
parent0239d37124f9184b478a42de8a7fa1bc85a6a6fe (diff)
Add realtek target files
Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'target/linux/realtek/files/arch/mips/rtl8196c/printf.c')
-rw-r--r--target/linux/realtek/files/arch/mips/rtl8196c/printf.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/target/linux/realtek/files/arch/mips/rtl8196c/printf.c b/target/linux/realtek/files/arch/mips/rtl8196c/printf.c
new file mode 100644
index 000000000..650f46d27
--- /dev/null
+++ b/target/linux/realtek/files/arch/mips/rtl8196c/printf.c
@@ -0,0 +1,51 @@
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
+#include <prom.h>
+#include <platform.h>
+
+void __init prom_console_init(void)
+{
+ /* 8 bits, 1 stop bit, no parity. */
+ REG8(UART0_LCR) = CHAR_LEN_8 | ONE_STOP | PARITY_DISABLE;
+
+ /* Reset/Enable the FIFO */
+ REG8(UART0_FCR) = FCR_EN | RXRST | TXRST | CHAR_TRIGGER_14;
+
+ /* Disable All Interrupts */
+ REG8(UART0_IER) = 0x00000000;
+
+ /* Enable Divisor Latch */
+ REG8(UART0_LCR) |= DLAB;
+
+ /* Set Divisor */
+ REG8(UART0_DLL) = (SYSCLK / (BAUDRATE * 16) - 1) & 0x00FF;
+ REG8(UART0_DLM) = ((SYSCLK / (BAUDRATE * 16) - 1) & 0xFF00) >> 8;
+
+ /* Disable Divisor Latch */
+ REG8(UART0_LCR) &= (~DLAB);
+}
+
+int prom_putchar(char c)
+{
+ unsigned int busy_cnt = 0;
+
+ do
+ {
+ /* Prevent Hanging */
+ if (busy_cnt++ >= 30000)
+ {
+ /* Reset Tx FIFO */
+ REG8(UART0_FCR) = TXRST | CHAR_TRIGGER_14;
+ return 0;
+ }
+ } while ((REG8(UART0_LSR) & LSR_THRE) == TxCHAR_AVAIL);
+
+ /* Send Character */
+ REG8(UART0_THR) = c;
+
+ return 1;
+}