1#![no_std]
6
7pub use nor::ConfigurationBlock;
8
9use imxrt_boot_gen::Imxrt;
10use imxrt_boot_gen::flexspi::{self, opcodes::sdr::*, *};
11use imxrt_boot_gen::serial_flash::*;
12
13const CHIP: Imxrt = Imxrt::Imxrt1010;
14
15const DENSITY_BITS: u32 = 128 * 1024 * 1024;
16const DENSITY_BYTES: u32 = DENSITY_BITS / 8;
17
18const SEQ_READ: Sequence = SequenceBuilder::new()
19 .instr(Instr::new(CMD, Pads::One, 0xEB))
20 .instr(Instr::new(RADDR, Pads::Four, 0x18))
21 .instr(Instr::new(DUMMY, Pads::Four, 0x06))
22 .instr(Instr::new(READ, Pads::Four, 0x04))
23 .build();
24const SEQ_READ_STATUS: Sequence = SequenceBuilder::new()
25 .instr(Instr::new(CMD, Pads::One, 0x05))
26 .instr(Instr::new(READ, Pads::One, 0x04))
27 .build();
28const SEQ_WRITE_ENABLE: Sequence = SequenceBuilder::new()
29 .instr(Instr::new(CMD, Pads::One, 0x06))
30 .build();
31const SEQ_ERASE_SECTOR: Sequence = SequenceBuilder::new()
32 .instr(Instr::new(CMD, Pads::One, 0x20))
33 .instr(Instr::new(RADDR, Pads::One, 0x18))
34 .build();
35const SEQ_PAGE_PROGRAM: Sequence = SequenceBuilder::new()
36 .instr(Instr::new(CMD, Pads::One, 0x02))
37 .instr(Instr::new(RADDR, Pads::One, 0x18))
38 .instr(Instr::new(WRITE, Pads::One, 0x04))
39 .build();
40const SEQ_CHIP_ERASE: Sequence = SequenceBuilder::new()
41 .instr(Instr::new(CMD, Pads::One, 0x60))
42 .build();
43
44const LUT: LookupTable = LookupTable::new()
45 .command(Command::Read, SEQ_READ)
46 .command(Command::ReadStatus, SEQ_READ_STATUS)
47 .command(Command::WriteEnable, SEQ_WRITE_ENABLE)
48 .command(Command::EraseSector, SEQ_ERASE_SECTOR)
49 .command(Command::PageProgram, SEQ_PAGE_PROGRAM)
50 .command(Command::ChipErase, SEQ_CHIP_ERASE);
51
52const COMMON_CONFIGURATION_BLOCK: flexspi::ConfigurationBlock =
53 flexspi::ConfigurationBlock::new(LUT)
54 .read_sample_clk_src(ReadSampleClockSource::LoopbackFromDQSPad)
55 .cs_hold_time(0x03)
56 .cs_setup_time(0x03)
57 .column_address_width(ColumnAddressWidth::OtherDevices)
58 .device_mode_configuration(DeviceModeConfiguration::Disabled)
59 .wait_time_cfg_commands(WaitTimeConfigurationCommands::disable())
60 .flash_size(SerialFlashRegion::A1, DENSITY_BYTES)
61 .serial_clk_freq(CHIP.serial_clock_frequency(SerialClockOption::MHz120))
62 .serial_flash_pad_type(FlashPadType::Quad);
63
64pub const SERIAL_NOR_CONFIGURATION_BLOCK: nor::ConfigurationBlock =
65 nor::ConfigurationBlock::new(CHIP, COMMON_CONFIGURATION_BLOCK)
66 .page_size(256)
67 .sector_size(4096)
68 .ip_cmd_serial_clk_freq(Some(
69 CHIP.ip_serial_clock_frequency(SerialClockOption::MHz30),
70 ));
71
72#[unsafe(no_mangle)]
73#[cfg_attr(
74 all(target_arch = "arm", target_os = "none"),
75 unsafe(link_section = ".fcb")
76)]
77pub static FLEXSPI_CONFIGURATION_BLOCK: nor::ConfigurationBlock = SERIAL_NOR_CONFIGURATION_BLOCK;