History

gpio: gpio-omap: configure edge detection for level IRQs for idle wakeup

The GPIO block can enter idle independently of the CPU power management calls via smart-idle. When the GPIO block enters idle, level detection stops working due to clocks being shut off, and an alternative form of edge detection is used. However, this needs the edge detection registers set to mark the appropriate edges. Arrange to configure the edge detection enables along with the level detection to ensure that any transition to active interrupt state that occurs while the block is idle is detected as a wake-up event. Since we enable the edge detection when configuring the IRQ, both omap2_gpio_enable_level_quirk() nor omap2_gpio_disable_level_quirk() become redundant, which also means OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER can be removed. This can be now done without regressions as patch "gpio: gpio-omap: fix level interrupt idling" allows level interrupts to idle on omap4 without a workaround.

Russell King committed 7 years ago

Commit e6818d21 parent 4779a062 files · +11 −81Browse files

Unified · Split

2 files
  1. drivers/gpio/gpio-omap.c +11 −79
  2. include/linux/platform_data/gpio-omap.h +0 −2
drivers/gpio/gpio-omap.c+11−79
@@ -31,8 +31,6 @@ · 30 unmodified lines
3131
3232 #define OMAP4_GPIO_DEBOUNCINGTIME_MASK 0xFF
3333
34−#define OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER BIT(2)
35−
3634 struct gpio_regs {
3735 u32 irqenable1;
3836 u32 irqenable2;
@@ -48,13 +46,6 @@ struct gpio_regs { · 9 unmodified lines
4846 u32 debounce_en;
4947 };
5048
51−struct gpio_bank;
52−
53−struct gpio_omap_funcs {
54− void (*idle_enable_level_quirk)(struct gpio_bank *bank);
55− void (*idle_disable_level_quirk)(struct gpio_bank *bank);
56−};
57−
5849 struct gpio_bank {
5950 struct list_head node;
6051 void __iomem *base;
@@ -62,7 +53,6 @@ struct gpio_bank { · 1 unmodified line
6253 u32 non_wakeup_gpios;
6354 u32 enabled_non_wakeup_gpios;
6455 struct gpio_regs context;
65− struct gpio_omap_funcs funcs;
6656 u32 saved_datain;
6757 u32 level_mask;
6858 u32 toggle_mask;
@@ -83,7 +73,6 @@ struct gpio_bank { · 14 unmodified lines
8373 int stride;
8474 u32 width;
8575 int context_loss_count;
86− u32 quirks;
8776
8877 void (*set_dataout)(struct gpio_bank *bank, unsigned gpio, int enable);
8978 void (*set_dataout_multiple)(struct gpio_bank *bank,
@@ -378,10 +367,16 @@ static inline void omap_set_gpio_trigger(struct gpio_bank *bank, int gpio, · 288 unmodified lines
378367 trigger & IRQ_TYPE_LEVEL_LOW);
379368 omap_gpio_rmw(base, bank->regs->leveldetect1, gpio_bit,
380369 trigger & IRQ_TYPE_LEVEL_HIGH);
370+
371+ /*
372+ * We need the edge detection enabled for to allow the GPIO block
373+ * to be woken from idle state. Set the appropriate edge detection
374+ * in addition to the level detection.
375+ */
381376 omap_gpio_rmw(base, bank->regs->risingdetect, gpio_bit,
382− trigger & IRQ_TYPE_EDGE_RISING);
377+ trigger & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_LEVEL_HIGH));
383378 omap_gpio_rmw(base, bank->regs->fallingdetect, gpio_bit,
384− trigger & IRQ_TYPE_EDGE_FALLING);
379+ trigger & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_LEVEL_LOW));
385380
386381 bank->context.leveldetect0 =
387382 readl_relaxed(bank->base + bank->regs->leveldetect0);
@@ -904,44 +899,6 @@ static void omap_gpio_unmask_irq(struct irq_data *d) · 516 unmodified lines
904899 raw_spin_unlock_irqrestore(&bank->lock, flags);
905900 }
906901
907−/*
908− * Only edges can generate a wakeup event to the PRCM.
909− *
910− * Therefore, ensure any wake-up capable GPIOs have
911− * edge-detection enabled before going idle to ensure a wakeup
912− * to the PRCM is generated on a GPIO transition. (c.f. 34xx
913− * NDA TRM 25.5.3.1)
914− *
915− * The normal values will be restored upon ->runtime_resume()
916− * by writing back the values saved in bank->context.
917− */
918−static void __maybe_unused
919−omap2_gpio_enable_level_quirk(struct gpio_bank *bank)
920−{
921− u32 wake_low, wake_hi;
922−
923− /* Enable additional edge detection for level gpios for idle */
924− wake_low = bank->context.leveldetect0 & bank->context.wake_en;
925− if (wake_low)
926− writel_relaxed(wake_low | bank->context.fallingdetect,
927− bank->base + bank->regs->fallingdetect);
928−
929− wake_hi = bank->context.leveldetect1 & bank->context.wake_en;
930− if (wake_hi)
931− writel_relaxed(wake_hi | bank->context.risingdetect,
932− bank->base + bank->regs->risingdetect);
933−}
934−
935−static void __maybe_unused
936−omap2_gpio_disable_level_quirk(struct gpio_bank *bank)
937−{
938− /* Disable edge detection for level gpios after idle */
939− writel_relaxed(bank->context.fallingdetect,
940− bank->base + bank->regs->fallingdetect);
941− writel_relaxed(bank->context.risingdetect,
942− bank->base + bank->regs->risingdetect);
943−}
944−
945902 /*---------------------------------------------------------------------*/
946903
947904 static int omap_mpuio_suspend_noirq(struct device *dev)
@@ -1324,9 +1281,6 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context) · 376 unmodified lines
13241281
13251282 bank->saved_datain = readl_relaxed(base + bank->regs->datain);
13261283
1327− if (bank->funcs.idle_enable_level_quirk)
1328− bank->funcs.idle_enable_level_quirk(bank);
1329−
13301284 if (!bank->enabled_non_wakeup_gpios)
13311285 goto update_gpio_context_count;
13321286
@@ -1373,9 +1327,6 @@ static void omap_gpio_unidle(struct gpio_bank *bank) · 40 unmodified lines
13731327
13741328 omap_gpio_dbck_enable(bank);
13751329
1376− if (bank->funcs.idle_disable_level_quirk)
1377− bank->funcs.idle_disable_level_quirk(bank);
1378−
13791330 if (bank->loses_context) {
13801331 if (!bank->get_context_loss_count) {
13811332 omap_gpio_restore_context(bank);
@@ -1519,11 +1470,6 @@ static struct omap_gpio_reg_offs omap4_gpio_regs = { · 137 unmodified lines
15191470 .fallingdetect = OMAP4_GPIO_FALLINGDETECT,
15201471 };
15211472
1522−/*
1523− * Note that omap2 does not currently support idle modes with context loss so
1524− * no need to add OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER quirk flag to save
1525− * and restore context.
1526− */
15271473 static const struct omap_gpio_platform_data omap2_pdata = {
15281474 .regs = &omap2_gpio_regs,
15291475 .bank_width = 32,
@@ -1534,14 +1480,12 @@ static const struct omap_gpio_platform_data omap3_pdata = { · 4 unmodified lines
15341480 .regs = &omap2_gpio_regs,
15351481 .bank_width = 32,
15361482 .dbck_flag = true,
1537− .quirks = OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER,
15381483 };
15391484
15401485 static const struct omap_gpio_platform_data omap4_pdata = {
15411486 .regs = &omap4_gpio_regs,
15421487 .bank_width = 32,
15431488 .dbck_flag = true,
1544− .quirks = OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER,
15451489 };
15461490
15471491 static const struct of_device_id omap_gpio_match[] = {
@@ -1611,7 +1555,6 @@ static int omap_gpio_probe(struct platform_device *pdev) · 63 unmodified lines
16111555 bank->chip.parent = dev;
16121556 bank->chip.owner = THIS_MODULE;
16131557 bank->dbck_flag = pdata->dbck_flag;
1614− bank->quirks = pdata->quirks;
16151558 bank->stride = pdata->bank_stride;
16161559 bank->width = pdata->bank_width;
16171560 bank->is_mpuio = pdata->is_mpuio;
@@ -1641,13 +1584,6 @@ static int omap_gpio_probe(struct platform_device *pdev) · 23 unmodified lines
16411584 omap_set_gpio_dataout_mask_multiple;
16421585 }
16431586
1644− if (bank->quirks & OMAP_GPIO_QUIRK_IDLE_REMOVE_TRIGGER) {
1645− bank->funcs.idle_enable_level_quirk =
1646− omap2_gpio_enable_level_quirk;
1647− bank->funcs.idle_disable_level_quirk =
1648− omap2_gpio_disable_level_quirk;
1649− }
1650−
16511587 raw_spin_lock_init(&bank->lock);
16521588 raw_spin_lock_init(&bank->wa_lock);
16531589
@@ -1689,11 +1625,8 @@ static int omap_gpio_probe(struct platform_device *pdev) · 35 unmodified lines
16891625
16901626 omap_gpio_show_rev(bank);
16911627
1692− if (bank->funcs.idle_enable_level_quirk &&
1693− bank->funcs.idle_disable_level_quirk) {
1694− bank->nb.notifier_call = gpio_omap_cpu_notifier;
1695− cpu_pm_register_notifier(&bank->nb);
1696− }
1628+ bank->nb.notifier_call = gpio_omap_cpu_notifier;
1629+ cpu_pm_register_notifier(&bank->nb);
16971630
16981631 pm_runtime_put(dev);
16991632
@@ -1704,8 +1637,7 @@ static int omap_gpio_remove(struct platform_device *pdev) · 4 unmodified lines
17041637 {
17051638 struct gpio_bank *bank = platform_get_drvdata(pdev);
17061639
1707− if (bank->nb.notifier_call)
1708− cpu_pm_unregister_notifier(&bank->nb);
1640+ cpu_pm_unregister_notifier(&bank->nb);
17091641 list_del(&bank->node);
17101642 gpiochip_remove(&bank->chip);
17111643 pm_runtime_disable(&pdev->dev);
include/linux/platform_data/gpio-omap.h+0−2
@@ -200,8 +200,6 @@ struct omap_gpio_platform_data { · 199 unmodified lines
200200 bool is_mpuio; /* whether the bank is of type MPUIO */
201201 u32 non_wakeup_gpios;
202202
203− u32 quirks; /* Version specific quirks mask */
204−
205203 struct omap_gpio_reg_offs *regs;
206204
207205 /* Return context loss count due to PM states changing */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t