Skip to content

Commit cc78507

Browse files
committed
Save/restore XIP cache state around flash functions
1 parent 8880cab commit cc78507

File tree

1 file changed

+10
-3
lines changed
  • src/rp2_common/hardware_flash

1 file changed

+10
-3
lines changed

src/rp2_common/hardware_flash/flash.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#if PICO_RP2040
1111
#include "hardware/structs/io_qspi.h"
1212
#include "hardware/structs/ssi.h"
13+
#include "hardware/structs/xip.h"
1314
#else
1415
#include "hardware/structs/qmi.h"
1516
#include "hardware/regs/otp_data.h"
@@ -127,7 +128,9 @@ static void __no_inline_not_in_flash_func(flash_rp2350_restore_qmi_cs1)(const fl
127128

128129

129130
typedef struct flash_hardware_save_state {
130-
#if !PICO_RP2040
131+
#if PICO_RP2040
132+
uint32_t xip_ctrl;
133+
#else
131134
flash_rp2350_qmi_save_state_t qmi_save;
132135
#endif
133136
uint32_t qspi_pads[count_of(pads_qspi_hw->io)];
@@ -139,7 +142,9 @@ static void __no_inline_not_in_flash_func(flash_save_hardware_state)(flash_hardw
139142
for (size_t i = 0; i < count_of(pads_qspi_hw->io); ++i) {
140143
state->qspi_pads[i] = pads_qspi_hw->io[i];
141144
}
142-
#if !PICO_RP2040
145+
#if PICO_RP2040
146+
state->xip_ctrl = xip_ctrl_hw->ctrl;
147+
#else
143148
flash_rp2350_save_qmi_cs1(&state->qmi_save);
144149
#endif
145150
}
@@ -148,7 +153,9 @@ static void __no_inline_not_in_flash_func(flash_restore_hardware_state)(flash_ha
148153
for (size_t i = 0; i < count_of(pads_qspi_hw->io); ++i) {
149154
pads_qspi_hw->io[i] = state->qspi_pads[i];
150155
}
151-
#if !PICO_RP2040
156+
#if PICO_RP2040
157+
xip_ctrl_hw->ctrl = state->xip_ctrl;
158+
#else
152159
// Tail call!
153160
flash_rp2350_restore_qmi_cs1(&state->qmi_save);
154161
#endif

0 commit comments

Comments
 (0)