31. Mass storage interfaces

31.1 Overview

STM32MP21xx devices embed three types of mass storage interfaces:

31.2 FMC interface

The FMC is compliant with the RIF (resource isolation framework). See Section 32: Flexible memory controller (FMC).

Main features of the FMC interface

31.2.1 FMC interface block diagram

Figure 163. FMC interface block diagram

FMC interface block diagram

The diagram shows the FMC interface internal and external connections. Major blocks include RCC supplying clock signals (ck_ker_fmc -> kclk, ck_icn_s_fmc -> aclk, ck_icn_p_fmc -> hclk) to FMC; SoC Interconnect interfacing via AHB Slave and AXI Slave; IAC (RIF Illegal Access Controller) receiving illegal access signals (h*_ilac, a*_ilac); HPDMA communicating via dmareq/dmaack pairs for FMC_TXRX and FMC_BCH; interrupt outputs nd_int[1] (fmc_gbl_it) to CPU1 GIC and nd_int[2] (fmc_gbl_it) to CPU2 NVIC; and external pins including FMC_CLK, FMC_NE[4:1], FMC_NBL[1:0], FMC_NL, FMC_A[25:18], FMC_A17/FMC_ALE, FMC_A16/FMC_CLE, FMC_NCE[4:1], FMC_AD[15:0] / FMC_D[15:0], FMC_NWE, FMC_NOE, FMC_NWAIT, FMC_RNB along with internal nd_rnb[0] and nd_rnb[3:1] tied to 0.

FMC interface block diagram

31.2.2 FMC interface reset

Figure 164. FMC interface reset

FMC interface reset diagram

The diagram shows the RCC block with FMCRST generating the rstn_fmc signal which drives the active-low RESETn input of the FMC block (MSv66527V1).

FMC interface reset diagram

There is only one reset for the FMC interface (rstn_fmc) which is controlled by FMCRST in RCC_FMCCFGR register.

31.2.3 FMC interface interrupt

The FMC generates two interrupts, one for each CID that can be attached to the NAND controller:

Table 207. FMC interface interrupts

FMC signal nameCPU1 interruptCPU2 interrupt
nd_int[1]fmc_gbl_it-
nd_int[2]-fmc_gbl_it

31.3 Octo-SPI interface

The Octo-SPI interface offers one OCTOSPI physical port. Accesses to the OCTOSPI controller are protected by RISUP components.

31.3.1 Main features of the Octo-SPI interface

For a complete list of features, refer to:

31.3.2 Octo-SPI interface block diagram

Figure 165. Octo-SPI interface block diagram

Figure 165. Octo-SPI interface block diagram

A detailed block diagram of the Octo-SPI interface containing:

MSv73180V2

Figure 165. Octo-SPI interface block diagram

OCTOSPI1 is the memory controller. It can be accessed by either CPU1 or CPU2. It provides 1 chip select which can be mapped on OCTOSPI_NCS1 or OCTOSPI_NCS2 depending on CSSEL setting.

OTFDEC1 is in charge of on-the-fly decryption of data read from the external memory devices.

DLYBOS1 is a DLL-based programmable delay which allows to tune the phase of the RX sampling clock and the TX launch clock.

31.3.3 Octo-SPI interface resets

Figure 166. OCTOSPI interface resets

Block diagram of OCTOSPI interface resets showing the relationship between RCC, DLYBOS1, OCTOSPI1, and OTFDEC1.

The diagram illustrates the reset logic for the OCTOSPI interface. It is divided into two main sections: the RCC (Reset and Clock Control) block on the left and a dashed box on the right containing the DLYBOS1, OCTOSPI1, and OTFDEC1 blocks.

MSv73182V1

Block diagram of OCTOSPI interface resets showing the relationship between RCC, DLYBOS1, OCTOSPI1, and OTFDEC1.

There are three independent resets for the OCTOSPI interface:

