12.14. QSPI memory interface (QMI)

12.14.1. Overview

The QSPI memory interface (QMI) provides read/write memory-mapped access to two external QSPI memory devices. RP2350 has a single QMI instance, embedded in the XIP subsystem (Section 4.4), which replaces the SSI interface present on RP2040. The QMI supports serial-SPI, dual-SPI, and quad-SPI transfers, with two chip selects and shared clock/data signals.

Figure 129. QMI block diagram: AHB accesses are address-translated, broken down into the necessary QSPI transfer phases such as command, address and data, and interfaced to the external QSPI signals via the serialiser/deserialiser. There is a chip select per device, and shared clock/data signals. Separately, the direct mode interface can be used to issue raw SPI commands through a pair of FIFOs, which can be used to program and configure the external QSPI devices.

Figure 129: QMI block diagram. The diagram shows the internal architecture of the QMI. At the top, AHB (XIP access) connects to an Address Translation block, and APB (configuration) connects to a Control/Configuration Interface block. Both are connected to Configuration Registers. The Address Translation block connects to a QSPI Transfer Sequencer. The Control/Configuration Interface connects to TX FIFO (4 x 21b) and RX FIFO (4 x 16b), which then connect to a Direct Mode Interface. Both the QSPI Transfer Sequencer and the Direct Mode Interface connect to a Mux (DIRECT_CSR.EN). The Mux connects to a QSPI Serialiser/Deserialiser block. This block has three outputs: SCK, CSn[1:0], and SD[3:0].
Figure 129: QMI block diagram. The diagram shows the internal architecture of the QMI. At the top, AHB (XIP access) connects to an Address Translation block, and APB (configuration) connects to a Control/Configuration Interface block. Both are connected to Configuration Registers. The Address Translation block connects to a QSPI Transfer Sequencer. The Control/Configuration Interface connects to TX FIFO (4 x 21b) and RX FIFO (4 x 16b), which then connect to a Direct Mode Interface. Both the QSPI Transfer Sequencer and the Direct Mode Interface connect to a Mux (DIRECT_CSR.EN). The Mux connects to a QSPI Serialiser/Deserialiser block. This block has three outputs: SCK, CSn[1:0], and SD[3:0].

Each chip select corresponds to a 16 MB AHB address window, so a maximum of 32 MB of external memory is supported. Chip select 0, which has a dedicated external pin, is mapped to addresses starting from 0x10000000, and chip select 1, which is available as an alternate GPIO function, starts from 0x11000000. This mapping is mirrored in the uncached and uncached + untranslated XIP address windows described in Section 4.4 .

All timing and SPI command format parameters are configured per chip select, with the correct configuration used automatically based on address decode. For example, M0_TIMING configures timing parameters for accesses to chip select 0, and M1_TIMING is an identical register for chip select 1.

The serial clock ( SCK) is any integer division of the system clock in the range 1 to 256. The divisors can be adjusted at any time. Input sample timing can be adjusted in half-system-clock-cycle increments, to compensate for clock-to-data delay at high SCK frequencies. Double transfer rate mode (DTR) is implemented by halving the SCK frequency whilst maintaining the data transfer rate, which is capped at 4 bits per system clock cycle.

The number of SCK cycles issued for each access depends on the access size, which varies between one byte and one cache line. For example, an uncached one-byte read by a processor will fetch exactly one byte of data over the QSPI bus, to avoid wasting time fetching unwanted data. Cache misses are always issued as 64-bit QSPI transfers.

Optionally, the QMI can automatically chain sequentially addressed AHB accesses into a single, long QSPI transfer. This avoids issuing redundant commands and addresses on the QSPI bus, and is particularly beneficial for cold code paths and for streaming in flash data using the XIP streaming hardware ( Section 4.4.3 ). For PSRAM compatibility, chains can be broken when they exceed a maximum chip select time ( M0_TIMING.MAX_SELECT ) or when they cross certain power-of-two address boundaries ( M0_TIMING.PAGEBREAK ). Section 12.14.2.1 goes into more detail on these features.

The QMI can map addresses with its built-in address translation hardware: each chip select is partitioned into \( 4 \times 4 \) MB windows, whose physical base address and aperture size are configured in units of 4 kB (one flash sector). This enables the runtime addresses of flash programs to be independent of where they are stored: for example, a flash-resident bootloader at flash storage address 0 could select one of multiple flash-resident program images, all of them linked to run at address 0x10000000, and these can be executed in place with no position-independent code required. Address translation is described fully in Section 12.14.4 .

Finally, the direct-mode interface is included for cases where software needs to communicate directly with the external QSPI devices, for example to access status registers. This interface also supports serial, dual, and quad interface widths as described in Section 12.14.5 .

12.14.2. QSPI transfers

A QSPI bus connects one host, such as QMI, to multiple devices, such as a serial NOR flash. It consists of:

No single specification defines the format of QSPI commands. However, certain de facto command sets exist on most QSPI flash/SRAM/PSRAM devices. QMI supports the most common variations of these commands.

QMI is primarily a memory interface, not a general-purpose QSPI peripheral. Although the direct-mode interface (Section 12.14.5) allows arbitrary QSPI accesses by passing raw data through the FIFOs, QMI is optimised for preformatted read/write transfers in response to AHB read/write bus accesses.

All QSPI read/write accesses performed by the QMI use the following five phases:

  1. 1. Prefix: An optional, constant 8-bit value that indicates the SPI command being performed (referred to as the command prefix or instruction prefix in SPI device datasheets)
  2. 2. Address: A 24-bit byte address that specifies the SPI memory location being read/written, corresponding to the lower 24 bits of the AHB address
  3. 3. Suffix: An optional, constant 8-bit value which follows the address in certain access modes
  4. 4. Dummy: 0-value (SPI) or high-impedance (dual/quad-SPI) cycles which precede the data, to provide the SPI device adequate time to access the first address
  5. 5. Data: Transfers memory contents to/from the SPI device at sequential byte addresses from the initial address indicated in the address phase

The chip select for the addressed device is asserted before the prefix phase, and de-asserted at the end of the data phase.

Each phase has a length in bits and interface width (single/dual/quad) configured using M0_RFMT/M1_RFMT (for reads) and M0_WFMT/M1_WFMT for writes. The M0/M1 versions of each register configure accesses to memory windows 0 and 1 (the two chip selects) respectively. This allows you to address two different QSPI devices with different command formats transparently.

Figure 130. An example serial read. After an 8-bit prefix, the host sends 24 address bits, and the device replies with data starting from the next cycle.

Timing diagram for a QSPI serial read transaction. The diagram shows four signals: CSn, SCK, SD0, and SD1. CSn is asserted at the start of the Prefix phase and de-asserted at the end of the Read Data phase. SCK is a continuous clock signal. SD0 and SD1 are data lines. The transaction consists of three phases: Prefix (03h) x8, Address x24, and Read Data x8. The Prefix phase is 8 clock cycles long. The Address phase is 24 clock cycles long, with the address bits A23, A2, A1, and A0 labeled. The Read Data phase is 8 clock cycles long, with data bits D7, D6, D5, D4, D3, D2, D1, and D0 labeled. The data is transferred in a single cycle on SD0 and SD1.
Timing diagram for a QSPI serial read transaction. The diagram shows four signals: CSn, SCK, SD0, and SD1. CSn is asserted at the start of the Prefix phase and de-asserted at the end of the Read Data phase. SCK is a continuous clock signal. SD0 and SD1 are data lines. The transaction consists of three phases: Prefix (03h) x8, Address x24, and Read Data x8. The Prefix phase is 8 clock cycles long. The Address phase is 24 clock cycles long, with the address bits A23, A2, A1, and A0 labeled. The Read Data phase is 8 clock cycles long, with data bits D7, D6, D5, D4, D3, D2, D1, and D0 labeled. The data is transferred in a single cycle on SD0 and SD1.

Figure 130 illustrates the 03h serial read command. This section refers to a handful of common QSPI read/write commands used by QSPI flash/SRAM/PSRAM devices; refer to a QSPI device datasheet for command details. For example, the W25Q16JV datasheet available from Winbond provides descriptions of all of the read commands mentioned in this section.

Applying the five-phase structure introduced previously, the 03h QSPI transaction breaks down as follows:

  1. 1. 8-bit prefix, at serial width (prefix = 0x03 )
  2. 2. 24-bit address, at serial width
  3. 3. No suffix (length 0)
  4. 4. No dummy bits (length 0)
  5. 5. Data bits, at serial width

