// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. #ifndef HOST_IRQ_CONTROL_H_ #define HOST_IRQ_CONTROL_H_ #include #include "status/rot_status.h" /** * API for controlling the processing of host IRQs. */ struct host_irq_control { /** * Enable or disable the IRQ that indicates when a host processor has left the reset state. * * @param control The API for the IRQs to update. * @param enable true to enable the IRQ or false to disable it. * * @return 0 if the IRQ was updated successfully or an error code. */ int (*enable_exit_reset) (const struct host_irq_control *control, bool enable); /** * Enable or disable the IRQ that indicates when SPI chip selects have been asserted by the * host. * * @param control The API for the IRQs to update. * @param enable true to enable the IRQs or false to disable them. * * @return 0 if the IRQs were updated successfully or an error code. */ int (*enable_chip_selects) (const struct host_irq_control *control, bool enable); /** * Enable or disable IRQ notifications for enabled interrupts. * * This call cannot fail, but it will have no effect if the API instance is null. * * @param control The API for the IRQs to update. * @param enable true to enable IRQ notifications or false to disable them. */ void (*enable_notifications) (const struct host_irq_control *control, bool enable); }; #define HOST_IRQ_CTRL_ERROR(code) ROT_ERROR (ROT_MODULE_HOST_IRQ_CTRL, code) /** * Error codes that can be generated by an IRQ control driver. */ enum { HOST_IRQ_CTRL_INVALID_ARGUMENT = HOST_IRQ_CTRL_ERROR (0x00), /**< Input parameter is null or not valid. */ HOST_IRQ_CTRL_NO_MEMORY = HOST_IRQ_CTRL_ERROR (0x01), /**< Memory allocation failed. */ HOST_IRQ_CTRL_EXIT_RESET_FAILED = HOST_IRQ_CTRL_ERROR (0x02), /**< Exit reset IRQ has not been enabled/disabled. */ HOST_IRQ_CTRL_CHIP_SEL_FAILED = HOST_IRQ_CTRL_ERROR (0x03), /**< Chip select IRQs have not been enabled/disabled. */ HOST_IRQ_CTRL_IRQ_NOT_SUPPORTED = HOST_IRQ_CTRL_ERROR (0x04), /**< The type of IRQ is not supported by the driver. */ }; #endif /* HOST_IRQ_CONTROL_H_ */