When configuring the OCTOSPI interface, the reset sequence to be applied is:

  1. 1. At device reset, OSPI1DLLRST, OSPI1RST, OTFDEC1RST are all 0. DLYBOS1, OCTOSPI1, OTFDEC1 are under reset because their clocks are disabled.
  2. 2. Set OSPI1EN. This activates the peripheral clock of OCTOSPI1 and OTFDEC1 and releases their resets.
  3. 3. Configure the OCTOSPI1 controller and OTFDEC1 engine.
  4. 4. For configurations where the programmable delays must be used:
    1. a) Wait for the DLL to be locked. This is indicated by the bit LOCK in SYSCFG_DLYBOS1SR register.
    2. b) Perform a training sequence to determine which delay values correspond to the middle of the valid window for RX sampling (and possibly Tx launching)

For configurations where the programmable delay is not needed, DLYBOS1 can be maintained under reset by setting OSPI1DLLRST to 1.

31.3.4 Octo-SPI interface memory

256 MBytes are allocated in STM32MP21xx memory map for OCTOSPI1. This area is used when OCTOSPI1 is operating in memory-mapped mode.

31.3.5 OCTOSPI1 description

Refer to Section 33: Octo-SPI interface (OCTOSPI).

31.3.6 OTFDEC1 description

Refer to Section 51: On-the-fly decryption engine (OTFDEC).

31.3.7 DLYBOS1 description

Refer to Section 35: Delay block (DLYB)

The programmable delay is used to tune the phase of:

The programmable delay block is based on a DLL that compensates for voltage and temperature variations. The DLL features 32 taps and covers the [50 MHz, 208 MHz] frequency range. The clock on which the DLL locks is a free running clock provided by the OCTOSPI. This clock is at the same frequency as the clock sent to the memory. When OCTOSPI1 interface operates below 50 MHz, either the programmable delay is not used (standard case), or it must be used in bypass mode (case of OCTOSPI devices with DQS strobe).

Figure 167. Programmable delay block diagram

Block diagram of the DLYBOSx programmable delay block. The diagram shows the internal structure of the DLYBOSx block, which includes a Master Delay Line, a Phase Comparator, a Digital Control unit, and RX/TX Delay Lines. The Master Delay Line has 32 taps. The Phase Comparator compares the Master Delay Line output with the input clock (dll_clk) and provides up/down control signals to the Digital Control unit. The Digital Control unit receives commands (dll_start_lock, dll_bypass_cmd[4:0], dll_bypass_cmd_en) and feedback (dll_locked, rx_ph_select_ack, tx_ph_select_ack) from the SYSCFG block. It also receives rx_ph_select[5:0] and tx_ph_select[5:0] for phase selection. The RX Delay Line and TX Delay Line each have 32 taps and are controlled by the Digital Control unit. The RX Delay Line takes rx_ip_clk as input and produces rx_op_clk as output. The TX Delay Line takes tx_ip_clk as input and produces tx_op_clk as output. The SYSCFG block is shown as an external interface to the DLYBOSx block.
Block diagram of the DLYBOSx programmable delay block. The diagram shows the internal structure of the DLYBOSx block, which includes a Master Delay Line, a Phase Comparator, a Digital Control unit, and RX/TX Delay Lines. The Master Delay Line has 32 taps. The Phase Comparator compares the Master Delay Line output with the input clock (dll_clk) and provides up/down control signals to the Digital Control unit. The Digital Control unit receives commands (dll_start_lock, dll_bypass_cmd[4:0], dll_bypass_cmd_en) and feedback (dll_locked, rx_ph_select_ack, tx_ph_select_ack) from the SYSCFG block. It also receives rx_ph_select[5:0] and tx_ph_select[5:0] for phase selection. The RX Delay Line and TX Delay Line each have 32 taps and are controlled by the Digital Control unit. The RX Delay Line takes rx_ip_clk as input and produces rx_op_clk as output. The TX Delay Line takes tx_ip_clk as input and produces tx_op_clk as output. The SYSCFG block is shown as an external interface to the DLYBOSx block.

The DLL architecture is based on one master delay line, and two slave delay lines (RX and TX). There are two operating modes:

Table 208. RX and TX delays in lock mode

rx_ph_select[5:0] (respectively tx_ph_select[5:0])RX delay (respectively TX delay)
0000000
0000011/32 x T(dll_clk)
......
01111131/32 x T(dll_clk)
10000032/32 x T(dll_clk)
Table 209. Number of delay elements enabled in each delay unit
dll_bypass_cmd[4:0]Number of delay elements enabled
00000reserved
000011 delay element is enabled
000102 delay elements are enabled
......
11000 to 11111All 24 delay elements are enabled

