[coreboot-gerrit] Patch set updated for coreboot: 6e5c169 allwinner/a10: Fix baudrate calculation

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Mon Feb 24 10:18:28 CET 2014


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5289

-gerrit

commit 6e5c169c4219ea81945ea5d0192dab5524a98f8c
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Wed Feb 19 08:58:12 2014 +0200

    allwinner/a10: Fix baudrate calculation
    
    UART input clock is platform dependent. Also account for possible
    use of get_option() where baudrate is not compile-time constant.
    
    Change-Id: Ie1c8789ef72430e43fc33bfa9ffb9f5346762439
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/cpu/allwinner/a10/uart.c         |  4 ++--
 src/cpu/allwinner/a10/uart_console.c | 22 ++++++----------------
 2 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/src/cpu/allwinner/a10/uart.c b/src/cpu/allwinner/a10/uart.c
index 97ac302..5486ac8 100644
--- a/src/cpu/allwinner/a10/uart.c
+++ b/src/cpu/allwinner/a10/uart.c
@@ -19,11 +19,11 @@ void a10_uart_configure(void *uart_base, u32 baud_rate, u8 data_bits,
 	u16 div;
 	struct a10_uart *uart = uart_base;
 
+	div = (u16) uart_baudrate_divisor(baud_rate,
+		uart_platform_refclk(), 16);
 	/* Enable access to Divisor Latch register */
 	write32(UART_LCR_DLAB, &uart->lcr);
 	/* Set baudrate */
-	/* FIXME: We assume clock is 24MHz, which may not be the case */
-	div = 24000000 / 16 / baud_rate;
 	write32((div >> 8) & 0xff, &uart->dlh);
 	write32(div & 0xff, &uart->dll);
 	/* Set line control */
diff --git a/src/cpu/allwinner/a10/uart_console.c b/src/cpu/allwinner/a10/uart_console.c
index 58930dd..f7bd3c6 100644
--- a/src/cpu/allwinner/a10/uart_console.c
+++ b/src/cpu/allwinner/a10/uart_console.c
@@ -38,29 +38,19 @@ static void *get_console_uart_base_addr(void)
 	return (void *)A1X_UART0_BASE;
 }
 
-static u32 get_console_uart_baud(void)
+/* FIXME: We assume clock is 24MHz, which may not be the case. */
+unsigned int uart_platform_refclk(void)
 {
-	if (CONFIG_CONSOLE_SERIAL_115200)
-		return 115200;
-	else if (CONFIG_CONSOLE_SERIAL_57600)
-		return 57600;
-	else if (CONFIG_CONSOLE_SERIAL_38400)
-		return 34800;
-	else if (CONFIG_CONSOLE_SERIAL_19200)
-		return 19200;
-	else if (CONFIG_CONSOLE_SERIAL_9600)
-		return 9600;
-
-	/* Default to 115200 if selection is invalid */
-	return 115200;
+	return 24000000;
 }
 
 static void a10_uart_init_dev(void)
 {
 	void *uart_base = get_console_uart_base_addr();
+
 	/* Use default 8N1 encoding */
-	a10_uart_configure(uart_base, get_console_uart_baud(),
-			   8, UART_PARITY_NONE, 1);
+	a10_uart_configure(uart_base, default_baudrate(),
+		8, UART_PARITY_NONE, 1);
 	a10_uart_enable_fifos(uart_base);
 }
 



More information about the coreboot-gerrit mailing list