Commit 6e780c7a7bfea05429d29fd30cdbf213583e03f6
1 parent
6f849c3012
Exists in
v2017.01-smarct4x
and in
30 other branches
ns16550: Improve debug UART so it can work with 32-bit access
Since Rockchip requires 32-bit serial access, add this to the driver. Refactor a little to make this easier. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 1 changed file with 21 additions and 15 deletions Side-by-side Diff
drivers/serial/ns16550.c
... | ... | @@ -246,6 +246,17 @@ |
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 | + | |
249 | 260 | void debug_uart_init(void) |
250 | 261 | { |
251 | 262 | struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; |
252 | 263 | |
253 | 264 | |
254 | 265 | |
... | ... | @@ -259,28 +270,23 @@ |
259 | 270 | */ |
260 | 271 | baud_divisor = calc_divisor(com_port, CONFIG_DEBUG_UART_CLOCK, |
261 | 272 | CONFIG_BAUDRATE); |
262 | - serial_out_shift(&com_port->ier, CONFIG_DEBUG_UART_SHIFT, | |
263 | - CONFIG_SYS_NS16550_IER); | |
264 | - serial_out_shift(&com_port->mcr, CONFIG_DEBUG_UART_SHIFT, UART_MCRVAL); | |
265 | - serial_out_shift(&com_port->fcr, CONFIG_DEBUG_UART_SHIFT, UART_FCRVAL); | |
273 | + serial_dout(&com_port->ier, CONFIG_SYS_NS16550_IER); | |
274 | + serial_dout(&com_port->mcr, UART_MCRVAL); | |
275 | + serial_dout(&com_port->fcr, UART_FCRVAL); | |
266 | 276 | |
267 | - serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT, | |
268 | - UART_LCR_BKSE | UART_LCRVAL); | |
269 | - serial_out_shift(&com_port->dll, CONFIG_DEBUG_UART_SHIFT, | |
270 | - baud_divisor & 0xff); | |
271 | - serial_out_shift(&com_port->dlm, CONFIG_DEBUG_UART_SHIFT, | |
272 | - (baud_divisor >> 8) & 0xff); | |
273 | - serial_out_shift(&com_port->lcr, CONFIG_DEBUG_UART_SHIFT, | |
274 | - UART_LCRVAL); | |
277 | + serial_dout(&com_port->lcr, UART_LCR_BKSE | UART_LCRVAL); | |
278 | + serial_dout(&com_port->dll, baud_divisor & 0xff); | |
279 | + serial_dout(&com_port->dlm, (baud_divisor >> 8) & 0xff); | |
280 | + serial_dout(&com_port->lcr, UART_LCRVAL); | |
275 | 281 | } |
276 | 282 | |
277 | 283 | static inline void _debug_uart_putc(int ch) |
278 | 284 | { |
279 | 285 | struct NS16550 *com_port = (struct NS16550 *)CONFIG_DEBUG_UART_BASE; |
280 | 286 | |
281 | - while (!(serial_in_shift(&com_port->lsr, 0) & UART_LSR_THRE)) | |
287 | + while (!(serial_din(&com_port->lsr) & UART_LSR_THRE)) | |
282 | 288 | ; |
283 | - serial_out_shift(&com_port->thr, CONFIG_DEBUG_UART_SHIFT, ch); | |
289 | + serial_dout(&com_port->thr, ch); | |
284 | 290 | } |
285 | 291 | |
286 | 292 | DEBUG_UART_FUNCS |