From: Andreas =?iso-8859-1?Q?Bie=DFmann?= Date: Sun, 16 Oct 2016 22:07:39 +0200 Subject: [U-Boot] [U-Boot, v2, 2/2] serial: atmel_usart: Support enable an early debug UART In-Reply-To: <1473734253-21583-3-git-send-email-wenyou.yang@atmel.com> References: <1473734253-21583-3-git-send-email-wenyou.yang@atmel.com> Message-ID: <20161016200739.GA29644@mba.int.er.biessmann.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Sep 13, 2016 at 10:37:33AM +0800, Wenyou Yang wrote: > Add support to enable an early debug UART for debugging. > > Signed-off-by: Wenyou Yang > Reviewed-by: Simon Glass Reviewed-by: Andreas Bie?mann > --- > > Changes in v2: > - Collect the Reviewed-by tag. > > drivers/serial/Kconfig | 7 +++++++ > drivers/serial/atmel_usart.c | 22 ++++++++++++++++++++++ > 2 files changed, 29 insertions(+) > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index a6035dc..b8ecd80 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -98,6 +98,13 @@ config DEBUG_UART_AR933X > driver will be available until the real driver model serial is > running. > > +config DEBUG_UART_ATMEL > + bool "Atmel USART" > + help > + Select this to enable a debug UART using the atmel usart driver. You > + will need to provide parameters to make this work. The driver will > + be available until the real driver-model serial is running. > + > config DEBUG_UART_NS16550 > bool "ns16550" > help > diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c > index e450135..7674f97 100644 > --- a/drivers/serial/atmel_usart.c > +++ b/drivers/serial/atmel_usart.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -226,3 +227,24 @@ U_BOOT_DRIVER(serial_atmel) = { > .priv_auto_alloc_size = sizeof(struct atmel_serial_priv), > }; > #endif > + > +#ifdef CONFIG_DEBUG_UART_ATMEL > +static inline void _debug_uart_init(void) > +{ > + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; > + > + atmel_serial_setbrg_internal(usart, 0, CONFIG_BAUDRATE); > +} > + > +static inline void _debug_uart_putc(int ch) > +{ > + atmel_usart3_t *usart = (atmel_usart3_t *)CONFIG_DEBUG_UART_BASE; > + > + while (!(readl(&usart->csr) & USART3_BIT(TXRDY))) > + ; > + > + writel(ch, &usart->thr); > +} > + > +DEBUG_UART_FUNCS > +#endif