summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWenyou Yang <wenyou.yang@atmel.com>2016-06-01 08:36:56 +0800
committerAndreas Bießmann <andreas@biessmann.org>2016-06-12 23:49:38 +0200
commitc1631c8a04f53e694dd73bbb987b97eed5188517 (patch)
tree273eaeefd46d447503526db1712d1db62bba79ec
parentd3b6662086de317e0495edf9c4670772bff98211 (diff)
downloadu-boot-imx-c1631c8a04f53e694dd73bbb987b97eed5188517.zip
u-boot-imx-c1631c8a04f53e694dd73bbb987b97eed5188517.tar.gz
u-boot-imx-c1631c8a04f53e694dd73bbb987b97eed5188517.tar.bz2
serial: atmel_usart: Add device tree support
Add device tree support. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Reviewed-by: Andreas Bießmann <andreas@biessmann.org> Reviewed-by: Simon Glass <sjg@chromium.org>
-rw-r--r--drivers/serial/atmel_usart.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index 4fe992b..e450135 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -191,16 +191,35 @@ static int atmel_serial_probe(struct udevice *dev)
{
struct atmel_serial_platdata *plat = dev->platdata;
struct atmel_serial_priv *priv = dev_get_priv(dev);
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+ fdt_addr_t addr_base;
+ addr_base = dev_get_addr(dev);
+ if (addr_base == FDT_ADDR_T_NONE)
+ return -ENODEV;
+
+ plat->base_addr = (uint32_t)addr_base;
+#endif
priv->usart = (atmel_usart3_t *)plat->base_addr;
atmel_serial_init_internal(priv->usart);
return 0;
}
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct udevice_id atmel_serial_ids[] = {
+ { .compatible = "atmel,at91sam9260-usart" },
+ { }
+};
+#endif
+
U_BOOT_DRIVER(serial_atmel) = {
.name = "serial_atmel",
.id = UCLASS_SERIAL,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+ .of_match = atmel_serial_ids,
+ .platdata_auto_alloc_size = sizeof(struct atmel_serial_platdata),
+#endif
.probe = atmel_serial_probe,
.ops = &atmel_serial_ops,
.flags = DM_FLAG_PRE_RELOC,