diff mbox

[U-Boot,v1,2/3] gpio: at91_gpio: Add the device tree support

Message ID 1477019241-30660-3-git-send-email-wenyou.yang@atmel.com
State Accepted
Commit cf468880c37be1a7fea0a842a14ba1e1e388147c
Delegated to: Andreas Bießmann
Headers show

Commit Message

Wenyou Yang Oct. 21, 2016, 3:07 a.m. UTC
Add the device tree support.

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

 drivers/gpio/at91_gpio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Simon Glass Oct. 26, 2016, 4:30 p.m. UTC | #1
Hi Wenyou,

On 20 October 2016 at 20:07, Wenyou Yang <wenyou.yang@atmel.com> wrote:
> Add the device tree support.
>
> Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
> ---
>
>  drivers/gpio/at91_gpio.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)

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

>
> diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
> index 8e52e3d..23b2dc3 100644
> --- a/drivers/gpio/at91_gpio.c
> +++ b/drivers/gpio/at91_gpio.c
> @@ -520,14 +520,29 @@ static int at91_gpio_probe(struct udevice *dev)
>
>         uc_priv->bank_name = plat->bank_name;
>         uc_priv->gpio_count = GPIO_PER_BANK;
> +
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
> +       plat->base_addr = (uint32_t)dev_get_addr_ptr(dev);
> +#endif
>         port->regs = (struct at91_port *)plat->base_addr;
>
>         return 0;
>  }
>
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
> +static const struct udevice_id at91_gpio_ids[] = {
> +       { .compatible = "atmel,at91rm9200-gpio" },
> +       { }
> +};
> +#endif
> +
>  U_BOOT_DRIVER(gpio_at91) = {
>         .name   = "gpio_at91",
>         .id     = UCLASS_GPIO,
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
> +       .of_match = at91_gpio_ids,

You can bracket this with of_match_ptr() and avoid the #if.

> +       .platdata_auto_alloc_size = sizeof(struct at91_port_platdata),

It would be good to have a similar macro for this one - maybe of_alloc_size()?

> +#endif
>         .ops    = &gpio_at91_ops,
>         .probe  = at91_gpio_probe,
>         .priv_auto_alloc_size = sizeof(struct at91_port_priv),
> --
> 2.7.4
>

Regards,
Simon
diff mbox

Patch

diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c
index 8e52e3d..23b2dc3 100644
--- a/drivers/gpio/at91_gpio.c
+++ b/drivers/gpio/at91_gpio.c
@@ -520,14 +520,29 @@  static int at91_gpio_probe(struct udevice *dev)
 
 	uc_priv->bank_name = plat->bank_name;
 	uc_priv->gpio_count = GPIO_PER_BANK;
+
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	plat->base_addr = (uint32_t)dev_get_addr_ptr(dev);
+#endif
 	port->regs = (struct at91_port *)plat->base_addr;
 
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct udevice_id at91_gpio_ids[] = {
+	{ .compatible = "atmel,at91rm9200-gpio" },
+	{ }
+};
+#endif
+
 U_BOOT_DRIVER(gpio_at91) = {
 	.name	= "gpio_at91",
 	.id	= UCLASS_GPIO,
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+	.of_match = at91_gpio_ids,
+	.platdata_auto_alloc_size = sizeof(struct at91_port_platdata),
+#endif
 	.ops	= &gpio_at91_ops,
 	.probe	= at91_gpio_probe,
 	.priv_auto_alloc_size = sizeof(struct at91_port_priv),