The number of address bits is fixed at 24 for all QMI accesses. The number of data bits depends on the size of the transfer: this diagram shows 8 bits being transferred, which corresponds to an uncached byte read from the processor.

The M0_RFMT/M1_RFMT registers configure all other parameters used for the data phase, such as serial interface width.

The four data lines SD3 through SD0 make up the QSPI bus. At serial width, the host drives data out on SD0 , and the device responds with data travelling in the opposite direction on SD1 . SD3 and SD2 are undriven during serial-SPI and dual-SPI width parts of a transfer, and are usually pulled high. The shaded background behind the D7 through D0 data bits indicates that the transfer direction is device-to-host. Higher interface widths use the SDx lines bidirectionally.

Figure 131. The 0Bh read command adds 8 dummy cycles between address and data, to permit higher bus frequencies.

Timing diagram for the 0Bh read command. The diagram shows four signals: CSn, SCK, SD0, and SD1/SD2/SD3. The phases are: Prefix (0Bh) x8, Address x24, Dummy x8, and Read Data x8. The address is split into A23, A2, A1, and A0. The data is split into D7, D6, D5, D4, D3, D2, D1, and D0. The dummy phase is shaded, indicating device-to-host transfer direction.
Timing diagram for the 0Bh read command. The diagram shows four signals: CSn, SCK, SD0, and SD1/SD2/SD3. The phases are: Prefix (0Bh) x8, Address x24, Dummy x8, and Read Data x8. The address is split into A23, A2, A1, and A0. The data is split into D7, D6, D5, D4, D3, D2, D1, and D0. The dummy phase is shaded, indicating device-to-host transfer direction.

Figure 131 shows the 0Bh serial read command, a common variation on the 03h . 0Bh adds dummy cycles between the address and data phases, which helps hide the initial access latency of the storage array inside of the QSPI device. This allows higher operating frequencies.

Applying the five-phase structure introduced previously, the 0Bh QSPI transaction breaks down as follows:

  1. 1. 8-bit prefix, at serial width (prefix = 0x0b )
  2. 2. 24-bit address, at serial width
  3. 3. No suffix (length 0)
  4. 4. Eight dummy bits, at serial width
  5. 5. Data bits, at serial width

At serial width, the QMI continues to drive the SD0 line low throughout the dummy phase, as this line is unidirectional at this width. At dual-SPI and quad-SPI width, SD0 is tristated during the dummy phase along with SD1 through SD3 .

QMI idles its clock low between transfers, expecting data to be captured on the leading edge of each clock pulse (i.e. the rising edge). In legacy Motorola SPI terms, the clock polarity is 0 and the clock phase is 0. Other clock polarities and phases are not supported. To ensure data is stable across the rising edge, new data is launched on each falling edge.

When transfer chaining is disabled (Section 12.14.2.1), QMI takes advantage of this clock behaviour by suppressing the final clock pulse on reads. This saves energy by avoiding unnecessary SCK transitions, and by not inadvertently requesting the data that immediately follows the requested data. QMI still leaves one full SCK period where the last data is valid, and still captures at the point the SCK rising edge would be launched (Section 12.14.3), but the actual SCK clock pulse is suppressed.

Figure 132. An EBh quad I/O read command. The command prefix is serial, but address and data are 4 bits per cycle.

Timing diagram for the EBh quad I/O read command. The diagram shows four signals: CSn, SCK, SD0, and SD1/SD2/SD3. The phases are: Prefix (EBh) x8, Address x6, Suffix x2, Dummy x6, and Read Data x8. The address is split into A20, A16, A12, A8, A4, and A0. The data is split into D4, D0, D12, D8, D20, D16, D28, D24, D5, D1, D13, D9, D21, D17, D29, D25, D6, D2, D14, D10, D22, D18, D30, D26, D7, D3, D15, D11, D23, D19, D31, D27. The dummy phase is shaded, indicating device-to-host transfer direction.
Timing diagram for the EBh quad I/O read command. The diagram shows four signals: CSn, SCK, SD0, and SD1/SD2/SD3. The phases are: Prefix (EBh) x8, Address x6, Suffix x2, Dummy x6, and Read Data x8. The address is split into A20, A16, A12, A8, A4, and A0. The data is split into D4, D0, D12, D8, D20, D16, D28, D24, D5, D1, D13, D9, D21, D17, D29, D25, D6, D2, D14, D10, D22, D18, D30, D26, D7, D3, D15, D11, D23, D19, D31, D27. The dummy phase is shaded, indicating device-to-host transfer direction.

Figure 132 shows a quad-width read transfer. In this example, the command prefix is still transferred at serial width, but the full quad-width is used thereafter, as the prefix identifies the width of the access.

Applying the five-phase structure introduced previously, the QSPI transaction breaks down as follows:

  1. 1. 8-bit prefix, at serial width (prefix = 0xeb )
  2. 2. 24-bit address, at quad width
  3. 3. 8-bit suffix, at quad width (suffix = 0x00 )
  4. 4. 24 dummy bits, at quad width
  5. 5. Data bits, at quad width

The suffix is an extension of the command prefix, placed after the address bits to avoid extending the initial access

latency. The bit patterns used for prefixes and suffixes are configured using the M0_RCMD/M1_RCMD registers (for reads) and M0_WCMD/M1_WCMD registers (for writes). One common use of the suffix on EBh quad I/O read commands is to enter a so-called continuous read mode, where the prefix of the next command is skipped (assumed to be the same as the current command) to reduce the number of cycles required for the next read access.

Figure 133. An 02h write transfer, shown with the device in QPI mode (4 bits per cycle for all transfers)

Timing diagram for a QPI write transfer (02h command). The diagram shows the relationship between the Phase, CSn, SCK, and data lines SD0, SD1, SD2, and SD3. The Phase is divided into Prefix x2, Address x6, and Write Data x8. CSn is active low. SCK is a clock signal. SD0, SD1, SD2, and SD3 transfer data in parallel. The Address phase (6 cycles) shows the address bits A20-A0 on SD0, A21-A1 on SD1, A22-A2 on SD2, and A23-A3 on SD3. The Write Data phase (8 cycles) shows the data bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The data is transferred in 4-bit cycles (2 bytes per cycle).
Timing diagram for a QPI write transfer (02h command). The diagram shows the relationship between the Phase, CSn, SCK, and data lines SD0, SD1, SD2, and SD3. The Phase is divided into Prefix x2, Address x6, and Write Data x8. CSn is active low. SCK is a clock signal. SD0, SD1, SD2, and SD3 transfer data in parallel. The Address phase (6 cycles) shows the address bits A20-A0 on SD0, A21-A1 on SD1, A22-A2 on SD2, and A23-A3 on SD3. The Write Data phase (8 cycles) shows the data bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The data is transferred in 4-bit cycles (2 bytes per cycle).

Figure 133 shows a write command at quad width. In this example, the command prefix is also issued in quad mode, which is common for QSPI RAM. Since read and write commands mix freely, dropping the prefix (like flash continuous read mode) is less useful, so QSPI RAM devices often support a QPI mode that also issues command prefixes in quad width to reduce per-access cost.

Applying the five-phase structure introduced previously, the QSPI transaction breaks down as follows:

  1. 1. 8-bit prefix, at quad width (prefix = 0x02)
  2. 2. 24-bit address, at quad width
  3. 3. No suffix (0 bits)
  4. 4. No dummy bits
  5. 5. Data bits, at quad width

It is worth noting the bit and byte order in this diagram. SPI is conventionally MSB-first within each byte. When multiple bits transfer each cycle (using the SD0 , SD1 , SD2 and SD3 data lines in parallel), higher-numbered data lines carry more-significant bits. The first cycle of the data transfer in Figure 133 transfers the four most-significant bits of the first byte of data. The most-significant bit (bit 7) transfers on SD3 , and the least-significant of these bits (bit 4) transfers on SD0 .

Since RP2350 is a little-endian system, higher byte addresses correspond to higher numerical significance. Figure 133 shows the transfer of a 32-bit value spanning four consecutive byte addresses, starting at the initial address transmitted by the host during the address phase. The first two cycles of the data phase transfer the first byte, containing the 8 least-significant bits of the 32-bit value. The last two cycles of the data phase transfer the last byte, containing the 8 most-significant bits of the 32-bit value (bits 31 through 24, inclusive).

