aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRickard Andersson <rickard.andersson@stericsson.com>2011-05-24 17:07:17 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-05-26 19:30:18 -0400
commitbc6f5cf6484a509cfe0533b8ddf8b8ca60f35557 (patch)
tree6129c19354abc14e1e3b6a8b0fec9e4a89ab3662 /drivers
parent8ea72a30a31c30ec7fa0c30c743b2cec0712d143 (diff)
gpio/nomadik: add function to read GPIO pull down status
Signed-off-by: Rickard Andersson <rickard.andersson@stericsson.com> Reviewed-by: Martin Persson <martin.persson@stericsson.com> [Split off from larger patch] Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpio-nomadik.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/drivers/gpio/gpio-nomadik.c b/drivers/gpio/gpio-nomadik.c
index 380204781f84..4961ef9bc153 100644
--- a/drivers/gpio/gpio-nomadik.c
+++ b/drivers/gpio/gpio-nomadik.c
@@ -57,6 +57,7 @@ struct nmk_gpio_chip {
57 u32 fwimsc; 57 u32 fwimsc;
58 u32 slpm; 58 u32 slpm;
59 u32 enabled; 59 u32 enabled;
60 u32 pull_up;
60}; 61};
61 62
62static struct nmk_gpio_chip * 63static struct nmk_gpio_chip *
@@ -103,16 +104,22 @@ static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip,
103 u32 pdis; 104 u32 pdis;
104 105
105 pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); 106 pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS);
106 if (pull == NMK_GPIO_PULL_NONE) 107 if (pull == NMK_GPIO_PULL_NONE) {
107 pdis |= bit; 108 pdis |= bit;
108 else 109 nmk_chip->pull_up &= ~bit;
110 } else {
109 pdis &= ~bit; 111 pdis &= ~bit;
112 }
113
110 writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); 114 writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS);
111 115
112 if (pull == NMK_GPIO_PULL_UP) 116 if (pull == NMK_GPIO_PULL_UP) {
117 nmk_chip->pull_up |= bit;
113 writel(bit, nmk_chip->addr + NMK_GPIO_DATS); 118 writel(bit, nmk_chip->addr + NMK_GPIO_DATS);
114 else if (pull == NMK_GPIO_PULL_DOWN) 119 } else if (pull == NMK_GPIO_PULL_DOWN) {
120 nmk_chip->pull_up &= ~bit;
115 writel(bit, nmk_chip->addr + NMK_GPIO_DATC); 121 writel(bit, nmk_chip->addr + NMK_GPIO_DATC);
122 }
116} 123}
117 124
118static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip, 125static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip,
@@ -921,6 +928,25 @@ void nmk_gpio_wakeups_resume(void)
921 } 928 }
922} 929}
923 930
931/*
932 * Read the pull up/pull down status.
933 * A bit set in 'pull_up' means that pull up
934 * is selected if pull is enabled in PDIS register.
935 * Note: only pull up/down set via this driver can
936 * be detected due to HW limitations.
937 */
938void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up)
939{
940 if (gpio_bank < NUM_BANKS) {
941 struct nmk_gpio_chip *chip = nmk_gpio_chips[gpio_bank];
942
943 if (!chip)
944 return;
945
946 *pull_up = chip->pull_up;
947 }
948}
949
924static int __devinit nmk_gpio_probe(struct platform_device *dev) 950static int __devinit nmk_gpio_probe(struct platform_device *dev)
925{ 951{
926 struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; 952 struct nmk_gpio_platform_data *pdata = dev->dev.platform_data;