diff options
author | Arnd Bergmann <arnd@arndb.de> | 2013-04-09 09:29:20 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2013-04-09 09:29:43 -0400 |
commit | 44c0d2377539fafd1023ec7e16765b71c7f4fbce (patch) | |
tree | 49065c2af83c723f150bf636939790ad3108a897 /drivers/pinctrl/pinctrl-at91.c | |
parent | 8024206dbf4e0701f0cdf259a122ea23db3a7a16 (diff) | |
parent | 07961ac7c0ee8b546658717034fe692fd12eefa9 (diff) |
Merge tag 'v3.9-rc5' into next/cleanup
This is a dependency for the mxs/cleanup branch.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/pinctrl/pinctrl-at91.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-at91.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 5cbadc9ad2e8..b141a28473b5 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c | |||
@@ -1276,21 +1276,80 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type) | |||
1276 | } | 1276 | } |
1277 | 1277 | ||
1278 | #ifdef CONFIG_PM | 1278 | #ifdef CONFIG_PM |
1279 | |||
1280 | static u32 wakeups[MAX_GPIO_BANKS]; | ||
1281 | static u32 backups[MAX_GPIO_BANKS]; | ||
1282 | |||
1279 | static int gpio_irq_set_wake(struct irq_data *d, unsigned state) | 1283 | static int gpio_irq_set_wake(struct irq_data *d, unsigned state) |
1280 | { | 1284 | { |
1281 | struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); | 1285 | struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); |
1282 | unsigned bank = at91_gpio->pioc_idx; | 1286 | unsigned bank = at91_gpio->pioc_idx; |
1287 | unsigned mask = 1 << d->hwirq; | ||
1283 | 1288 | ||
1284 | if (unlikely(bank >= MAX_GPIO_BANKS)) | 1289 | if (unlikely(bank >= MAX_GPIO_BANKS)) |
1285 | return -EINVAL; | 1290 | return -EINVAL; |
1286 | 1291 | ||
1292 | if (state) | ||
1293 | wakeups[bank] |= mask; | ||
1294 | else | ||
1295 | wakeups[bank] &= ~mask; | ||
1296 | |||
1287 | irq_set_irq_wake(at91_gpio->pioc_virq, state); | 1297 | irq_set_irq_wake(at91_gpio->pioc_virq, state); |
1288 | 1298 | ||
1289 | return 0; | 1299 | return 0; |
1290 | } | 1300 | } |
1301 | |||
1302 | void at91_pinctrl_gpio_suspend(void) | ||
1303 | { | ||
1304 | int i; | ||
1305 | |||
1306 | for (i = 0; i < gpio_banks; i++) { | ||
1307 | void __iomem *pio; | ||
1308 | |||
1309 | if (!gpio_chips[i]) | ||
1310 | continue; | ||
1311 | |||
1312 | pio = gpio_chips[i]->regbase; | ||
1313 | |||
1314 | backups[i] = __raw_readl(pio + PIO_IMR); | ||
1315 | __raw_writel(backups[i], pio + PIO_IDR); | ||
1316 | __raw_writel(wakeups[i], pio + PIO_IER); | ||
1317 | |||
1318 | if (!wakeups[i]) { | ||
1319 | clk_unprepare(gpio_chips[i]->clock); | ||
1320 | clk_disable(gpio_chips[i]->clock); | ||
1321 | } else { | ||
1322 | printk(KERN_DEBUG "GPIO-%c may wake for %08x\n", | ||
1323 | 'A'+i, wakeups[i]); | ||
1324 | } | ||
1325 | } | ||
1326 | } | ||
1327 | |||
1328 | void at91_pinctrl_gpio_resume(void) | ||
1329 | { | ||
1330 | int i; | ||
1331 | |||
1332 | for (i = 0; i < gpio_banks; i++) { | ||
1333 | void __iomem *pio; | ||
1334 | |||
1335 | if (!gpio_chips[i]) | ||
1336 | continue; | ||
1337 | |||
1338 | pio = gpio_chips[i]->regbase; | ||
1339 | |||
1340 | if (!wakeups[i]) { | ||
1341 | if (clk_prepare(gpio_chips[i]->clock) == 0) | ||
1342 | clk_enable(gpio_chips[i]->clock); | ||
1343 | } | ||
1344 | |||
1345 | __raw_writel(wakeups[i], pio + PIO_IDR); | ||
1346 | __raw_writel(backups[i], pio + PIO_IER); | ||
1347 | } | ||
1348 | } | ||
1349 | |||
1291 | #else | 1350 | #else |
1292 | #define gpio_irq_set_wake NULL | 1351 | #define gpio_irq_set_wake NULL |
1293 | #endif | 1352 | #endif /* CONFIG_PM */ |
1294 | 1353 | ||
1295 | static struct irq_chip gpio_irqchip = { | 1354 | static struct irq_chip gpio_irqchip = { |
1296 | .name = "GPIO", | 1355 | .name = "GPIO", |