12.14.2.1. Transfer chaining

Referring back to Figure 132 , which shows a 32-bit QSPI read with an EBh serial prefix, it's evident that more time is spent issuing the prefix and address (14 cycles) and waiting for the initial read latency (an additional 8 cycles), than actually transferring the data (8 cycles). This overhead leaves only a small fraction of the theoretical maximum QSPI throughput available for transferring data from flash, which limits the performance of direct code execution.

Figure 134. An EBh read, without the command prefix. The suffix is used to indicate the lack of prefix on the next command.

Timing diagram for a QPI read transfer (EBh command) without a command prefix. The diagram shows the relationship between the Phase, CSn, SCK, and data lines SD0, SD1, SD2, and SD3. The Phase is divided into Address x6, Suffix x2, Dummy x6, and Read Data x4. CSn is active low. SCK is a clock signal. SD0, SD1, SD2, and SD3 transfer data in parallel. The Address phase (6 cycles) shows the address bits A20-A0 on SD0, A21-A1 on SD1, A22-A2 on SD2, and A23-A3 on SD3. The Suffix phase (2 cycles) shows the suffix bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The Dummy phase (6 cycles) shows no data transfer. The Read Data phase (4 cycles) shows the data bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The data is transferred in 4-bit cycles (2 bytes per cycle).
Timing diagram for a QPI read transfer (EBh command) without a command prefix. The diagram shows the relationship between the Phase, CSn, SCK, and data lines SD0, SD1, SD2, and SD3. The Phase is divided into Address x6, Suffix x2, Dummy x6, and Read Data x4. CSn is active low. SCK is a clock signal. SD0, SD1, SD2, and SD3 transfer data in parallel. The Address phase (6 cycles) shows the address bits A20-A0 on SD0, A21-A1 on SD1, A22-A2 on SD2, and A23-A3 on SD3. The Suffix phase (2 cycles) shows the suffix bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The Dummy phase (6 cycles) shows no data transfer. The Read Data phase (4 cycles) shows the data bits D4-D0 on SD0, D5-D1 on SD1, D6-D2 on SD2, and D7-D3 on SD3. The data is transferred in 4-bit cycles (2 bytes per cycle).

Figure 134 shows how this can be improved by continuous read mode , which uses a suffix (here 0xa0) to indicate the lack of command prefix on the next command. This example only transfers 16 bits of data (e.g. an uncached halfword read by the processor). Suffixes are effectively free to transfer, because they are transferred during the latency wait period between the address being issued and the first data returned from the QSPI device's internal storage. However, this still leaves the majority of the QSPI bus cycles spent issuing addresses and waiting, not transferring data.

Consequently, QSPI memory’s random-access performance is much lower than its sequential-access performance.

Figure 135. An EBh read, with a subsequent sequential read chained onto the next transfer

Timing diagram for Figure 135 showing an EBh read followed by a chained sequential read. The diagram includes signals for Phase, CSn, SCK, SD0, SD1, SD2, and SD3. The first transfer (EBh read) has an address of A0-A23 and a suffix of D4-D7. The second transfer (chained sequential read) starts at address A24 and has a suffix of D8-D11. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers.

The diagram shows a sequence of two transfers. The first transfer is an EBh read with address A0-A23 and suffix D4-D7. The second transfer is a chained sequential read starting at address A24 and having suffix D8-D11. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers. The data lines SD0, SD1, SD2, and SD3 show the data being transferred in parallel.

Timing diagram for Figure 135 showing an EBh read followed by a chained sequential read. The diagram includes signals for Phase, CSn, SCK, SD0, SD1, SD2, and SD3. The first transfer (EBh read) has an address of A0-A23 and a suffix of D4-D7. The second transfer (chained sequential read) starts at address A24 and has a suffix of D8-D11. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers.

QMI’s transfer chaining feature exploits the difference between sequential and non-sequential access speed. Figure 135 shows two sequentially-addressed halfword reads (i.e. the address of the second transfer is two plus the address of the first transfer), with M0_TIMING.COOLDOWN / M1_TIMING.COOLDOWN set to a non-zero value.

In Figure 134 , QMI suppressed the last clock pulse and immediately released the chip select after the last data transferred. When transfer chaining is enabled, as in Figure 135 , QMI does not suppress the last clock pulse, instead keeping the chip select asserted. It remains in this state for a certain amount of time, configured by the COOLDOWN register field, waiting for another transfer. QMI then executes the next transfer by appending more clocks to the current transfer. The chip select remains asserted throughout instead of releasing and reasserting between commands. To benefit from transfer chaining, the next transfer must meet the following criteria:

This considerably improves throughput for long uncached linear transfers such as using the XIP stream peripheral ( Section 4.4.3 ) or executing cold code sequences which tend to miss the cache many times sequentially.

This can continue for arbitrarily many transfers. It is possible to read the entire contents of a typical flash device using transfer chaining from a single address.

Note that the transfer chaining feature can slightly degrade random access performance. If the next transfer is non-sequential, the chip select must be de-asserted, possibly dwell high for some minimum period (depending on timing requirements of the QSPI device), and then be reasserted to issue the new address. If transfer chaining were not used, the chip select would have de-asserted immediately following the end of the previous transfer, avoiding some of this delay. This can be mitigated by tuning the COOLDOWN timer register parameter to avoid leaving the chip select asserted for excessively long periods, since sequential transfers are usually tightly grouped in time.

12.14.3. Timing

QMI operates in SPI mode 0, capturing data on each rising edge of SCK . New data is asserted on each subsequent falling edge. The first output data launches simultaneously with the assertion of the chip select, as illustrated by Figure 136 .

Figure 136. A bidirectional SPI transfer, as used by QMI.

Timing diagram for Figure 136 showing a bidirectional SPI transfer. The diagram includes signals for Byte index, CSn, SCK, SD0, and SD1. The first transfer (Byte 0) has address D0-D7. The second transfer (Byte 1) has address D8-D15. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers. The data lines SD0 and SD1 show the data being transferred in parallel.

The diagram shows a sequence of two transfers. The first transfer is for Byte 0 with address D0-D7. The second transfer is for Byte 1 with address D8-D15. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers. The data lines SD0 and SD1 show the data being transferred in parallel.

Timing diagram for Figure 136 showing a bidirectional SPI transfer. The diagram includes signals for Byte index, CSn, SCK, SD0, and SD1. The first transfer (Byte 0) has address D0-D7. The second transfer (Byte 1) has address D8-D15. The SCK signal is asserted throughout both transfers, and the CSn signal is asserted for the duration of both transfers. The data lines SD0 and SD1 show the data being transferred in parallel.

QMI timing is relative to the system clock. As this is generally quite fast relative to external signals, the M0_TIMING.CLKDIV / M1_TIMING.CLKDIV field can uniformly slow SCK and data lines by an integer factor.

Figure 137. The CLKDIV controls set the number of system clock cycles per SCK cycle, for each memory window.

Timing diagram showing System clock, CSn, SCK (div=1), SD0 (div=1), SCK (div=2), SD0 (div=2), SCK (div=3), and SD0 (div=3). The diagram illustrates how the SCK and SD0 signals are derived from the system clock using different divisors. SCK (div=1) is the system clock itself. SD0 (div=1) is the system clock divided by 1. SCK (div=2) is the system clock divided by 2. SD0 (div=2) is the system clock divided by 2. SCK (div=3) is the system clock divided by 3. SD0 (div=3) is the system clock divided by 3. The diagram shows the relationship between the system clock, CSn, and the SCK and SD0 signals for different divisors.
Timing diagram showing System clock, CSn, SCK (div=1), SD0 (div=1), SCK (div=2), SD0 (div=2), SCK (div=3), and SD0 (div=3). The diagram illustrates how the SCK and SD0 signals are derived from the system clock using different divisors. SCK (div=1) is the system clock itself. SD0 (div=1) is the system clock divided by 1. SCK (div=2) is the system clock divided by 2. SD0 (div=2) is the system clock divided by 2. SCK (div=3) is the system clock divided by 3. SD0 (div=3) is the system clock divided by 3. The diagram shows the relationship between the system clock, CSn, and the SCK and SD0 signals for different divisors.

QMI uses DDR input/output registers to enable a resolution of one half system clock cycle for output signal generation and input sampling. This allows QMI to support odd clock divisors, including divide-by-one (SCK frequency equal to system clock frequency).

