diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2013-03-11 13:26:37 +0400 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2013-03-11 22:17:42 +0100 |
commit | 5fdba0feadefd2cc15a5c4d094f5891bf90e4a3b (patch) | |
tree | 2de7e75106231926175d7ebb049af56c404ce45b /drivers | |
parent | 100c016f3561d5f87fd27f8cb02d886ba3e72536 (diff) | |
download | barebox-5fdba0feadefd2cc15a5c4d094f5891bf90e4a3b.tar.gz barebox-5fdba0feadefd2cc15a5c4d094f5891bf90e4a3b.tar.xz |
ARM: clps711x: Add GPIO driver
This patch adds support for CLPS711X GPIOs. Driver based on
generic GPIO driver.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/Kconfig | 7 | ||||
-rw-r--r-- | drivers/gpio/Makefile | 1 | ||||
-rw-r--r-- | drivers/gpio/gpio-clps711x.c | 70 |
3 files changed, 78 insertions, 0 deletions
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index 895eb688ad..ea07028db5 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -13,6 +13,13 @@ config GPIO_BCM2835 bool "GPIO support for BCM2835" depends on ARCH_BCM2835 +config GPIO_CLPS711X + bool "GPIO support for CLPS711X" + depends on ARCH_CLPS711X + select GPIO_GENERIC + help + Say yes here to enable the GPIO driver for the CLPS711X CPUs + config GPIO_GENERIC_PLATFORM bool "Generic memory-mapped GPIO controller support" select GPIO_GENERIC diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index 1ef345ca72..00acb68b37 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_GPIOLIB) += gpio.o obj-$(CONFIG_GPIO_BCM2835) += gpio-bcm2835.o +obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o obj-$(CONFIG_GPIO_PL061) += gpio-pl061.o obj-$(CONFIG_GPIO_STMPE) += gpio-stmpe.o diff --git a/drivers/gpio/gpio-clps711x.c b/drivers/gpio/gpio-clps711x.c new file mode 100644 index 0000000000..feead51527 --- /dev/null +++ b/drivers/gpio/gpio-clps711x.c @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2013 Alexander Shiyan <shc_work@mail.ru> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + */ + +#include <init.h> +#include <common.h> +#include <malloc.h> + +#include <linux/basic_mmio_gpio.h> + +static int clps711x_gpio_probe(struct device_d *dev) +{ + int err; + void __iomem *dat, *dir = NULL, *dir_inv = NULL; + struct bgpio_chip *bgc; + + if ((dev->id < 0) || (dev->id > 4)) + return -ENODEV; + + dat = dev_request_mem_region(dev, 0); + switch (dev->id) { + case 3: + dir_inv = dev_request_mem_region(dev, 1); + break; + default: + dir = dev_request_mem_region(dev, 1); + break; + } + + if (!dat || (!dir && !dir_inv)) + return -EINVAL; + + bgc = xzalloc(sizeof(struct bgpio_chip)); + if (!bgc) + return -ENOMEM; + + err = bgpio_init(bgc, dev, 1, dat, NULL, NULL, dir, dir_inv, 0); + if (err) { + free(bgc); + return err; + } + + bgc->gc.base = dev->id * 8; + switch (dev->id) { + case 4: + bgc->gc.ngpio = 3; + break; + default: + bgc->gc.ngpio = 8; + break; + } + + return gpiochip_add(&bgc->gc); +} + +static struct driver_d clps711x_gpio_driver = { + .name = "clps711x-gpio", + .probe = clps711x_gpio_probe, +}; + +static __init int clps711x_gpio_register(void) +{ + return platform_driver_register(&clps711x_gpio_driver); +} +coredevice_initcall(clps711x_gpio_register); |