* [PATCH v2 01/11] add gpiolib support
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 02/11] ARM i.MX: switch to " Steffen Trumtrar
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
From: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
drivers/Makefile | 1 +
drivers/gpio/Kconfig | 2 +
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++
include/gpio.h | 27 +++++++++-
5 files changed, 164 insertions(+), 1 deletion(-)
create mode 100644 drivers/gpio/Kconfig
create mode 100644 drivers/gpio/Makefile
create mode 100644 drivers/gpio/gpio.c
diff --git a/drivers/Makefile b/drivers/Makefile
index ea3263f..1d14e6c 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_PWM) += pwm/
obj-y += input/
obj-y += dma/
obj-y += watchdog/
+obj-y += gpio/
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
new file mode 100644
index 0000000..a681973
--- /dev/null
+++ b/drivers/gpio/Kconfig
@@ -0,0 +1,2 @@
+config GPIOLIB
+ bool
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
new file mode 100644
index 0000000..7837966
--- /dev/null
+++ b/drivers/gpio/Makefile
@@ -0,0 +1 @@
+obj-y += gpio.o
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
new file mode 100644
index 0000000..6ad8d27
--- /dev/null
+++ b/drivers/gpio/gpio.c
@@ -0,0 +1,134 @@
+#include <common.h>
+#include <gpio.h>
+#include <errno.h>
+
+static LIST_HEAD(chip_list);
+
+#define ARCH_NR_GPIOS 256
+
+static struct gpio_chip *gpio_desc[ARCH_NR_GPIOS];
+
+static int gpio_is_valid(unsigned gpio)
+{
+ if (gpio < ARCH_NR_GPIOS)
+ return 1;
+ return 0;
+}
+
+void gpio_set_value(unsigned gpio, int value)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return;
+ if (!chip)
+ return;
+ if (!chip->ops->set)
+ return;
+ chip->ops->set(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL(gpio_set_value);
+
+int gpio_get_value(unsigned gpio)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->get)
+ return -ENOSYS;
+ return chip->ops->get(chip, gpio - chip->base);
+}
+EXPORT_SYMBOL(gpio_get_value);
+
+int gpio_direction_output(unsigned gpio, int value)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->direction_output)
+ return -ENOSYS;
+ return chip->ops->direction_output(chip, gpio - chip->base, value);
+}
+EXPORT_SYMBOL(gpio_direction_output);
+
+int gpio_direction_input(unsigned gpio)
+{
+ struct gpio_chip *chip = gpio_desc[gpio];
+
+ if (!gpio_is_valid(gpio))
+ return -EINVAL;
+ if (!chip)
+ return -ENODEV;
+ if (!chip->ops->direction_input)
+ return -ENOSYS;
+ return chip->ops->direction_input(chip, gpio - chip->base);
+}
+EXPORT_SYMBOL(gpio_direction_input);
+
+static int gpiochip_find_base(int start, int ngpio)
+{
+ int i;
+ int spare = 0;
+ int base = -ENOSPC;
+
+ if (start < 0)
+ start = 0;
+
+ for (i = start; i < ARCH_NR_GPIOS; i++) {
+ struct gpio_chip *chip = gpio_desc[i];
+
+ if (!chip) {
+ spare++;
+ if (spare == ngpio) {
+ base = i + 1 - ngpio;
+ break;
+ }
+ } else {
+ spare = 0;
+ i += chip->ngpio - 1;
+ }
+ }
+
+ if (gpio_is_valid(base))
+ debug("%s: found new base at %d\n", __func__, base);
+ return base;
+}
+
+int gpiochip_add(struct gpio_chip *chip)
+{
+ int base, i;
+
+ base = gpiochip_find_base(chip->base, chip->ngpio);
+ if (base < 0)
+ return base;
+
+ if (chip->base >= 0 && chip->base != base)
+ return -EBUSY;
+
+ chip->base = base;
+
+ list_add_tail(&chip->list, &chip_list);
+
+ for (i = chip->base; i < chip->base + chip->ngpio; i++)
+ gpio_desc[i] = chip;
+
+ return 0;
+}
+
+int gpio_get_num(struct device_d *dev, int gpio)
+{
+ struct gpio_chip *chip;
+
+ list_for_each_entry(chip, &chip_list, list) {
+ if (chip->dev == dev)
+ return chip->base + gpio;
+ }
+
+ return -ENODEV;
+}
diff --git a/include/gpio.h b/include/gpio.h
index b7d8402..9fb11c3 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -5,10 +5,35 @@
static inline int gpio_request(unsigned gpio, const char *label)
{
- return 0;
+ return 0;
}
static inline void gpio_free(unsigned gpio)
{
}
+
+struct gpio_chip;
+
+struct gpio_ops {
+ int (*direction_input)(struct gpio_chip *chip, unsigned offset);
+ int (*direction_output)(struct gpio_chip *chip, unsigned offset, int value);
+ int (*get)(struct gpio_chip *chip, unsigned offset);
+ void (*set)(struct gpio_chip *chip, unsigned offset, int value);
+};
+
+struct gpio_chip {
+ struct device_d *dev;
+
+ int base;
+ int ngpio;
+
+ struct gpio_ops *ops;
+
+ struct list_head list;
+};
+
+int gpiochip_add(struct gpio_chip *chip);
+
+int gpio_get_num(struct device_d *dev, int gpio);
+
#endif /* __GPIO_H */
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 02/11] ARM i.MX: switch to gpiolib support
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 01/11] " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 03/11] ARM i.MX1: add imx-gpio devices Steffen Trumtrar
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
From: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/gpio.c | 94 +++++++++++++++++++++++++++++-----------------
1 file changed, 59 insertions(+), 35 deletions(-)
diff --git a/arch/arm/mach-imx/gpio.c b/arch/arm/mach-imx/gpio.c
index fdee20b..8d5d4ce 100644
--- a/arch/arm/mach-imx/gpio.c
+++ b/arch/arm/mach-imx/gpio.c
@@ -27,7 +27,8 @@
#include <errno.h>
#include <io.h>
#include <mach/imx-regs.h>
-#include <mach/gpio.h>
+#include <gpio.h>
+#include <init.h>
#if defined CONFIG_ARCH_IMX1 || defined CONFIG_ARCH_IMX21 || defined CONFIG_ARCH_IMX27
#define GPIO_DR 0x1c
@@ -48,21 +49,15 @@
#define GPIO_ISR 0x18
#endif
-extern void __iomem *imx_gpio_base[];
-extern int imx_gpio_count;
+struct imx_gpio_chip {
+ void __iomem *base;
+ struct gpio_chip chip;
+};
-static void __iomem *gpio_get_base(unsigned gpio)
+static void imx_gpio_set_value(struct gpio_chip *chip, unsigned gpio, int value)
{
- if (gpio >= imx_gpio_count)
- return NULL;
-
- return imx_gpio_base[gpio / 32];
-}
-
-void gpio_set_value(unsigned gpio, int value)
-{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
if (!base)
@@ -71,59 +66,88 @@ void gpio_set_value(unsigned gpio, int value)
val = readl(base + GPIO_DR);
if (value)
- val |= 1 << shift;
+ val |= 1 << gpio;
else
- val &= ~(1 << shift);
+ val &= ~(1 << gpio);
writel(val, base + GPIO_DR);
}
-int gpio_direction_input(unsigned gpio)
+static int imx_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
if (!base)
return -EINVAL;
val = readl(base + GPIO_GDIR);
- val &= ~(1 << shift);
+ val &= ~(1 << gpio);
writel(val, base + GPIO_GDIR);
return 0;
}
-int gpio_direction_output(unsigned gpio, int value)
+static int imx_gpio_direction_output(struct gpio_chip *chip, unsigned gpio, int value)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
- if (!base)
- return -EINVAL;
-
- gpio_set_value(gpio, value);
+ gpio_set_value(gpio + chip->base, value);
val = readl(base + GPIO_GDIR);
- val |= 1 << shift;
+ val |= 1 << gpio;
writel(val, base + GPIO_GDIR);
return 0;
}
-int gpio_get_value(unsigned gpio)
+static int imx_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
{
- void __iomem *base = gpio_get_base(gpio);
- int shift = gpio % 32;
+ struct imx_gpio_chip *imxgpio = container_of(chip, struct imx_gpio_chip, chip);
+ void __iomem *base = imxgpio->base;
u32 val;
- if (!base)
- return -EINVAL;
-
val = readl(base + GPIO_PSR);
- return val & (1 << shift) ? 1 : 0;
+ return val & (1 << gpio) ? 1 : 0;
+}
+
+static struct gpio_ops imx_gpio_ops = {
+ .direction_input = imx_gpio_direction_input,
+ .direction_output = imx_gpio_direction_output,
+ .get = imx_gpio_get_value,
+ .set = imx_gpio_set_value,
+};
+
+static int imx_gpio_probe(struct device_d *dev)
+{
+ struct imx_gpio_chip *imxgpio;
+
+ imxgpio = xzalloc(sizeof(*imxgpio));
+ imxgpio->base = dev_request_mem_region(dev, 0);
+ imxgpio->chip.ops = &imx_gpio_ops;
+ imxgpio->chip.base = -1;
+ imxgpio->chip.ngpio = 32;
+ imxgpio->chip.dev = dev;
+ gpiochip_add(&imxgpio->chip);
+
+ dev_info(dev, "probed gpiochip%d with base %d\n", dev->id, imxgpio->chip.base);
+
+ return 0;
}
+static struct driver_d imx_gpio_driver = {
+ .name = "imx-gpio",
+ .probe = imx_gpio_probe,
+};
+
+static int imx_gpio_add(void)
+{
+ register_driver(&imx_gpio_driver);
+ return 0;
+}
+coredevice_initcall(imx_gpio_add);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 03/11] ARM i.MX1: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 01/11] " Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 02/11] ARM i.MX: switch to " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 04/11] ARM i.MX21: " Steffen Trumtrar
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx1.c | 18 +++++++++---------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index ce5edaa..112dcb1 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -148,6 +148,7 @@ choice
config ARCH_IMX1
bool "i.MX1"
+ select GPIOLIB
select CPU_ARM920T
config ARCH_IMX21
diff --git a/arch/arm/mach-imx/imx1.c b/arch/arm/mach-imx/imx1.c
index 742a260..bdd4f74 100644
--- a/arch/arm/mach-imx/imx1.c
+++ b/arch/arm/mach-imx/imx1.c
@@ -19,13 +19,13 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)0x0021c000,
- (void *)0x0021c100,
- (void *)0x0021c200,
- (void *)0x0021c300,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
+static int imx1_init(void)
+{
+ add_generic_device("imx-gpio", 0, NULL, 0x0021c000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x0021c100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x0021c200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x0021c300, 0x100, IORESOURCE_MEM, NULL);
+ return 0;
+}
+coredevice_initcall(imx1_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 04/11] ARM i.MX21: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (2 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 03/11] ARM i.MX1: add imx-gpio devices Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 05/11] ARM i.MX25: " Steffen Trumtrar
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx21.c | 22 +++++++++++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 112dcb1..c069ae8 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -153,6 +153,7 @@ config ARCH_IMX1
config ARCH_IMX21
bool "i.MX21"
+ select GPIOLIB
select CPU_ARM926T
config ARCH_IMX25
diff --git a/arch/arm/mach-imx/imx21.c b/arch/arm/mach-imx/imx21.c
index bbef33d..264477a 100644
--- a/arch/arm/mach-imx/imx21.c
+++ b/arch/arm/mach-imx/imx21.c
@@ -28,14 +28,18 @@ int imx_silicon_revision(void)
return CID;
}
-void *imx_gpio_base[] = {
- (void *)0x10015000,
- (void *)0x10015100,
- (void *)0x10015200,
- (void *)0x10015300,
- (void *)0x10015400,
- (void *)0x10015500,
-};
+static int imx21_init(void)
+{
+ add_generic_device("imx_iim", 0, NULL, MX51_IIM_BASE_ADDR, SZ_4K,
+ IORESOURCE_MEM, NULL);
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
+ add_generic_device("imx-gpio", 0, NULL, 0x10015000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x10015100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x10015200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x10015300, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, 0x10015400, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, 0x10015500, 0x100, IORESOURCE_MEM, NULL);
+ return 0;
+}
+coredevice_initcall(imx21_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 05/11] ARM i.MX25: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (3 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 04/11] ARM i.MX21: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 06/11] ARM i.MX27: " Steffen Trumtrar
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx25.c | 13 ++++---------
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index c069ae8..eb7518f 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -158,6 +158,7 @@ config ARCH_IMX21
config ARCH_IMX25
bool "i.MX25"
+ select GPIOLIB
select CPU_ARM926T
select ARCH_HAS_FEC_IMX
diff --git a/arch/arm/mach-imx/imx25.c b/arch/arm/mach-imx/imx25.c
index 19a2909..2c739b3 100644
--- a/arch/arm/mach-imx/imx25.c
+++ b/arch/arm/mach-imx/imx25.c
@@ -24,15 +24,6 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
- (void *)0x53f9c000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
u64 imx_uid(void)
{
u64 uid = 0;
@@ -59,6 +50,10 @@ static int imx25_init(void)
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, &imx25_iim_pdata);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x53f9c000, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx25_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 06/11] ARM i.MX27: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (4 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 05/11] ARM i.MX25: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 07/11] ARM i.MX31: " Steffen Trumtrar
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx27.c | 17 ++++++-----------
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index eb7518f..fcb5b27 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -164,6 +164,7 @@ config ARCH_IMX25
config ARCH_IMX27
bool "i.MX27"
+ select GPIOLIB
select CPU_ARM926T
select ARCH_HAS_FEC_IMX
diff --git a/arch/arm/mach-imx/imx27.c b/arch/arm/mach-imx/imx27.c
index 1af291d..7930f73 100644
--- a/arch/arm/mach-imx/imx27.c
+++ b/arch/arm/mach-imx/imx27.c
@@ -28,17 +28,6 @@ int imx_silicon_revision(void)
return CID >> 28;
}
-void *imx_gpio_base[] = {
- (void *)0x10015000,
- (void *)0x10015100,
- (void *)0x10015200,
- (void *)0x10015300,
- (void *)0x10015400,
- (void *)0x10015500,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
/*
* Initialize MAX on i.MX27. necessary to give the DMA engine
* higher priority to the memory than the CPU. Needed for proper
@@ -86,6 +75,12 @@ static int imx27_init(void)
imx27_init_max();
+ add_generic_device("imx-gpio", 0, NULL, 0x10015000, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x10015100, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x10015200, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x10015300, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, 0x10015400, 0x100, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, 0x10015500, 0x100, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx27_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 07/11] ARM i.MX31: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (5 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 06/11] ARM i.MX27: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 08/11] ARM i.MX35: " Steffen Trumtrar
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx31.c | 12 ++++--------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index fcb5b27..129960f 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -170,6 +170,7 @@ config ARCH_IMX27
config ARCH_IMX31
select CPU_V6
+ select GPIOLIB
bool "i.MX31"
config ARCH_IMX35
diff --git a/arch/arm/mach-imx/imx31.c b/arch/arm/mach-imx/imx31.c
index bb713ca..8661561 100644
--- a/arch/arm/mach-imx/imx31.c
+++ b/arch/arm/mach-imx/imx31.c
@@ -22,19 +22,15 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
static int imx31_init(void)
{
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx31_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 08/11] ARM i.MX35: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (6 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 07/11] ARM i.MX31: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 09/11] ARM i.MX51: " Steffen Trumtrar
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx35.c | 12 ++++--------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 129960f..f06788d 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -176,6 +176,7 @@ config ARCH_IMX31
config ARCH_IMX35
bool "i.MX35"
select CPU_V6
+ select GPIOLIB
select ARCH_HAS_FEC_IMX
config ARCH_IMX51
diff --git a/arch/arm/mach-imx/imx35.c b/arch/arm/mach-imx/imx35.c
index fe0c99e..7bc5401 100644
--- a/arch/arm/mach-imx/imx35.c
+++ b/arch/arm/mach-imx/imx35.c
@@ -25,14 +25,6 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)0x53fcc000,
- (void *)0x53fd0000,
- (void *)0x53fa4000,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
int imx_silicon_revision()
{
uint32_t reg;
@@ -66,6 +58,10 @@ static int imx35_init(void)
add_generic_device("imx_iim", 0, NULL, IMX_IIM_BASE, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x53fcc000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x53fd0000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x53fa4000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx35_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 09/11] ARM i.MX51: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (7 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 08/11] ARM i.MX35: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 10/11] ARM i.MX53: " Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 11/11] ARM i.MX6: " Steffen Trumtrar
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx51.c | 14 +++++---------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index f06788d..9d7b931 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -182,6 +182,7 @@ config ARCH_IMX35
config ARCH_IMX51
bool "i.MX51"
select CPU_V7
+ select GPIOLIB
select ARCH_HAS_FEC_IMX
config ARCH_IMX53
diff --git a/arch/arm/mach-imx/imx51.c b/arch/arm/mach-imx/imx51.c
index 53205a9..aa54990 100644
--- a/arch/arm/mach-imx/imx51.c
+++ b/arch/arm/mach-imx/imx51.c
@@ -26,15 +26,6 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)MX51_GPIO1_BASE_ADDR,
- (void *)MX51_GPIO2_BASE_ADDR,
- (void *)MX51_GPIO3_BASE_ADDR,
- (void *)MX51_GPIO4_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
#define SI_REV 0x48
static u32 mx51_silicon_revision;
@@ -89,6 +80,11 @@ static int imx51_init(void)
add_generic_device("imx_iim", 0, NULL, MX51_IIM_BASE_ADDR, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, 0x73f84000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, 0x73f88000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, 0x73f8c000, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, 0x73f90000, 0x1000, IORESOURCE_MEM, NULL);
+
return 0;
}
coredevice_initcall(imx51_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 10/11] ARM i.MX53: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (8 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 09/11] ARM i.MX51: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
2012-09-03 8:18 ` [PATCH v2 11/11] ARM i.MX6: " Steffen Trumtrar
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx53.c | 19 +++++++------------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 9d7b931..0c09b57 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -188,6 +188,7 @@ config ARCH_IMX51
config ARCH_IMX53
bool "i.MX53"
select CPU_V7
+ select GPIOLIB
select ARCH_HAS_FEC_IMX
config ARCH_IMX6
diff --git a/arch/arm/mach-imx/imx53.c b/arch/arm/mach-imx/imx53.c
index 7c679bb..24530ad 100644
--- a/arch/arm/mach-imx/imx53.c
+++ b/arch/arm/mach-imx/imx53.c
@@ -26,18 +26,6 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)MX53_GPIO1_BASE_ADDR,
- (void *)MX53_GPIO2_BASE_ADDR,
- (void *)MX53_GPIO3_BASE_ADDR,
- (void *)MX53_GPIO4_BASE_ADDR,
- (void *)MX53_GPIO5_BASE_ADDR,
- (void *)MX53_GPIO6_BASE_ADDR,
- (void *)MX53_GPIO7_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
#define SI_REV 0x48
static u32 mx53_silicon_revision;
@@ -88,6 +76,13 @@ static int imx53_init(void)
add_generic_device("imx_iim", 0, NULL, MX53_IIM_BASE_ADDR, SZ_4K,
IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 0, NULL, MX53_GPIO1_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, MX53_GPIO2_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, MX53_GPIO3_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, MX53_GPIO4_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, MX53_GPIO5_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, MX53_GPIO6_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 6, NULL, MX53_GPIO7_BASE_ADDR, 0x1000, IORESOURCE_MEM, NULL);
return 0;
}
coredevice_initcall(imx53_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 11/11] ARM i.MX6: add imx-gpio devices
2012-09-03 8:18 [PATCH v2 00/11] ARM i.MX: add gpiolib support Steffen Trumtrar
` (9 preceding siblings ...)
2012-09-03 8:18 ` [PATCH v2 10/11] ARM i.MX53: " Steffen Trumtrar
@ 2012-09-03 8:18 ` Steffen Trumtrar
10 siblings, 0 replies; 12+ messages in thread
From: Steffen Trumtrar @ 2012-09-03 8:18 UTC (permalink / raw)
To: barebox; +Cc: Steffen Trumtrar
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 1 +
arch/arm/mach-imx/imx6.c | 26 ++++++++++++++------------
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 0c09b57..eb4c2ae 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -194,6 +194,7 @@ config ARCH_IMX53
config ARCH_IMX6
bool "i.MX6"
select ARCH_HAS_FEC_IMX
+ select GPIOLIB
select CPU_V7
endchoice
diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c
index a443343..80f558e 100644
--- a/arch/arm/mach-imx/imx6.c
+++ b/arch/arm/mach-imx/imx6.c
@@ -23,18 +23,6 @@
#include "gpio.h"
-void *imx_gpio_base[] = {
- (void *)MX6_GPIO1_BASE_ADDR,
- (void *)MX6_GPIO2_BASE_ADDR,
- (void *)MX6_GPIO3_BASE_ADDR,
- (void *)MX6_GPIO4_BASE_ADDR,
- (void *)MX6_GPIO5_BASE_ADDR,
- (void *)MX6_GPIO6_BASE_ADDR,
- (void *)MX6_GPIO7_BASE_ADDR,
-};
-
-int imx_gpio_count = ARRAY_SIZE(imx_gpio_base) * 32;
-
void imx6_init_lowlevel(void)
{
void __iomem *aips1 = (void *)MX6_AIPS1_ON_BASE_ADDR;
@@ -69,3 +57,17 @@ void imx6_init_lowlevel(void)
writel(0xffffffff, 0x020c407c);
writel(0xffffffff, 0x020c4080);
}
+
+static int imx6_init(void)
+{
+ add_generic_device("imx-gpio", 0, NULL, MX6_GPIO1_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 1, NULL, MX6_GPIO2_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 2, NULL, MX6_GPIO3_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 3, NULL, MX6_GPIO4_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 4, NULL, MX6_GPIO5_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 5, NULL, MX6_GPIO6_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+ add_generic_device("imx-gpio", 6, NULL, MX6_GPIO7_BASE_ADDR, 0x4000, IORESOURCE_MEM, NULL);
+
+ return 0;
+}
+coredevice_initcall(imx6_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 12+ messages in thread