i NOTE

In practice, the maximum SCK frequency is constrained by the limits of the attached QSPI device, the signal integrity afforded by the PCB layout, and IO delays in the pads. See Section 12.14.3.4 .

12.14.3.1. Input sampling and RXDELAY

QMI samples input data on the rising edge of SCK ( Section 12.14.3 ). To introduce additional delay to the input delay register (helpful when the round trip delay is longer than half an SCK cycle), use MO_TIMING.RXDELAY / M1_TIMING.RXDELAY . RXDELAY counts delay in half system clock cycles, instead of SCK cycles.

12.14.3.2. Chip select timing

To save power, chip select is de-asserted after a transaction completes. To leave chip select asserted after a transaction, use MO_TIMING.COOLDOWN / M1_TIMING.COOLDOWN . This can reduce latency and increase bus throughput.

Chip select can be asserted one system clock cycle early via MO_TIMING.SELECT_SETUP / M1_TIMING.SELECT_SETUP . Some flash devices require this setting at very high SCK frequencies. Without this setting, QMI asserts chip select one half SCK period before the first rising edge of SCK. This is simultaneous with the assertion of the first data on SDx.

Chip select hold time can also be extended by up to 3 additional system clock cycles via MO_TIMING.SELECT_HOLD / M1_TIMING.SELECT_HOLD .

To enforce a maximum amount of time that chip select can remain asserted, use MO_TIMING.MAX_SELECT / M1_TIMING.MAX_SELECT . This is useful for PSRAM devices, which must issue internal DRAM refresh cycles when deselected.

To enforce a minimum amount of time that chip select can remain de-asserted, use MO_TIMING.MIN_DESELECT / M1_TIMING.MIN_DESELECT .

12.14.3.3. Double transfer rate (DTR)

Some QSPI memory devices transfer data on both edges of SCK. This feature, known as double transfer rate (DTR) , allows a lower SCK frequency for a given data transfer rate, reducing EM emissions and the energy cost of toggling the external clock. To enable DTR mode (per-window and per-direction), set the MO_RFMT.DTR / M1_RFMT.DTR flag (for reads) or MO_WFMT.DTR / M1_WFMT.DTR (for writes).

QMI implements DTR by halving the clock frequency whilst maintaining the data rate. To achieve this, QMI inverts alternate single transfer rate SCK clock periods, transforming a low-high-low-high sequence into a low-high-high-low sequence. When DTR is disabled, the QMI launches data on SCK falling edges and captures on rising edges. When DTR is enabled, the QMI launches data at the point half-way in between two SCK edges, and captures on each edge, as shown in Figure 138 .

Figure 138. DTR is implemented by halving the SCK frequency whilst maintaining data rate.

Timing diagram for Figure 138 showing System clock, SCK (pre-inversion), Invert SCK?, SCK (post-inversion), and SD0 data. The SCK frequency is halved compared to the system clock, while the data rate on SD0 remains constant.

The diagram shows a system clock (blue) with a period of 1 unit. The SCK (pre-inversion) is a square wave with a period of 2 units. The 'Invert SCK?' signal is a square wave that is high for the first half and low for the second half of each SCK period. The SCK (post-inversion) is a square wave with a period of 2 units, inverted relative to the pre-inversion signal. The SD0 data is shown as a sequence of bits D7, D6, D5, D4, D3, D2, D1, D0, each occupying one SCK period.

Timing diagram for Figure 138 showing System clock, SCK (pre-inversion), Invert SCK?, SCK (post-inversion), and SD0 data. The SCK frequency is halved compared to the system clock, while the data rate on SD0 remains constant.

Enabling DTR mode does not change the data timing, only the SCK timing. Data is launched at the point where a SCK negative edge would be, had the clock rate not been halved.

When DTR is enabled, the prefix and dummy phase of a transfer remain single transfer rate. In these phases, data bits are doubled to match the half-rate SCK , so that new data is ready in time for each rising edge only. Figure 139 shows the first byte (the command prefix) at single transfer rate and the second byte (address and data) at double transfer rate.

Figure 139. Parts of DTR-enabled transfers are still single transfer rate: effectively each data bit is sent twice.

Timing diagram for Figure 139 showing Byte 0 (STR) and Byte 1 (DTR) transfers. It includes System clock, CSn, SCK, SD0, and SD1 signals. Byte 0 is at single transfer rate, and Byte 1 is at double transfer rate.

The diagram shows a system clock (blue) with a period of 1 unit. The CSn signal is a square wave that is high for the first half and low for the second half of each SCK period. The SCK signal is a square wave with a period of 2 units. The SD0 data is shown as a sequence of bits D7, D6, D5, D4, D3, D2, D1, D0, each occupying one SCK period. The SD1 data is shown as a sequence of bits Q7, Q6, Q5, Q4, Q3, Q2, Q1, Q0, each occupying one SCK period. The first byte (Byte 0) is at single transfer rate (STR), and the second byte (Byte 1) is at double transfer rate (DTR).

Timing diagram for Figure 139 showing Byte 0 (STR) and Byte 1 (DTR) transfers. It includes System clock, CSn, SCK, SD0, and SD1 signals. Byte 0 is at single transfer rate, and Byte 1 is at double transfer rate.

The arrows on the SCK line in Figure 139 show the active edges of SCK (where data is captured). The single transfer rate portion of the access expects data capture on the rising edge. The double transfer rate portion of the access expects data capture on both edges.

Data travelling from device to host is likewise launched on both edges of SCK . Each time the QMI launches a new clock edge, there is some delay as transitions propagate through the RP2350 pad output delay, QSPI device SCK -to- SDx delay, and back in through the RP2350 SDx pad input delays. QMI captures data simultaneously with the launch of the next SCK edge, plus any delay configured by MO_TIMING .RXDELAY/ M1_TIMING .RXDELAY. The round-trip delay from SCK output back to SDx input provides the SDx input hold time. If the input setup time is not sufficient, you can increase RXDELAY . For more information, see the specific QSPI device datasheet, as well as Section 12.14.3.4.

12.14.3.4. AC timing parameters

The QMI interface is timed using the internal system clock. Skew between different QMI pins for inputs or outputs is kept to a minimum. Any additional setup or hold time is supported by using additional clock cycle delays as mentioned in other sections. Skew values vary depending on whether we consider just the dedicated QSPI pins ( QSPI_SS , QSPI_SD[3:0] , QSPI_SCLK ) or include the Bank 0 GPIO XIP special functions (for the additional QMI chip select). Different package options have different skew timing, shown below.

Table 1291. QMI Timing skew

InterfaceTypical Skew (ps)Max Skew (ps)
QSPI input1525
QSPI output100180
Bank 0 GPIO (QFN-60) output10801725
Bank 0 GPIO (QFN-80) output12802100

It is also useful to know the delay from internal register running on system clock to output pin, and similarly the delay from input pin to the sampling register running on system clock. Table 1292 provides worst case process, voltage, and temperature timings for inputs and outputs on QSPI, and outputs on GPIO. Note that this delay varies based on the VDDIO voltage level as shown in the table.

Table 1292. QMI Timing delay

PathMax delay (ns) VDDIO=3.3VMax delay (ns) VDDIO=1.8V
QSPI input to system clock1.51.2
system clock to QSPI output2.53.6
PathMax delay (ns) VDDIO=3.3VMax delay (ns) VDDIO=1.8V
system clock to GPIO (QFN-60) output3.54.9
system clock to GPIO (QFN-80) output4.15.4

12.14.4. Address translation

QMI applies a configurable mapping from the virtual address requested by the processor or DMA to the physical address transmitted to the external QSPI device. This is performed separately for each of the 16 MB chip select windows. You cannot map contents between devices.

Each window is divided into four panes , each independently mapped onto the physical address space for that window. The default configuration applied on QMI reset, as shown in Figure 140 , is a 1:1 identity mapping between virtual and physical addresses. In this state the address mapping has no effect, and the entire 16 MB address space of the external QSPI device is mapped directly into the system address space.

Figure 140. By default, each window is set up to map the full 16 MB virtual address space directly 1:1 with the 16 MB physical address space.

Figure 140: Address translation diagram showing a 1:1 mapping between virtual and physical address spaces for Window 0.

