diff options
Diffstat (limited to 'drivers/gpio/gpio-omap.c')
-rw-r--r-- | drivers/gpio/gpio-omap.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index 2050891d9c65..d3f7d2db870f 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -69,6 +69,7 @@ struct gpio_bank { | |||
69 | bool is_mpuio; | 69 | bool is_mpuio; |
70 | bool dbck_flag; | 70 | bool dbck_flag; |
71 | bool loses_context; | 71 | bool loses_context; |
72 | bool context_valid; | ||
72 | int stride; | 73 | int stride; |
73 | u32 width; | 74 | u32 width; |
74 | int context_loss_count; | 75 | int context_loss_count; |
@@ -1128,6 +1129,10 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1128 | bank->loses_context = true; | 1129 | bank->loses_context = true; |
1129 | } else { | 1130 | } else { |
1130 | bank->loses_context = pdata->loses_context; | 1131 | bank->loses_context = pdata->loses_context; |
1132 | |||
1133 | if (bank->loses_context) | ||
1134 | bank->get_context_loss_count = | ||
1135 | pdata->get_context_loss_count; | ||
1131 | } | 1136 | } |
1132 | 1137 | ||
1133 | 1138 | ||
@@ -1178,9 +1183,6 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1178 | omap_gpio_chip_init(bank); | 1183 | omap_gpio_chip_init(bank); |
1179 | omap_gpio_show_rev(bank); | 1184 | omap_gpio_show_rev(bank); |
1180 | 1185 | ||
1181 | if (bank->loses_context) | ||
1182 | bank->get_context_loss_count = pdata->get_context_loss_count; | ||
1183 | |||
1184 | pm_runtime_put(bank->dev); | 1186 | pm_runtime_put(bank->dev); |
1185 | 1187 | ||
1186 | list_add_tail(&bank->node, &omap_gpio_list); | 1188 | list_add_tail(&bank->node, &omap_gpio_list); |
@@ -1259,6 +1261,8 @@ update_gpio_context_count: | |||
1259 | return 0; | 1261 | return 0; |
1260 | } | 1262 | } |
1261 | 1263 | ||
1264 | static void omap_gpio_init_context(struct gpio_bank *p); | ||
1265 | |||
1262 | static int omap_gpio_runtime_resume(struct device *dev) | 1266 | static int omap_gpio_runtime_resume(struct device *dev) |
1263 | { | 1267 | { |
1264 | struct platform_device *pdev = to_platform_device(dev); | 1268 | struct platform_device *pdev = to_platform_device(dev); |
@@ -1268,6 +1272,20 @@ static int omap_gpio_runtime_resume(struct device *dev) | |||
1268 | int c; | 1272 | int c; |
1269 | 1273 | ||
1270 | spin_lock_irqsave(&bank->lock, flags); | 1274 | spin_lock_irqsave(&bank->lock, flags); |
1275 | |||
1276 | /* | ||
1277 | * On the first resume during the probe, the context has not | ||
1278 | * been initialised and so initialise it now. Also initialise | ||
1279 | * the context loss count. | ||
1280 | */ | ||
1281 | if (bank->loses_context && !bank->context_valid) { | ||
1282 | omap_gpio_init_context(bank); | ||
1283 | |||
1284 | if (bank->get_context_loss_count) | ||
1285 | bank->context_loss_count = | ||
1286 | bank->get_context_loss_count(bank->dev); | ||
1287 | } | ||
1288 | |||
1271 | _gpio_dbck_enable(bank); | 1289 | _gpio_dbck_enable(bank); |
1272 | 1290 | ||
1273 | /* | 1291 | /* |
@@ -1384,6 +1402,29 @@ void omap2_gpio_resume_after_idle(void) | |||
1384 | } | 1402 | } |
1385 | 1403 | ||
1386 | #if defined(CONFIG_PM_RUNTIME) | 1404 | #if defined(CONFIG_PM_RUNTIME) |
1405 | static void omap_gpio_init_context(struct gpio_bank *p) | ||
1406 | { | ||
1407 | struct omap_gpio_reg_offs *regs = p->regs; | ||
1408 | void __iomem *base = p->base; | ||
1409 | |||
1410 | p->context.ctrl = __raw_readl(base + regs->ctrl); | ||
1411 | p->context.oe = __raw_readl(base + regs->direction); | ||
1412 | p->context.wake_en = __raw_readl(base + regs->wkup_en); | ||
1413 | p->context.leveldetect0 = __raw_readl(base + regs->leveldetect0); | ||
1414 | p->context.leveldetect1 = __raw_readl(base + regs->leveldetect1); | ||
1415 | p->context.risingdetect = __raw_readl(base + regs->risingdetect); | ||
1416 | p->context.fallingdetect = __raw_readl(base + regs->fallingdetect); | ||
1417 | p->context.irqenable1 = __raw_readl(base + regs->irqenable); | ||
1418 | p->context.irqenable2 = __raw_readl(base + regs->irqenable2); | ||
1419 | |||
1420 | if (regs->set_dataout && p->regs->clr_dataout) | ||
1421 | p->context.dataout = __raw_readl(base + regs->set_dataout); | ||
1422 | else | ||
1423 | p->context.dataout = __raw_readl(base + regs->dataout); | ||
1424 | |||
1425 | p->context_valid = true; | ||
1426 | } | ||
1427 | |||
1387 | static void omap_gpio_restore_context(struct gpio_bank *bank) | 1428 | static void omap_gpio_restore_context(struct gpio_bank *bank) |
1388 | { | 1429 | { |
1389 | __raw_writel(bank->context.wake_en, | 1430 | __raw_writel(bank->context.wake_en, |
@@ -1421,6 +1462,7 @@ static void omap_gpio_restore_context(struct gpio_bank *bank) | |||
1421 | #else | 1462 | #else |
1422 | #define omap_gpio_runtime_suspend NULL | 1463 | #define omap_gpio_runtime_suspend NULL |
1423 | #define omap_gpio_runtime_resume NULL | 1464 | #define omap_gpio_runtime_resume NULL |
1465 | static void omap_gpio_init_context(struct gpio_bank *p) {} | ||
1424 | #endif | 1466 | #endif |
1425 | 1467 | ||
1426 | static const struct dev_pm_ops gpio_pm_ops = { | 1468 | static const struct dev_pm_ops gpio_pm_ops = { |