From 26a17ad59544f026878efdb0524ce66b7a314784 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Tue, 29 Jul 2014 17:18:51 +0100 Subject: [PATCH] bootwrapper: improve UART initialisation The PL011 spec requires that baud rate settings should be done by writing both xBRD registers followed by a write to LCR_H (which we skipped so far completely).[1] So include the FBRD register write as well and set up the LCR_H register to initialise the UART to 8N1. Also skip the automatic RTS/CTS enablement, as this may not be used by the peer (and the generic UART does not have it at all). [1] ARM PL011 TRM, 3.3.7 (top of page 3-14) Signed-off-by: Andre Przywara --- ns.S | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ns.S b/ns.S index f432bcf..d3feb4a 100644 --- a/ns.S +++ b/ns.S @@ -8,6 +8,8 @@ */ #define PL011_UARTIBRD 0x24 +#define PL011_UARTFBRD 0x28 +#define PL011_UART_LCR_H 0x2c #define PL011_UARTCR 0x30 #define V2M_SYS_CFGDATA 0xa0 @@ -23,8 +25,12 @@ ns_init_system: ldr x4, =UART_BASE mov w5, #0x10 str w5, [x4, #PL011_UARTIBRD] - mov w5, #0xc300 - orr w5, w5, #0x0001 + str wzr, [x4, #PL011_UARTFBRD] + /* set parameters to 8N1 and enable the FIFOs */ + mov w5, #0x70 + str w5, [x4, #PL011_UART_LCR_H] + /* enable the UART, TXen and RXen */ + mov w5, #0x301 str w5, [x4, #PL011_UARTCR] /* @@ -38,4 +44,4 @@ ns_init_system: ret .ltorg - .org 0x40 + .org 0x80 -- 2.39.5