The diagram illustrates the default 1:1 identity mapping for Window 0. At the top, a horizontal axis represents the virtual address space from 0 MB to 16 MB, divided into four 4 MB panes: Pane 0, Pane 1, Pane 2, and Pane 3. Below each pane, an arrow points to a corresponding ATRANS register: ATRANS0 (base=0, size=4M), ATRANS1 (base=4M, size=4M), ATRANS2 (base=8M, size=4M), and ATRANS3 (base=12M, size=4M). At the bottom, a single block represents the physical address space, also from 0 MB to 16 MB, which is a direct 1:1 mapping of the virtual space above it.

Figure 140: Address translation diagram showing a 1:1 mapping between virtual and physical address spaces for Window 0.

Each pane corresponds to the one of the four ATTRANSx registers for that window: ATTRANS0 through ATTRANS3 for window 0, and ATTRANS4 through ATTRANS7 for window 1.

The virtual base address of each pane is fixed and assigned in 4 MB increments. There are two configurable parameters for the mapping of that pane into physical address space:

The mapping grows from the start of the pane. A SIZE of 1 MB maps the first 1 MB of that pane’s virtual address range to downstream memory, and the remainder is unmapped. A SIZE of 0 means that no address within this virtual address pane is accessible. Accesses beyond the currently configured SIZE return a bus error, and do not pass through to the downstream QSPI bus. As a result, they have no effect on the external memory device.

Figure 141. The BASE of a pane defines where its physical mapping begins. The SIZE defines how far it extends. A SIZE of 0 means no addresses are mapped through that pane.

Figure 141: Address translation diagram showing a non-identity mapping for Window 0 where only the first 4 MB of virtual address space is mapped to a 4 MB physical address window starting at a 1 MB offset.

The diagram shows a non-identity mapping for Window 0. The virtual address space (0 MB to 16 MB) is divided into four 4 MB panes. ATRANS0 is configured with base=1M and size=4M, mapping the first 4 MB of virtual space to a physical address window from 1 MB to 5 MB. ATRANS1, ATRANS2, and ATRANS3 are all configured with size=0, meaning no addresses from those panes are mapped. The physical address space (0 MB to 16 MB) shows a shaded region from 1 MB to 5 MB, representing the mapped area, and the rest is unshaded.

Figure 141: Address translation diagram showing a non-identity mapping for Window 0 where only the first 4 MB of virtual address space is mapped to a 4 MB physical address window starting at a 1 MB offset.

Figure 141 shows an example mapping, where the first 4 MB of virtual address space for chip select 0 (virtual address offsets 0x000000 through 0x3fffff inclusive) map to a 4 MB physical address window starting at a 1 MB offset (physical address offsets 0x100000 through 0x4fffff inclusive). This mapping could be used for flash that contains a 1 MB

bootloader application followed by a 4 MB user application. Ideally, the user application should not be aware of the flash layout defined by the bootloader; that way, the same application can run under different bootloader implementations. The virtual-to-physical mapping solves this problem by making the storage location of the user application (starting at 1 MB) independent of the address it appears at in the system address space (starting at 0 MB).

12.14.4.1. Bootrom support for address translation

The bootrom can automatically configure address translation at boot time, so that a binary stored at some arbitrary location in physical flash storage can appear at a runtime flash address of 0.

This is done automatically when the booted image is inside of a flash partition (Section 5.1.2), and can be adjusted manually based on a rolling window delta specified in the IMAGE_DEF of the launched executable (Section 5.1.4).

The bootrom source code and bootrom documentation often refers to the QMI ATRANS mapping as "rolling windows", due to the modulo address wrapping on 16 MB boundaries — see Section 5.1.19.

12.14.4.2. Translation and the XIP cache

The QMI address translation is performed downstream of the system XIP cache (Section 4.4.1). Therefore, the XIP cache is a virtual cache with respect to this translation, because the address translation performed inside QMI is opaque to the XIP cache.

Consequently, changes to the QMI address translation necessitate a flush of the XIP cache. From the cache's point of view, the translation change has moved QMI memory contents around in the cache's downstream address space in a way that is incoherent with the cache contents, so a flush is required to restore coherence. At a minimum, any virtual address whose ATRANSx register ( ATRANS0 through ATRANS7) has been modified, and which may be allocated in the cache in either the clean or the dirty state, must be flushed. It may be simplest to flush the entire cache.

QMI's address mapping creates another hazard: the same physical address may map to multiple virtual addresses, and therefore may be allocated multiple times in the XIP cache. When you write to a physical address through a cached virtual address alias, the XIP cache does not propagate the change to other aliases. To avoid this issue, do not allow multiple aliases of the same writable physical address at the same instant. Aliasing read-only memory is usually safe. Aliases that exist at different points in time (for example, across an RTOS context switch boundary) can be kept coherent with appropriate cleaning and flushing when the translation is changed.

12.14.5. Direct mode

In direct mode, the AHB XIP address window is disconnected from the QSPI bus, and the bus is controlled through a TX/RX FIFO pair, similar to a normal SPI peripheral. In this state, the XIP window becomes inaccessible. Attempting to access it generates a bus fault. This mode is used for low-level access to the QSPI bus, for example when issuing flash erase/programming commands, or when accessing QSPI device status registers.

All direct-mode operation is controlled through DIRECT_CSR, with data being exchanged through DIRECT_TX and DIRECT_RX. To enable direct mode, first set DIRECT_CSR.EN, and then poll for DIRECT_CSR.BUSY to go low to ensure that any in-progress XIP transfer at the point direct mode was enabled has completed.

Direct mode has its own clock divisor and RX sampling delay, configured by DIRECT_CSR.CLKDIV and DIRECT_CSR.RXDELAY. These are separate from the per-window settings configured in MO_TIMING/M1_TIMING, because serial commands used for control purposes may have different frequency limits than data accesses used for execute-in-place.

For each push to DIRECT_TX, QMI will issue 8 or 16 bits of FIFO data to the QSPI bus. Optionally, the same number of bits are simultaneously sampled and returned in DIRECT_RX. The clock is initially low, and data is always captured on the rising edge of SCK, transitioning on the subsequent falling edge.

After pushing to DIRECT_TX, DIRECT_CSR.BUSY will go high, and remain high until all direct-mode activity has completed. This works even if no RX data is returned, so is more reliable than polling the RX FIFO status. The BUSY flag

stays high for half an SCK period after the transfer finishes, to ensure safe chip select timing when this is used to drive the chip selects — see Section 12.14.5.2 .

QMI will never push to a full RX FIFO, or drop data as a result of the FIFO being full — instead, the interface is paused until the system pops DIRECT_RX . This avoids a common trap of RX data being lost when the processor is heavily interrupted during direct-mode operation, but software must take care not to poll for DIRECT_CSR.BUSY low without also checking the RX FIFO, as this can cause a deadlock when the FIFO fills.

12.14.5.1. Controls in DIRECT_TX

The TX FIFO carries control information as well as data, with data in the 16 LSBs, and control information in the immediately more-significant bits:

The default when all control bits are zero is an 8-bit serial transfer, with 8 bits of sampled data returned. Therefore, you can ignore the control bits and treat this as a plain 8-bit data FIFO.

12.14.5.2. Chip select control

There are two options for driving the chip selects, both via DIRECT_CSR :

! IMPORTANT

The ASSERT_CSxN fields assert the chip select unconditionally , including when DIRECT_CSR.EN is clear. Software must take care not to set these fields when XIP transfers may be active.

12.14.6. List of registers

The QMI control registers start at address 0x400d0000 , defined as XIP_QMI_BASE in the SDK.

Table 1293. List of QMI registers

OffsetNameInfo
0x00DIRECT_CSRControl and status for direct serial mode

