14 #include "flash_ctrl_regs.h"
19 if (flash_ctrl == NULL) {
23 flash_ctrl->base_addr = base_addr;
30 if (flash_ctrl == NULL) {
37 alert_idx = FLASH_CTRL_ALERT_TEST_RECOV_ERR_BIT;
40 alert_idx = FLASH_CTRL_ALERT_TEST_FATAL_STD_ERR_BIT;
43 alert_idx = FLASH_CTRL_ALERT_TEST_FATAL_ERR_BIT;
46 alert_idx = FLASH_CTRL_ALERT_TEST_FATAL_PRIM_FLASH_ALERT_BIT;
49 alert_idx = FLASH_CTRL_ALERT_TEST_RECOV_PRIM_FLASH_ALERT_BIT;
56 mmio_region_write32(flash_ctrl->base_addr,
57 (ptrdiff_t)FLASH_CTRL_ALERT_TEST_REG_OFFSET,
70 *index_out = FLASH_CTRL_INTR_COMMON_PROG_EMPTY_BIT;
73 *index_out = FLASH_CTRL_INTR_COMMON_PROG_LVL_BIT;
76 *index_out = FLASH_CTRL_INTR_COMMON_RD_FULL_BIT;
79 *index_out = FLASH_CTRL_INTR_COMMON_RD_LVL_BIT;
82 *index_out = FLASH_CTRL_INTR_COMMON_OP_DONE_BIT;
85 *index_out = FLASH_CTRL_INTR_COMMON_CORR_ERR_BIT;
103 if (flash_ctrl == NULL || type == NULL ||
108 *type = irq_types[irq];
117 if (flash_ctrl == NULL || snapshot == NULL) {
121 *snapshot = mmio_region_read32(flash_ctrl->base_addr,
122 (ptrdiff_t)FLASH_CTRL_INTR_STATE_REG_OFFSET);
131 if (flash_ctrl == NULL) {
135 mmio_region_write32(flash_ctrl->base_addr,
136 (ptrdiff_t)FLASH_CTRL_INTR_STATE_REG_OFFSET, snapshot);
145 if (flash_ctrl == NULL || is_pending == NULL) {
150 if (!flash_ctrl_get_irq_bit_index(irq, &index)) {
154 uint32_t intr_state_reg = mmio_region_read32(
155 flash_ctrl->base_addr, (ptrdiff_t)FLASH_CTRL_INTR_STATE_REG_OFFSET);
165 if (flash_ctrl == NULL) {
170 mmio_region_write32(flash_ctrl->base_addr,
171 (ptrdiff_t)FLASH_CTRL_INTR_STATE_REG_OFFSET, UINT32_MAX);
179 if (flash_ctrl == NULL) {
184 if (!flash_ctrl_get_irq_bit_index(irq, &index)) {
190 mmio_region_write32(flash_ctrl->base_addr,
191 (ptrdiff_t)FLASH_CTRL_INTR_STATE_REG_OFFSET,
201 if (flash_ctrl == NULL) {
206 if (!flash_ctrl_get_irq_bit_index(irq, &index)) {
211 mmio_region_write32(flash_ctrl->base_addr,
212 (ptrdiff_t)FLASH_CTRL_INTR_TEST_REG_OFFSET,
222 if (flash_ctrl == NULL || state == NULL) {
227 if (!flash_ctrl_get_irq_bit_index(irq, &index)) {
231 uint32_t intr_enable_reg = mmio_region_read32(
232 flash_ctrl->base_addr, (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET);
244 if (flash_ctrl == NULL) {
249 if (!flash_ctrl_get_irq_bit_index(irq, &index)) {
253 uint32_t intr_enable_reg = mmio_region_read32(
254 flash_ctrl->base_addr, (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET);
258 mmio_region_write32(flash_ctrl->base_addr,
259 (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET,
269 if (flash_ctrl == NULL) {
274 if (snapshot != NULL) {
275 *snapshot = mmio_region_read32(
276 flash_ctrl->base_addr, (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET);
280 mmio_region_write32(flash_ctrl->base_addr,
281 (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET, 0u);
290 if (flash_ctrl == NULL || snapshot == NULL) {
294 mmio_region_write32(flash_ctrl->base_addr,
295 (ptrdiff_t)FLASH_CTRL_INTR_ENABLE_REG_OFFSET, *snapshot);