31.3.8 Octo-SPI interface interrupts

OCTOSPI1 and OTFDEC1 generate one interrupt.

Table 210. Octo-SPI interface interrupts
PeripheralSignal nameCPU1 interruptCPU2 interrupt
OCTOSPI1it_ospoctospi1_itoctospi1_it
OTFDEC1irqotfdec1_itotfdec1_it

31.3.9 Chip select management

The chip select signal provided by the OCTOSPI controller is mapped on OCTOSPI_NCS1 or OCTOSPI_NCS2 depending on the value of CSSEL bit in OCTOSPI_CR register.

Table 211. OCTOSPI1 CS mapping
OCTOSPI1 CSSELOCTOSPI1 CS mapped on
0OCTOSPI_NCS1
1OCTOSPI_NCS2

Note: It is possible to connect 2 flash devices to the OCTOSPI interface and control them both by the OCTOSPI controller. However, the two devices cannot be used simultaneously. Switching from one device to the other requires to:

The figure below gives an example of this possibility where two 8-bit devices are attached to the OCTOSPI interface.

Figure 168. Flash configuration example:
2× 8-bit flash devices connected to the OCTOSPI interface

Schematic diagram of two 8-bit flash devices connected to the OCTOSPI interface. The OCTOSPI1 block outputs OCTOSPI_NCLK (buffered), OCTOSPI_CLK, OCTOSPI_IO[7:0], and OCTOSPI_DQS. These connect to Device 1 and Device 2. Device 1 uses OCTOSPI_NCS1 as its chip select. Device 2 uses OCTOSPI_NCS2 as its chip select. The afo_ncs and afo_CSSEL signals control multiplexers that route the chip select signals. A table on the left explains the CSSEL mapping: 0 maps to OCTOSPI_NCS1 ( Device 1 active), and 1 maps to OCTOSPI_NCS2 ( Device 2 active).

OCTOSPI1 CSSEL value

0:chip select is mapped to OCTOSPI_NCS1.
OCTOSPI_NCS2 is inactive. Device1 can be selected.
1:chip select is mapped to OCTOSPI_NCS2.
OCTOSPI_NCS1 is inactive. Device2 can be selected.

OCTOSPI1

afo_ncs

afo_CSSEL

OCTOSPI_NCLK

OCTOSPI_CLK

OCTOSPI_IO[7:0]

OCTOSPI_DQS

OCTOSPI_NCS1

OCTOSPI_NCS2

Device 1

clock

data

data strobe

chip select

Device 2

data strobe

data

clock

chip select

MSv73181V1

Schematic diagram of two 8-bit flash devices connected to the OCTOSPI interface. The OCTOSPI1 block outputs OCTOSPI_NCLK (buffered), OCTOSPI_CLK, OCTOSPI_IO[7:0], and OCTOSPI_DQS. These connect to Device 1 and Device 2. Device 1 uses OCTOSPI_NCS1 as its chip select. Device 2 uses OCTOSPI_NCS2 as its chip select. The afo_ncs and afo_CSSEL signals control multiplexers that route the chip select signals. A table on the left explains the CSSEL mapping: 0 maps to OCTOSPI_NCS1 ( Device 1 active), and 1 maps to OCTOSPI_NCS2 ( Device 2 active).

The OCTOSPI interface also supports dual-quad mode. In dual quad mode, two 4-bit devices are connected to the same chip select in order to provide a throughput similar to an 8-bit device. This mode is configured by the bit DQM in OCTOSPI_CR register. An example is shown in the figure below.

Figure 169. Flash configuration example: dual quad mode.
Two 4-bit devices are connected to the same Chip Select of the OCTOSPI interface

