From 6538f1285df4f8c0381b9995d8fd74b866119ebe Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 10 Aug 2010 17:21:20 +0530 Subject: [arm/tegra] Serial: Confirming configured baudrate. Sometimes, in uart, the desired baudrate can not be configured in 5% error accuracy due to not finding the correct combination of clock source freq and integer divisor. In this case the driver should generate the error message. Change-Id: Iafe245876a2cb9810c1025c02a4b6a36eb26aa4c Reviewed-on: http://git-master/r/4974 Tested-by: Laxman Dewangan Reviewed-by: Gary King --- drivers/serial/tegra_hsuart.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/serial/tegra_hsuart.c b/drivers/serial/tegra_hsuart.c index 7c1b1ac5bf42..0ff553d6f74f 100755 --- a/drivers/serial/tegra_hsuart.c +++ b/drivers/serial/tegra_hsuart.c @@ -971,13 +971,15 @@ static void tegra_enable_ms(struct uart_port *u) { } -#define UART_CLOCK_ACCURACY 5 +#define UART_BAUD_ACCURACY 5 static void tegra_set_baudrate(struct tegra_uart_port *t, unsigned int baud) { unsigned long rate; unsigned int divisor; unsigned char lcr; + unsigned int baud_actual; + unsigned int baud_delta; if (t->baud == baud) return; @@ -991,6 +993,13 @@ static void tegra_set_baudrate(struct tegra_uart_port *t, unsigned int baud) divisor += baud/2; do_div(divisor, baud); + /* The allowable baudrate error from desired baudrate is 5% */ + baud_actual = divisor ? rate / (16 * divisor) : 0; + baud_delta = abs(baud_actual - baud); + if (WARN_ON(baud_delta * 20 > baud)) { + dev_err(t->uport.dev, "requested baud %lu, actual %lu\n", baud, baud_actual); + } + lcr = t->lcr_shadow; lcr |= UART_LCR_DLAB; uart_writeb(t, lcr, UART_LCR); -- cgit v1.2.3