public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Matthijs van Duin <matthijsvanduin@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/4] serial: ns16550: add definitions for register mdr1
Date: Mon, 8 Jan 2018 13:51:29 +0100	[thread overview]
Message-ID: <20180108125129.GA14062@squirrel.local> (raw)

Signed-off-by: Matthijs van Duin <matthijsvanduin@gmail.com>
---
 drivers/serial/ns16550.c | 10 +++++-----
 include/ns16550.h        | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 5ac2469b5760..41eb098c847e 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -166,7 +166,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 	     == UART_LSR_THRE) {
 		if (baud_divisor != -1)
 			NS16550_setbrg(com_port, baud_divisor);
-		serial_out(0, &com_port->mdr1);
+		serial_out(UART_MDR1_16X, &com_port->mdr1);
 	}
 #endif
 
@@ -175,7 +175,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 
 	serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
 #ifdef CONFIG_NS16550_OMAP
-	serial_out(0x7, &com_port->mdr1);	/* mode select reset TL16C750*/
+	serial_out(UART_MDR1_DISABLE, &com_port->mdr1);
 #endif
 	serial_out(UART_MCRVAL, &com_port->mcr);
 	serial_out(ns16550_getfcr(com_port), &com_port->fcr);
@@ -183,7 +183,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 		NS16550_setbrg(com_port, baud_divisor);
 #ifdef CONFIG_NS16550_OMAP
 	/* /16 is proper to hit 115200 with 48MHz */
-	serial_out(0, &com_port->mdr1);
+	serial_out(UART_MDR1_16X, &com_port->mdr1);
 #endif
 #ifdef CONFIG_NS16550_C6X
 	serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, &com_port->pwr_mgmt);
@@ -289,7 +289,7 @@ static inline void _debug_uart_init(void)
 	baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK,
 					    CONFIG_BAUDRATE);
 	serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER);
-	serial_dout(&com_port->mdr1, 0x7);
+	serial_dout(&com_port->mdr1, UART_MDR1_DISABLE);
 	serial_dout(&com_port->mcr, UART_MCRVAL);
 	serial_dout(&com_port->fcr, UART_FCR_DEFVAL);
 
@@ -297,7 +297,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, 0x0);
+	serial_dout(&com_port->mdr1, UART_MDR1_16X);
 }
 
 static inline void _debug_uart_putc(int ch)
diff --git a/include/ns16550.h b/include/ns16550.h
index 4a87ab9c8e71..540337258c1e 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -208,6 +208,20 @@ typedef struct NS16550 *NS16550_t;
 /* useful defaults for LCR */
 #define UART_LCR_8N1	0x03
 
+/*
+ * These are the definitions for Mode Definition Register 1
+ */
+#if defined(CONFIG_NS16550_C6X)
+#define UART_MDR1_16X		0x00	/* 16x oversampling (default) */
+#define UART_MDR1_13X		0x01	/* 13x oversampling */
+#elif defined(CONFIG_NS16550_OMAP)
+#define UART_MDR1_16X		0x00	/* 16x oversampling */
+#define UART_MDR1_16X_AUTOBAUD	0x02	/* 16x oversampling, auto-baud */
+#define UART_MDR1_13X		0x03	/* 13x oversampling */
+#define UART_MDR1_DISABLE	0x07	/* disable uart (default) */
+/* other values/bits are for infrared modes */
+#endif
+
 void NS16550_init(NS16550_t com_port, int baud_divisor);
 void NS16550_putc(NS16550_t com_port, char c);
 char NS16550_getc(NS16550_t com_port);
-- 
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=20180108125129.GA14062@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