This patch adds devicetree support to the mcfuart.c driver.

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

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 <ang...@sysam.it>
+ *
+ * Modified to add fdt support
+ * (C) Copyright 2018  Angelo Dureghello <ang...@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,
-- 
2.19.0

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to