summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2010-08-10 17:21:20 +0530
committerGary King <gking@nvidia.com>2010-08-17 00:35:54 -0700
commit6538f1285df4f8c0381b9995d8fd74b866119ebe (patch)
tree42de5e9c4bf81bb57676d4a9256cd3059905990a
parent284c5db914749b90da35a827d2ac0e343de7e9a8 (diff)
[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 <ldewangan@nvidia.com> Reviewed-by: Gary King <gking@nvidia.com>
-rwxr-xr-xdrivers/serial/tegra_hsuart.c11
1 files changed, 10 insertions, 1 deletions
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);