Commit a52cf086ace7e6107f399fcf37059dc9e02916f3
Committed by
Tom Rini
1 parent
46f51dc9c7
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
serial: omap: Support debug UART
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>
Showing 3 changed files with 54 additions and 11 deletions Side-by-side Diff
drivers/serial/Kconfig
... | ... | @@ -257,6 +257,13 @@ |
257 | 257 | driver will be available until the real driver-model serial is |
258 | 258 | running. |
259 | 259 | |
260 | +config DEBUG_UART_OMAP | |
261 | + bool "OMAP uart" | |
262 | + help | |
263 | + Select this to enable a debug UART using the omap ns16550 driver. | |
264 | + You will need to provide parameters to make this work. The driver | |
265 | + will be available until the real driver model serial is running. | |
266 | + | |
260 | 267 | endchoice |
261 | 268 | |
262 | 269 | config DEBUG_UART_BASE |
drivers/serial/ns16550.c
... | ... | @@ -246,17 +246,6 @@ |
246 | 246 | |
247 | 247 | #include <debug_uart.h> |
248 | 248 | |
249 | -#define serial_dout(reg, value) \ | |
250 | - serial_out_shift((char *)com_port + \ | |
251 | - ((char *)reg - (char *)com_port) * \ | |
252 | - (1 << CONFIG_DEBUG_UART_SHIFT), \ | |
253 | - CONFIG_DEBUG_UART_SHIFT, value) | |
254 | -#define serial_din(reg) \ | |
255 | - serial_in_shift((char *)com_port + \ | |
256 | - ((char *)reg - (char *)com_port) * \ | |
257 | - (1 << CONFIG_DEBUG_UART_SHIFT), \ | |
258 | - CONFIG_DEBUG_UART_SHIFT) | |
259 | - | |
260 | 249 | static inline void _debug_uart_init(void) |
261 | 250 | { |
262 | 251 | struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; |
... | ... | @@ -278,6 +267,42 @@ |
278 | 267 | serial_dout(&com_port->dll, baud_divisor & 0xff); |
279 | 268 | serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff); |
280 | 269 | serial_dout(&com_port->lcr, UART_LCRVAL); |
270 | +} | |
271 | + | |
272 | +static inline void _debug_uart_putc(int ch) | |
273 | +{ | |
274 | + struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; | |
275 | + | |
276 | + while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) | |
277 | + ; | |
278 | + serial_dout(&com_port->thr, ch); | |
279 | +} | |
280 | + | |
281 | +DEBUG_UART_FUNCS | |
282 | + | |
283 | +#endif | |
284 | + | |
285 | +#ifdef CONFIG_DEBUG_UART_OMAP | |
286 | + | |
287 | +#include <debug_uart.h> | |
288 | + | |
289 | +static inline void _debug_uart_init(void) | |
290 | +{ | |
291 | + struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; | |
292 | + int baud_divisor; | |
293 | + | |
294 | + baud_divisor = ns16550_calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, | |
295 | + CONFIG_BAUDRATE); | |
296 | + serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER); | |
297 | + serial_dout(&com_port->mdr1, 0x7); | |
298 | + serial_dout(&com_port->mcr, UART_MCRVAL); | |
299 | + serial_dout(&com_port->fcr, UART_FCR_DEFVAL); | |
300 | + | |
301 | + serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL); | |
302 | + serial_dout(&com_port->dll, baud_divisor & 0xff); | |
303 | + serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff); | |
304 | + serial_dout(&com_port->lcr, UART_LCRVAL); | |
305 | + serial_dout(&com_port->mdr1, 0x0); | |
281 | 306 | } |
282 | 307 | |
283 | 308 | static inline void _debug_uart_putc(int ch) |
include/debug_uart.h
... | ... | @@ -111,6 +111,17 @@ |
111 | 111 | #define _DEBUG_UART_ANNOUNCE |
112 | 112 | #endif |
113 | 113 | |
114 | +#define serial_dout(reg, value) \ | |
115 | + serial_out_shift((char *)com_port + \ | |
116 | + ((char *)reg - (char *)com_port) * \ | |
117 | + (1 << CONFIG_DEBUG_UART_SHIFT), \ | |
118 | + CONFIG_DEBUG_UART_SHIFT, value) | |
119 | +#define serial_din(reg) \ | |
120 | + serial_in_shift((char *)com_port + \ | |
121 | + ((char *)reg - (char *)com_port) * \ | |
122 | + (1 << CONFIG_DEBUG_UART_SHIFT), \ | |
123 | + CONFIG_DEBUG_UART_SHIFT) | |
124 | + | |
114 | 125 | /* |
115 | 126 | * Now define some functions - this should be inserted into the serial driver |
116 | 127 | */ |