From 5deb3317cb51ac52de922bb55f8492624018906d Mon Sep 17 00:00:00 2001 From: Roman Yeryomin Date: Thu, 13 Sep 2012 00:40:35 +0300 Subject: Add realtek target files Signed-off-by: Roman Yeryomin --- .../realtek/files/arch/mips/rtl8196c/printf.c | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 target/linux/realtek/files/arch/mips/rtl8196c/printf.c (limited to 'target/linux/realtek/files/arch/mips/rtl8196c/printf.c') 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 +#include +#include +#include +#include + +#include +#include + +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; +} -- cgit v1.2.3