From: Matthijs van Duin <matthijsvanduin@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] serial: ns16550: use 13x oversampling when available
Date: Mon, 8 Jan 2018 13:51:51 +0100 [thread overview]
Message-ID: <20180108125151.GA14079@squirrel.local> (raw)
This allows much higher baudrates in the standard series to be used, up
to 32 * 115200 = 3686400 bps with 0.16% deviation.
Signed-off-by: Matthijs van Duin <matthijsvanduin@gmail.com>
---
drivers/serial/ns16550.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 41eb098c847e..a131d1658bd4 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -140,7 +140,11 @@ static u32 ns16550_getfcr(NS16550_t port)
int ns16550_calc_divisor(NS16550_t port, int clock, int baudrate)
{
+#ifdef UART_MDR1_13X
+ const unsigned int mode_x_div = 13;
+#else
const unsigned int mode_x_div = 16;
+#endif
return DIV_ROUND_CLOSEST(clock, mode_x_div * baudrate);
}
@@ -181,9 +185,9 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
serial_out(ns16550_getfcr(com_port), &com_port->fcr);
if (baud_divisor != -1)
NS16550_setbrg(com_port, baud_divisor);
-#ifdef CONFIG_NS16550_OMAP
- /* /16 is proper to hit 115200 with 48MHz */
- serial_out(UART_MDR1_16X, &com_port->mdr1);
+#ifdef UART_MDR1_13X
+ /* /13 is proper to hit 115200*{1,2,4,8,16,32} with 48MHz */
+ serial_out(UART_MDR1_13X, &com_port->mdr1);
#endif
#ifdef CONFIG_NS16550_C6X
serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, &com_port->pwr_mgmt);
@@ -297,7 +301,7 @@ static inline void _debug_uart_init(void)
serial_dout(&com_port->dll, baud_divisor & 0xff);
serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff);
serial_dout(&com_port->lcr, UART_LCRVAL);
- serial_dout(&com_port->mdr1, UART_MDR1_16X);
+ serial_dout(&com_port->mdr1, UART_MDR1_13X);
}
static inline void _debug_uart_putc(int ch)
--
2.11.0
reply other threads:[~2018-01-08 12:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180108125151.GA14079@squirrel.local \
--to=matthijsvanduin@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox