From: Lukasz Majewski <lukma@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 3/4] serial: add an of-platdata driver for "snps, dw-apb-uart"
Date: Mon, 7 Jan 2019 23:12:05 +0100 [thread overview]
Message-ID: <20190107231205.3ae0c8cd@jawa> (raw)
In-Reply-To: <20190107211423.10151-4-simon.k.r.goldschmidt@gmail.com>
Hi Simon,
> Add a driver for the "snps,dw-apb-uart" used in socfpga and others.
>
> This driver is required to get OF_PLATDATA to work for socfpga.
> It uses the ns16550 driver, converting the platdata from of-platdata
> go the ns16550 format.
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> ---
>
> drivers/serial/Kconfig | 10 ++++++++
> drivers/serial/Makefile | 1 +
> drivers/serial/serial_dw_apb.c | 42
> ++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+)
> create mode 100644 drivers/serial/serial_dw_apb.c
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index b7ff2960ab..10addd3309 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -511,6 +511,16 @@ config BCM283X_PL011_SERIAL
> that supports automatic disable, so that it only gets used
> when the UART is actually muxed.
>
> +config DESIGNWARE_SERIAL
> + bool "DesignWare UART support"
> + depends on DM_SERIAL && SPL_OF_PLATDATA
> + help
> + Select this to enable a UART driver for "snps,dw-apb-uart"
> devices
> + when using CONFIG_SPL_OF_PLATDATA (i.e. a compiled-in
> device tree
> + replacement).
> + This uses the ns16550 driver, converting the platdata from
> of-platdata
> + to the ns16550 format.
> +
> config BCM6345_SERIAL
> bool "Support for BCM6345 UART"
> depends on DM_SERIAL
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index 06ee30697d..f1ebb90d92 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -46,6 +46,7 @@ obj-$(CONFIG_MESON_SERIAL) += serial_meson.o
> obj-$(CONFIG_INTEL_MID_SERIAL) += serial_intel_mid.o
> ifdef CONFIG_SPL_BUILD
> obj-$(CONFIG_ROCKCHIP_SERIAL) += serial_rockchip.o
> +obj-$(CONFIG_DESIGNWARE_SERIAL) += serial_dw_apb.o
> endif
> obj-$(CONFIG_XILINX_UARTLITE) += serial_xuartlite.o
> obj-$(CONFIG_SANDBOX_SERIAL) += sandbox.o
> diff --git a/drivers/serial/serial_dw_apb.c
> b/drivers/serial/serial_dw_apb.c new file mode 100644
> index 0000000000..26580e5ba5
> --- /dev/null
> +++ b/drivers/serial/serial_dw_apb.c
> @@ -0,0 +1,42 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2018 Simon Goldschmidt
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <dt-structs.h>
> +#include <ns16550.h>
> +#include <serial.h>
> +
> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
> +struct dw_apb_uart_platdata {
> + struct dtd_snps_dw_apb_uart dtplat;
> + struct ns16550_platdata plat;
> +};
> +
> +static int dw_apb_serial_probe(struct udevice *dev)
> +{
> + struct dw_apb_uart_platdata *plat = dev_get_platdata(dev);
> +
> + /* Set up correct platform data for the standard driver */
> + plat->plat.base = plat->dtplat.reg[0];
> + plat->plat.reg_shift = plat->dtplat.reg_shift;
> + plat->plat.reg_width = plat->dtplat.reg_io_width;
> + plat->plat.clock = plat->dtplat.clock_frequency;
> + plat->plat.fcr = UART_FCR_DEFVAL;
> + dev->platdata = &plat->plat;
> +
> + return ns16550_serial_probe(dev);
> +}
> +
> +U_BOOT_DRIVER(snps_dw_apb_uart) = {
> + .name = "snps_dw_apb_uart",
> + .id = UCLASS_SERIAL,
> + .priv_auto_alloc_size = sizeof(struct NS16550),
> + .platdata_auto_alloc_size = sizeof(struct
> dw_apb_uart_platdata),
> + .probe = dw_apb_serial_probe,
> + .ops = &ns16550_serial_ops,
> + .flags = DM_FLAG_PRE_RELOC,
Is it possible/or is your application requiring the pinmux/clock setting
for this serial?
With OF_PLATDATA we don't need to parse (and provide) the DTS (and we
use the DM/DTS driver's code in a way similar to "native" one).
I'm wondering, if it would be possible to "mimic" the dependencies
between DM drivers without DTS parsing / providing overhead.
At least in my case I would need in SPL:
-> driver XXX (working with u-boot proper's DM/DTS)
---> CLK (uclass-clk) to enable clocks
---> pinctrl (to config pins)
As an example: uart or eMMC.
I'm aware that it would be possible to use the old "approach" to
configure pinmux and clk separately (as it is done now) and only
re-use the DM portion of driver with OF_PLATDATA having all the
necessary info.
However, I'm wondering if there is a better way to achieve it (or if I
misunderstood something).
> +};
> +#endif
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190107/120a02ab/attachment.sig>
next prev parent reply other threads:[~2019-01-07 22:12 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-07 21:14 [U-Boot] [PATCH v1 0/4] arm: socfgpa: support of-platdata Simon Goldschmidt
2019-01-07 21:14 ` [U-Boot] [PATCH v1 1/4] arm: socfpga: imply SPL config instead of select Simon Goldschmidt
2019-01-07 22:53 ` Marek Vasut
2019-01-08 6:24 ` Simon Goldschmidt
2019-01-08 11:22 ` Marek Vasut
2019-01-08 12:09 ` Simon Goldschmidt
2019-01-08 12:22 ` Marek Vasut
2019-01-08 12:46 ` Simon Goldschmidt
2019-01-08 12:49 ` Marek Vasut
2019-01-08 14:48 ` Tom Rini
2019-01-08 14:50 ` Marek Vasut
2019-01-08 14:58 ` Tom Rini
2019-01-08 15:04 ` Simon Goldschmidt
2019-01-08 15:11 ` Tom Rini
2019-01-08 15:05 ` Marek Vasut
2019-01-08 15:01 ` Simon Goldschmidt
2019-01-08 20:52 ` Simon Goldschmidt
2019-01-08 20:54 ` Marek Vasut
2019-01-11 20:39 ` Simon Goldschmidt
2019-01-11 22:02 ` Marek Vasut
2019-01-14 15:50 ` Simon Goldschmidt
2019-01-14 15:58 ` Dinh Nguyen
2019-01-14 16:05 ` Simon Goldschmidt
2019-01-14 18:31 ` Marek Vasut
2019-01-14 18:58 ` Simon Goldschmidt
2019-01-14 19:33 ` Marek Vasut
2019-01-14 19:43 ` Simon Goldschmidt
2019-01-14 20:01 ` Marek Vasut
2019-01-14 20:12 ` Simon Goldschmidt
2019-01-14 20:23 ` Marek Vasut
2019-01-14 20:30 ` Simon Goldschmidt
2019-01-14 20:49 ` Marek Vasut
2019-01-14 20:59 ` Simon Goldschmidt
2019-01-14 21:28 ` Tom Rini
2019-01-14 21:30 ` Marek Vasut
2019-01-14 21:35 ` Simon Goldschmidt
2019-01-14 21:50 ` Tom Rini
2019-01-14 21:53 ` Simon Goldschmidt
2019-01-14 21:57 ` Marek Vasut
2019-01-14 22:26 ` Dinh Nguyen
2019-01-15 6:59 ` Simon Goldschmidt
2019-01-07 21:14 ` [U-Boot] [PATCH v1 2/4] arm: socfpga: fix compiling with OF_PLATDATA Simon Goldschmidt
2019-01-07 22:53 ` Marek Vasut
2019-01-08 6:32 ` Simon Goldschmidt
2019-01-08 11:46 ` Marek Vasut
2019-01-08 12:14 ` Simon Goldschmidt
2019-01-08 12:23 ` Marek Vasut
2019-01-07 21:14 ` [U-Boot] [PATCH v1 3/4] serial: add an of-platdata driver for "snps, dw-apb-uart" Simon Goldschmidt
2019-01-07 22:12 ` Lukasz Majewski [this message]
2019-01-08 6:06 ` Simon Goldschmidt
2019-01-08 7:30 ` Lukasz Majewski
2019-01-08 7:41 ` Simon Goldschmidt
2019-01-08 8:49 ` Lukasz Majewski
2019-01-09 8:35 ` Alexey Brodkin
2019-01-09 11:33 ` Simon Goldschmidt
2019-01-09 18:43 ` Simon Goldschmidt
2019-01-11 8:33 ` Alexey Brodkin
2019-01-11 8:41 ` Simon Goldschmidt
2019-01-11 9:03 ` Alexey Brodkin
2019-01-11 10:00 ` Simon Goldschmidt
2019-01-11 9:22 ` Andy Shevchenko
2019-01-11 10:01 ` Simon Goldschmidt
2019-01-16 21:35 ` Simon Glass
2019-01-10 12:56 ` Simon Glass
2019-01-07 21:14 ` [U-Boot] [PATCH v1 4/4] mmc: socfpga: support of-platdata Simon Goldschmidt
2019-01-07 21:59 ` [U-Boot] [PATCH v1 0/4] arm: socfgpa: " Lukasz Majewski
2019-01-08 6:53 ` Simon Goldschmidt
2019-01-07 22:57 ` Marek Vasut
2019-01-08 6:56 ` Simon Goldschmidt
2019-01-08 11:49 ` Marek Vasut
2019-01-08 12:38 ` Simon Goldschmidt
2019-01-08 12:57 ` Marek Vasut
2019-01-08 13:07 ` Simon Goldschmidt
2019-01-08 13:38 ` Marek Vasut
2019-01-08 13:51 ` Simon Goldschmidt
2019-01-08 14:43 ` Marek Vasut
2019-02-01 18:58 ` Simon Goldschmidt
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=20190107231205.3ae0c8cd@jawa \
--to=lukma@denx.de \
--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.