From: Matthijs van Duin <matthijsvanduin@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] serial: ns16550: centralize identification of uart variants
Date: Mon, 8 Jan 2018 13:51:15 +0100 [thread overview]
Message-ID: <20180108125115.GA14044@squirrel.local> (raw)
Signed-off-by: Matthijs van Duin <matthijsvanduin@gmail.com>
---
drivers/serial/ns16550.c | 8 ++++----
include/ns16550.h | 11 +++++++++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 9cec58c887c8..5ac2469b5760 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -36,7 +36,7 @@ DECLARE_GLOBAL_DATA_PTR;
#endif
#endif /* !CONFIG_DM_SERIAL */
-#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
+#ifdef CONFIG_NS16550_C6X
#define UART_REG_VAL_PWREMU_MGMT_UART_DISABLE 0
#define UART_REG_VAL_PWREMU_MGMT_UART_ENABLE ((1 << 14) | (1 << 13) | (1 << 0))
#undef UART_MCRVAL
@@ -174,18 +174,18 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
;
serial_out(CONFIG_SYS_NS16550_IER, &com_port->ier);
-#if defined(CONFIG_ARCH_OMAP2PLUS)
+#ifdef CONFIG_NS16550_OMAP
serial_out(0x7, &com_port->mdr1); /* mode select reset TL16C750*/
#endif
serial_out(UART_MCRVAL, &com_port->mcr);
serial_out(ns16550_getfcr(com_port), &com_port->fcr);
if (baud_divisor != -1)
NS16550_setbrg(com_port, baud_divisor);
-#if defined(CONFIG_ARCH_OMAP2PLUS)
+#ifdef CONFIG_NS16550_OMAP
/* /16 is proper to hit 115200 with 48MHz */
serial_out(0, &com_port->mdr1);
#endif
-#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
+#ifdef CONFIG_NS16550_C6X
serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, &com_port->pwr_mgmt);
#endif
}
diff --git a/include/ns16550.h b/include/ns16550.h
index a988d297e144..4a87ab9c8e71 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -45,6 +45,13 @@
unsigned char postpad_##x[-CONFIG_SYS_NS16550_REG_SIZE - 1];
#endif
+/* Identify major NS16550 variants */
+#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
+#define CONFIG_NS16550_C6X 1
+#elif defined(CONFIG_ARCH_OMAP2PLUS)
+#define CONFIG_NS16550_OMAP 1
+#endif
+
/**
* struct ns16550_platdata - information about a NS16550 port
*
@@ -71,14 +78,14 @@ struct NS16550 {
UART_REG(lsr); /* 5 */
UART_REG(msr); /* 6 */
UART_REG(spr); /* 7 */
-#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
+#if defined(CONFIG_NS16550_C6X)
UART_REG(reg8); /* 8 */
UART_REG(reg9); /* 9 */
UART_REG(revid1); /* A */
UART_REG(revid2); /* B */
UART_REG(pwr_mgmt); /* C */
UART_REG(mdr1); /* D */
-#else
+#elif defined(CONFIG_NS16550_OMAP)
UART_REG(mdr1); /* 8 */
UART_REG(reg9); /* 9 */
UART_REG(regA); /* A */
--
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=20180108125115.GA14044@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