diff mbox series

[U-Boot,3/7] drivers: serial: mcfuart: add DT support

Message ID 20180920210755.22381-4-angelo@sysam.it
State Superseded
Delegated to: Jason Jin
Headers show
Series [U-Boot,1/7] m68k: add basic set of devicetrees | expand

Commit Message

Angelo Dureghello Sept. 20, 2018, 9:07 p.m. UTC
This patch adds devicetree support to the mcfuart.c driver.

Signed-off-by: Angelo Dureghello <angelo@sysam.it>
---
 drivers/serial/mcfuart.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Comments

Simon Glass Sept. 26, 2018, 5:42 a.m. UTC | #1
On 20 September 2018 at 15:07, Angelo Dureghello <angelo@sysam.it> wrote:
> This patch adds devicetree support to the mcfuart.c driver.
>
> Signed-off-by: Angelo Dureghello <angelo@sysam.it>
> ---
>  drivers/serial/mcfuart.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/serial/mcfuart.c b/drivers/serial/mcfuart.c
index 1371049de2..5896a19805 100644
--- a/drivers/serial/mcfuart.c
+++ b/drivers/serial/mcfuart.c
@@ -5,6 +5,9 @@ 
  *
  * Modified to add device model (DM) support
  * (C) Copyright 2015  Angelo Dureghello <angelo@sysam.it>
+ *
+ * Modified to add fdt support
+ * (C) Copyright 2018  Angelo Dureghello <angelo@sysam.it>
  */
 
 /*
@@ -212,6 +215,23 @@  static int coldfire_serial_pending(struct udevice *dev, bool input)
 	return 0;
 }
 
+static int coldfire_ofdata_to_platdata(struct udevice *dev)
+{
+	struct coldfire_serial_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr_base;
+
+	addr_base = devfdt_get_addr(dev);
+	if (addr_base == FDT_ADDR_T_NONE)
+		return -ENODEV;
+
+	plat->base = (uint32_t)addr_base;
+
+	plat->port = dev->seq;
+	plat->baudrate = gd->baudrate;
+
+	return 0;
+}
+
 static const struct dm_serial_ops coldfire_serial_ops = {
 	.putc = coldfire_serial_putc,
 	.pending = coldfire_serial_pending,
@@ -219,9 +239,17 @@  static const struct dm_serial_ops coldfire_serial_ops = {
 	.setbrg = coldfire_serial_setbrg,
 };
 
+static const struct udevice_id coldfire_serial_ids[] = {
+	{ .compatible = "fsl,mcf-uart" },
+	{ }
+};
+
 U_BOOT_DRIVER(serial_coldfire) = {
 	.name = "serial_coldfire",
 	.id = UCLASS_SERIAL,
+	.of_match = coldfire_serial_ids,
+	.ofdata_to_platdata = coldfire_ofdata_to_platdata,
+	.platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata),
 	.probe = coldfire_serial_probe,
 	.ops = &coldfire_serial_ops,
 	.flags = DM_FLAG_PRE_RELOC,