Schematic diagram of OCTOSPI1 interface configuration for dual quad mode. The OCTOSPI1 block has pins: OCTOSPI_NCLK, OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], OCTOSPI_DQS, OCTOSPI_NCS1, and OCTOSPI_NCS2. It also has internal control pins afo_ncs and afo_CSSEL. OCTOSPI_NCLK is connected to an inverter. OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], and OCTOSPI_DQS are connected to Quad device 1. OCTOSPI_NCS1 and OCTOSPI_NCS2 are connected to Quad device 2. The afo_ncs and afo_CSSEL pins are connected to a 2-to-1 multiplexer. The multiplexer's output is connected to OCTOSPI_NCS1. The multiplexer's select input is connected to afo_CSSEL. The multiplexer's other input is connected to a constant '1'.

OCTOSPI1 DQM = 1

OCTOSPI1 CSSEL = 0: OCTOSPI1 Chip Select is mapped to OCTOSPI_NCS1.

MSv72203V1

Schematic diagram of OCTOSPI1 interface configuration for dual quad mode. The OCTOSPI1 block has pins: OCTOSPI_NCLK, OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], OCTOSPI_DQS, OCTOSPI_NCS1, and OCTOSPI_NCS2. It also has internal control pins afo_ncs and afo_CSSEL. OCTOSPI_NCLK is connected to an inverter. OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], and OCTOSPI_DQS are connected to Quad device 1. OCTOSPI_NCS1 and OCTOSPI_NCS2 are connected to Quad device 2. The afo_ncs and afo_CSSEL pins are connected to a 2-to-1 multiplexer. The multiplexer's output is connected to OCTOSPI_NCS1. The multiplexer's select input is connected to afo_CSSEL. The multiplexer's other input is connected to a constant '1'.

31.3.10 Octo-SPI interface programmable parameters

Octo-SPI memory area allocation in memory-mapped mode

Refer to Section 31.3.4: Octo-SPI interface memory.

DLYBOS1 control

The DLYBOS1 programmable delay is controlled by bits in SYSCFG_DLYBOS1CR and SYSCFG_DLYBOS1SR registers. The table below gives the correspondence between SYSCFG bitfields and the control parameters described in Section 31.3.7.

Table 212. DLYBOS1 SYSCFG bits

DLYBOS1 SYSCFG bitsControl input or status output in the OCTOSPIComment
BYP_ENdll_bypass_cmd_enSelection of lock or pure-delay mode
ENdll_start_lockEnable of DLL when configured in Lock mode
RX_TAP_SEL[5:0]rx_ph_select[5:0]Selection of delay in RX delay line
TX_TAP_SEL[5:0]tx_ph_select[5:0]Selection of delay in TX delay line
BYP_CMD[4:0]dll_bypass_cmd[4:0]Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode
LOCKdll_lockedWhen in lock mode, indicates that the DLL has locked on the input clock frequency

Table 212. DLYBOS1 SYSCFG bits (continued)

DLYBOS1 SYSCFG bitsControl input or status output in the OCTOSPIComment
RX_TAP_SEL_ACKrx_ph_select_ackIndicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0]
TX_TAP_SEL_ACKtx_ph_select_ackIndicates that the TX delay line has switched to the delay selected by TX_TAP_SEL[5:0]

31.3.11 Select the RX sampling strobe and configure the TX clock

The table below lists the various OCTOSPI modes, and gives guidelines to select the RX sampling strobe and configure the TX clock. Some information is also given on how to enable the DLL.

Table 213. OCTOSPI modes and recommended clock configuration

OCTOSPI ModeSTR or DTRDQS used in read ?Max frequencySetup/Hold constraints on memory deviceData valid Window at output of memory DeviceTX clock configurationRX sampling strobe selection
HyperBus( Cypress, Spansion)DTRyes200
166
133
100
50
0.40 / 0.40 ns
0.60 / 0.60 ns
0.80 / 0.80 ns
1 / 1 ns
wrt memory clock edges
1.45 ns
1.70 ns
2.37 ns
3.30 ns
if kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay).
If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay.
DQS delayed (DQSE = 1, DLYBYP = 0).
The DLL must be used for RX delay.
Macronix [For instr. READ, FASTREAD, OCTAREAD-STR]STRno133
100
66
2 / 2 ns
2 / 2 ns
2 / 2 ns
wrt memory clock rising edge
2 ns@10pF
4 ns@15pF
7 ns@30pF
Set DQHC = 0 and configure the TX delay to minimum value.Feedback clock delayed @133 MHz and 100 MHz (DQSE=0, DLYBYP=0). The DLL must be used for RX delay.

