Re: [U-Boot] [U-Boot, 1/4] serial: ns16550: da8xx (freon/primus) is not omap-like

2018-01-19 Thread Matthijs van Duin
On 19 January 2018 at 16:41, Tom Rini  wrote:
> OK.  For v2, if you can convert CONFIG_SYS_NS16550_MEM32 to Kconfig as
> well I'd appreciate it.

I'm not hugely comfortable doing that, since that would affect even
more targets. To be honest, I don't understand why it even exists as a
separate var instead of just testing whether
CONFIG_SYS_NS16550_REG_SIZE is 4 or -4. Are there actually some crazy
targets that allocate 4 bytes per register yet fail if you use 32-bit
access?

Would you object hugely to me just implicitly setting
CONFIG_SYS_NS16550_MEM32 in ns16550.h for the c6x uart variant? I
think it makes a lot of sense to do so, since in that case the driver
itself explicitly depends on being able to write a value that doesn't
fit in a byte.

> I'll see about digging out and setting up one
> of my da8xx platforms for a quick runtime test too.

Thanks!

Matthijs
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [U-Boot, 1/4] serial: ns16550: da8xx (freon/primus) is not omap-like

2018-01-19 Thread Matthijs van Duin
On 19 January 2018 at 16:26, Tom Rini  wrote:
> This introduces a warning on all SOC_DA8XX systems because they do not
> set CONFIG_SYS_NS16550_MEM32 so serial_out is writeb

Well that's a mistake. Its uart uses 32-bit registers, and 8-bit
access is not documented to be acceptable.

Apologies for forgetting to at least compile-test this for all
affected targets, I really should have done that.

> Are you able to test SOC_DA8XX platforms?

No, this was based on my knowledge that freon/primus SoCs
(OMAP-L1xx/AM1xxx/TMS320C674x/DA8xx) are architecturally members of
the TI C6x family and not remotely related to the OMAP (despite the
part code "OMAP-L1xx"), and I double-checked the technical reference
manual: their UART is identical to that on Keystone.

Matthijs
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/4] serial: ns16550: add definitions for register mdr1

2018-01-08 Thread Matthijs van Duin
Signed-off-by: Matthijs van Duin <matthijsvand...@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, _port->mdr1);
+   serial_out(UART_MDR1_16X, _port->mdr1);
}
 #endif
 
@@ -175,7 +175,7 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
 
serial_out(CONFIG_SYS_NS16550_IER, _port->ier);
 #ifdef CONFIG_NS16550_OMAP
-   serial_out(0x7, _port->mdr1);   /* mode select reset TL16C750*/
+   serial_out(UART_MDR1_DISABLE, _port->mdr1);
 #endif
serial_out(UART_MCRVAL, _port->mcr);
serial_out(ns16550_getfcr(com_port), _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, _port->mdr1);
+   serial_out(UART_MDR1_16X, _port->mdr1);
 #endif
 #ifdef CONFIG_NS16550_C6X
serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, _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(_port->ier, CONFIG_SYS_NS16550_IER);
-   serial_dout(_port->mdr1, 0x7);
+   serial_dout(_port->mdr1, UART_MDR1_DISABLE);
serial_dout(_port->mcr, UART_MCRVAL);
serial_dout(_port->fcr, UART_FCR_DEFVAL);
 
@@ -297,7 +297,7 @@ static inline void _debug_uart_init(void)
serial_dout(_port->dll, baud_divisor & 0xff);
serial_dout(_port->dlm, (baud_divisor >> 8) & 0xff);
serial_dout(_port->lcr, UART_LCRVAL);
-   serial_dout(_port->mdr1, 0x0);
+   serial_dout(_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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/4] serial: ns16550: use 13x oversampling when available

2018-01-08 Thread Matthijs van Duin
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 <matthijsvand...@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), _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, _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, _port->mdr1);
 #endif
 #ifdef CONFIG_NS16550_C6X
serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, _port->pwr_mgmt);
@@ -297,7 +301,7 @@ static inline void _debug_uart_init(void)
serial_dout(_port->dll, baud_divisor & 0xff);
serial_dout(_port->dlm, (baud_divisor >> 8) & 0xff);
serial_dout(_port->lcr, UART_LCRVAL);
-   serial_dout(_port->mdr1, UART_MDR1_16X);
+   serial_dout(_port->mdr1, UART_MDR1_13X);
 }
 
 static inline void _debug_uart_putc(int ch)
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/4] serial: ns16550: da8xx (freon/primus) is not omap-like

