summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorFabian Vogt <fvogt@suse.com>2016-09-26 14:26:43 +0200
committerTom Rini <trini@konsulko.com>2016-11-28 20:09:45 -0500
commit4faf5f93c61632c18e435dc6a190b30893786a10 (patch)
tree5f86f0037690559ecb084d0b1589fe0b5c3c38d7 /drivers
parent7aa1a6b71c9af4651f6b3a164c84096a84d24285 (diff)
downloadu-boot-4faf5f93c61632c18e435dc6a190b30893786a10.tar.gz
gpio: bcm2835: add device tree support
This patch adds device tree support for the bcm2835 GPIO driver. Signed-off-by: Fabian Vogt <fvogt@suse.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/bcm2835_gpio.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/gpio/bcm2835_gpio.c b/drivers/gpio/bcm2835_gpio.c
index 8dd7a28e26..cd5480ee09 100644
--- a/drivers/gpio/bcm2835_gpio.c
+++ b/drivers/gpio/bcm2835_gpio.c
@@ -10,6 +10,7 @@
#include <errno.h>
#include <asm/gpio.h>
#include <asm/io.h>
+#include <fdtdec.h>
struct bcm2835_gpios {
struct bcm2835_gpio_regs *reg;
@@ -118,9 +119,32 @@ static int bcm2835_gpio_probe(struct udevice *dev)
return 0;
}
+#if CONFIG_IS_ENABLED(OF_CONTROL)
+static const struct udevice_id bcm2835_gpio_id[] = {
+ {.compatible = "brcm,bcm2835-gpio"},
+ {}
+};
+
+static int bcm2835_gpio_ofdata_to_platdata(struct udevice *dev)
+{
+ struct bcm2835_gpio_platdata *plat = dev_get_platdata(dev);
+ fdt_addr_t addr;
+
+ addr = dev_get_addr(dev);
+ if (addr == FDT_ADDR_T_NONE)
+ return -EINVAL;
+
+ plat->base = addr;
+ return 0;
+}
+#endif
+
U_BOOT_DRIVER(gpio_bcm2835) = {
.name = "gpio_bcm2835",
.id = UCLASS_GPIO,
+ .of_match = of_match_ptr(bcm2835_gpio_id),
+ .ofdata_to_platdata = of_match_ptr(bcm2835_gpio_ofdata_to_platdata),
+ .platdata_auto_alloc_size = sizeof(struct bcm2835_gpio_platdata),
.ops = &gpio_bcm2835_ops,
.probe = bcm2835_gpio_probe,
.flags = DM_FLAG_PRE_RELOC,