diff options
-rw-r--r-- | arch/arm/mach-ux500/cpu-db8500.c | 3 | ||||
-rw-r--r-- | arch/arm/plat-nomadik/include/plat/gpio.h | 1 | ||||
-rw-r--r-- | drivers/gpio/gpio-nomadik.c | 40 | ||||
-rw-r--r-- | include/linux/basic_mmio_gpio.h | 1 |
4 files changed, 34 insertions, 11 deletions
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c index c3c417656bd9..4598b06c8c55 100644 --- a/arch/arm/mach-ux500/cpu-db8500.c +++ b/arch/arm/mach-ux500/cpu-db8500.c | |||
@@ -159,6 +159,9 @@ static void __init db8500_add_gpios(void) | |||
159 | /* No custom data yet */ | 159 | /* No custom data yet */ |
160 | }; | 160 | }; |
161 | 161 | ||
162 | if (cpu_is_u8500v2()) | ||
163 | pdata.supports_sleepmode = true; | ||
164 | |||
162 | dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base), | 165 | dbx500_add_gpios(ARRAY_AND_SIZE(db8500_gpio_base), |
163 | IRQ_DB8500_GPIO0, &pdata); | 166 | IRQ_DB8500_GPIO0, &pdata); |
164 | } | 167 | } |
diff --git a/arch/arm/plat-nomadik/include/plat/gpio.h b/arch/arm/plat-nomadik/include/plat/gpio.h index ea19a5b2f227..d5d7e651269c 100644 --- a/arch/arm/plat-nomadik/include/plat/gpio.h +++ b/arch/arm/plat-nomadik/include/plat/gpio.h | |||
@@ -90,6 +90,7 @@ struct nmk_gpio_platform_data { | |||
90 | int num_gpio; | 90 | int num_gpio; |
91 | u32 (*get_secondary_status)(unsigned int bank); | 91 | u32 (*get_secondary_status)(unsigned int bank); |
92 | void (*set_ioforce)(bool enable); | 92 | void (*set_ioforce)(bool enable); |
93 | bool supports_sleepmode; | ||
93 | }; | 94 | }; |
94 | 95 | ||
95 | #endif /* __ASM_PLAT_GPIO_H */ | 96 | #endif /* __ASM_PLAT_GPIO_H */ |
diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c index 4961ef9bc153..2c212c732d76 100644 --- a/drivers/gpio/gpio-nomadik.c +++ b/drivers/gpio/gpio-nomadik.c | |||
@@ -4,6 +4,7 @@ | |||
4 | * Copyright (C) 2008,2009 STMicroelectronics | 4 | * Copyright (C) 2008,2009 STMicroelectronics |
5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> | 5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> |
6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> | 6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> |
7 | * Copyright (C) 2011 Linus Walleij <linus.walleij@linaro.org> | ||
7 | * | 8 | * |
8 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
@@ -49,6 +50,7 @@ struct nmk_gpio_chip { | |||
49 | u32 (*get_secondary_status)(unsigned int bank); | 50 | u32 (*get_secondary_status)(unsigned int bank); |
50 | void (*set_ioforce)(bool enable); | 51 | void (*set_ioforce)(bool enable); |
51 | spinlock_t lock; | 52 | spinlock_t lock; |
53 | bool sleepmode; | ||
52 | /* Keep track of configured edges */ | 54 | /* Keep track of configured edges */ |
53 | u32 edge_rising; | 55 | u32 edge_rising; |
54 | u32 edge_falling; | 56 | u32 edge_falling; |
@@ -393,14 +395,25 @@ EXPORT_SYMBOL(nmk_config_pins_sleep); | |||
393 | * @gpio: pin number | 395 | * @gpio: pin number |
394 | * @mode: NMK_GPIO_SLPM_INPUT or NMK_GPIO_SLPM_NOCHANGE, | 396 | * @mode: NMK_GPIO_SLPM_INPUT or NMK_GPIO_SLPM_NOCHANGE, |
395 | * | 397 | * |
396 | * Sets the sleep mode of a pin. If @mode is NMK_GPIO_SLPM_INPUT, the pin is | 398 | * This register is actually in the pinmux layer, not the GPIO block itself. |
397 | * changed to an input (with pullup/down enabled) in sleep and deep sleep. If | 399 | * The GPIO1B_SLPM register defines the GPIO mode when SLEEP/DEEP-SLEEP |
398 | * @mode is NMK_GPIO_SLPM_NOCHANGE, the pin remains in the state it was | 400 | * mode is entered (i.e. when signal IOFORCE is HIGH by the platform code). |
399 | * configured even when in sleep and deep sleep. | 401 | * Each GPIO can be configured to be forced into GPIO mode when IOFORCE is |
402 | * HIGH, overriding the normal setting defined by GPIO_AFSELx registers. | ||
403 | * When IOFORCE returns LOW (by software, after SLEEP/DEEP-SLEEP exit), | ||
404 | * the GPIOs return to the normal setting defined by GPIO_AFSELx registers. | ||
400 | * | 405 | * |
401 | * On DB8500v2 onwards, this setting loses the previous meaning and instead | 406 | * If @mode is NMK_GPIO_SLPM_INPUT, the corresponding GPIO is switched to GPIO |
402 | * indicates if wakeup detection is enabled on the pin. Note that | 407 | * mode when signal IOFORCE is HIGH (i.e. when SLEEP/DEEP-SLEEP mode is |
403 | * enable_irq_wake() will automatically enable wakeup detection. | 408 | * entered) regardless of the altfunction selected. Also wake-up detection is |
409 | * ENABLED. | ||
410 | * | ||
411 | * If @mode is NMK_GPIO_SLPM_NOCHANGE, the corresponding GPIO remains | ||
412 | * controlled by NMK_GPIO_DATC, NMK_GPIO_DATS, NMK_GPIO_DIR, NMK_GPIO_PDIS | ||
413 | * (for altfunction GPIO) or respective on-chip peripherals (for other | ||
414 | * altfuncs) when IOFORCE is HIGH. Also wake-up detection DISABLED. | ||
415 | * | ||
416 | * Note that enable_irq_wake() will automatically enable wakeup detection. | ||
404 | */ | 417 | */ |
405 | int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode) | 418 | int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode) |
406 | { | 419 | { |
@@ -551,6 +564,12 @@ static void __nmk_gpio_irq_modify(struct nmk_gpio_chip *nmk_chip, | |||
551 | static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, | 564 | static void __nmk_gpio_set_wake(struct nmk_gpio_chip *nmk_chip, |
552 | int gpio, bool on) | 565 | int gpio, bool on) |
553 | { | 566 | { |
567 | if (nmk_chip->sleepmode) { | ||
568 | __nmk_gpio_set_slpm(nmk_chip, gpio - nmk_chip->chip.base, | ||
569 | on ? NMK_GPIO_SLPM_WAKEUP_ENABLE | ||
570 | : NMK_GPIO_SLPM_WAKEUP_DISABLE); | ||
571 | } | ||
572 | |||
554 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, on); | 573 | __nmk_gpio_irq_modify(nmk_chip, gpio, WAKE, on); |
555 | } | 574 | } |
556 | 575 | ||
@@ -901,7 +920,7 @@ void nmk_gpio_wakeups_suspend(void) | |||
901 | writel(chip->fwimsc & chip->real_wake, | 920 | writel(chip->fwimsc & chip->real_wake, |
902 | chip->addr + NMK_GPIO_FWIMSC); | 921 | chip->addr + NMK_GPIO_FWIMSC); |
903 | 922 | ||
904 | if (cpu_is_u8500v2()) { | 923 | if (chip->sleepmode) { |
905 | chip->slpm = readl(chip->addr + NMK_GPIO_SLPC); | 924 | chip->slpm = readl(chip->addr + NMK_GPIO_SLPC); |
906 | 925 | ||
907 | /* 0 -> wakeup enable */ | 926 | /* 0 -> wakeup enable */ |
@@ -923,7 +942,7 @@ void nmk_gpio_wakeups_resume(void) | |||
923 | writel(chip->rwimsc, chip->addr + NMK_GPIO_RWIMSC); | 942 | writel(chip->rwimsc, chip->addr + NMK_GPIO_RWIMSC); |
924 | writel(chip->fwimsc, chip->addr + NMK_GPIO_FWIMSC); | 943 | writel(chip->fwimsc, chip->addr + NMK_GPIO_FWIMSC); |
925 | 944 | ||
926 | if (cpu_is_u8500v2()) | 945 | if (chip->sleepmode) |
927 | writel(chip->slpm, chip->addr + NMK_GPIO_SLPC); | 946 | writel(chip->slpm, chip->addr + NMK_GPIO_SLPC); |
928 | } | 947 | } |
929 | } | 948 | } |
@@ -1010,6 +1029,7 @@ static int __devinit nmk_gpio_probe(struct platform_device *dev) | |||
1010 | nmk_chip->secondary_parent_irq = secondary_irq; | 1029 | nmk_chip->secondary_parent_irq = secondary_irq; |
1011 | nmk_chip->get_secondary_status = pdata->get_secondary_status; | 1030 | nmk_chip->get_secondary_status = pdata->get_secondary_status; |
1012 | nmk_chip->set_ioforce = pdata->set_ioforce; | 1031 | nmk_chip->set_ioforce = pdata->set_ioforce; |
1032 | nmk_chip->sleepmode = pdata->supports_sleepmode; | ||
1013 | spin_lock_init(&nmk_chip->lock); | 1033 | spin_lock_init(&nmk_chip->lock); |
1014 | 1034 | ||
1015 | chip = &nmk_chip->chip; | 1035 | chip = &nmk_chip->chip; |
@@ -1065,5 +1085,3 @@ core_initcall(nmk_gpio_init); | |||
1065 | MODULE_AUTHOR("Prafulla WADASKAR and Alessandro Rubini"); | 1085 | MODULE_AUTHOR("Prafulla WADASKAR and Alessandro Rubini"); |
1066 | MODULE_DESCRIPTION("Nomadik GPIO Driver"); | 1086 | MODULE_DESCRIPTION("Nomadik GPIO Driver"); |
1067 | MODULE_LICENSE("GPL"); | 1087 | MODULE_LICENSE("GPL"); |
1068 | |||
1069 | |||
diff --git a/include/linux/basic_mmio_gpio.h b/include/linux/basic_mmio_gpio.h index 1ae12710d732..98999cf107ce 100644 --- a/include/linux/basic_mmio_gpio.h +++ b/include/linux/basic_mmio_gpio.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/gpio.h> | 16 | #include <linux/gpio.h> |
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/compiler.h> | 18 | #include <linux/compiler.h> |
19 | #include <linux/spinlock_types.h> | ||
19 | 20 | ||
20 | struct bgpio_pdata { | 21 | struct bgpio_pdata { |
21 | int base; | 22 | int base; |