Feedback clock @66 MHz (DQSE=0, DLYBYP=1). The DLL is not used for RX delay.
Macronix [For instr. OCTAREAD - DTR]DTRyes133
100
66
0.8 / 0.8 ns
1 / 1 ns
1 / 1 ns
1.5ns@10pF
2.8ns @15pF
4.9ns @30pF
if kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay).
If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay.
DQS delayed (DQSE = 1, DLYBYP = 0). The DLL must be used for RX delay.
Micron Xcella (MT35XL01 GBBA ds)STRno1331.8 / 1.8 ns
Wrt memory clock rising edge
2.8ns @12pFSet DQHC = 0 and configure the TX delay to minimum value.Feedback clock delayed @133 MHz and 100 MHz (DQSE=0, DLYBYP=0). The DLL must be used for RX delay.

Feedback clock @66 MHz (DQSE=0, DLYBYP=1). The DLL is not used for RX delay.
Micron Xcella (MT35XL01 GBBA ds)DTRyes1330.8 / 0.8 ns
Wrt memory clock edges
2 nsif kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay).
If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay.
DQS delayed (DQSE = 1, DLYBYP = 0). The DLL must be used for RX delay.

DHQC is bit #28 in OCTOSPI_TCR register. DQSE is bit #29 in OCTOSPI_CCR register. DLYBYP is bit #3 in OCTOSPI_DCR1 register.

Enabling the DLL for frequencies greater or equal to 50 MHz (lock mode)

The DLL is enabled by setting EN = 1. The DLL lock state is reached when LOCK = 1. Once the DLL is locked, an RX delay value can be selected by programming RX_TAP_SEL[5:0], and a TX delay value can be selected by programming TX_TAP_SEL[5:0]. Each tap corresponds to 1/32th of the memory device clock period. The selected delays are applied to RX sampling strobe and TX launch clock once RX_TAP_SEL_ACK and TX_TAP_SEL_ACK are set to 1.

Enabling the DLL for frequencies lower than 50 MHz (bypass mode)

The DLL is enabled by setting BYP_EN = 1. The command applied to every DLL delay unit is defined by BYP_CMD[4:0] bits (the value 0 is reserved and must not be used). RX_TAP_SEL[5:0] and TX_TAP_SEL[5:0] define the number of elementary delays inserted on RX sampling clock and TX launch clock. For minimum delay, RX_TAP_SEL[5:0] (respectively TX_TAP_SEL[5:0]) must be set to 0.

EN, RX_TAP_SEL[5:0], TX_TAP_SEL[5:0], BYP_EN, BYP_CMD[4:0] bits are located in SYSCFG_DLYBOSnCR (n=1,2) registers. LOCK, RX_TAP_SEL_ACK, TX_TAP_SEL_ACK bits are located in SYSCFG_DLYBOSnSR (n=1,2) registers.

31.4 SD/eMMC interface

The SD/eMMC interface offers three SD/eMMC physical ports. The accesses to the SDMMC controllers are protected by RISUP components.

31.4.1 SD/eMMC interface main features

For a complete list of features refer to Section 34: Secure digital input/output MultiMediaCard interface (SDMMC).

31.4.2 SD/eMMC interface block diagram

Figure 170. SD/eMMC interface block diagram

SD/eMMC interface block diagram showing SoC Interconnect, SYSCFG, SDMMC1, SDMMC2, SDMMC3, DLYBSD1, DLYBSD2, DLYBSD3, and various signal lines like SDVSEL, SDMMC1_CMD, SDMMC1_D[3:0], etc.

