[U-Boot] [PATCH] serial: atmel_usart: Add device tree support

Andreas Bießmann andreas at biessmann.org
Tue May 31 10:24:13 CEST 2016


Hi Wenyou,

On 2016-05-31 05:14, Wenyou Yang wrote:
> Add device tree support.
> 
> Signed-off-by: Wenyou Yang <wenyou.yang at 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


More information about the U-Boot mailing list