diff options
Diffstat (limited to 'arch/arm/plat-nomadik/gpio.c')
-rw-r--r-- | arch/arm/plat-nomadik/gpio.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/arch/arm/plat-nomadik/gpio.c b/arch/arm/plat-nomadik/gpio.c index 50c49fa9e01a..a678e887e0fe 100644 --- a/arch/arm/plat-nomadik/gpio.c +++ b/arch/arm/plat-nomadik/gpio.c | |||
@@ -46,6 +46,20 @@ struct nmk_gpio_chip { | |||
46 | u32 edge_falling; | 46 | u32 edge_falling; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, | ||
50 | unsigned offset, enum nmk_gpio_slpm mode) | ||
51 | { | ||
52 | u32 bit = 1 << offset; | ||
53 | u32 slpm; | ||
54 | |||
55 | slpm = readl(nmk_chip->addr + NMK_GPIO_SLPC); | ||
56 | if (mode == NMK_GPIO_SLPM_NOCHANGE) | ||
57 | slpm |= bit; | ||
58 | else | ||
59 | slpm &= ~bit; | ||
60 | writel(slpm, nmk_chip->addr + NMK_GPIO_SLPC); | ||
61 | } | ||
62 | |||
49 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, | 63 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, |
50 | unsigned offset, enum nmk_gpio_pull pull) | 64 | unsigned offset, enum nmk_gpio_pull pull) |
51 | { | 65 | { |
@@ -66,6 +80,32 @@ static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, | |||
66 | } | 80 | } |
67 | 81 | ||
68 | /** | 82 | /** |
83 | * nmk_gpio_set_slpm() - configure the sleep mode of a pin | ||
84 | * @gpio: pin number | ||
85 | * @mode: NMK_GPIO_SLPM_INPUT or NMK_GPIO_SLPM_NOCHANGE, | ||
86 | * | ||
87 | * Sets the sleep mode of a pin. If @mode is NMK_GPIO_SLPM_INPUT, the pin is | ||
88 | * changed to an input (with pullup/down enabled) in sleep and deep sleep. If | ||
89 | * @mode is NMK_GPIO_SLPM_NOCHANGE, the pin remains in the state it was | ||
90 | * configured even when in sleep and deep sleep. | ||
91 | */ | ||
92 | int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode) | ||
93 | { | ||
94 | struct nmk_gpio_chip *nmk_chip; | ||
95 | unsigned long flags; | ||
96 | |||
97 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); | ||
98 | if (!nmk_chip) | ||
99 | return -EINVAL; | ||
100 | |||
101 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
102 | __nmk_gpio_set_slpm(nmk_chip, gpio - nmk_chip->chip.base, mode); | ||
103 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
104 | |||
105 | return 0; | ||
106 | } | ||
107 | |||
108 | /** | ||
69 | * nmk_gpio_set_pull() - enable/disable pull up/down on a gpio | 109 | * nmk_gpio_set_pull() - enable/disable pull up/down on a gpio |
70 | * @gpio: pin number | 110 | * @gpio: pin number |
71 | * @pull: one of NMK_GPIO_PULL_DOWN, NMK_GPIO_PULL_UP, and NMK_GPIO_PULL_NONE | 111 | * @pull: one of NMK_GPIO_PULL_DOWN, NMK_GPIO_PULL_UP, and NMK_GPIO_PULL_NONE |