The diagram illustrates the SD/eMMC interface architecture within a SoC. A vertical SoC Interconnect bus on the left connects to three SDMMC blocks (SDMMC1, SDMMC2, and SDMMC3) via AHB Slave and AHB Master interfaces. Each SDMMC block is associated with a SYSCFG block and a DLYBSD block. The DLYBSD blocks are connected to the SDMMC blocks and to SDVSEL signals. The SDMMC blocks have IRQ outputs connected to CPU1 GIC and CPU2 NVIC. The SDMMC blocks also have various signal inputs/outputs: SDMMC1_CMD, SDMMC1_D[3:0], SDMMC1_D[7:4], SDMMC1_CDIR, SDMMC1_D0DIR, SDMMC1_D123DIR, SDMMC2_CMD, SDMMC2_D[7:0], SDMMC2_CDIR, SDMMC2_D0DIR, SDMMC2_D123DIR, SDMMC3_CMD, SDMMC3_D[3:0], SDMMC3_CDIR, SDMMC3_D0DIR, and SDMMC3_D123DIR. The CPU1 GIC and CPU2 NVIC blocks are connected to the IRQ outputs of the SDMMC blocks via sdmmc1_gbl_it, sdmmc2_gbl_it, and sdmmc3_gbl_it signals.

SD/eMMC interface block diagram showing SoC Interconnect, SYSCFG, SDMMC1, SDMMC2, SDMMC3, DLYBSD1, DLYBSD2, DLYBSD3, and various signal lines like SDVSEL, SDMMC1_CMD, SDMMC1_D[3:0], etc.

MSv66525V2

31.4.3 SD/eMMC interface reset

Figure 171. SD/eMMC interface resets

Block diagram of SD/eMMC interface resets showing connections from RCC to SDMMC1, SDMMC2, SDMMC3 and DLYBSD1, DLYBSD2, DLYBSD3 through Reset Sync blocks.

The diagram illustrates the reset architecture for SDMMC1, SDMMC2, and SDMMC3 along with delay blocks DLYBSD1, DLYBSD2, and DLYBSD3. From the RCC block on the left: - SDMMC1RST generates rstn_sdmmc1 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc1, outputting to HRESETn of SDMMC1. ck_icn_m_sdmmc1 connects directly to HCLK of SDMMC1. - SDMMC1DLLRST generates rstn_sdmmc1dll connecting directly to rst_n of DLYBSD1. - SDMMC2RST generates rstn_sdmmc2 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc2, outputting to HRESETn of SDMMC2. ck_icn_m_sdmmc2 connects directly to HCLK of SDMMC2. - SDMMC2DLLRST generates rstn_sdmmc2dll connecting directly to rst_n of DLYBSD2. - SDMMC3RST generates rstn_sdmmc3 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc3, outputting to HRESETn of SDMMC3. ck_icn_m_sdmmc3 connects directly to HCLK of SDMMC3. - SDMMC3DLLRST generates rstn_sdmmc3dll connecting directly to rst_n of DLYBSD3.

Block diagram of SD/eMMC interface resets showing connections from RCC to SDMMC1, SDMMC2, SDMMC3 and DLYBSD1, DLYBSD2, DLYBSD3 through Reset Sync blocks.

31.4.4 SDMMC1/2 description

Refer to Section 34: Secure digital input/output MultiMediaCard interface (SDMMC).

31.4.5 DLYBSD1/2 description

One programmable delay is used for each SDMMC interface. The programmable delay can be used to tune the phase of the RX sampling clock in order to sample the data in their valid window. The programmable delay has no effect on the TX path.

These programmable delays are identical to the ones used in the OCTOSPI interfaces. The clock on which the DLL locks is a free running clock provided by the SDMMC controller which is at the same frequency as the clock sent to the memory. When an SDMMC interface operates below 50 MHz, the programmable delay cannot be used. Refer to Section 31.3.7 for a detailed description.

31.4.6 SD/eMMC interface interrupts

Each SDMMC instance generates one interrupt.

Table 214. SD/eMMC interface interrupts

Peripheralpin nameCPU1 interruptCPU2 interrupt
SDMMC1IRQsdmmc1_gbl_itsdmmc1_gbl_it
SDMMC2IRQsdmmc2_gbl_itsdmmc2_gbl_it
SDMMC3IRQsdmmc3_gbl_itsdmmc3_gbl_it

31.4.7 SD/eMMC interface programmable parameters

Control of external voltage regulator

For SDMMC1 and SDMMC2 interfaces, an external voltage regulator can be used to manage the 3V3 to 1V8 voltage transition for UHS-1 modes of SD card. This external voltage regulator can be controlled by the SDMMC1_VSEL (respectively SDMMC2_VSEL) alternate function. These alternate functions are controlled by the following SYSCFG bits:

