summaryrefslogtreecommitdiff
path: root/src/cpu/ti
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2014-02-19 08:58:12 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2014-03-04 15:24:50 +0100
commit2cbcd2b7103f61a0a5b5f755aa92e3da8ec527f5 (patch)
tree1c070fd53f101b8a0bae66b6e298beadc08a0188 /src/cpu/ti
parent65ba20e17bd91e4b92e34b495f64a51a0313f6a9 (diff)
downloadcoreboot-2cbcd2b7103f61a0a5b5f755aa92e3da8ec527f5.tar.xz
ti/am335x: Fix baudrate calculation
UART input clock is platform dependent. Also account for possible use of get_option() where baudrate is not compile-time constant. The hardware reference on BeagleBone is from a 48 MHz oscillator input. With pre-divisor of 16 we get same register values as in table 19-25. Change-Id: I89aee27c958f8618ce79a968ae7520a867e7e8a2 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/5290 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/cpu/ti')
-rw-r--r--src/cpu/ti/am335x/uart.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/cpu/ti/am335x/uart.c b/src/cpu/ti/am335x/uart.c
index bd2ff44044..719215ec8c 100644
--- a/src/cpu/ti/am335x/uart.c
+++ b/src/cpu/ti/am335x/uart.c
@@ -35,10 +35,10 @@
#define LSR_TXFIFOE (1 << 5)
/*
- * Initialise the serial port with the given baudrate. The settings
+ * Initialise the serial port with the given baudrate divisor. The settings
* are always 8 data bits, no parity, 1 stop bit, no start bits.
*/
-static void am335x_uart_init_dev(void)
+static void am335x_uart_init(uint16_t div)
{
struct am335x_uart *uart = (struct am335x_uart *)
CONFIG_CONSOLE_SERIAL_UART_ADDRESS;
@@ -107,24 +107,8 @@ static void am335x_uart_init_dev(void)
write16(0xbf, &uart->lcr);
/* 7. Set dll and dlh to the desired values (table 19-25) */
- if (CONFIG_CONSOLE_SERIAL_9600) {
- write16(0x01, &uart->dlh);
- write16(0x38, &uart->dll);
- } else if (CONFIG_CONSOLE_SERIAL_19200) {
- write16(0x00, &uart->dlh);
- write16(0x9c, &uart->dll);
- } else if (CONFIG_CONSOLE_SERIAL_38400) {
- write16(0x00, &uart->dlh);
- write16(0x4e, &uart->dll);
- } else if (CONFIG_CONSOLE_SERIAL_57600) {
- write16(0x00, &uart->dlh);
- write16(0x34, &uart->dll);
- } else if (CONFIG_CONSOLE_SERIAL_115200) {
- write16(0x00, &uart->dlh);
- write16(0x1a, &uart->dll);
- } else {
- /* Unrecognized baud rate? */
- }
+ write16((div >> 8), &uart->dlh);
+ write16((div & 0xff), &uart->dll);
/* 8. Switch to operational mode to access ier */
write16(0x0, &uart->lcr);
@@ -173,12 +157,24 @@ static void am335x_uart_tx_byte(unsigned char data)
return write8(data, &uart->thr);
}
+unsigned int uart_platform_refclk(void)
+{
+ return 48000000;
+}
+
+static void am335x_uart_init_dev(void)
+{
+ uint16_t div = (uint16_t) uart_baudrate_divisor(
+ default_baudrate(), uart_platform_refclk(), 16);
+ am335x_uart_init(div);
+}
+
+#if !defined(__PRE_RAM__)
uint32_t uartmem_getbaseaddr(void)
{
return CONFIG_CONSOLE_SERIAL_UART_ADDRESS;
}
-#if !defined(__PRE_RAM__)
static const struct console_driver exynos5_uart_console __console = {
.init = am335x_uart_init_dev,
.tx_byte = am335x_uart_tx_byte,