diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2007-11-22 06:10:53 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2007-11-22 06:10:53 +0000 |
commit | f5dea7005a658b2fe7ff8828b00c3a397119a985 (patch) | |
tree | 996130c40fc84592c239e4649f8a4a27424616cf /c/src/lib/libbsp/powerpc/shared/console/uart.c | |
parent | 2007-11-22 Chris Johns <chrisj@rtems.org> (diff) | |
download | rtems-f5dea7005a658b2fe7ff8828b00c3a397119a985.tar.bz2 |
2007-11-21 Till Straumann <strauman@slac.stanford.edu>
* shared/console/uart.c: when draining UART during
initialization (wait for possible printk() activity
to finish) look at TEMT (fifo, holding-reg and shift-reg)
rather than THRE (fifo, holding-reg only). This resolved
some scrambled output issues for me.
Enhanced semantics: if BSP initializes BSPBaseBaud to a negative
value then the driver interprets the modulus as a speed value
and uses the current setting of the divisor to compute the
clock speed (BSPBaseBaud). This is useful if you have a board
that you know is initialized e.g., to 9600 but you
don't know the clock speed.
Diffstat (limited to '')
-rw-r--r-- | c/src/lib/libbsp/powerpc/shared/console/uart.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/c/src/lib/libbsp/powerpc/shared/console/uart.c b/c/src/lib/libbsp/powerpc/shared/console/uart.c index 11d9b64ce7..2e564a6af9 100644 --- a/c/src/lib/libbsp/powerpc/shared/console/uart.c +++ b/c/src/lib/libbsp/powerpc/shared/console/uart.c @@ -144,7 +144,7 @@ BSP_uart_init(int uart, int baud, int hwFlow) /* Make sure any printk activity drains before * re-initializing. */ - while ( ! (uread(uart, LSR) & THRE) ) + while ( ! (uread(uart, LSR) & TEMT) ) ; switch(baud) @@ -171,6 +171,12 @@ BSP_uart_init(int uart, int baud, int hwFlow) /* Set DLAB bit to 1 */ uwrite(uart, LCR, DLAB); + if ( (int)BSPBaseBaud <= 0 ) { + /* Use current divisor assuming BSPBaseBaud gives us the current speed */ + BSPBaseBaud = BSPBaseBaud ? -BSPBaseBaud : 9600; + BSPBaseBaud *= ((uread(uart, DLM) << 8) | uread(uart, DLL)); + } + /* Set baud rate */ uwrite(uart, DLL, (BSPBaseBaud/baud) & 0xff); uwrite(uart, DLM, ((BSPBaseBaud/baud) >> 8) & 0xff); |