2018-01-08 Thread Matthijs van Duin
These are SoCs in the lineage of TI C6x DSPs, and as such have the same
uart as TI Keystone SoCs.

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

diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index c702304e79bd..9cec58c887c8 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)
+#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
 #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
@@ -181,12 +181,12 @@ void NS16550_init(NS16550_t com_port, int baud_divisor)
serial_out(ns16550_getfcr(com_port), _port->fcr);
if (baud_divisor != -1)
NS16550_setbrg(com_port, baud_divisor);
-#if defined(CONFIG_ARCH_OMAP2PLUS) || defined(CONFIG_SOC_DA8XX)
+#if defined(CONFIG_ARCH_OMAP2PLUS)
/* /16 is proper to hit 115200 with 48MHz */
serial_out(0, _port->mdr1);
 #endif
-#if defined(CONFIG_SOC_KEYSTONE)
-   serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, _port->regC);
+#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
+   serial_out(UART_REG_VAL_PWREMU_MGMT_UART_ENABLE, _port->pwr_mgmt);
 #endif
 }
 
diff --git a/include/ns16550.h b/include/ns16550.h
index 5fcbcd2e74e3..a988d297e144 100644
--- a/include/ns16550.h
+++ b/include/ns16550.h
@@ -71,7 +71,7 @@ struct NS16550 {
UART_REG(lsr);  /* 5 */
UART_REG(msr);  /* 6 */
UART_REG(spr);  /* 7 */
-#ifdef CONFIG_SOC_DA8XX
+#if defined(CONFIG_SOC_KEYSTONE) || defined(CONFIG_SOC_DA8XX)
UART_REG(reg8); /* 8 */
UART_REG(reg9); /* 9 */
UART_REG(revid1);   /* A */
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/4] serial: ns16550: centralize identification of uart variants

2018-01-08 Thread Matthijs van Duin
Signed-off-by: Matthijs van Duin <matthijsvand...@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, _port->ier);
-#if defined(CONFIG_ARCH_OMAP2PLUS)
+#ifdef CONFIG_NS16550_OMAP
serial_out(0x7, _port->mdr1);   /* mode select reset TL16C750*/
 #endif
serial_out(UART_MCRVAL, _port->mcr);
serial_out(ns16550_getfcr(com_port), _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, _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, _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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/4] serial: ns16550: cleanups and 13x oversampling

2018-01-08 Thread Matthijs van Duin
This is a small patch set we've been using internally for a while now,
and I figured it may be useful for mainline.

It originated from the desire of running the linux console at a higher
bitrate, and therefore also the u-boot console for consistency's sake.

When using 16x oversampling and an 48 MHz reference clock, the standard
rate 115200 requires a /26 divider, which also means that the only
higher standard rate available is 230400 (/13 divider).  In contrast, if
13x oversampling is used then the divider for 115200 is /32, which
yields a much greater range of standard rates to be used.

This patch set consists of three cleanup patches related to TI OMAP and
TI C6x style uarts, and finally one patch that configures 13x
oversampling on both of them.

-- 
Matthijs van Duin
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] arm: omap-common: Fix typo in CONFIG_OMAP54XX guard

2017-03-08 Thread Matthijs van Duin
Some initialization was unintentionally being skipped on omap5.

Fixes: f5af0827f276 ("arm: omap-common: Guard some parts of the code with 
CONFIG_OMAP44XX/OMAP54XX")
Signed-off-by: Matthijs van Duin <matthijsvand...@gmail.com>
---
 arch/arm/mach-omap2/emif-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-omap2/emif-common.c 
b/arch/arm/mach-omap2/emif-common.c
index b26984e26c5e..def7fe0f0a85 100644
--- a/arch/arm/mach-omap2/emif-common.c
+++ b/arch/arm/mach-omap2/emif-common.c
@@ -1195,7 +1195,7 @@ static void do_sdram_init(u32 base)
ddr3_init(base, regs);
 #endif
}
-#ifdef CONFIG_OMAP54X
+#ifdef CONFIG_OMAP54XX
if (warm_reset() && (emif_sdram_type(regs->sdram_config) ==
EMIF_SDRAM_TYPE_DDR3) && !is_dra7xx()) {
set_lpmode_selfrefresh(base);
-- 
2.11.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot