Skip to content

Commit 7989302

Browse files
kwd-doodlingcarlescufi
authored andcommitted
interrupt_controller: ioapic: support more device power states
do nothing when enter or resume from DEVICE_PM_LOW_POWER_STATE Signed-off-by: Dong Wang <[email protected]>
1 parent 0ede57e commit 7989302

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

drivers/interrupt_controller/intc_ioapic.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ int ioapic_suspend(const struct device *port)
265265
store_flags(irq, rte_lo);
266266
}
267267
}
268-
ioapic_device_power_state = PM_DEVICE_SUSPEND_STATE;
269268
return 0;
270269
}
271270

@@ -295,7 +294,6 @@ int ioapic_resume_from_suspend(const struct device *port)
295294
ioApicRedSetHi(irq, DEFAULT_RTE_DEST);
296295
ioApicRedSetLo(irq, rteValue);
297296
}
298-
ioapic_device_power_state = PM_DEVICE_ACTIVE_STATE;
299297
return 0;
300298
}
301299

@@ -310,10 +308,28 @@ static int ioapic_device_ctrl(const struct device *dev,
310308
int ret = 0;
311309

312310
if (ctrl_command == PM_DEVICE_STATE_SET) {
313-
if (*((uint32_t *)context) == PM_DEVICE_SUSPEND_STATE) {
311+
uint32_t new_state = *((uint32_t *)context);
312+
313+
switch (new_state) {
314+
case PM_DEVICE_LOW_POWER_STATE:
315+
break;
316+
case PM_DEVICE_ACTIVE_STATE:
317+
if (ioapic_device_power_state !=
318+
PM_DEVICE_LOW_POWER_STATE) {
319+
ret = ioapic_resume_from_suspend(dev);
320+
}
321+
break;
322+
case PM_DEVICE_SUSPEND_STATE:
323+
case PM_DEVICE_FORCE_SUSPEND_STATE:
324+
case PM_DEVICE_OFF_STATE:
314325
ret = ioapic_suspend(dev);
315-
} else if (*((uint32_t *)context) == PM_DEVICE_ACTIVE_STATE) {
316-
ret = ioapic_resume_from_suspend(dev);
326+
break;
327+
default:
328+
ret = -ENOTSUP;
329+
}
330+
331+
if (ret == 0) {
332+
ioapic_device_power_state = new_state;
317333
}
318334
} else if (ctrl_command == PM_DEVICE_STATE_GET) {
319335
*((uint32_t *)context) = ioapic_device_power_state;

0 commit comments

Comments
 (0)