All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhuvanchandra DV <bhuvanchandra.dv@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 7/8] serial: lpuart: Add driver model serial support
Date: Wed, 13 Jan 2016 11:19:21 +0530	[thread overview]
Message-ID: <CAO-kzf9DWJCPym3H0PcrVa_wA+MV9FJhTy_1Kxb3YNinRB5Wpg@mail.gmail.com> (raw)
In-Reply-To: <1451551990-32165-8-git-send-email-bmeng.cn@gmail.com>

Hi Bin,

With reference to the discussion here[1].

Unfortunately the lpuart driver is now broken for legacy code and also
the driver doesn't
work with serial driver model enabled on Toradex Colibri VF50/VF61,
Freescale VF610twr
and Phytec pcm052 boards. Did some one tested this patchset on these boards ?

[1] http://lists.denx.de/pipermail/u-boot/2016-January/240781.html

Best regards,
Bhuvan

On Thu, Dec 31, 2015 at 2:23 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> This adds driver model support to lpuart serial driver.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  doc/driver-model/serial-howto.txt |   1 -
>  drivers/serial/serial_lpuart.c    | 157 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 157 insertions(+), 1 deletion(-)
>
> diff --git a/doc/driver-model/serial-howto.txt b/doc/driver-model/serial-howto.txt
> index 76ad629..b933836 100644
> --- a/doc/driver-model/serial-howto.txt
> +++ b/doc/driver-model/serial-howto.txt
> @@ -13,7 +13,6 @@ is time for maintainers to start converting over the remaining serial drivers:
>     opencores_yanu.c
>     serial_bfin.c
>     serial_imx.c
> -   serial_lpuart.c
>     serial_max3100.c
>     serial_pxa.c
>     serial_s3c24x0.c
> diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
> index fed83a6..b1ba1bc 100644
> --- a/drivers/serial/serial_lpuart.c
> +++ b/drivers/serial/serial_lpuart.c
> @@ -5,6 +5,7 @@
>   */
>
>  #include <common.h>
> +#include <dm.h>
>  #include <watchdog.h>
>  #include <asm/io.h>
>  #include <serial.h>
> @@ -49,6 +50,10 @@ DECLARE_GLOBAL_DATA_PTR;
>
>  struct lpuart_fsl *base = (struct lpuart_fsl *)LPUART_BASE;
>
> +struct lpuart_serial_platdata {
> +       struct lpuart_fsl *reg;
> +};
> +
>  #ifndef CONFIG_LPUART_32B_REG
>  static void _lpuart_serial_setbrg(struct lpuart_fsl *reg, int baudrate)
>  {
> @@ -122,6 +127,7 @@ static int _lpuart_serial_init(struct lpuart_fsl *reg)
>         return 0;
>  }
>
> +#ifndef CONFIG_DM_SERIAL
>  static void lpuart_serial_setbrg(void)
>  {
>         _lpuart_serial_setbrg(base, gd->baudrate);
> @@ -157,6 +163,54 @@ static struct serial_device lpuart_serial_drv = {
>         .getc = lpuart_serial_getc,
>         .tstc = lpuart_serial_tstc,
>  };
> +#else /* CONFIG_DM_SERIAL */
> +static int lpuart_serial_setbrg(struct udevice *dev, int baudrate)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       _lpuart_serial_setbrg(reg, baudrate);
> +
> +       return 0;
> +}
> +
> +static int lpuart_serial_getc(struct udevice *dev)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       return _lpuart_serial_getc(reg);
> +}
> +
> +static int lpuart_serial_putc(struct udevice *dev, const char c)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       _lpuart_serial_putc(reg, c);
> +
> +       return 0;
> +}
> +
> +static int lpuart_serial_pending(struct udevice *dev, bool input)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       if (input)
> +               return _lpuart_serial_tstc(reg);
> +       else
> +               return __raw_readb(&reg->us1) & US1_TDRE ? 0 : 1;
> +}
> +
> +static int lpuart_serial_probe(struct udevice *dev)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       return _lpuart_serial_init(reg);
> +}
> +#endif /* CONFIG_DM_SERIAL */
>  #else
>  static void _lpuart32_serial_setbrg(struct lpuart_fsl *reg, int baudrate)
>  {
> @@ -227,6 +281,7 @@ static int _lpuart32_serial_init(struct lpuart_fsl *reg)
>         return 0;
>  }
>
> +#ifndef CONFIG_DM_SERIAL
>  static void lpuart32_serial_setbrg(void)
>  {
>         _lpuart32_serial_setbrg(base, gd->baudrate);
> @@ -262,8 +317,57 @@ static struct serial_device lpuart32_serial_drv = {
>         .getc = lpuart32_serial_getc,
>         .tstc = lpuart32_serial_tstc,
>  };
> +#else /* CONFIG_DM_SERIAL */
> +static int lpuart32_serial_setbrg(struct udevice *dev, int baudrate)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       _lpuart32_serial_setbrg(reg, baudrate);
> +
> +       return 0;
> +}
> +
> +static int lpuart32_serial_getc(struct udevice *dev)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       return _lpuart32_serial_getc(reg);
> +}
> +
> +static int lpuart32_serial_putc(struct udevice *dev, const char c)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       _lpuart32_serial_putc(reg, c);
> +
> +       return 0;
> +}
> +
> +static int lpuart32_serial_pending(struct udevice *dev, bool input)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       if (input)
> +               return _lpuart32_serial_tstc(reg);
> +       else
> +               return in_be32(&reg->stat) & STAT_TDRE ? 0 : 1;
> +}
> +
> +static int lpuart32_serial_probe(struct udevice *dev)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       struct lpuart_fsl *reg = plat->reg;
> +
> +       return _lpuart32_serial_init(reg);
> +}
> +#endif /* CONFIG_DM_SERIAL */
>  #endif
>
> +#ifndef CONFIG_DM_SERIAL
>  void lpuart_serial_initialize(void)
>  {
>  #ifdef CONFIG_LPUART_32B_REG
> @@ -281,3 +385,56 @@ __weak struct serial_device *default_serial_console(void)
>         return &lpuart_serial_drv;
>  #endif
>  }
> +#else /* CONFIG_DM_SERIAL */
> +static int lpuart_serial_ofdata_to_platdata(struct udevice *dev)
> +{
> +       struct lpuart_serial_platdata *plat = dev->platdata;
> +       fdt_addr_t addr;
> +
> +       addr = dev_get_addr(dev);
> +       if (addr == FDT_ADDR_T_NONE)
> +               return -EINVAL;
> +
> +       plat->reg = (struct lpuart_fsl *)addr;
> +
> +       return 0;
> +}
> +
> +static const struct dm_serial_ops lpuart_serial_ops = {
> +#ifdef CONFIG_LPUART_32B_REG
> +       .putc = lpuart32_serial_putc,
> +       .pending = lpuart32_serial_pending,
> +       .getc = lpuart32_serial_getc,
> +       .setbrg = lpuart32_serial_setbrg,
> +#else
> +       .putc = lpuart_serial_putc,
> +       .pending = lpuart_serial_pending,
> +       .getc = lpuart_serial_getc,
> +       .setbrg = lpuart_serial_setbrg,
> +#endif
> +};
> +
> +static const struct udevice_id lpuart_serial_ids[] = {
> +#ifdef CONFIG_LPUART_32B_REG
> +       { .compatible = "fsl,ls1021a-lpuart" },
> +#else
> +       { .compatible = "fsl,vf610-lpuart" },
> +#endif
> +       { }
> +};
> +
> +U_BOOT_DRIVER(serial_lpuart) = {
> +       .name   = "serial_lpuart",
> +       .id     = UCLASS_SERIAL,
> +       .of_match = lpuart_serial_ids,
> +       .ofdata_to_platdata = lpuart_serial_ofdata_to_platdata,
> +       .platdata_auto_alloc_size = sizeof(struct lpuart_serial_platdata),
> +#ifdef CONFIG_LPUART_32B_REG
> +       .probe = lpuart32_serial_probe,
> +#else
> +       .probe = lpuart_serial_probe,
> +#endif
> +       .ops    = &lpuart_serial_ops,
> +       .flags = DM_FLAG_PRE_RELOC,
> +};
> +#endif /* CONFIG_DM_SERIAL */
> --
> 1.8.2.1
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

  parent reply	other threads:[~2016-01-13  5:49 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-31  8:53 [U-Boot] [PATCH 0/8] arm: ls1021atwr: Convert to driver model and enable serial support Bin Meng
2015-12-31  8:53 ` [U-Boot] [PATCH 1/8] fdt: Fix up stdout correctly in fdt_fixup_stdout() Bin Meng
2016-01-08  3:34   ` Simon Glass
2016-01-11  3:02     ` Bin Meng
2016-01-11 16:58       ` Simon Glass
2016-01-13  9:14         ` Bin Meng
2016-01-13 20:10           ` Simon Glass
2015-12-31  8:53 ` [U-Boot] [PATCH 2/8] arm: ls1021atwr: Convert to driver model and enable serial support Bin Meng
2015-12-31  8:53 ` [U-Boot] [PATCH 3/8] serial: lpuart: Move CONFIG_FSL_LPUART to Kconfig Bin Meng
2016-01-06  0:25   ` Simon Glass
2016-01-13 18:45   ` Stefan Agner
2015-12-31  8:53 ` [U-Boot] [PATCH 4/8] serial: lpuart: Fix several cosmetic issues Bin Meng
2016-01-06  0:25   ` Simon Glass
2015-12-31  8:53 ` [U-Boot] [PATCH 5/8] serial: lpuart: Call local version of setbrg and putc directly Bin Meng
2016-01-06  0:25   ` Simon Glass
2015-12-31  8:53 ` [U-Boot] [PATCH 6/8] serial: lpuart: Prepare the driver for DM conversion Bin Meng
2016-01-06  0:25   ` Simon Glass
2016-01-13 18:51   ` Stefan Agner
2016-01-14  2:11     ` Bin Meng
2015-12-31  8:53 ` [U-Boot] [PATCH 7/8] serial: lpuart: Add driver model serial support Bin Meng
2016-01-06  0:25   ` Simon Glass
2016-01-11  3:08     ` Bin Meng
2016-01-13  5:49   ` Bhuvanchandra DV [this message]
2016-01-13  6:13     ` Bin Meng
2016-01-13  8:07       ` Bhuvanchandra DV
2016-01-13  8:19         ` Bin Meng
2016-01-13 19:20           ` Stefan Agner
2016-01-14  2:24             ` Bin Meng
2016-01-14  8:10               ` Bhuvanchandra DV
2015-12-31  8:53 ` [U-Boot] [PATCH 8/8] arm: ls1021atwr: Enable driver model lpuart serial driver Bin Meng
2016-01-06  0:25   ` Simon Glass
2016-01-06  5:31 ` [U-Boot] [PATCH 0/8] arm: ls1021atwr: Convert to driver model and enable serial support Huan Wang
2016-01-07  2:26   ` Bin Meng
2016-01-07  6:01     ` Huan Wang
2016-01-07  6:15       ` Bin Meng
2016-01-07  6:19         ` Huan Wang
2016-01-07  9:22           ` Bin Meng
2016-01-11  3:10             ` Bin Meng
2016-01-11 16:58               ` Simon Glass
2016-01-13 19:03             ` Stefan Agner
2016-01-14  2:13               ` Bin Meng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAO-kzf9DWJCPym3H0PcrVa_wA+MV9FJhTy_1Kxb3YNinRB5Wpg@mail.gmail.com \
    --to=bhuvanchandra.dv@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.