Direct serial mode allows the processor to send and receive raw serial frames, for programming, configuration and control of the external memory devices. Only SPI mode 0 (CPOL=0 CPHA=0) is supported.
0x04DIRECT_TXTransmit FIFO for direct mode
Offset 0x42fc8 0x42fcc 0x42fd0 0x42fd4 0x42fd8Name DEVID DEVTYPE PIDR4 PIDR5 PIDR6Info Device Configuration register Device Type Identifier register CoreSight Periperal ID4 CoreSight Periperal ID5 CoreSight Periperal ID6
0x08DIRECT_RXReceive FIFO for direct mode
0x0cM0_TIMINGTiming configuration register for memory address window 0.
0x10M0_RFMTRead transfer format configuration for memory address window
0x14M0_RCMDCommand constants used for reads from memory address window 0.
0x18M0_WFMTWrite transfer format configuration for memory address window
0x1cM0_WCMDCommand constants used for writes to memory address window
0x20M1_TIMINGTiming configuration register for memory address window 1.
0x24M1_RFMTRead transfer format configuration for memory address window
0x28M1_RCMDCommand constants used for reads from memory address window 1.
0x2cM1_WFMTWrite transfer format configuration for memory address window
0x30M1_WCMDCommand constants used for writes to memory address window
0x34ATRANS0Configure address translation for XIP virtual addresses 0x000000 through 0x3fffff (a 4 MiB window starting at +0 MiB).
0x38ATRANS1Configure address translation for XIP virtual addresses 0x400000 through 0x7fffff (a 4 MiB window starting at +4 MiB).
0x3cATRANS2Configure address translation for XIP virtual addresses 0x800000 through 0xbfffff (a 4 MiB window starting at +8 MiB).
0x40ATRANS3Configure address translation for XIP virtual addresses 0xc00000 through 0xffffff (a 4 MiB window starting at +12 MiB).
0x44ATRANS4Configure address translation for XIP virtual addresses 0x1000000 through 0x13fffff (a 4 MiB window starting at +16 MiB).
0x48ATRANS5Configure address translation for XIP virtual addresses 0x1400000 through 0x17fffff (a 4 MiB window starting at +20 MiB).
0x4cATRANS6Configure address translation for XIP virtual addresses 0x1800000 through 0x1bfffff (a 4 MiB window starting at +24 MiB).
0x50ATRANS7Configure address translation for XIP virtual addresses 0x1c00000 through 0x1ffffff (a 4 MiB window starting at +28 MiB).

QMI: DIRECT_CSR Register

Offset: 0x00

Description

Control and status for direct serial mode

Direct serial mode allows the processor to send and receive raw serial frames, for programming, configuration and control of the external memory devices. Only SPI mode 0 (CPOL=0 CPHA=0) is supported.

Table 1294.
DIRECT_CSR Register

Bits 31:0 Bits 31:0 Bits 31:28column_2Description Description Input value for GPIO0…31. Description QSPI_SD : Input value on QSPI SD0 (MOSI), SD1 (MISO), SD2 and SD3 pinsType RO Type RO Type ROReset - Reset 0x00000000 Reset 0x0
21Reserved.--
20:18RXLEVEL: Current level of DIRECT_RX FIFORO0x0
17RXFULL: When 1, the DIRECT_RX FIFO is currently full. The serial interface will when the DIRECT_TX FIFO is empty or the DIRECT_RX FIFO is full.RO0x0
16RXEMPTY: When 1, the DIRECT_RX FIFO is currently empty. If the processor attempts to read more data, the FIFO state is not affected, but the value returned to the processor is undefined.RO0x0
15Reserved.--
14:12TXLEVEL: Current level of DIRECT_TX FIFORO0x0
11TXEMPTY: When 1, the DIRECT_TX FIFO is currently empty. Unless the processor pushes more data, transmission will stop and BUSY will go low once the current 8-bit serial frame completes.RO0x0
10TXFULL: When 1, the DIRECT_TX FIFO is currently full. If the processor tries to write more data, that data will be ignored.RO0x0
9:8Reserved.--
7AUTO_CS1N: When 1, automatically assert the CS1n chip select line whenever the BUSY flag is set.RW0x0
6AUTO_CS0N: When 1, automatically assert the CS0n chip select line whenever the BUSY flag is set.RW0x0
5:4Reserved.--
3ASSERT_CS1N: When 1, assert (i.e. drive low) the CS1n chip select line. Note that this applies even when DIRECT_CSR_EN is 0.RW0x0
2ASSERT_CS0N: When 1, assert (i.e. drive low) the CS0n chip select line. Note that this applies even when DIRECT_CSR_EN is 0.RW0x0
BitsDescriptionTypeReset
1

BUSY: Direct mode busy flag. If 1, data is currently being shifted in/out (or would be if the interface were not stalled on the RX FIFO), and the chip select must not yet be deasserted.

The busy flag will also be set to 1 if a memory-mapped transfer is still in progress when direct mode is enabled. Direct mode blocks new memory-mapped transfers, but can't halt a transfer that is already in progress. If there is a chance that memory-mapped transfers may be in progress, the busy flag should be polled for 0 before asserting the chip select.

(In practice you will usually discover this timing condition through other means, because any subsequent memory-mapped transfers when direct mode is enabled will return bus errors, which are difficult to ignore.)

RO0x0
0

EN: Enable direct mode.

In direct mode, software controls the chip select lines, and can perform direct SPI transfers by pushing data to the DIRECT_TX FIFO, and popping the same amount of data from the DIRECT_RX FIFO.

Memory-mapped accesses will generate bus errors when direct serial mode is enabled.

RW0x0

QMI: DIRECT_TX Register

Offset: 0x04

Description

Transmit FIFO for direct mode

Table 1295.
DIRECT_TX Register

BitsDescriptionTypeReset
31:21Reserved.--
20

NOPUSH: Inhibit the RX FIFO push that would correspond to this TX FIFO entry.

Useful to avoid garbage appearing in the RX FIFO when pushing the command at the beginning of a SPI transfer.

WF0x0
19

OE: Output enable (active-high). For single width (SPI), this field is ignored, and SD0 is always set to output, with SD1 always set to input.

For dual and quad width (DSPI/QSPI), this sets whether the relevant SDx pads are set to output whilst transferring this FIFO record. In this case the command/address should have OE set, and the data transfer should have OE set or clear depending on the direction of the transfer.

WF0x0
18

DWIDTH: Data width. If 0, hardware will transmit the 8 LSBs of the DIRECT_TX DATA field, and return an 8-bit value in the 8 LSBs of DIRECT_RX. If 1, the full 16-bit width is used. 8-bit and 16-bit transfers can be mixed freely.

WF0x0
17:16

IWIDTH: Configure whether this FIFO record is transferred with single/dual/quad interface width (0/1/2). Different widths can be mixed freely.

WF0x0
Enumerated values:
0x0 → S: Single width
BitsDescriptionTypeReset
0x1 → D: Dual width
0x2 → Q: Quad width
15:0DATA: Data pushed here will be clocked out falling edges of SCK (or before the very first rising edge of SCK, if this is the first pulse). For each byte clocked out, the interface will simultaneously sample one byte, on rising edges of SCK, and push this to the DIRECT_RX FIFO.

For 16-bit data, the least-significant byte is transmitted first.
WF0x0000

QMI: DIRECT_RX Register

Offset: 0x08

Description

Receive FIFO for direct mode

Table 1296.
DIRECT_RX Register

BitsDescriptionTypeReset
31:16Reserved.--
15:0With each byte clocked out on the serial interface, one byte will simultaneously be clocked in, and will appear in this FIFO. The serial interface will stall when this FIFO is full, to avoid dropping data.

When 16-bit data is pushed into the TX FIFO, the corresponding RX FIFO push will also contain 16 bits of data. The least-significant byte is the first one received.
RF0x0000

QMI: M0_TIMING, M1_TIMING Registers

Offsets: 0x0c, 0x20

Description

Timing configuration register for memory address window 0/1.

Table 1297.
M0_TIMING,
M1_TIMING Registers

BitsDescriptionTypeReset
31:30COOLDOWN: Chip select cooldown period. When a memory transfer finishes, the chip select remains asserted for 64 x COOLDOWN system clock cycles, plus half an SCK clock period (rounded up for odd SCK divisors). After this cooldown expires, the chip select is always deasserted to save power.

If the next memory access arrives within the cooldown period, the QMI may be able to append more SCK cycles to the currently ongoing SPI transfer, rather than starting a new transfer. This reduces access latency and increases bus throughput.

Specifically, the next access must be in the same direction (read/write), access the same memory window (chip select 0/1), and follow sequentially the address of the last transfer. If any of these are false, the new access will first deassert the chip select, then begin a new transfer.

If COOLDOWN is 0, the address alignment configured by PAGEBREAK has been reached, or the total chip select assertion limit MAX_SELECT has been reached, the cooldown period is skipped, and the chip select will always be deasserted one half SCK period after the transfer finishes.
RW0x1
BitsDescriptionTypeReset
29:28

