Skip to content

Commit dabf237

Browse files
kwd-doodlingnashif
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]> Signed-off-by: Flavio Ceolin <[email protected]>
1 parent 4e8b382 commit dabf237

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
@@ -255,7 +255,6 @@ int ioapic_suspend(const struct device *port)
255255
store_flags(irq, rte_lo);
256256
}
257257
}
258-
ioapic_device_power_state = DEVICE_PM_SUSPEND_STATE;
259258
return 0;
260259
}
261260

@@ -285,7 +284,6 @@ int ioapic_resume_from_suspend(const struct device *port)
285284
ioApicRedSetHi(irq, DEFAULT_RTE_DEST);
286285
ioApicRedSetLo(irq, rteValue);
287286
}
288-
ioapic_device_power_state = DEVICE_PM_ACTIVE_STATE;
289287
return 0;
290288
}
291289

@@ -300,10 +298,28 @@ static int ioapic_device_ctrl(const struct device *device,
300298
int ret = 0;
301299

302300
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
303-
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
301+
uint32_t new_state = *((uint32_t *)context);
302+
303+
switch (new_state) {
304+
case DEVICE_PM_LOW_POWER_STATE:
305+
break;
306+
case DEVICE_PM_ACTIVE_STATE:
307+
if (ioapic_device_power_state !=
308+
DEVICE_PM_LOW_POWER_STATE) {
309+
ret = ioapic_resume_from_suspend(device);
310+
}
311+
break;
312+
case DEVICE_PM_SUSPEND_STATE:
313+
case DEVICE_PM_FORCE_SUSPEND_STATE:
314+
case DEVICE_PM_OFF_STATE:
304315
ret = ioapic_suspend(device);
305-
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
306-
ret = ioapic_resume_from_suspend(device);
316+
break;
317+
default:
318+
ret = -ENOTSUP;
319+
}
320+
321+
if (ret == 0) {
322+
ioapic_device_power_state = new_state;
307323
}
308324
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) {
309325
*((uint32_t *)context) = ioapic_device_power_state;

0 commit comments

Comments
 (0)