Skip to content

Commit df06bf9

Browse files
iabdalkaderdpgeorge
authored andcommitted
alif/ospi_ext: Optimize XIP speed.
This change increases XIP read speed to ~30Mbytes/s at 50MHz DDR: - Enable continuous mode. - Remove hard-coded settings. - Set XIP continuous mode timeout. The prefetch remains disabled. Although enabling the prefetch gives the best performance for the CPU in XIP mode, it must be disabled when the NPU accesses the OSPI flash. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
1 parent 0709936 commit df06bf9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

ports/alif/ospi_ext.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ void ospi_xip_enter_ext(ospi_flash_cfg_t *ospi_cfg, uint32_t inst_len, uint32_t
229229
| (ospi_cfg->ddr_en << XIP_CTRL_DDR_EN_OFFSET)
230230
| (0x1 << XIP_CTRL_RXDS_EN_OFFSET)
231231
| (0x1 << XIP_CTRL_INST_EN_OFFSET)
232-
| (0x0 << XIP_CTRL_CONT_XFER_EN_OFFSET)
232+
| (0x1 << XIP_CTRL_CONT_XFER_EN_OFFSET)
233233
| (0x0 << XIP_CTRL_HYPERBUS_EN_OFFSET)
234234
| (0x1 << XIP_CTRL_RXDS_SIG_EN)
235235
| (0x0 << XIP_CTRL_XIP_MBL_OFFSET)
@@ -242,14 +242,15 @@ void ospi_xip_enter_ext(ospi_flash_cfg_t *ospi_cfg, uint32_t inst_len, uint32_t
242242

243243
ospi_writel(ospi_cfg, xip_ctrl, val);
244244

245-
ospi_writel(ospi_cfg, rx_sample_dly, 4);
246-
ospi_writel(ospi_cfg, txd_drive_edge, 1);
245+
ospi_writel(ospi_cfg, rx_sample_dly, OSPI_XIP_RX_SAMPLE_DELAY);
246+
ospi_writel(ospi_cfg, txd_drive_edge, OSPI_XIP_DDR_DRIVE_EDGE);
247247
ospi_cfg->aes_regs->aes_rxds_delay = OSPI_XIP_RXDS_DELAY;
248248

249249
ospi_writel(ospi_cfg, xip_mode_bits, 0x0);
250250
ospi_writel(ospi_cfg, xip_incr_inst, incr_command);
251251
ospi_writel(ospi_cfg, xip_wrap_inst, wrap_command);
252252
ospi_writel(ospi_cfg, xip_ser, ospi_cfg->ser);
253+
ospi_writel(ospi_cfg, xip_cnt_time_out, 100);
253254

254255
spi_enable(ospi_cfg);
255256
ospi_xip_enable(ospi_cfg);

0 commit comments

Comments
 (0)