[U-Boot] [PATCH v1 0/3] gpio: at91_gpio: Add option and clock support

The CONFIG_AT91_GPIO option is added in Kconfig to be used to select the AT91 PIO GPIO driver, and the clock is supported.
Wenyou Yang (3): gpio: Kconfig: Add CONFIG_AT91_GPIO option gpio: at91_gpio: Add the device tree support gpio: at91_gpio: Add the clock support
drivers/gpio/Kconfig | 13 +++++++++++++ drivers/gpio/at91_gpio.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+)

The CONFIG_AT91_GPIO option is used to select AT91 PIO GPIO driver.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com ---
drivers/gpio/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 8d9ab52..c065342 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -28,6 +28,19 @@ config DWAPB_GPIO help Support for the Designware APB GPIO driver.
+config AT91_GPIO + bool "AT91 PIO GPIO driver" + depends on DM_GPIO + default n + help + Say yes here to select AT91 PIO GPIO driver. AT91 PIO + controller manages up to 32 fully programmable input/output + lines. Each I/O line may be dedicated as a general-purpose + I/O or be assigned to a function of an embedded peripheral. + The assignment to a function of an embedded peripheral is + the responsibility of AT91 Pinctrl driver. This driver is + responsible for the general-purpose I/O. + config ATMEL_PIO4 bool "ATMEL PIO4 driver" depends on DM_GPIO

On 20 October 2016 at 20:07, Wenyou Yang wenyou.yang@atmel.com wrote:
The CONFIG_AT91_GPIO option is used to select AT91 PIO GPIO driver.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com
drivers/gpio/Kconfig | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

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(+)
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),

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

Add the clock support.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com ---
drivers/gpio/at91_gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/gpio/at91_gpio.c b/drivers/gpio/at91_gpio.c index 23b2dc3..bd5c8c4 100644 --- a/drivers/gpio/at91_gpio.c +++ b/drivers/gpio/at91_gpio.c @@ -10,6 +10,7 @@
#include <config.h> #include <common.h> +#include <clk.h> #include <dm.h> #include <asm/io.h> #include <linux/sizes.h> @@ -517,6 +518,18 @@ static int at91_gpio_probe(struct udevice *dev) struct at91_port_priv *port = dev_get_priv(dev); struct at91_port_platdata *plat = dev_get_platdata(dev); struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + struct clk clk; + int ret; + + ret = clk_get_by_index(dev, 0, &clk); + if (ret) + return ret; + + ret = clk_enable(&clk); + if (ret) + return ret; + + clk_free(&clk);
uc_priv->bank_name = plat->bank_name; uc_priv->gpio_count = GPIO_PER_BANK;

On 20 October 2016 at 20:07, Wenyou Yang wenyou.yang@atmel.com wrote:
Add the clock support.
Signed-off-by: Wenyou Yang wenyou.yang@atmel.com
drivers/gpio/at91_gpio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org
participants (2)
-
Simon Glass
-
Wenyou Yang