From: Vicente <vicencb@gmail.com>
To: barebox@lists.infradead.org
Cc: Vicente <vicencb@gmail.com>
Subject: [PATCH 04/13] omap: revert gpiolib
Date: Mon, 8 Oct 2012 00:01:18 +0200 [thread overview]
Message-ID: <1349647287-28224-5-git-send-email-vicencb@gmail.com> (raw)
In-Reply-To: <1349647287-28224-1-git-send-email-vicencb@gmail.com>
Signed-off-by: Vicente <vicencb@gmail.com>
---
arch/arm/Kconfig | 1 -
arch/arm/mach-omap/gpio.c | 170 ++++++++++++++++++++-----------------
arch/arm/mach-omap/omap3_generic.c | 19 -----
arch/arm/mach-omap/omap4_generic.c | 19 -----
4 files changed, 93 insertions(+), 116 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8278c82..1cb56c5 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -60,7 +60,6 @@ config ARCH_NOMADIK
config ARCH_OMAP
bool "TI OMAP"
select HAS_DEBUG_LL
- select GPIOLIB
config ARCH_PXA
bool "Intel/Marvell PXA based"
diff --git a/arch/arm/mach-omap/gpio.c b/arch/arm/mach-omap/gpio.c
index 376e9a7..bb5f30f 100644
--- a/arch/arm/mach-omap/gpio.c
+++ b/arch/arm/mach-omap/gpio.c
@@ -32,10 +32,11 @@
* published by the Free Software Foundation.
*/
#include <common.h>
+#include <mach/gpio.h>
#include <io.h>
#include <errno.h>
-#include <gpio.h>
-#include <init.h>
+
+#ifdef CONFIG_ARCH_OMAP3
#define OMAP_GPIO_OE 0x0034
#define OMAP_GPIO_DATAIN 0x0038
@@ -43,114 +44,129 @@
#define OMAP_GPIO_CLEARDATAOUT 0x0090
#define OMAP_GPIO_SETDATAOUT 0x0094
-struct omap_gpio_chip {
- void __iomem *base;
- struct gpio_chip chip;
+static void __iomem *gpio_bank[] = {
+ (void *)0x48310000,
+ (void *)0x49050000,
+ (void *)0x49052000,
+ (void *)0x49054000,
+ (void *)0x49056000,
+ (void *)0x49058000,
+};
+#endif
+
+#ifdef CONFIG_ARCH_OMAP4
+
+#define OMAP_GPIO_OE 0x0134
+#define OMAP_GPIO_DATAIN 0x0138
+#define OMAP_GPIO_DATAOUT 0x013c
+#define OMAP_GPIO_CLEARDATAOUT 0x0190
+#define OMAP_GPIO_SETDATAOUT 0x0194
+
+static void __iomem *gpio_bank[] = {
+ (void *)0x4a310000,
+ (void *)0x48055000,
+ (void *)0x48057000,
+ (void *)0x48059000,
+ (void *)0x4805b000,
+ (void *)0x4805d000,
};
+#endif
-static inline int omap_get_gpio_index(int gpio)
+static inline void __iomem *get_gpio_base(int gpio)
{
- return gpio & 0x1f;
+ return gpio_bank[gpio >> 5];
}
-static void omap_gpio_set_value(struct gpio_chip *chip,
- unsigned gpio, int value)
+static inline int get_gpio_index(int gpio)
{
- struct omap_gpio_chip *omapgpio =
- container_of(chip, struct omap_gpio_chip, chip);
- void __iomem *base = omapgpio->base;
- u32 l = 0;
-
- if (value)
- base += OMAP_GPIO_SETDATAOUT;
- else
- base += OMAP_GPIO_CLEARDATAOUT;
+ return gpio & 0x1f;
+}
- l = 1 << omap_get_gpio_index(gpio);
+static inline int gpio_valid(int gpio)
+{
+ if (gpio < 0)
+ return -1;
+ if (gpio / 32 < ARRAY_SIZE(gpio_bank))
+ return 0;
+ return -1;
+}
- writel(l, base);
+static int check_gpio(int gpio)
+{
+ if (gpio_valid(gpio) < 0) {
+ printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
+ return -1;
+ }
+ return 0;
}
-static int omap_gpio_direction_input(struct gpio_chip *chip,
- unsigned gpio)
+void gpio_set_value(unsigned gpio, int value)
{
- struct omap_gpio_chip *omapgpio =
- container_of(chip, struct omap_gpio_chip, chip);
- void __iomem *base = omapgpio->base;
- u32 val;
+ void __iomem *reg;
+ u32 l = 0;
- base += OMAP_GPIO_OE;
+ if (check_gpio(gpio) < 0)
+ return;
- val = readl(base);
- val |= 1 << omap_get_gpio_index(gpio);
- writel(val, base);
+ reg = get_gpio_base(gpio);
- return 0;
+ if (value)
+ reg += OMAP_GPIO_SETDATAOUT;
+ else
+ reg += OMAP_GPIO_CLEARDATAOUT;
+ l = 1 << get_gpio_index(gpio);
+
+ __raw_writel(l, reg);
}
-static int omap_gpio_direction_output(struct gpio_chip *chip,
- unsigned gpio, int value)
+int gpio_direction_input(unsigned gpio)
{
- struct omap_gpio_chip *omapgpio =
- container_of(chip, struct omap_gpio_chip, chip);
- void __iomem *base = omapgpio->base;
+ void __iomem *reg;
u32 val;
- omap_gpio_set_value(chip, gpio, value);
+ if (check_gpio(gpio) < 0)
+ return -EINVAL;
+
+ reg = get_gpio_base(gpio);
- base += OMAP_GPIO_OE;
+ reg += OMAP_GPIO_OE;
- val = readl(base);
- val &= ~(1 << omap_get_gpio_index(gpio));
- writel(val, base);
+ val = __raw_readl(reg);
+ val |= 1 << get_gpio_index(gpio);
+ __raw_writel(val, reg);
return 0;
}
-static int omap_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
+int gpio_direction_output(unsigned gpio, int value)
{
- struct omap_gpio_chip *omapgpio =
- container_of(chip, struct omap_gpio_chip, chip);
- void __iomem *base = omapgpio->base;
-
- base += OMAP_GPIO_DATAIN;
-
- return (readl(base) & (1 << omap_get_gpio_index(gpio))) != 0;
-
-}
+ void __iomem *reg;
+ u32 val;
-static struct gpio_ops omap_gpio_ops = {
- .direction_input = omap_gpio_direction_input,
- .direction_output = omap_gpio_direction_output,
- .get = omap_gpio_get_value,
- .set = omap_gpio_set_value,
-};
+ if (check_gpio(gpio) < 0)
+ return -EINVAL;
+ reg = get_gpio_base(gpio);
-static int omap_gpio_probe(struct device_d *dev)
-{
- struct omap_gpio_chip *omapgpio;
+ gpio_set_value(gpio, value);
- omapgpio = xzalloc(sizeof(*omapgpio));
- omapgpio->base = dev_request_mem_region(dev, 0);
- omapgpio->chip.ops = &omap_gpio_ops;
- omapgpio->chip.base = -1;
- omapgpio->chip.ngpio = 32;
- omapgpio->chip.dev = dev;
- gpiochip_add(&omapgpio->chip);
+ reg += OMAP_GPIO_OE;
- dev_dbg(dev, "probed gpiochip%d with base %d\n",
- dev->id, omapgpio->chip.base);
+ val = __raw_readl(reg);
+ val &= ~(1 << get_gpio_index(gpio));
+ __raw_writel(val, reg);
return 0;
}
-static struct driver_d omap_gpio_driver = {
- .name = "omap-gpio",
- .probe = omap_gpio_probe,
-};
-
-static int omap_gpio_add(void)
+int gpio_get_value(unsigned gpio)
{
- return platform_driver_register(&omap_gpio_driver);
+ void __iomem *reg;
+
+ if (check_gpio(gpio) < 0)
+ return -EINVAL;
+ reg = get_gpio_base(gpio);
+
+ reg += OMAP_GPIO_DATAIN;
+
+ return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
}
-coredevice_initcall(omap_gpio_add);
diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c
index 5028e9a..af26af4 100644
--- a/arch/arm/mach-omap/omap3_generic.c
+++ b/arch/arm/mach-omap/omap3_generic.c
@@ -511,22 +511,3 @@ const struct gpmc_config omap3_nand_cfg = {
.base = 0x28000000,
.size = GPMC_SIZE_16M,
};
-
-static int omap3_gpio_init(void)
-{
- add_generic_device("omap-gpio", 0, NULL, 0x48310000,
- 0x100, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 1, NULL, 0x49050000,
- 0x100, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 2, NULL, 0x49052000,
- 0x100, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 3, NULL, 0x49054000,
- 0x100, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 4, NULL, 0x49056000,
- 0x100, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 5, NULL, 0x49058000,
- 0x100, IORESOURCE_MEM, NULL);
-
- return 0;
-}
-coredevice_initcall(omap3_gpio_init);
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index a159dfc..617d786 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -572,22 +572,3 @@ const struct gpmc_config omap4_nand_cfg = {
.base = 0x28000000,
.size = GPMC_SIZE_16M,
};
-
-static int omap4_gpio_init(void)
-{
- add_generic_device("omap-gpio", 0, NULL, 0x4a310100,
- 0x1000, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 1, NULL, 0x48055100,
- 0x1000, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 2, NULL, 0x48057100,
- 0x1000, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 3, NULL, 0x48059100,
- 0x1000, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 4, NULL, 0x4805b100,
- 0x1000, IORESOURCE_MEM, NULL);
- add_generic_device("omap-gpio", 5, NULL, 0x4805d100,
- 0x1000, IORESOURCE_MEM, NULL);
-
- return 0;
-}
-coredevice_initcall(omap4_gpio_init);
--
1.7.12.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-10-07 22:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-07 22:01 [PATCH 00/13] archosg9: add support for tablet, fourth round Vicente
2012-10-07 22:01 ` [PATCH 01/13] twl6030: add debug info Vicente
2012-10-07 22:01 ` [PATCH 02/13] omap4: add rename definitions to match datasheet Vicente
2012-10-07 22:01 ` [PATCH 03/13] ARM: ensure irqs are disabled Vicente
2012-10-08 20:21 ` Sascha Hauer
2012-10-07 22:01 ` Vicente [this message]
2012-10-07 22:01 ` [PATCH 05/13] omap4: add usb boot source Vicente
2012-10-07 22:01 ` [PATCH 06/13] bootm: close open files Vicente
2012-10-08 20:18 ` Sascha Hauer
2012-10-08 21:02 ` vj
2012-10-07 22:01 ` [PATCH 07/13] uimage: improve transfer speed Vicente
2012-10-08 20:01 ` Sascha Hauer
2012-10-08 20:48 ` vj
2012-10-07 22:01 ` [PATCH 08/13] fs: improve robustness Vicente
2012-10-07 22:01 ` [PATCH 09/13] omap4: add support for booting cpu from usb Vicente
2012-10-07 22:01 ` [PATCH 10/13] omap4: add serial communications over usb boot Vicente
2012-10-07 22:01 ` [PATCH 11/13] omap4: add filesystem support " Vicente
2012-10-07 22:01 ` [PATCH 12/13] omap4: add support for loading second stage from usb Vicente
2012-10-07 22:01 ` [PATCH 13/13] Add support for Archos G9 tablet Vicente
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349647287-28224-5-git-send-email-vicencb@gmail.com \
--to=vicencb@gmail.com \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox