[just RFC 1/2] serial: ns16550: introduce custom divisor latch setter

Antony Pavlov antonynpavlov at gmail.com
Sun Nov 22 23:55:35 PST 2015


Signed-off-by: Antony Pavlov <antonynpavlov at gmail.com>
---
 drivers/serial/serial_ns16550.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 1af226a..6a5e013 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -52,6 +52,7 @@ struct ns16550_priv {
 	unsigned iobase;
 	void (*write_reg)(struct ns16550_priv *, uint8_t val, unsigned offset);
 	uint8_t (*read_reg)(struct ns16550_priv *, unsigned offset);
+	void (*dl_write)(struct ns16550_priv *, unsigned baud_divisor);
 };
 
 struct ns16550_drvdata {
@@ -188,9 +189,14 @@ static int ns16550_setbaudrate(struct console_device *cdev, int baud_rate)
 	unsigned int baud_divisor = ns16550_calc_divisor(cdev, baud_rate);
 	struct ns16550_priv *priv = to_ns16550_priv(cdev);
 
-	ns16550_write(cdev, LCR_BKSE, lcr);
-	ns16550_write(cdev, baud_divisor & 0xff, dll);
-	ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
+	if (priv->dl_write) {
+		priv->dl_write(priv, baud_divisor);
+	} else {
+		ns16550_write(cdev, LCR_BKSE, lcr);
+		ns16550_write(cdev, baud_divisor & 0xff, dll);
+		ns16550_write(cdev, (baud_divisor >> 8) & 0xff, dlm);
+	}
+
 	ns16550_write(cdev, LCRVAL, lcr);
 	ns16550_write(cdev, MCRVAL, mcr);
 	ns16550_write(cdev, priv->fcrval, fcr);
-- 
2.6.2




More information about the barebox mailing list