diff options
author | Paul Mundt <lethal@linux-sh.org> | 2009-08-23 05:04:07 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2009-08-23 05:04:07 -0400 |
commit | c3144fc46f987413df10e83659f0bf1aad76f79e (patch) | |
tree | a09f3c13c32664a617d3981ae111436c3127ccc3 /arch/arm/plat-omap/gpio.c | |
parent | 4f896ffca2b72f4b719746e7fbb0b623252e6ac9 (diff) | |
parent | cc58f597afc63a57bb55ed97c2a72f7405320c93 (diff) |
Merge branches 'sh/hwblk' and 'sh/pm-runtime'
Diffstat (limited to 'arch/arm/plat-omap/gpio.c')
-rw-r--r-- | arch/arm/plat-omap/gpio.c | 141 |
1 files changed, 105 insertions, 36 deletions
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 26b387c12423..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 | ||
479 | static int __omap_get_gpio_datain(int gpio) | 479 | static 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 | ||
525 | static 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) \ |
528 | do { \ | 573 | do { \ |
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 | ||
1194 | static void gpio_unmask_irq(unsigned int irq) | 1240 | static 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 */ |
@@ -1264,8 +1315,9 @@ static struct irq_chip mpuio_irq_chip = { | |||
1264 | 1315 | ||
1265 | #include <linux/platform_device.h> | 1316 | #include <linux/platform_device.h> |
1266 | 1317 | ||
1267 | static int omap_mpuio_suspend_late(struct platform_device *pdev, pm_message_t mesg) | 1318 | static int omap_mpuio_suspend_noirq(struct device *dev) |
1268 | { | 1319 | { |
1320 | struct platform_device *pdev = to_platform_device(dev); | ||
1269 | struct gpio_bank *bank = platform_get_drvdata(pdev); | 1321 | struct gpio_bank *bank = platform_get_drvdata(pdev); |
1270 | void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; | 1322 | void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; |
1271 | unsigned long flags; | 1323 | unsigned long flags; |
@@ -1278,8 +1330,9 @@ static int omap_mpuio_suspend_late(struct platform_device *pdev, pm_message_t me | |||
1278 | return 0; | 1330 | return 0; |
1279 | } | 1331 | } |
1280 | 1332 | ||
1281 | static int omap_mpuio_resume_early(struct platform_device *pdev) | 1333 | static int omap_mpuio_resume_noirq(struct device *dev) |
1282 | { | 1334 | { |
1335 | struct platform_device *pdev = to_platform_device(dev); | ||
1283 | struct gpio_bank *bank = platform_get_drvdata(pdev); | 1336 | struct gpio_bank *bank = platform_get_drvdata(pdev); |
1284 | void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; | 1337 | void __iomem *mask_reg = bank->base + OMAP_MPUIO_GPIO_MASKIT; |
1285 | unsigned long flags; | 1338 | unsigned long flags; |
@@ -1291,14 +1344,18 @@ static int omap_mpuio_resume_early(struct platform_device *pdev) | |||
1291 | return 0; | 1344 | return 0; |
1292 | } | 1345 | } |
1293 | 1346 | ||
1347 | static struct dev_pm_ops omap_mpuio_dev_pm_ops = { | ||
1348 | .suspend_noirq = omap_mpuio_suspend_noirq, | ||
1349 | .resume_noirq = omap_mpuio_resume_noirq, | ||
1350 | }; | ||
1351 | |||
1294 | /* use platform_driver for this, now that there's no longer any | 1352 | /* use platform_driver for this, now that there's no longer any |
1295 | * point to sys_device (other than not disturbing old code). | 1353 | * point to sys_device (other than not disturbing old code). |
1296 | */ | 1354 | */ |
1297 | static struct platform_driver omap_mpuio_driver = { | 1355 | static struct platform_driver omap_mpuio_driver = { |
1298 | .suspend_late = omap_mpuio_suspend_late, | ||
1299 | .resume_early = omap_mpuio_resume_early, | ||
1300 | .driver = { | 1356 | .driver = { |
1301 | .name = "mpuio", | 1357 | .name = "mpuio", |
1358 | .pm = &omap_mpuio_dev_pm_ops, | ||
1302 | }, | 1359 | }, |
1303 | }; | 1360 | }; |
1304 | 1361 | ||
@@ -1350,9 +1407,49 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset) | |||
1350 | return 0; | 1407 | return 0; |
1351 | } | 1408 | } |
1352 | 1409 | ||
1410 | static 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 | |||
1353 | static int gpio_get(struct gpio_chip *chip, unsigned offset) | 1437 | static int gpio_get(struct gpio_chip *chip, unsigned offset) |
1354 | { | 1438 | { |
1355 | 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); | ||
1356 | } | 1453 | } |
1357 | 1454 | ||
1358 | static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) | 1455 | static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) |
@@ -1886,34 +1983,6 @@ arch_initcall(omap_gpio_sysinit); | |||
1886 | #include <linux/debugfs.h> | 1983 | #include <linux/debugfs.h> |
1887 | #include <linux/seq_file.h> | 1984 | #include <linux/seq_file.h> |
1888 | 1985 | ||
1889 | static int gpio_is_input(struct gpio_bank *bank, int mask) | ||
1890 | { | ||
1891 | void __iomem *reg = bank->base; | ||
1892 | |||
1893 | switch (bank->method) { | ||
1894 | case METHOD_MPUIO: | ||
1895 | reg += OMAP_MPUIO_IO_CNTL; | ||
1896 | break; | ||
1897 | case METHOD_GPIO_1510: | ||
1898 | reg += OMAP1510_GPIO_DIR_CONTROL; | ||
1899 | break; | ||
1900 | case METHOD_GPIO_1610: | ||
1901 | reg += OMAP1610_GPIO_DIRECTION; | ||
1902 | break; | ||
1903 | case METHOD_GPIO_730: | ||
1904 | reg += OMAP730_GPIO_DIR_CONTROL; | ||
1905 | break; | ||
1906 | case METHOD_GPIO_850: | ||
1907 | reg += OMAP850_GPIO_DIR_CONTROL; | ||
1908 | break; | ||
1909 | case METHOD_GPIO_24XX: | ||
1910 | reg += OMAP24XX_GPIO_OE; | ||
1911 | break; | ||
1912 | } | ||
1913 | return __raw_readl(reg) & mask; | ||
1914 | } | ||
1915 | |||
1916 | |||
1917 | static int dbg_gpio_show(struct seq_file *s, void *unused) | 1986 | static int dbg_gpio_show(struct seq_file *s, void *unused) |
1918 | { | 1987 | { |
1919 | unsigned i, j, gpio; | 1988 | unsigned i, j, gpio; |