Commit dabf2375 authored by Dong Wang's avatar Dong Wang Committed by Anas Nashif
Browse files

interrupt_controller: ioapic: support more device power states



do nothing when enter or resume from DEVICE_PM_LOW_POWER_STATE

Signed-off-by: default avatarDong Wang <dong.d.wang@intel.com>
Signed-off-by: default avatarFlavio Ceolin <flavio.ceolin@intel.com>
parent 4e8b382e
Loading
Loading
Loading
Loading
+21 −5
Original line number Diff line number Diff line
@@ -255,7 +255,6 @@ int ioapic_suspend(const struct device *port)
			store_flags(irq, rte_lo);
		}
	}
	ioapic_device_power_state = DEVICE_PM_SUSPEND_STATE;
	return 0;
}

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

@@ -300,11 +298,29 @@ static int ioapic_device_ctrl(const struct device *device,
	int ret = 0;

	if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
		if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
			ret = ioapic_suspend(device);
		} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
		uint32_t new_state = *((uint32_t *)context);

		switch (new_state) {
		case DEVICE_PM_LOW_POWER_STATE:
			break;
		case DEVICE_PM_ACTIVE_STATE:
			if (ioapic_device_power_state !=
					DEVICE_PM_LOW_POWER_STATE) {
				ret = ioapic_resume_from_suspend(device);
			}
			break;
		case DEVICE_PM_SUSPEND_STATE:
		case DEVICE_PM_FORCE_SUSPEND_STATE:
		case DEVICE_PM_OFF_STATE:
			ret = ioapic_suspend(device);
			break;
		default:
			ret = -ENOTSUP;
		}

		if (ret == 0) {
			ioapic_device_power_state = new_state;
		}
	} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) {
		*((uint32_t *)context) = ioapic_device_power_state;
	}