From 7514ffe3b565669f6535ce05826613a884fb0665 Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Sat, 13 Dec 2025 13:30:49 -0500 Subject: Support ISSI LP and WP configs in one algo The configurations and sequences need to vary depending on the connected part. We can determine the part at runtime to vary the config. We could probably do this for all the parts. Maybe I'll try that later. --- src/flash/issi.rs | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'src/flash') diff --git a/src/flash/issi.rs b/src/flash/issi.rs index 1d36bb0..6b517af 100644 --- a/src/flash/issi.rs +++ b/src/flash/issi.rs @@ -1,27 +1,50 @@ //! ISSI Serial NOR Flash. +//! +//! The same algorithm will query the flash part to differentiate +//! the 3.3V part ("LP") from the 1.8V part ("WP"). Sequences and +//! configurations vary by part. Replace the W and L with 'x'. use super::*; use crate::{ImxrtFlashAlgorithm, sequences::common as sequences}; -pub type Is25WP128 = Issi<{ 128 / 8 * 1024 * 1024 }, 15>; +pub type Is25xP128 = Issi<{ 128 / 8 * 1024 * 1024 }>; /// An ISSI serial NOR flash driver. -pub struct Issi; +pub struct Issi; -impl ImxrtFlashAlgorithm - for Issi -{ +const ISSI_WP_MEM_TYPE: u8 = 0x70; +const ISSI_LP_MEM_TYPE: u8 = 0x60; + +impl ImxrtFlashAlgorithm for Issi { const FLASH_CAPACITY_BYTES: usize = FLASH_CAPACITY_BYTES; const FLASH_PAGE_SIZE_BYTES: usize = 256; const FLASH_SECTOR_SIZE_BYTES: usize = 4096; fn initialize(flexspi: imxrt_drivers_flexspi::Instance) { + defmt::assert_eq!( + READ_ID_JEDEC_ID, + defmt::unwrap!(crate::install_ip_cmd( + flexspi, + READ_ID_JEDEC_ID.seq_id, + &[sequences::SEQ_READ_ID_JEDEC_ID] + )) + ); + + let jedec_id = super::read_jedec_id(flexspi); + defmt::assert_eq!(jedec_id.mnf_id, 0x9D); + + let (dummy_cycles, set_read_params_data) = match jedec_id.mem_type { + ISSI_WP_MEM_TYPE => (15, 15 << 3), + ISSI_LP_MEM_TYPE => (10, (0b111 << 5) | (0b11) << 3), + _ => defmt::panic!("{=u8:#X}", jedec_id.mem_type), + }; + defmt::assert_eq!( READ, defmt::unwrap!(crate::install_ip_cmd( flexspi, READ.seq_id, - &[sequences::seq_fast_read_quad_io(DUMMY_CYCLES)], + &[sequences::seq_fast_read_quad_io(dummy_cycles)], )) ); @@ -91,7 +114,7 @@ impl ImxrtFlashAlgori )) ); - let set_read_params_data = [DUMMY_CYCLES << 3]; + let set_read_params_data = [set_read_params_data]; crate::start_ip_cmd(flexspi, SET_READ_PARAMS, 0, &set_read_params_data); crate::transmit_bytes(flexspi, &set_read_params_data); crate::wait_for_ip_cmd_done(flexspi); -- cgit v1.2.3