diff options
author | Jon Hunter <jon-hunter@ti.com> | 2013-04-04 16:16:15 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-04-10 17:41:16 -0400 |
commit | a2797beadfcb5a0974a30929b613b4d1adb023d1 (patch) | |
tree | 4f3e62d1353bfbf2c05798d02d0dd2a06149e9fc /drivers/gpio | |
parent | 3513cdeccc647d41c4a9ff923af17deaaac04a66 (diff) |
gpio/omap: force restore if context loss is not detectable
When booting with device-tree the function pointer for detecting context
loss is not populated. Ideally, the pm_runtime framework should be
enhanced to allow a means for reporting context/state loss and we could
avoid populating such function pointers altogether. In the interim until
a generic non-device specific solution is in place, force a restore of
the gpio bank when enabling the gpio controller.
Adds a new device-tree property for the OMAP GPIO controller to indicate
if the GPIO controller is located in a power-domain that never loses
power and hence will always maintain its logic state.
Signed-off-by: Jon Hunter <jon-hunter@ti.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Reviewed-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-omap.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index f46b600e5e56..bb1e54f168b4 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
@@ -1120,11 +1120,17 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
1120 | bank->width = pdata->bank_width; | 1120 | bank->width = pdata->bank_width; |
1121 | bank->is_mpuio = pdata->is_mpuio; | 1121 | bank->is_mpuio = pdata->is_mpuio; |
1122 | bank->non_wakeup_gpios = pdata->non_wakeup_gpios; | 1122 | bank->non_wakeup_gpios = pdata->non_wakeup_gpios; |
1123 | bank->loses_context = pdata->loses_context; | ||
1124 | bank->regs = pdata->regs; | 1123 | bank->regs = pdata->regs; |
1125 | #ifdef CONFIG_OF_GPIO | 1124 | #ifdef CONFIG_OF_GPIO |
1126 | bank->chip.of_node = of_node_get(node); | 1125 | bank->chip.of_node = of_node_get(node); |
1127 | #endif | 1126 | #endif |
1127 | if (node) { | ||
1128 | if (!of_property_read_bool(node, "ti,gpio-always-on")) | ||
1129 | bank->loses_context = true; | ||
1130 | } else { | ||
1131 | bank->loses_context = pdata->loses_context; | ||
1132 | } | ||
1133 | |||
1128 | 1134 | ||
1129 | bank->domain = irq_domain_add_linear(node, bank->width, | 1135 | bank->domain = irq_domain_add_linear(node, bank->width, |
1130 | &irq_domain_simple_ops, NULL); | 1136 | &irq_domain_simple_ops, NULL); |
@@ -1258,9 +1264,9 @@ static int omap_gpio_runtime_resume(struct device *dev) | |||
1258 | { | 1264 | { |
1259 | struct platform_device *pdev = to_platform_device(dev); | 1265 | struct platform_device *pdev = to_platform_device(dev); |
1260 | struct gpio_bank *bank = platform_get_drvdata(pdev); | 1266 | struct gpio_bank *bank = platform_get_drvdata(pdev); |
1261 | int context_lost_cnt_after; | ||
1262 | u32 l = 0, gen, gen0, gen1; | 1267 | u32 l = 0, gen, gen0, gen1; |
1263 | unsigned long flags; | 1268 | unsigned long flags; |
1269 | int c; | ||
1264 | 1270 | ||
1265 | spin_lock_irqsave(&bank->lock, flags); | 1271 | spin_lock_irqsave(&bank->lock, flags); |
1266 | _gpio_dbck_enable(bank); | 1272 | _gpio_dbck_enable(bank); |
@@ -1276,14 +1282,17 @@ static int omap_gpio_runtime_resume(struct device *dev) | |||
1276 | __raw_writel(bank->context.risingdetect, | 1282 | __raw_writel(bank->context.risingdetect, |
1277 | bank->base + bank->regs->risingdetect); | 1283 | bank->base + bank->regs->risingdetect); |
1278 | 1284 | ||
1279 | if (bank->get_context_loss_count) { | 1285 | if (bank->loses_context) { |
1280 | context_lost_cnt_after = | 1286 | if (!bank->get_context_loss_count) { |
1281 | bank->get_context_loss_count(bank->dev); | ||
1282 | if (context_lost_cnt_after != bank->context_loss_count) { | ||
1283 | omap_gpio_restore_context(bank); | 1287 | omap_gpio_restore_context(bank); |
1284 | } else { | 1288 | } else { |
1285 | spin_unlock_irqrestore(&bank->lock, flags); | 1289 | c = bank->get_context_loss_count(bank->dev); |
1286 | return 0; | 1290 | if (c != bank->context_loss_count) { |
1291 | omap_gpio_restore_context(bank); | ||
1292 | } else { | ||
1293 | spin_unlock_irqrestore(&bank->lock, flags); | ||
1294 | return 0; | ||
1295 | } | ||
1287 | } | 1296 | } |
1288 | } | 1297 | } |
1289 | 1298 | ||