Skip to content

Commit 347ae6e

Browse files
author
Linus Walleij
committed
Merge branch 'ib-omap-block-idle' into devel
2 parents bc0ae0e + 579ced8 commit 347ae6e

4 files changed

Lines changed: 44 additions & 28 deletions

File tree

‎arch/arm/mach-omap2/cpuidle34xx.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
109109
int index)
110110
{
111111
struct omap3_idle_statedata *cx = &omap3_idle_data[index];
112+
int error;
112113

113114
if (omap_irq_pending() || need_resched())
114115
goto return_sleep_time;
@@ -125,8 +126,11 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
125126
* Call idle CPU PM enter notifier chain so that
126127
* VFP context is saved.
127128
*/
128-
if (cx->mpu_state == PWRDM_POWER_OFF)
129-
cpu_pm_enter();
129+
if (cx->mpu_state == PWRDM_POWER_OFF) {
130+
error = cpu_pm_enter();
131+
if (error)
132+
goto out_clkdm_set;
133+
}
130134

131135
/* Execute ARM wfi */
132136
omap_sram_idle();
@@ -139,6 +143,7 @@ static int omap3_enter_idle(struct cpuidle_device *dev,
139143
pwrdm_read_prev_pwrst(mpu_pd) == PWRDM_POWER_OFF)
140144
cpu_pm_exit();
141145

146+
out_clkdm_set:
142147
/* Re-allow idle for C1 */
143148
if (cx->flags & OMAP_CPUIDLE_CX_NO_CLKDM_IDLE)
144149
clkdm_allow_idle(mpu_pd->pwrdm_clkdms[0]);

‎arch/arm/mach-omap2/cpuidle44xx.c‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
122122
{
123123
struct idle_statedata *cx = state_ptr + index;
124124
u32 mpuss_can_lose_context = 0;
125+
int error;
125126

126127
/*
127128
* CPU0 has to wait and stay ON until CPU1 is OFF state.
@@ -159,7 +160,9 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
159160
* Call idle CPU PM enter notifier chain so that
160161
* VFP and per CPU interrupt context is saved.
161162
*/
162-
cpu_pm_enter();
163+
error = cpu_pm_enter();
164+
if (error)
165+
goto cpu_pm_out;
163166

164167
if (dev->cpu == 0) {
165168
pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
@@ -169,13 +172,17 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
169172
* Call idle CPU cluster PM enter notifier chain
170173
* to save GIC and wakeupgen context.
171174
*/
172-
if (mpuss_can_lose_context)
173-
cpu_cluster_pm_enter();
175+
if (mpuss_can_lose_context) {
176+
error = cpu_cluster_pm_enter();
177+
if (error)
178+
goto cpu_cluster_pm_out;
179+
}
174180
}
175181

176182
omap4_enter_lowpower(dev->cpu, cx->cpu_state);
177183
cpu_done[dev->cpu] = true;
178184

185+
cpu_cluster_pm_out:
179186
/* Wakeup CPU1 only if it is not offlined */
180187
if (dev->cpu == 0 && cpumask_test_cpu(1, cpu_online_mask)) {
181188

@@ -197,19 +204,20 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev,
197204
}
198205
}
199206

200-
/*
201-
* Call idle CPU PM exit notifier chain to restore
202-
* VFP and per CPU IRQ context.
203-
*/
204-
cpu_pm_exit();
205-
206207
/*
207208
* Call idle CPU cluster PM exit notifier chain
208209
* to restore GIC and wakeupgen context.
209210
*/
210211
if (dev->cpu == 0 && mpuss_can_lose_context)
211212
cpu_cluster_pm_exit();
212213

214+
/*
215+
* Call idle CPU PM exit notifier chain to restore
216+
* VFP and per CPU IRQ context.
217+
*/
218+
cpu_pm_exit();
219+
220+
cpu_pm_out:
213221
tick_broadcast_exit();
214222

215223
fail:

‎arch/arm/mach-omap2/pm34xx.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ void omap_sram_idle(void)
191191
int per_next_state = PWRDM_POWER_ON;
192192
int core_next_state = PWRDM_POWER_ON;
193193
u32 sdrc_pwr = 0;
194+
int error;
194195

195196
mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
196197
switch (mpu_next_state) {
@@ -219,8 +220,11 @@ void omap_sram_idle(void)
219220
pwrdm_pre_transition(NULL);
220221

221222
/* PER */
222-
if (per_next_state == PWRDM_POWER_OFF)
223-
cpu_cluster_pm_enter();
223+
if (per_next_state == PWRDM_POWER_OFF) {
224+
error = cpu_cluster_pm_enter();
225+
if (error)
226+
return;
227+
}
224228

225229
/* CORE */
226230
if (core_next_state < PWRDM_POWER_ON) {

‎drivers/gpio/gpio-omap.c‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,23 +1102,13 @@ static void omap_gpio_idle(struct gpio_bank *bank, bool may_lose_context)
11021102
{
11031103
struct device *dev = bank->chip.parent;
11041104
void __iomem *base = bank->base;
1105-
u32 mask, nowake;
1105+
u32 nowake;
11061106

11071107
bank->saved_datain = readl_relaxed(base + bank->regs->datain);
11081108

11091109
if (!bank->enabled_non_wakeup_gpios)
11101110
goto update_gpio_context_count;
11111111

1112-
/* Check for pending EDGE_FALLING, ignore EDGE_BOTH */
1113-
mask = bank->enabled_non_wakeup_gpios & bank->context.fallingdetect;
1114-
mask &= ~bank->context.risingdetect;
1115-
bank->saved_datain |= mask;
1116-
1117-
/* Check for pending EDGE_RISING, ignore EDGE_BOTH */
1118-
mask = bank->enabled_non_wakeup_gpios & bank->context.risingdetect;
1119-
mask &= ~bank->context.fallingdetect;
1120-
bank->saved_datain &= ~mask;
1121-
11221112
if (!may_lose_context)
11231113
goto update_gpio_context_count;
11241114

@@ -1237,26 +1227,35 @@ static int gpio_omap_cpu_notifier(struct notifier_block *nb,
12371227
{
12381228
struct gpio_bank *bank;
12391229
unsigned long flags;
1230+
int ret = NOTIFY_OK;
1231+
u32 isr, mask;
12401232

12411233
bank = container_of(nb, struct gpio_bank, nb);
12421234

12431235
raw_spin_lock_irqsave(&bank->lock, flags);
1236+
if (bank->is_suspended)
1237+
goto out_unlock;
1238+
12441239
switch (cmd) {
12451240
case CPU_CLUSTER_PM_ENTER:
1246-
if (bank->is_suspended)
1241+
mask = omap_get_gpio_irqbank_mask(bank);
1242+
isr = readl_relaxed(bank->base + bank->regs->irqstatus) & mask;
1243+
if (isr) {
1244+
ret = NOTIFY_BAD;
12471245
break;
1246+
}
12481247
omap_gpio_idle(bank, true);
12491248
break;
12501249
case CPU_CLUSTER_PM_ENTER_FAILED:
12511250
case CPU_CLUSTER_PM_EXIT:
1252-
if (bank->is_suspended)
1253-
break;
12541251
omap_gpio_unidle(bank);
12551252
break;
12561253
}
1254+
1255+
out_unlock:
12571256
raw_spin_unlock_irqrestore(&bank->lock, flags);
12581257

1259-
return NOTIFY_OK;
1258+
return ret;
12601259
}
12611260

12621261
static const struct omap_gpio_reg_offs omap2_gpio_regs = {

0 commit comments

Comments
 (0)