PWR_CR8.VDDIO1VRSEL (respectively PWR_CR7.VDDIO2VRSEL) must be controlled according to external voltage regulator transition.

DLYBSD1 control

DLYBSD1 programmable delay is controlled by bits in SYSCFG_DLYBSD1CR and SYSCFG_DLYBSD1SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.

Table 215. DLYBSD1 SYSCFG bits

DLYBSD1 SYSCFG bitsControl input or status output in the SDMMCComment
BYP_ENdll_bypass_cmd_enSelection of lock or pure-delay mode
ENdll_start_lockEnable of DLL when configured in Lock mode
RX_TAP_SEL[5:0]rx_ph_select[5:0]Selection of delay in RX delay line
Table 215. DLYBSD1 SYSCFG bits (continued)
DLYBSD1 SYSCFG bitsControl input or status output in the SDMMCComment
BYP_CMD[4:0]dll_bypass_cmd[4:0]Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode
LOCKdll_lockedWhen in lock mode, indicates that the DLL has locked on the input clock frequency
RX_TAP_SEL_ACKrx_ph_select_ackIndicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0]

DLYBSD2 control

DLYBSD2 programmable delay is controlled by bits in SYSCFG_DLYBSD2CR and SYSCFG_DLYBSD2SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.

Table 216. DLYBSD2 SYSCFG bits
DLYBSD2 SYSCFG bitsControl input or status output in the SDMMCComment
BYP_ENdll_bypass_cmd_enSelection of lock or pure-delay mode
ENdll_start_lockEnable of DLL when configured in Lock mode
RX_TAP_SEL[5:0]rx_ph_select[5:0]Selection of delay in RX delay line
BYP_CMD[4:0]dll_bypass_cmd[4:0]Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode
LOCKdll_lockedWhen in lock mode, indicates that the DLL has locked on the input clock frequency
RX_TAP_SEL_ACKrx_ph_select_ackIndicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0]

DLYBSD3 control

DLYBSD3 programmable delay is controlled by bits in SYSCFG_DLYBSD3CR and SYSCFG_DLYBSD3SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.

Table 217. DLYBSD3 SYSCFG bits

DLYBSD3 SYSCFG bitsControl input or status output in SDMMCComment
BYP_ENdll_bypass_cmd_enSelection of lock or pure-delay mode
ENdll_start_lockEnable of DLL when configured in Lock mode
RX_TAP_SEL[5:0]rx_ph_select[5:0]Selection of delay in RX delay line
BYP_CMD[4:0]dll_bypass_cmd[4:0]Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode
LOCKdll_lockedWhen in lock mode, indicates that the DLL has locked on the input clock frequency
RX_TAP_SEL_ACKrx_ph_select_ackIndicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0]

31.4.8 Guidelines for selecting the RX sampling clock

The tables below list the various SD/eMMC speed modes and gives guidelines to select the RX sampling clock and configure the clock control bits in the SDMMC cell. It is assumed here that no external level shifters are used. Some information is also given on how to enable the DLL.

Table 218. SD speed modes and recommended clock configuration

Speed ModeMax card clock freq. SDMMCn_CLKIO VoltageSetup/hold constraints on SD deviceData valid Window at output of SD DeviceKernel clock freq (SCLK)DDRNEGEDGECLKDIVSelection of RX sampling clock (SELCLKRX)
DS (default speed)(1)25 MHz3V35ns/5ns26ns25 MHz0NA0 (div by 1)SDMMC_CLKio
HS (high speed)(1)50 MHz3V36ns/2ns8.5ns50 MHz0NA0 (div by 1)SDMMC_CLKio
SDR12(1)25 MHz1V83ns/0.8ns27.5ns25 MHz0NA0 (div by 1)SDMMC_CLKio
SDR25(1)50 MHz1V83ns/0.8ns7.5ns50 MHz0NA0 (div by 1)SDMMC_CLKio
DDR50 (2)50 MHz1V83ns/0.8ns4.5ns50 MHz1(3)1 (div by 2)SDMMC_CLKio
SDR50(2)100 MHz1V83ns/0.8ns4ns100 MHz0NA0 (div by 1)SDMMC_CLKio
SDR104208 MHz1V81.4ns/0.8ns2,88ns208 MHz0NA0 (div by 1)SDMMC_FB_CLK
  1. 1. For these modes, other clock configurations exist where the kernel clock frequency is a multiple of the card clock. However, considering that all three SDMMC controllers have dedicated kernel clocks, it seems more straightforward to align the kernel clock frequency with the card clock frequency.
  2. 2. For these modes, it is also possible to enable the programmable delay and select the delayed loopback clock (SDMMC_FB_CLK) as RX sampling clock if it is needed to adjust the sampling edge.
  3. 3. Value to be programmed depend on timings of the interface. For functional simulation, either value works.
