All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] serial: atmel_usart: Add device tree support
@ 2016-05-31  3:14 Wenyou Yang
  2016-05-31  8:24 ` Andreas Bießmann
  0 siblings, 1 reply; 2+ messages in thread
From: Wenyou Yang @ 2016-05-31  3:14 UTC (permalink / raw)
  To: u-boot

Add device tree support.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
---

 drivers/serial/atmel_usart.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/serial/atmel_usart.c b/drivers/serial/atmel_usart.c
index 4fe992b..b78a94c 100644
--- a/drivers/serial/atmel_usart.c
+++ b/drivers/serial/atmel_usart.c
@@ -191,19 +191,32 @@ static int atmel_serial_probe(struct udevice *dev)
 {
 	struct atmel_serial_platdata *plat = dev->platdata;
 	struct atmel_serial_priv *priv = dev_get_priv(dev);
+	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;
 	priv->usart = (atmel_usart3_t *)plat->base_addr;
 	atmel_serial_init_internal(priv->usart);
 
 	return 0;
 }
 
+static const struct udevice_id atmel_serial_ids[] = {
+	{ .compatible = "atmel,at91sam9260-usart" },
+	{ }
+};
+
 U_BOOT_DRIVER(serial_atmel) = {
 	.name	= "serial_atmel",
 	.id	= UCLASS_SERIAL,
+	.of_match = atmel_serial_ids,
 	.probe = atmel_serial_probe,
 	.ops	= &atmel_serial_ops,
 	.flags = DM_FLAG_PRE_RELOC,
+	.platdata_auto_alloc_size = sizeof(struct atmel_serial_platdata),
 	.priv_auto_alloc_size	= sizeof(struct atmel_serial_priv),
 };
 #endif
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH] serial: atmel_usart: Add device tree support
  2016-05-31  3:14 [U-Boot] [PATCH] serial: atmel_usart: Add device tree support Wenyou Yang
@ 2016-05-31  8:24 ` Andreas Bießmann
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Bießmann @ 2016-05-31  8:24 UTC (permalink / raw)
  To: u-boot

Hi Wenyou,

On 2016-05-31 05:14, Wenyou Yang wrote:
> Add device tree support.
> 
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
> 
>  drivers/serial/atmel_usart.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/serial/atmel_usart.c 
> b/drivers/serial/atmel_usart.c
> index 4fe992b..b78a94c 100644
> --- a/drivers/serial/atmel_usart.c
> +++ b/drivers/serial/atmel_usart.c
> @@ -191,19 +191,32 @@ static int atmel_serial_probe(struct udevice 
> *dev)
>  {
>  	struct atmel_serial_platdata *plat = dev->platdata;
>  	struct atmel_serial_priv *priv = dev_get_priv(dev);
> +	fdt_addr_t addr_base;
> 
> +	addr_base = dev_get_addr(dev);
> +	if (addr_base == FDT_ADDR_T_NONE)
> +		return -ENODEV;

We may use this driver without FDT (now some arm boards have not been 
converted and avr32 will never use FDT). Please make this conditional.

Andreas

> +
> +	plat->base_addr = (uint32_t)addr_base;
>  	priv->usart = (atmel_usart3_t *)plat->base_addr;
>  	atmel_serial_init_internal(priv->usart);
> 
>  	return 0;
>  }
> 
> +static const struct udevice_id atmel_serial_ids[] = {
> +	{ .compatible = "atmel,at91sam9260-usart" },
> +	{ }
> +};
> +
>  U_BOOT_DRIVER(serial_atmel) = {
>  	.name	= "serial_atmel",
>  	.id	= UCLASS_SERIAL,
> +	.of_match = atmel_serial_ids,
>  	.probe = atmel_serial_probe,
>  	.ops	= &atmel_serial_ops,
>  	.flags = DM_FLAG_PRE_RELOC,
> +	.platdata_auto_alloc_size = sizeof(struct atmel_serial_platdata),
>  	.priv_auto_alloc_size	= sizeof(struct atmel_serial_priv),
>  };
>  #endif

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-31  8:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31  3:14 [U-Boot] [PATCH] serial: atmel_usart: Add device tree support Wenyou Yang
2016-05-31  8:24 ` Andreas Bießmann

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.