diff options
author | Rabin Vincent <rabin.vincent@stericsson.com> | 2010-05-27 07:29:50 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-06-16 17:26:10 -0400 |
commit | 5b327edf03c037ea6dc49a98a2b7f7186298ad1e (patch) | |
tree | e971eed0cbd971dd30f821b4d32f4bf0fb848541 /arch/arm/plat-nomadik/gpio.c | |
parent | 6647c6c0b62ae14ca994c5776ddb084820bea808 (diff) |
ARM: 6148/1: nomadik-gpio: add function to configure pullup/pulldown
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 | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/arm/plat-nomadik/gpio.c b/arch/arm/plat-nomadik/gpio.c index 13cdbbdc08ca..50c49fa9e01a 100644 --- a/arch/arm/plat-nomadik/gpio.c +++ b/arch/arm/plat-nomadik/gpio.c | |||
@@ -46,6 +46,54 @@ struct nmk_gpio_chip { | |||
46 | u32 edge_falling; | 46 | u32 edge_falling; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, | ||
50 | unsigned offset, enum nmk_gpio_pull pull) | ||
51 | { | ||
52 | u32 bit = 1 << offset; | ||
53 | u32 pdis; | ||
54 | |||
55 | pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); | ||
56 | if (pull == NMK_GPIO_PULL_NONE) | ||
57 | pdis |= bit; | ||
58 | else | ||
59 | pdis &= ~bit; | ||
60 | writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); | ||
61 | |||
62 | if (pull == NMK_GPIO_PULL_UP) | ||
63 | writel(bit, nmk_chip->addr + NMK_GPIO_DATS); | ||
64 | else if (pull == NMK_GPIO_PULL_DOWN) | ||
65 | writel(bit, nmk_chip->addr + NMK_GPIO_DATC); | ||
66 | } | ||
67 | |||
68 | /** | ||
69 | * nmk_gpio_set_pull() - enable/disable pull up/down on a gpio | ||
70 | * @gpio: pin number | ||
71 | * @pull: one of NMK_GPIO_PULL_DOWN, NMK_GPIO_PULL_UP, and NMK_GPIO_PULL_NONE | ||
72 | * | ||
73 | * Enables/disables pull up/down on a specified pin. This only takes effect if | ||
74 | * the pin is configured as an input (either explicitly or by the alternate | ||
75 | * function). | ||
76 | * | ||
77 | * NOTE: If enabling the pull up/down, the caller must ensure that the GPIO is | ||
78 | * configured as an input. Otherwise, due to the way the controller registers | ||
79 | * work, this function will change the value output on the pin. | ||
80 | */ | ||
81 | int nmk_gpio_set_pull(int gpio, enum nmk_gpio_pull pull) | ||
82 | { | ||
83 | struct nmk_gpio_chip *nmk_chip; | ||
84 | unsigned long flags; | ||
85 | |||
86 | nmk_chip = get_irq_chip_data(NOMADIK_GPIO_TO_IRQ(gpio)); | ||
87 | if (!nmk_chip) | ||
88 | return -EINVAL; | ||
89 | |||
90 | spin_lock_irqsave(&nmk_chip->lock, flags); | ||
91 | __nmk_gpio_set_pull(nmk_chip, gpio - nmk_chip->chip.base, pull); | ||
92 | spin_unlock_irqrestore(&nmk_chip->lock, flags); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | |||
49 | /* Mode functions */ | 97 | /* Mode functions */ |
50 | int nmk_gpio_set_mode(int gpio, int gpio_mode) | 98 | int nmk_gpio_set_mode(int gpio, int gpio_mode) |
51 | { | 99 | { |