Table 219. eMMC Speed modes and recommended clock configuration
Speed ModeMax card clock freq. SDMMCn_CKIO Voltage(1)Setup/Hold constraints on SD deviceData valid Window at output of eMMC DeviceKernel clock freq (SCLK)DDRNEGEDGECLKDIVSelection of RX sampling clock (SELCLKRX)
Legacy compatible(2)26 MHz3V3, 1V8, 1V23ns/3ns20ns26 MHz0NA0 (div by 1)SDMMC_CLKio
High speed SDR(2)52 MHz3V3, 1V8, 1V23ns/3ns8ns52 MHz0NA0 (div by 1)SDMMC_CLKio
High Speed DDR(3)52 MHz3V3, 1V8, 1V2CMD: 3ns/3ns
DATA: 2.5ns/2.5ns
CMD: 8ns
DATA: 4.1ns
104 MHz1(4)1 (div by 2)SDMMC_CLKio
High speed HS200200 MHz1V8, 1V21.4ns/0.8ns0.575 UI (2.88ns at 200 MHz)200 MHz0NA0 (div by 1)SDMMC_FB_CLK
  1. 1V2 is not supported in STM32MP21xx.
  2. For these modes, other clock configurations exist where the kernel clock frequency is a multiple of the card clock. However, considering that all three SDMMC controllers have dedicated kernel clocks, it seems more straightforward to align the kernel clock frequency with the card clock frequency.
  3. For this mode, it is also possible to enable the programmable delay and select the delayed loopback clock (SDMMC_FB_CLK) as RX sampling clock if it is needed to adjust the sampling edge.
  4. Value to be programmed depend on timings of the interface. For functional simulation, either value works.

DDR, NEGEDGE, CLKDIV and SELCLKRX are bitfields in SDMMC_CLKCR register.

The DLL is enabled by writing BYP_EN to 0 and setting EN to 1. The DLL lock state is reached when the status bit LOCK is equal to 1. Once the DLL is locked, a delay value can be selected by programming RX_TAP_SEL[5:0]. The selected delay is applied to the RX sampling clock when the status bit RX_TAP_SEL_ACK is equal to 1. These control and status bits are located in the SYSCFG_DLYBSDnCR and SYSCFG_DLYBSDnSR registers (n=1,2,3).

Sequencing between SDMMC and DLL programming when the DLL is used

  1. 1. Enable in SDMMC the generation of the free running clock towards the DLL. This is done as soon as PWRCTRL is set to 0b11.
  2. 2. Once the memory frequency is increased to high speed (i.e. after the initialization sequence), reset and enable the DLL. The reset of the DLL is controlled by SDMMCnDLLRST (n=1,2,3) bit in the RCC. The enable of the DLL is controlled by EN bit in SYSCFG_DLYBSDnCR (n=1,2,3) register.
  3. 3. Once the DLL is locked (as indicated by LOCK = 1 in SYSCFG_DLYBSDnSR register), select the delayed feedback clock as the RX sampling clock by writing SELCLKRX to 0b10.
  4. 4. Select the RX delay value by programming RX_TAP_SEL[5:0] in SYSCFG_DLYBSDnCR.
  5. 5. Wait for RX_TAP_SEL_ACK bit to be set to 1 in SYSCFG_DLYBSDnSR register before reading data from memory.

At startup a tuning phase is required where steps 4 and 5 are repeated for every RX_TAP_SEL[5:0] values. This enables to determine a range of delays where data are read successfully. The delay value corresponding to the middle of this valid range must be selected for further operation.