aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/gpio.c')
-rw-r--r--arch/arm/plat-omap/gpio.c121
1 files changed, 89 insertions, 32 deletions
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 00940dc6bb50..fd21937fe110 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -514,14 +514,12 @@ static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
514 __raw_writel(l, reg); 514 __raw_writel(l, reg);
515} 515}
516 516
517static int __omap_get_gpio_datain(int gpio) 517static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
518{ 518{
519 struct gpio_bank *bank;
520 void __iomem *reg; 519 void __iomem *reg;
521 520
522 if (check_gpio(gpio) < 0) 521 if (check_gpio(gpio) < 0)
523 return -EINVAL; 522 return -EINVAL;
524 bank = get_gpio_bank(gpio);
525 reg = bank->base; 523 reg = bank->base;
526 switch (bank->method) { 524 switch (bank->method) {
527#ifdef CONFIG_ARCH_OMAP1 525#ifdef CONFIG_ARCH_OMAP1
@@ -566,6 +564,53 @@ static int __omap_get_gpio_datain(int gpio)
566 & (1 << get_gpio_index(gpio))) != 0; 564 & (1 << get_gpio_index(gpio))) != 0;
567} 565}
568 566
567static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
568{
569 void __iomem *reg;
570
571 if (check_gpio(gpio) < 0)
572 return -EINVAL;
573 reg = bank->base;
574
575 switch (bank->method) {
576#ifdef CONFIG_ARCH_OMAP1
577 case METHOD_MPUIO:
578 reg += OMAP_MPUIO_OUTPUT;
579 break;
580#endif
581#ifdef CONFIG_ARCH_OMAP15XX
582 case METHOD_GPIO_1510:
583 reg += OMAP1510_GPIO_DATA_OUTPUT;
584 break;
585#endif
586#ifdef CONFIG_ARCH_OMAP16XX
587 case METHOD_GPIO_1610:
588 reg += OMAP1610_GPIO_DATAOUT;
589 break;
590#endif
591#ifdef CONFIG_ARCH_OMAP730
592 case METHOD_GPIO_730:
593 reg += OMAP730_GPIO_DATA_OUTPUT;
594 break;
595#endif
596#ifdef CONFIG_ARCH_OMAP850
597 case METHOD_GPIO_850:
598 reg += OMAP850_GPIO_DATA_OUTPUT;
599 break;
600#endif
601#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) || \
602 defined(CONFIG_ARCH_OMAP4)
603 case METHOD_GPIO_24XX:
604 reg += OMAP24XX_GPIO_DATAOUT;
605 break;
606#endif
607 default:
608 return -EINVAL;
609 }
610
611 return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
612}
613
569#define MOD_REG_BIT(reg, bit_mask, set) \ 614#define MOD_REG_BIT(reg, bit_mask, set) \
570do { \ 615do { \
571 int l = __raw_readl(base + reg); \ 616 int l = __raw_readl(base + reg); \
@@ -1459,9 +1504,49 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset)
1459 return 0; 1504 return 0;
1460} 1505}
1461 1506
1507static int gpio_is_input(struct gpio_bank *bank, int mask)
1508{
1509 void __iomem *reg = bank->base;
1510
1511 switch (bank->method) {
1512 case METHOD_MPUIO:
1513 reg += OMAP_MPUIO_IO_CNTL;
1514 break;
1515 case METHOD_GPIO_1510:
1516 reg += OMAP1510_GPIO_DIR_CONTROL;
1517 break;
1518 case METHOD_GPIO_1610:
1519 reg += OMAP1610_GPIO_DIRECTION;
1520 break;
1521 case METHOD_GPIO_730:
1522 reg += OMAP730_GPIO_DIR_CONTROL;
1523 break;
1524 case METHOD_GPIO_850:
1525 reg += OMAP850_GPIO_DIR_CONTROL;
1526 break;
1527 case METHOD_GPIO_24XX:
1528 reg += OMAP24XX_GPIO_OE;
1529 break;
1530 }
1531 return __raw_readl(reg) & mask;
1532}
1533
1462static int gpio_get(struct gpio_chip *chip, unsigned offset) 1534static int gpio_get(struct gpio_chip *chip, unsigned offset)
1463{ 1535{
1464 return __omap_get_gpio_datain(chip->base + offset); 1536 struct gpio_bank *bank;
1537 void __iomem *reg;
1538 int gpio;
1539 u32 mask;
1540
1541 gpio = chip->base + offset;
1542 bank = get_gpio_bank(gpio);
1543 reg = bank->base;
1544 mask = 1 << get_gpio_index(gpio);
1545
1546 if (gpio_is_input(bank, mask))
1547 return _get_gpio_datain(bank, gpio);
1548 else
1549 return _get_gpio_dataout(bank, gpio);
1465} 1550}
1466 1551
1467static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) 1552static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
@@ -2039,34 +2124,6 @@ arch_initcall(omap_gpio_sysinit);
2039#include <linux/debugfs.h> 2124#include <linux/debugfs.h>
2040#include <linux/seq_file.h> 2125#include <linux/seq_file.h>
2041 2126
2042static int gpio_is_input(struct gpio_bank *bank, int mask)
2043{
2044 void __iomem *reg = bank->base;
2045
2046 switch (bank->method) {
2047 case METHOD_MPUIO:
2048 reg += OMAP_MPUIO_IO_CNTL;
2049 break;
2050 case METHOD_GPIO_1510:
2051 reg += OMAP1510_GPIO_DIR_CONTROL;
2052 break;
2053 case METHOD_GPIO_1610:
2054 reg += OMAP1610_GPIO_DIRECTION;
2055 break;
2056 case METHOD_GPIO_730:
2057 reg += OMAP730_GPIO_DIR_CONTROL;
2058 break;
2059 case METHOD_GPIO_850:
2060 reg += OMAP850_GPIO_DIR_CONTROL;
2061 break;
2062 case METHOD_GPIO_24XX:
2063 reg += OMAP24XX_GPIO_OE;
2064 break;
2065 }
2066 return __raw_readl(reg) & mask;
2067}
2068
2069
2070static int dbg_gpio_show(struct seq_file *s, void *unused) 2127static int dbg_gpio_show(struct seq_file *s, void *unused)
2071{ 2128{
2072 unsigned i, j, gpio; 2129 unsigned i, j, gpio;