* [U-Boot] [RFC PATCH] serial: omap: Support debug UART
@ 2017-04-22 10:27 Lokesh Vutla
2017-04-29 0:26 ` Simon Glass
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Lokesh Vutla @ 2017-04-22 10:27 UTC (permalink / raw)
To: u-boot
Add debug UART functions to permit omap specific ns16550 to
provide an early debug UART. This is mostly in common with
DEBUG_UART_NS16550 except for Mode definition register which
is required for selecting UART mode(16x auto-baud or 13x mode).
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
- I understand it is duplication of code, but I guess the idea
is not to use NS16550_init() as it has lot of ifdefs. Please
advice if this can be improved.
drivers/serial/Kconfig | 7 +++++++
drivers/serial/ns16550.c | 47 ++++++++++++++++++++++++++++++++++++-----------
include/debug_uart.h | 11 +++++++++++
3 files changed, 54 insertions(+), 11 deletions(-)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index c0ec2ec2e4..5db9ec744e 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -238,6 +238,13 @@ config DEBUG_UART_UNIPHIER
driver will be available until the real driver-model serial is
running.
+config DEBUG_UART_OMAP
+ bool "OMAP uart"
+ help
+ Select this to enable a debug UART using the omap ns16550 driver.
+ You will need to provide parameters to make this work. The driver
+ will be available until the real driver model serial is running.
+
endchoice
config DEBUG_UART_BASE
diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c
index 4f86780cb1..ca55df78b7 100644
--- a/drivers/serial/ns16550.c
+++ b/drivers/serial/ns16550.c
@@ -246,17 +246,6 @@ int NS16550_tstc(NS16550_t com_port)
#include <debug_uart.h>
-#define serial_dout(reg, value) \
- serial_out_shift((char *)com_port + \
- ((char *)reg - (char *)com_port) * \
- (1 << CONFIG_DEBUG_UART_SHIFT), \
- CONFIG_DEBUG_UART_SHIFT, value)
-#define serial_din(reg) \
- serial_in_shift((char *)com_port + \
- ((char *)reg - (char *)com_port) * \
- (1 << CONFIG_DEBUG_UART_SHIFT), \
- CONFIG_DEBUG_UART_SHIFT)
-
static inline void _debug_uart_init(void)
{
struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
@@ -293,6 +282,42 @@ DEBUG_UART_FUNCS
#endif
+#ifdef CONFIG_DEBUG_UART_OMAP
+
+#include <debug_uart.h>
+
+static inline void _debug_uart_init(void)
+{
+ struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+ int baud_divisor;
+
+ 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->mcr, UART_MCRVAL);
+ serial_dout(&com_port->fcr, UART_FCR_DEFVAL);
+
+ serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL);
+ 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);
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+ struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE;
+
+ while (!(serial_din(&com_port->lsr) & UART_LSR_THRE))
+ ;
+ serial_dout(&com_port->thr, ch);
+}
+
+DEBUG_UART_FUNCS
+
+#endif
+
#ifdef CONFIG_DM_SERIAL
static int ns16550_serial_putc(struct udevice *dev, const char ch)
{
diff --git a/include/debug_uart.h b/include/debug_uart.h
index 2980ae6200..6f0b0c5e15 100644
--- a/include/debug_uart.h
+++ b/include/debug_uart.h
@@ -111,6 +111,17 @@ void printhex8(uint value);
#define _DEBUG_UART_ANNOUNCE
#endif
+#define serial_dout(reg, value) \
+ serial_out_shift((char *)com_port + \
+ ((char *)reg - (char *)com_port) * \
+ (1 << CONFIG_DEBUG_UART_SHIFT), \
+ CONFIG_DEBUG_UART_SHIFT, value)
+#define serial_din(reg) \
+ serial_in_shift((char *)com_port + \
+ ((char *)reg - (char *)com_port) * \
+ (1 << CONFIG_DEBUG_UART_SHIFT), \
+ CONFIG_DEBUG_UART_SHIFT)
+
/*
* Now define some functions - this should be inserted into the serial driver
*/
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [RFC PATCH] serial: omap: Support debug UART
2017-04-22 10:27 [U-Boot] [RFC PATCH] serial: omap: Support debug UART Lokesh Vutla
@ 2017-04-29 0:26 ` Simon Glass
2017-05-05 14:18 ` Tom Rini
2017-05-12 17:19 ` [U-Boot] [U-Boot,RFC] " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2017-04-29 0:26 UTC (permalink / raw)
To: u-boot
On 22 April 2017 at 04:27, Lokesh Vutla <lokeshvutla@ti.com> wrote:
> Add debug UART functions to permit omap specific ns16550 to
> provide an early debug UART. This is mostly in common with
> DEBUG_UART_NS16550 except for Mode definition register which
> is required for selecting UART mode(16x auto-baud or 13x mode).
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
> - I understand it is duplication of code, but I guess the idea
> is not to use NS16550_init() as it has lot of ifdefs. Please
> advice if this can be improved.
>
> drivers/serial/Kconfig | 7 +++++++
> drivers/serial/ns16550.c | 47 ++++++++++++++++++++++++++++++++++++-----------
> include/debug_uart.h | 11 +++++++++++
> 3 files changed, 54 insertions(+), 11 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [RFC PATCH] serial: omap: Support debug UART
2017-04-22 10:27 [U-Boot] [RFC PATCH] serial: omap: Support debug UART Lokesh Vutla
2017-04-29 0:26 ` Simon Glass
@ 2017-05-05 14:18 ` Tom Rini
2017-05-12 17:19 ` [U-Boot] [U-Boot,RFC] " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-05-05 14:18 UTC (permalink / raw)
To: u-boot
On Sat, Apr 22, 2017 at 03:57:25PM +0530, Lokesh Vutla wrote:
> Add debug UART functions to permit omap specific ns16550 to
> provide an early debug UART. This is mostly in common with
> DEBUG_UART_NS16550 except for Mode definition register which
> is required for selecting UART mode(16x auto-baud or 13x mode).
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170505/3832e781/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [U-Boot,RFC] serial: omap: Support debug UART
2017-04-22 10:27 [U-Boot] [RFC PATCH] serial: omap: Support debug UART Lokesh Vutla
2017-04-29 0:26 ` Simon Glass
2017-05-05 14:18 ` Tom Rini
@ 2017-05-12 17:19 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2017-05-12 17:19 UTC (permalink / raw)
To: u-boot
On Sat, Apr 22, 2017 at 03:57:25PM +0530, Lokesh Vutla wrote:
> Add debug UART functions to permit omap specific ns16550 to
> provide an early debug UART. This is mostly in common with
> DEBUG_UART_NS16550 except for Mode definition register which
> is required for selecting UART mode(16x auto-baud or 13x mode).
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170512/16d40f07/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-12 17:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-22 10:27 [U-Boot] [RFC PATCH] serial: omap: Support debug UART Lokesh Vutla
2017-04-29 0:26 ` Simon Glass
2017-05-05 14:18 ` Tom Rini
2017-05-12 17:19 ` [U-Boot] [U-Boot,RFC] " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox