diff options
author | iabdalkader <i.abdalkader@gmail.com> | 2024-12-20 08:57:08 +0100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-04-09 00:22:32 +1000 |
commit | df06bf91a5a78c89eaa7b6b7d157df83c576553f (patch) | |
tree | d7f4dba1bdcd52ab67e8fa30d1a0f237d39ab7d9 | |
parent | 0709936653895e0de499e0a7019afb80eda7425c (diff) |
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>
-rw-r--r-- | ports/alif/ospi_ext.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ports/alif/ospi_ext.c b/ports/alif/ospi_ext.c index 3226c2446..e3389d8bd 100644 --- a/ports/alif/ospi_ext.c +++ b/ports/alif/ospi_ext.c @@ -229,7 +229,7 @@ void ospi_xip_enter_ext(ospi_flash_cfg_t *ospi_cfg, uint32_t inst_len, uint32_t | (ospi_cfg->ddr_en << XIP_CTRL_DDR_EN_OFFSET) | (0x1 << XIP_CTRL_RXDS_EN_OFFSET) | (0x1 << XIP_CTRL_INST_EN_OFFSET) - | (0x0 << XIP_CTRL_CONT_XFER_EN_OFFSET) + | (0x1 << XIP_CTRL_CONT_XFER_EN_OFFSET) | (0x0 << XIP_CTRL_HYPERBUS_EN_OFFSET) | (0x1 << XIP_CTRL_RXDS_SIG_EN) | (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 ospi_writel(ospi_cfg, xip_ctrl, val); - ospi_writel(ospi_cfg, rx_sample_dly, 4); - ospi_writel(ospi_cfg, txd_drive_edge, 1); + ospi_writel(ospi_cfg, rx_sample_dly, OSPI_XIP_RX_SAMPLE_DELAY); + ospi_writel(ospi_cfg, txd_drive_edge, OSPI_XIP_DDR_DRIVE_EDGE); ospi_cfg->aes_regs->aes_rxds_delay = OSPI_XIP_RXDS_DELAY; ospi_writel(ospi_cfg, xip_mode_bits, 0x0); ospi_writel(ospi_cfg, xip_incr_inst, incr_command); ospi_writel(ospi_cfg, xip_wrap_inst, wrap_command); ospi_writel(ospi_cfg, xip_ser, ospi_cfg->ser); + ospi_writel(ospi_cfg, xip_cnt_time_out, 100); spi_enable(ospi_cfg); ospi_xip_enable(ospi_cfg); |