[U-Boot] [PATCH v3 4/9] STiH410: Add STi serial driver

Simon Glass sjg at chromium.org
Tue Feb 14 05:23:37 UTC 2017


Hi Patrice,

On 10 February 2017 at 08:04,  <patrice.chotard at st.com> wrote:
> From: Patrice Chotard <patrice.chotard at st.com>
>
> This patch adds support to ASC (asynchronous serial controller)
> driver, which is basically a standard serial driver. This IP
> is common across other STMicroelectronics SoCs
>
> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>

Please can you include a change log with each patch?

> ---
>  arch/arm/Kconfig                          |   2 +
>  arch/arm/include/asm/arch-stih410/sti.h   |  16 +++
>  drivers/serial/Kconfig                    |   7 +
>  drivers/serial/Makefile                   |   1 +
>  drivers/serial/serial_sti_asc.c           | 218 ++++++++++++++++++++++++++++++
>  include/dm/platform_data/serial_sti_asc.h |  17 +++
>  6 files changed, 261 insertions(+)
>  create mode 100644 arch/arm/include/asm/arch-stih410/sti.h
>  create mode 100644 drivers/serial/serial_sti_asc.c
>  create mode 100644 include/dm/platform_data/serial_sti_asc.h
>
[..]


> +/* blocking function, that returns next char */
> +static int sti_asc_serial_getc(struct udevice *dev)
> +{
> +       struct sti_asc_serial_platdata *plat = dev->platdata;
> +       struct sti_asc_uart *const uart = plat->base;
> +
> +       /* polling wait: for a char to be read */
> +       if (!sti_asc_pending(dev, true))
> +               return -EAGAIN;
> +
> +       return readl(&uart->rxbuf);
> +}
> +
> +/* write write out a single char */
> +static int sti_asc_serial_putc(struct udevice *dev, const char c)
> +{
> +       struct sti_asc_serial_platdata *plat = dev->platdata;
> +       struct sti_asc_uart *const uart = plat->base;
> +
> +       /* Stream-LF to CR+LF conversion */
> +       if (c == 10)
> +               sti_asc_serial_putc(dev, '\r');

The uclass does this for you.

> +
> +       /* wait till safe to write next char */
> +       while (sti_asc_pending(dev, false))
> +               ;

No loops - just return -EAGAIN

> +
> +       /* finally, write next char */
> +       writel(c, &uart->txbuf);
> +
> +       return 0;
> +}
> +

Regards,
Simon


More information about the U-Boot mailing list