Blob Blame History Raw
From: Vabhav Sharma <vabhav.sharma@nxp.com>
Date: Fri, 26 Jun 2020 16:50:34 +0530
Subject: tty: serial: fsl_lpuart: minimum baud rate support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Git-commit: d10ee1d1917b082f0008a840cde5aeaad11b396b
Patch-mainline: v5.9-rc1
References: jsc#SLE-12251

The formula for the baud rate is
baud rate = "baud clock / ((OSR+1) × SBR)

Algorithm used in function lpuart32_serial_setbrg() only changes
the SBR. Even with maxmum value put in, OSR stays at 0x7 and the
lowest baud rate would be ~ 2600 bps

Update the algorithm to allow driver operation at 1200,2400 or 600 bps

Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Link: https://lore.kernel.org/r/1593170434-13524-1-git-send-email-vabhav.sharma@oss.nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@suse.com>
---
 drivers/tty/serial/fsl_lpuart.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 90298c403042..7ca642249224 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -1925,6 +1925,9 @@ static void __lpuart32_serial_setbrg(struct uart_port *port,
 			tmp_sbr++;
 		}
 
+		if (tmp_sbr > UARTBAUD_SBR_MASK)
+			continue;
+
 		if (tmp_diff <= baud_diff) {
 			baud_diff = tmp_diff;
 			osr = tmp_osr;
-- 
2.26.2