PAGEBREAK: When page break is enabled, chip select will automatically deassert when crossing certain power-of-2-aligned address boundaries. The next access will always begin a new read/write SPI burst, even if the address of the next access follows in sequence with the last access before the page boundary.

Some flash and PSRAM devices forbid crossing page boundaries with a single read/write transfer, or restrict the operating frequency for transfers that do cross page a boundary. This option allows the QMI to safely support those devices.

This field has no effect when COOLDOWN is disabled.

RW0x0
Enumerated values:
0x0 → NONE: No page boundary is enforced
0x1 → 256: Break bursts crossing a 256-byte page boundary
0x2 → 1024: Break bursts crossing a 1024-byte quad-page boundary
0x3 → 4096: Break bursts crossing a 4096-byte sector boundary
27:26Reserved.--
25

SELECT_SETUP: Add up to one additional system clock cycle of setup between chip select assertion and the first rising edge of SCK.

The default setup time is one half SCK period, which is usually sufficient except for very high SCK frequencies with some flash devices.

RW0x0
24:23

SELECT_HOLD: Add up to three additional system clock cycles of active hold between the last falling edge of SCK and the deassertion of this window's chip select.

The default hold time is one system clock cycle. Note that flash datasheets usually give chip select active hold time from the last rising edge of SCK, and so even zero hold from the last falling edge would be safe.

Note that this is a minimum hold time guaranteed by the QMI: the actual chip select active hold may be slightly longer for read transfers with low clock divisors and/or high sample delays. Specifically, if the point two cycles after the last RX data sample is later than the last SCK falling edge, then the hold time is measured from this point.

Note also that, in case the final SCK pulse is masked to save energy (true for non-DTR reads when COOLDOWN is disabled or PAGE_BREAK is reached), all of QMI's timing logic behaves as though the clock pulse were still present. The SELECT_HOLD time is applied from the point where the last SCK falling edge would be if the clock pulse were not masked.

RW0x0
BitsDescriptionTypeReset
22:17

MAX_SELECT: Enforce a maximum assertion duration for this window's chip select, in units of 64 system clock cycles. If 0, the QMI is permitted to keep the chip select asserted indefinitely when servicing sequential memory accesses (see COOLDOWN).

This feature is required to meet timing constraints of PSRAM devices, which specify a maximum chip select assertion so they can perform DRAM refresh cycles. See also MIN_DESELECT, which can enforce a minimum deselect time.

If a memory access is in progress at the time MAX_SELECT is reached, the QMI will wait for the access to complete before deasserting the chip select. This additional time must be accounted for to calculate a safe MAX_SELECT value. In the worst case, this may be a fully-formed serial transfer, including command prefix and address, with a data payload as large as one cache line.

RW0x00
16:12

MIN_DESELECT: After this window's chip select is deasserted, it remains deasserted for half an SCK cycle (rounded up to an integer number of system clock cycles), plus MIN_DESELECT additional system clock cycles, before the QMI reasserts either chip select pin.

Nonzero values may be required for PSRAM devices which enforce a longer minimum CS deselect time, so that they can perform internal DRAM refresh cycles whilst deselected.

RW0x00
11Reserved.--
10:8

RXDELAY: Delay the read data sample timing, in units of one half of a system clock cycle. (Not necessarily half of an SCK cycle.) An RXDELAY of 0 means the sample is captured at the SDI input registers simultaneously with the rising edge of SCK launched from the SCK output register.

At higher SCK frequencies, RXDELAY may need to be increased to account for the round trip delay of the pads, and the clock-to-Q delay of the QSPI memory device.

RW0x0
7:0

CLKDIV: Clock divisor. Odd and even divisors are supported. Defines the SCK clock period in units of 1 system clock cycle. Divisors 1..255 are encoded directly, and a divisor of 256 is encoded with a value of CLKDIV=0.

The clock divisor can be changed on-the-fly, even when the QMI is currently accessing memory in this address window. All other parameters must only be changed when the QMI is idle.

If software is increasing CLKDIV in anticipation of an increase in the system clock frequency, a dummy access to either memory window (and appropriate processor barriers/fences) must be inserted after the Mx_TIMING write to ensure the SCK divisor change is in effect before the system clock is changed.

RW0x04

QMI: M0_RFMT, M1_RFMT Registers

Offsets: 0x10, 0x24

Description

Read transfer format configuration for memory address window 0/1.

Configure the bus width of each transfer phase individually, and configure the length or presence of the command prefix, command suffix and dummy/turnaround transfer phases. Only 24-bit addresses are supported.

The reset value of the Mx_RFMT register is configured to support a basic 03h serial read transfer with no additional configuration.

Table 1298.
M0_RFMT, M1_RFMT
Registers

BitsDescriptionTypeReset
31:29Reserved.--
28

DTR : Enable double transfer rate (DTR) for read commands: address, suffix and read data phases are active on both edges of SCK. SDO data is launched centre-aligned on each SCK edge, and SDI data is captured on the SCK edge that follows its launch.

DTR is implemented by halving the clock rate; SCK has a period of 2 x CLK_DIV throughout the transfer. The prefix and dummy phases are still single transfer rate.

If the suffix is quad-width, it must be 0 or 8 bits in length, to ensure an even number of SCK edges.

RW0x0
27:19Reserved.--
18:16

DUMMY_LEN : Length of dummy phase between command suffix and data phase, in units of 4 bits. (i.e. 1 cycle for quad width, 2 for dual, 4 for single)

RW0x0
Enumerated values:
0x0 → NONE: No dummy phase
0x1 → 4: 4 dummy bits
0x2 → 8: 8 dummy bits
0x3 → 12: 12 dummy bits
0x4 → 16: 16 dummy bits
0x5 → 20: 20 dummy bits
0x6 → 24: 24 dummy bits
0x7 → 28: 28 dummy bits
15:14

SUFFIX_LEN : Length of post-address command suffix, in units of 4 bits. (i.e. 1 cycle for quad width, 2 for dual, 4 for single)

Only values of 0 and 8 bits are supported.

RW0x0
Enumerated values:
0x0 → NONE: No suffix
0x2 → 8: 8-bit suffix
13Reserved.--
12

PREFIX_LEN : Length of command prefix, in units of 8 bits. (i.e. 2 cycles for quad width, 4 for dual, 8 for single)

RW0x1
Enumerated values:
0x0 → NONE: No prefix
0x1 → 8: 8-bit prefix
11:10Reserved.--
9:8DATA_WIDTH : The width used for the data transferRW0x0
BitsDescriptionTypeReset
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
7:6DUMMY_WIDTH : The width used for the dummy phase, if any.

If width is single, SD0/MOSI is held asserted low during the dummy phase, and SD1...SD3 are tristated. If width is dual/quad, all IOs are tristated during the dummy phase.
RW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
5:4SUFFIX_WIDTH : The width used for the post-address command suffix, if anyRW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
3:2ADDR_WIDTH : The transfer width used for the address. The address phase always transfers 24 bits in total.RW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
1:0PREFIX_WIDTH : The transfer width used for the command prefix, if anyRW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width

QMI: M0_RCMD, M1_RCMD Registers

Offsets: 0x14, 0x28

Description

Command constants used for reads from memory address window 0/1.

The reset value of the Mx_RCMD register is configured to support a basic 03h serial read transfer with no additional configuration.

Table 1299.
M0_RCMD, M1_RCMD
Registers

BitsDescriptionTypeReset
31:16Reserved.--
BitsDescriptionTypeReset
15:8SUFFIX: The command suffix bits following the address, if Mx_RFMT_SUFFIX_LEN is nonzero.RW0xa0
7:0PREFIX: The command prefix bits to prepend on each new transfer, if Mx_RFMT_PREFIX_LEN is nonzero.RW0x03

QMI: M0_WFMT, M1_WFMT Registers

Offsets: 0x18, 0x2c

Description

Write transfer format configuration for memory address window 0/1.

Configure the bus width of each transfer phase individually, and configure the length or presence of the command prefix, command suffix and dummy/turnaround transfer phases. Only 24-bit addresses are supported.

The reset value of the Mx_WFMT register is configured to support a basic 02h serial write transfer. However, writes to this window must first be enabled via the XIP_CTRL_WRITABLE_Mx bit for this window, as XIP memory is read-only by default.

Table 1300.
M0_WFMT, M1_WFMT
Registers

BitsDescriptionTypeReset
31:29Reserved.--
28

