aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/gpio.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2009-08-18 17:37:37 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2009-08-18 17:37:37 -0400
commitaf15c1addf920d830b030e3489a482456904ca8c (patch)
treedc4adab63d19507f7ac44855ad9920f8fd2dd2f0 /arch/arm/plat-omap/gpio.c
parente6f25a7b2398581a5f96bf9021d0b22c9647acf4 (diff)
parentdcd94dbdaff452b95d4ba11fdbf853b5bda8e6e7 (diff)
Merge branch 'master' into for-linus
Diffstat (limited to 'arch/arm/plat-omap/gpio.c')
-rw-r--r--arch/arm/plat-omap/gpio.c127
1 files changed, 95 insertions, 32 deletions
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 3d03337ad422..50b19a3027bc 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -476,14 +476,12 @@ static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
476 __raw_writel(l, reg); 476 __raw_writel(l, reg);
477} 477}
478 478
479static int __omap_get_gpio_datain(int gpio) 479static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
480{ 480{
481 struct gpio_bank *bank;
482 void __iomem *reg; 481 void __iomem *reg;
483 482
484 if (check_gpio(gpio) < 0) 483 if (check_gpio(gpio) < 0)
485 return -EINVAL; 484 return -EINVAL;
486 bank = get_gpio_bank(gpio);
487 reg = bank->base; 485 reg = bank->base;
488 switch (bank->method) { 486 switch (bank->method) {
489#ifdef CONFIG_ARCH_OMAP1 487#ifdef CONFIG_ARCH_OMAP1
@@ -524,6 +522,53 @@ static int __omap_get_gpio_datain(int gpio)
524 & (1 << get_gpio_index(gpio))) != 0; 522 & (1 << get_gpio_index(gpio))) != 0;
525} 523}
526 524
525static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
526{
527 void __iomem *reg;
528
529 if (check_gpio(gpio) < 0)
530 return -EINVAL;
531 reg = bank->base;
532
533 switch (bank->method) {
534#ifdef CONFIG_ARCH_OMAP1
535 case METHOD_MPUIO:
536 reg += OMAP_MPUIO_OUTPUT;
537 break;
538#endif
539#ifdef CONFIG_ARCH_OMAP15XX
540 case METHOD_GPIO_1510:
541 reg += OMAP1510_GPIO_DATA_OUTPUT;
542 break;
543#endif
544#ifdef CONFIG_ARCH_OMAP16XX
545 case METHOD_GPIO_1610:
546 reg += OMAP1610_GPIO_DATAOUT;
547 break;
548#endif
549#ifdef CONFIG_ARCH_OMAP730
550 case METHOD_GPIO_730:
551 reg += OMAP730_GPIO_DATA_OUTPUT;
552 break;
553#endif
554#ifdef CONFIG_ARCH_OMAP850
555 case METHOD_GPIO_850:
556 reg += OMAP850_GPIO_DATA_OUTPUT;
557 break;
558#endif
559#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) || \
560 defined(CONFIG_ARCH_OMAP4)
561 case METHOD_GPIO_24XX:
562 reg += OMAP24XX_GPIO_DATAOUT;
563 break;
564#endif
565 default:
566 return -EINVAL;
567 }
568
569 return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
570}
571
527#define MOD_REG_BIT(reg, bit_mask, set) \ 572#define MOD_REG_BIT(reg, bit_mask, set) \
528do { \ 573do { \
529 int l = __raw_readl(base + reg); \ 574 int l = __raw_readl(base + reg); \
@@ -1189,6 +1234,7 @@ static void gpio_mask_irq(unsigned int irq)
1189 struct gpio_bank *bank = get_irq_chip_data(irq); 1234 struct gpio_bank *bank = get_irq_chip_data(irq);
1190 1235
1191 _set_gpio_irqenable(bank, gpio, 0); 1236 _set_gpio_irqenable(bank, gpio, 0);
1237 _set_gpio_triggering(bank, get_gpio_index(gpio), IRQ_TYPE_NONE);
1192} 1238}
1193 1239
1194static void gpio_unmask_irq(unsigned int irq) 1240static void gpio_unmask_irq(unsigned int irq)
@@ -1196,6 +1242,11 @@ static void gpio_unmask_irq(unsigned int irq)
1196 unsigned int gpio = irq - IH_GPIO_BASE; 1242 unsigned int gpio = irq - IH_GPIO_BASE;
1197 struct gpio_bank *bank = get_irq_chip_data(irq); 1243 struct gpio_bank *bank = get_irq_chip_data(irq);
1198 unsigned int irq_mask = 1 << get_gpio_index(gpio); 1244 unsigned int irq_mask = 1 << get_gpio_index(gpio);
1245 struct irq_desc *desc = irq_to_desc(irq);
1246 u32 trigger = desc->status & IRQ_TYPE_SENSE_MASK;
1247
1248 if (trigger)
1249 _set_gpio_triggering(bank, get_gpio_index(gpio), trigger);
1199 1250
1200 /* For level-triggered GPIOs, the clearing must be done after 1251 /* For level-triggered GPIOs, the clearing must be done after
1201 * the HW source is cleared, thus after the handler has run */ 1252 * the HW source is cleared, thus after the handler has run */
@@ -1356,9 +1407,49 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset)
1356 return 0; 1407 return 0;
1357} 1408}
1358 1409
1410static int gpio_is_input(struct gpio_bank *bank, int mask)
1411{
1412 void __iomem *reg = bank->base;
1413
1414 switch (bank->method) {
1415 case METHOD_MPUIO:
1416 reg += OMAP_MPUIO_IO_CNTL;
1417 break;
1418 case METHOD_GPIO_1510:
1419 reg += OMAP1510_GPIO_DIR_CONTROL;
1420 break;
1421 case METHOD_GPIO_1610:
1422 reg += OMAP1610_GPIO_DIRECTION;
1423 break;
1424 case METHOD_GPIO_730:
1425 reg += OMAP730_GPIO_DIR_CONTROL;
1426 break;
1427 case METHOD_GPIO_850:
1428 reg += OMAP850_GPIO_DIR_CONTROL;
1429 break;
1430 case METHOD_GPIO_24XX:
1431 reg += OMAP24XX_GPIO_OE;
1432 break;
1433 }
1434 return __raw_readl(reg) & mask;
1435}
1436
1359static int gpio_get(struct gpio_chip *chip, unsigned offset) 1437static int gpio_get(struct gpio_chip *chip, unsigned offset)
1360{ 1438{
1361 return __omap_get_gpio_datain(chip->base + offset); 1439 struct gpio_bank *bank;
1440 void __iomem *reg;
1441 int gpio;
1442 u32 mask;
1443
1444 gpio = chip->base + offset;
1445 bank = get_gpio_bank(gpio);
1446 reg = bank->base;
1447 mask = 1 << get_gpio_index(gpio);
1448
1449 if (gpio_is_input(bank, mask))
1450 return _get_gpio_datain(bank, gpio);
1451 else
1452 return _get_gpio_dataout(bank, gpio);
1362} 1453}
1363 1454
1364static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) 1455static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
@@ -1892,34 +1983,6 @@ arch_initcall(omap_gpio_sysinit);
1892#include <linux/debugfs.h> 1983#include <linux/debugfs.h>
1893#include <linux/seq_file.h> 1984#include <linux/seq_file.h>
1894 1985
1895static int gpio_is_input(struct gpio_bank *bank, int mask)
1896{
1897 void __iomem *reg = bank->base;
1898
1899 switch (bank->method) {
1900 case METHOD_MPUIO:
1901 reg += OMAP_MPUIO_IO_CNTL;
1902 break;
1903 case METHOD_GPIO_1510:
1904 reg += OMAP1510_GPIO_DIR_CONTROL;
1905 break;
1906 case METHOD_GPIO_1610:
1907 reg += OMAP1610_GPIO_DIRECTION;
1908 break;
1909 case METHOD_GPIO_730:
1910 reg += OMAP730_GPIO_DIR_CONTROL;
1911 break;
1912 case METHOD_GPIO_850:
1913 reg += OMAP850_GPIO_DIR_CONTROL;
1914 break;
1915 case METHOD_GPIO_24XX:
1916 reg += OMAP24XX_GPIO_OE;
1917 break;
1918 }
1919 return __raw_readl(reg) & mask;
1920}
1921
1922
1923static int dbg_gpio_show(struct seq_file *s, void *unused) 1986static int dbg_gpio_show(struct seq_file *s, void *unused)
1924{ 1987{
1925 unsigned i, j, gpio; 1988 unsigned i, j, gpio;