2828#include "ospi_ext.h"
2929#include "ospi_xip_user.h"
3030
31- #define INST_L16bit (3)
32-
3331static void ospi_xip_disable (ospi_flash_cfg_t * ospi_cfg ) {
3432 ospi_cfg -> aes_regs -> aes_control &= ~AES_CONTROL_XIP_EN ;
3533}
@@ -208,7 +206,7 @@ void ospi_setup_write_ext(ospi_flash_cfg_t *ospi_cfg, bool rxds, uint32_t inst_l
208206 spi_enable (ospi_cfg );
209207}
210208
211- void ospi_xip_enter_16bit_cmd (ospi_flash_cfg_t * ospi_cfg , uint32_t data_len , uint16_t incr_command , uint16_t wrap_command , uint16_t read_dummy_cycles ) {
209+ void ospi_xip_enter_ext (ospi_flash_cfg_t * ospi_cfg , uint32_t inst_len , uint32_t data_len , uint16_t incr_command , uint16_t wrap_command , uint16_t read_dummy_cycles ) {
212210 spi_disable (ospi_cfg );
213211
214212 uint32_t val = CTRLR0_IS_MST
@@ -224,12 +222,11 @@ void ospi_xip_enter_16bit_cmd(ospi_flash_cfg_t *ospi_cfg, uint32_t data_len, uin
224222 val = (OCTAL << XIP_CTRL_FRF_OFFSET )
225223 | (0x2 << XIP_CTRL_TRANS_TYPE_OFFSET )
226224 | (ADDR_L32bit << XIP_CTRL_ADDR_L_OFFSET )
227- | (INST_L16bit << XIP_CTRL_INST_L_OFFSET )
225+ | (inst_len << XIP_CTRL_INST_L_OFFSET )
228226 | (0x0 << XIP_CTRL_MD_BITS_EN_OFFSET )
229227 | (read_dummy_cycles << XIP_CTRL_WAIT_CYCLES_OFFSET )
230228 | (0x1 << XIP_CTRL_DFC_HC_OFFSET )
231229 | (ospi_cfg -> ddr_en << XIP_CTRL_DDR_EN_OFFSET )
232- | (ospi_cfg -> ddr_en << XIP_CTRL_INST_DDR_EN_OFFSET )
233230 | (0x1 << XIP_CTRL_RXDS_EN_OFFSET )
234231 | (0x1 << XIP_CTRL_INST_EN_OFFSET )
235232 | (0x0 << XIP_CTRL_CONT_XFER_EN_OFFSET )
@@ -239,6 +236,10 @@ void ospi_xip_enter_16bit_cmd(ospi_flash_cfg_t *ospi_cfg, uint32_t data_len, uin
239236 | (0x0 << XIP_PREFETCH_EN_OFFSET )
240237 | (0x0 << XIP_CTRL_RXDS_VL_EN_OFFSET );
241238
239+ if (inst_len == OSPI_INST_L_16bit ) {
240+ val |= 1 << XIP_CTRL_INST_DDR_EN_OFFSET ;
241+ }
242+
242243 ospi_writel (ospi_cfg , xip_ctrl , val );
243244
244245 ospi_writel (ospi_cfg , rx_sample_dly , 4 );
@@ -254,7 +255,7 @@ void ospi_xip_enter_16bit_cmd(ospi_flash_cfg_t *ospi_cfg, uint32_t data_len, uin
254255 ospi_xip_enable (ospi_cfg );
255256}
256257
257- void ospi_xip_exit_16bit_cmd (ospi_flash_cfg_t * ospi_cfg , uint16_t incr_command , uint16_t wrap_command ) {
258+ void ospi_xip_exit_ext (ospi_flash_cfg_t * ospi_cfg , uint32_t inst_len , uint16_t incr_command , uint16_t wrap_command ) {
258259 spi_disable (ospi_cfg );
259260
260261 uint32_t val = CTRLR0_IS_MST
@@ -272,7 +273,7 @@ void ospi_xip_exit_16bit_cmd(ospi_flash_cfg_t *ospi_cfg, uint16_t incr_command,
272273 | (2 << CTRLR0_XIP_MBL_OFFSET )
273274 | (1 << CTRLR0_XIP_DFS_HC_OFFSET )
274275 | (1 << CTRLR0_XIP_INST_EN_OFFSET )
275- | (CTRLR0_INST_L_16bit << CTRLR0_INST_L_OFFSET )
276+ | (inst_len << CTRLR0_INST_L_OFFSET )
276277 | (ospi_cfg -> addrlen ) << (CTRLR0_ADDR_L_OFFSET )
277278 | (ospi_cfg -> wait_cycles << CTRLR0_WAIT_CYCLES_OFFSET );
278279
0 commit comments