DTR: Enable double transfer rate (DTR) for write commands: address, suffix and write data phases are active on both edges of SCK. SDO data is launched centre-aligned on each SCK edge, and SDI data is captured on the SCK edge that follows its launch.

DTR is implemented by halving the clock rate; SCK has a period of 2 x CLK_DIV throughout the transfer. The prefix and dummy phases are still single transfer rate.

If the suffix is quad-width, it must be 0 or 8 bits in length, to ensure an even number of SCK edges.

RW0x0
27:19Reserved.--
18:16

DUMMY_LEN: Length of dummy phase between command suffix and data phase, in units of 4 bits. (i.e. 1 cycle for quad width, 2 for dual, 4 for single)

RW0x0
Enumerated values:
0x0 → NONE: No dummy phase
0x1 → 4: 4 dummy bits
0x2 → 8: 8 dummy bits
0x3 → 12: 12 dummy bits
0x4 → 16: 16 dummy bits
0x5 → 20: 20 dummy bits
0x6 → 24: 24 dummy bits
0x7 → 28: 28 dummy bits
15:14

SUFFIX_LEN: Length of post-address command suffix, in units of 4 bits. (i.e. 1 cycle for quad width, 2 for dual, 4 for single)

Only values of 0 and 8 bits are supported.

RW0x0
BitsDescriptionTypeReset
Enumerated values:
0x0 → NONE: No suffix
0x2 → 8: 8-bit suffix
13Reserved.--
12PREFIX_LEN : Length of command prefix, in units of 8 bits. (i.e. 2 cycles for quad width, 4 for dual, 8 for single)RW0x1
Enumerated values:
0x0 → NONE: No prefix
0x1 → 8: 8-bit prefix
11:10Reserved.--
9:8DATA_WIDTH : The width used for the data transferRW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
7:6DUMMY_WIDTH : The width used for the dummy phase, if any.

If width is single, SD0/MOSI is held asserted low during the dummy phase, and SD1...SD3 are tristated. If width is dual/quad, all IOs are tristated during the dummy phase.
RW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
5:4SUFFIX_WIDTH : The width used for the post-address command suffix, if anyRW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
3:2ADDR_WIDTH : The transfer width used for the address. The address phase always transfers 24 bits in total.RW0x0
Enumerated values:
0x0 → S: Single width
0x1 → D: Dual width
0x2 → Q: Quad width
1:0PREFIX_WIDTH : The transfer width used for the command prefix, if anyRW0x0
Enumerated values:
0x0 → S: Single width
BitsDescriptionTypeReset
0x1 → D: Dual width
0x2 → Q: Quad width

QMI: M0_WCMD, M1_WCMD Registers

Offsets: 0x1c, 0x30

Description

Command constants used for writes to memory address window 0/1.

The reset value of the Mx_WCMD register is configured to support a basic 02h serial write transfer with no additional configuration.

Table 1301.
M0_WCMD,
M1_WCMD Registers

BitsDescriptionTypeReset
31:16Reserved.--
15:8SUFFIX: The command suffix bits following the address, if Mx_WFMT_SUFFIX_LEN is nonzero.RW0xa0
7:0PREFIX: The command prefix bits to prepend on each new transfer, if Mx_WFMT_PREFIX_LEN is nonzero.RW0x02

QMI: ATRANS0, ATRANS4 Registers

Offsets: 0x34, 0x44

Description

Configure address translation for a 4 MiB window of XIP virtual addresses starting at \( n \times 4 \) MiB.

Address translation allows a program image to be executed in place at multiple physical flash addresses (for example, a double-buffered flash image for over-the-air updates), without the overhead of position-independent code.

At reset, the address translation registers are initialised to an identity mapping, so that they can be ignored if address translation is not required.

Note that the XIP cache is fully virtually addressed, so a cache flush is required after changing the address translation.

Table 1302. ATRANS0,
ATrans4 Registers

BitsDescriptionTypeReset
31:27Reserved.--
26:16SIZE: Translation aperture size for this virtual address range, in units of 4 kiB (one flash sector).

Bits 21:12 of the virtual address are compared to SIZE. Offsets greater than SIZE return a bus error, and do not cause a QSPI access.
RW0x400
15:12Reserved.--
11:0BASE: Physical address base for this virtual address range, in units of 4 kiB (one flash sector).

Taking a 24-bit virtual address, firstly bits 23:22 (the two MSBs) are masked to zero, and then BASE is added to bits 23:12 (the upper 12 bits) to form the physical address. Translation wraps on a 16 MiB boundary.
RW0x000

QMI: ATRANS1, ATRANS5 Registers

Offsets: 0x38, 0x48

Description

Configure address translation for XIP virtual addresses 0x400000 through 0x7fffff (a 4 MiB window starting at +4 MiB).

Address translation allows a program image to be executed in place at multiple physical flash addresses (for example, a double-buffered flash image for over-the-air updates), without the overhead of position-independent code.

At reset, the address translation registers are initialised to an identity mapping, so that they can be ignored if address translation is not required.

Note that the XIP cache is fully virtually addressed, so a cache flush is required after changing the address translation.

Table 1303. ATRANS1, ATRANS5 Registers

BitsDescriptionTypeReset
31:27Reserved.--
26:16SIZE: Translation aperture size for this virtual address range, in units of 4 kiB (one flash sector).

Bits 21:12 of the virtual address are compared to SIZE. Offsets greater than SIZE return a bus error, and do not cause a QSPI access.
RW0x400
15:12Reserved.--
11:0BASE: Physical address base for this virtual address range, in units of 4 kiB (one flash sector).

Taking a 24-bit virtual address, firstly bits 23:22 (the two MSBs) are masked to zero, and then BASE is added to bits 23:12 (the upper 12 bits) to form the physical address. Translation wraps on a 16 MiB boundary.
RW0x400

QMI: ATRANS2, ATRANS6 Registers

Offsets: 0x3c, 0x4c

Description

Configure address translation for XIP virtual addresses 0x800000 through 0xbfffff (a 4 MiB window starting at +8 MiB).

Address translation allows a program image to be executed in place at multiple physical flash addresses (for example, a double-buffered flash image for over-the-air updates), without the overhead of position-independent code.

At reset, the address translation registers are initialised to an identity mapping, so that they can be ignored if address translation is not required.

Note that the XIP cache is fully virtually addressed, so a cache flush is required after changing the address translation.

Table 1304. ATRANS2, ATRANS6 Registers

BitsDescriptionTypeReset
31:27Reserved.--
26:16SIZE: Translation aperture size for this virtual address range, in units of 4 kiB (one flash sector).

Bits 21:12 of the virtual address are compared to SIZE. Offsets greater than SIZE return a bus error, and do not cause a QSPI access.
RW0x400
15:12Reserved.--
BitsDescriptionTypeReset
11:0BASE: Physical address base for this virtual address range, in units of 4 kiB (one flash sector).

Taking a 24-bit virtual address, firstly bits 23:22 (the two MSBs) are masked to zero, and then BASE is added to bits 23:12 (the upper 12 bits) to form the physical address. Translation wraps on a 16 MiB boundary.
RW0x800

QMI: ATRANS3, ATRANS7 Registers

Offsets: 0x40, 0x50

Description

Configure address translation for XIP virtual addresses 0xc00000 through 0xffffffff (a 4 MiB window starting at +12 MiB).

Address translation allows a program image to be executed in place at multiple physical flash addresses (for example, a double-buffered flash image for over-the-air updates), without the overhead of position-independent code.

At reset, the address translation registers are initialised to an identity mapping, so that they can be ignored if address translation is not required.

Note that the XIP cache is fully virtually addressed, so a cache flush is required after changing the address translation.

Table 1305. ATRANS3, ATRANS7 Registers

BitsDescriptionTypeReset
31:27Reserved.--
26:16SIZE: Translation aperture size for this virtual address range, in units of 4 kiB (one flash sector).

Bits 21:12 of the virtual address are compared to SIZE. Offsets greater than SIZE return a bus error, and do not cause a QSPI access.
RW0x400
15:12Reserved.--
11:0BASE: Physical address base for this virtual address range, in units of 4 kiB (one flash sector).

Taking a 24-bit virtual address, firstly bits 23:22 (the two MSBs) are masked to zero, and then BASE is added to bits 23:12 (the upper 12 bits) to form the physical address. Translation wraps on a 16 MiB boundary.
RW0xc00