summaryrefslogtreecommitdiff
path: root/drivers/serial/serial_ns16550.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/serial/serial_ns16550.c')
-rw-r--r--drivers/serial/serial_ns16550.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index ba68d46948..4413e69118 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -120,6 +120,8 @@ static NS16550_t serial_ports[6] = {
static int calc_divisor (NS16550_t port)
{
+ const unsigned int mode_x_div = 16;
+
#ifdef CONFIG_OMAP1510
/* If can't cleanly clock 115200 set div to 1 */
if ((CONFIG_SYS_NS16550_CLK == 12000000) && (gd->baudrate == 115200)) {
@@ -128,21 +130,9 @@ static int calc_divisor (NS16550_t port)
}
port->osc_12m_sel = 0; /* clear if previsouly set */
#endif
-#ifdef CONFIG_OMAP1610
- /* If can't cleanly clock 115200 set div to 1 */
- if ((CONFIG_SYS_NS16550_CLK == 48000000) && (gd->baudrate == 115200)) {
- return (26); /* return 26 for base divisor */
- }
-#endif
-#define MODE_X_DIV 16
- /* Compute divisor value. Normally, we should simply return:
- * CONFIG_SYS_NS16550_CLK) / MODE_X_DIV / gd->baudrate
- * but we need to round that value by adding 0.5.
- * Rounding is especially important at high baud rates.
- */
- return (CONFIG_SYS_NS16550_CLK + (gd->baudrate * (MODE_X_DIV / 2))) /
- (MODE_X_DIV * gd->baudrate);
+ return DIV_ROUND_CLOSEST(CONFIG_SYS_NS16550_CLK,
+ mode_x_div * gd->baudrate);
}
void