14 #include "spi_device_regs.h"
19 if (spi_device == NULL) {
30 if (spi_device == NULL) {
37 alert_idx = SPI_DEVICE_ALERT_TEST_FATAL_FAULT_BIT;
44 mmio_region_write32(spi_device->
base_addr,
45 (ptrdiff_t)SPI_DEVICE_ALERT_TEST_REG_OFFSET,
58 *index_out = SPI_DEVICE_INTR_COMMON_UPLOAD_CMDFIFO_NOT_EMPTY_BIT;
61 *index_out = SPI_DEVICE_INTR_COMMON_UPLOAD_PAYLOAD_NOT_EMPTY_BIT;
64 *index_out = SPI_DEVICE_INTR_COMMON_UPLOAD_PAYLOAD_OVERFLOW_BIT;
67 *index_out = SPI_DEVICE_INTR_COMMON_READBUF_WATERMARK_BIT;
70 *index_out = SPI_DEVICE_INTR_COMMON_READBUF_FLIP_BIT;
73 *index_out = SPI_DEVICE_INTR_COMMON_TPM_HEADER_NOT_EMPTY_BIT;
76 *index_out = SPI_DEVICE_INTR_COMMON_TPM_RDFIFO_CMD_END_BIT;
79 *index_out = SPI_DEVICE_INTR_COMMON_TPM_RDFIFO_DROP_BIT;
97 if (spi_device == NULL || type == NULL || irq < 0 ||
102 *type = irq_types[irq];
111 if (spi_device == NULL || snapshot == NULL) {
115 *snapshot = mmio_region_read32(spi_device->
base_addr,
116 (ptrdiff_t)SPI_DEVICE_INTR_STATE_REG_OFFSET);
125 if (spi_device == NULL) {
129 mmio_region_write32(spi_device->
base_addr,
130 (ptrdiff_t)SPI_DEVICE_INTR_STATE_REG_OFFSET, snapshot);
139 if (spi_device == NULL || is_pending == NULL) {
144 if (!spi_device_get_irq_bit_index(irq, &index)) {
148 uint32_t intr_state_reg = mmio_region_read32(
149 spi_device->
base_addr, (ptrdiff_t)SPI_DEVICE_INTR_STATE_REG_OFFSET);
159 if (spi_device == NULL) {
164 mmio_region_write32(spi_device->
base_addr,
165 (ptrdiff_t)SPI_DEVICE_INTR_STATE_REG_OFFSET, UINT32_MAX);
173 if (spi_device == NULL) {
178 if (!spi_device_get_irq_bit_index(irq, &index)) {
184 mmio_region_write32(spi_device->
base_addr,
185 (ptrdiff_t)SPI_DEVICE_INTR_STATE_REG_OFFSET,
195 if (spi_device == NULL) {
200 if (!spi_device_get_irq_bit_index(irq, &index)) {
205 mmio_region_write32(spi_device->
base_addr,
206 (ptrdiff_t)SPI_DEVICE_INTR_TEST_REG_OFFSET,
216 if (spi_device == NULL || state == NULL) {
221 if (!spi_device_get_irq_bit_index(irq, &index)) {
225 uint32_t intr_enable_reg = mmio_region_read32(
226 spi_device->
base_addr, (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET);
238 if (spi_device == NULL) {
243 if (!spi_device_get_irq_bit_index(irq, &index)) {
247 uint32_t intr_enable_reg = mmio_region_read32(
248 spi_device->
base_addr, (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET);
252 mmio_region_write32(spi_device->
base_addr,
253 (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET,
263 if (spi_device == NULL) {
268 if (snapshot != NULL) {
269 *snapshot = mmio_region_read32(
270 spi_device->
base_addr, (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET);
274 mmio_region_write32(spi_device->
base_addr,
275 (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET, 0u);
284 if (spi_device == NULL || snapshot == NULL) {
288 mmio_region_write32(spi_device->
base_addr,
289 (ptrdiff_t)SPI_DEVICE_INTR_ENABLE_REG_OFFSET, *snapshot);