提交 bc6f5cf6 编写于 作者: R Rickard Andersson 提交者: Grant Likely

gpio/nomadik: add function to read GPIO pull down status

Signed-off-by: NRickard Andersson <rickard.andersson@stericsson.com>
Reviewed-by: NMartin Persson <martin.persson@stericsson.com>
[Split off from larger patch]
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
上级 8ea72a30
...@@ -78,6 +78,8 @@ extern int nmk_gpio_get_mode(int gpio); ...@@ -78,6 +78,8 @@ extern int nmk_gpio_get_mode(int gpio);
extern void nmk_gpio_wakeups_suspend(void); extern void nmk_gpio_wakeups_suspend(void);
extern void nmk_gpio_wakeups_resume(void); extern void nmk_gpio_wakeups_resume(void);
extern void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up);
/* /*
* Platform data to register a block: only the initial gpio/irq number. * Platform data to register a block: only the initial gpio/irq number.
*/ */
......
...@@ -57,6 +57,7 @@ struct nmk_gpio_chip { ...@@ -57,6 +57,7 @@ struct nmk_gpio_chip {
u32 fwimsc; u32 fwimsc;
u32 slpm; u32 slpm;
u32 enabled; u32 enabled;
u32 pull_up;
}; };
static struct nmk_gpio_chip * static struct nmk_gpio_chip *
...@@ -103,16 +104,22 @@ static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip, ...@@ -103,16 +104,22 @@ static void __nmk_gpio_set_pull(struct nmk_gpio_chip *nmk_chip,
u32 pdis; u32 pdis;
pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS); pdis = readl(nmk_chip->addr + NMK_GPIO_PDIS);
if (pull == NMK_GPIO_PULL_NONE) if (pull == NMK_GPIO_PULL_NONE) {
pdis |= bit; pdis |= bit;
else nmk_chip->pull_up &= ~bit;
} else {
pdis &= ~bit; pdis &= ~bit;
}
writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS); writel(pdis, nmk_chip->addr + NMK_GPIO_PDIS);
if (pull == NMK_GPIO_PULL_UP) if (pull == NMK_GPIO_PULL_UP) {
nmk_chip->pull_up |= bit;
writel(bit, nmk_chip->addr + NMK_GPIO_DATS); writel(bit, nmk_chip->addr + NMK_GPIO_DATS);
else if (pull == NMK_GPIO_PULL_DOWN) } else if (pull == NMK_GPIO_PULL_DOWN) {
nmk_chip->pull_up &= ~bit;
writel(bit, nmk_chip->addr + NMK_GPIO_DATC); writel(bit, nmk_chip->addr + NMK_GPIO_DATC);
}
} }
static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip, static void __nmk_gpio_make_input(struct nmk_gpio_chip *nmk_chip,
...@@ -921,6 +928,25 @@ void nmk_gpio_wakeups_resume(void) ...@@ -921,6 +928,25 @@ void nmk_gpio_wakeups_resume(void)
} }
} }
/*
* Read the pull up/pull down status.
* A bit set in 'pull_up' means that pull up
* is selected if pull is enabled in PDIS register.
* Note: only pull up/down set via this driver can
* be detected due to HW limitations.
*/
void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up)
{
if (gpio_bank < NUM_BANKS) {
struct nmk_gpio_chip *chip = nmk_gpio_chips[gpio_bank];
if (!chip)
return;
*pull_up = chip->pull_up;
}
}
static int __devinit nmk_gpio_probe(struct platform_device *dev) static int __devinit nmk_gpio_probe(struct platform_device *dev)
{ {
struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; struct nmk_gpio_platform_data *pdata = dev->dev.platform_data;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册