diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2010-06-02 00:50:28 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-06-16 17:27:35 -0400 |
commit | 6f9a974cf6fdd189ff383c8b75c22c65dab20b52 (patch) | |
tree | ec1e142b40646a1fced854f11044eac9ccf82c20 /arch/arm/plat-nomadik/gpio.c | |
parent | 81a3c2989227e025b715e18299431395083b39e5 (diff) |
ARM: 6154/1: nomadik-gpio: refactor nmk_gpio_set_mode
Extract out a portion of nmk_gpio_set_mode() that can be called with the
lock already held. This will be used from the pincfg API.
Cc: Alessandro Rubini <rubini@unipv.it>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/plat-nomadik/gpio.c')
-rw-r--r-- | arch/arm/plat-nomadik/gpio.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/arch/arm/plat-nomadik/gpio.c b/arch/arm/plat-nomadik/gpio.c index a678e887e0fe..7b7393f96a9c 100644 --- a/arch/arm/plat-nomadik/gpio.c +++ b/arch/arm/plat-nomadik/gpio.c | |||
@@ -46,6 +46,22 @@ struct nmk_gpio_chip { | |||
46 | u32 edge_falling; | 46 | u32 edge_falling; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static void __nmk_gpio_set_mode(struct nmk_gpio_chip *nmk_chip, | ||
50 | unsigned offset, int gpio_mode) | ||
51 | { | ||
52 | u32 bit = 1 << offset; | ||
53 | u32 afunc, bfunc; | ||
54 | |||
55 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~bit; | ||
56 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~bit; | ||
57 | if (gpio_mode & NMK_GPIO_ALT_A) | ||
58 | afunc |= bit; | ||
59 | if (gpio_mode & NMK_GPIO_ALT_B) | ||
60 | bfunc |= bit; | ||
61 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); | ||
62 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); | ||
63 | } | ||
64 | |||
49 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, | 65 | static void __nmk_gpio_set_slpm(struct nmk_gpio_chip *nmk_chip, |
50 | unsigned offset, enum nmk_gpio_slpm mode) | 66 | unsigned offset, enum nmk_gpio_slpm mode) |
51 | { | 67 | { |
@@ -139,23 +155,13 @@ int nmk_gpio_set_mode(int gpio, int gpio_mode) | |||
139 | { | 155 | { |
140 | struct nmk_gpio_chip *nmk_chip; | 156 | struct nmk_gpio_chip *nmk_chip; |
141 | unsigned long flags; | 157 | unsigned long flags; |
142 | u32 afunc, bfunc, bit; | ||
143 | 158 | ||
144 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); | 159 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); |
145 | if (!nmk_chip) | 160 | if (!nmk_chip) |
146 | return -EINVAL; | 161 | return -EINVAL; |
147 | 162 | ||
148 | bit = 1 << (gpio - nmk_chip->chip.base); | ||
149 | |||
150 | spin_lock_irqsave(&nmk_chip->lock, flags); | 163 | spin_lock_irqsave(&nmk_chip->lock, flags); |
151 | afunc = readl(nmk_chip->addr + NMK_GPIO_AFSLA) & ~bit; | 164 | __nmk_gpio_set_mode(nmk_chip, gpio - nmk_chip->chip.base, gpio_mode); |
152 | bfunc = readl(nmk_chip->addr + NMK_GPIO_AFSLB) & ~bit; | ||
153 | if (gpio_mode & NMK_GPIO_ALT_A) | ||
154 | afunc |= bit; | ||
155 | if (gpio_mode & NMK_GPIO_ALT_B) | ||
156 | bfunc |= bit; | ||
157 | writel(afunc, nmk_chip->addr + NMK_GPIO_AFSLA); | ||
158 | writel(bfunc, nmk_chip->addr + NMK_GPIO_AFSLB); | ||
159 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | 165 | spin_unlock_irqrestore(&nmk_chip->lock, flags); |
160 | 166 | ||
161 | return 0; | 167 | return 0; |