[PATCH 04/10] mci: add HS400 mode selection

Sascha Hauer s.hauer at pengutronix.de
Mon May 18 05:35:23 PDT 2026


On 2026-05-18 11:36, Ahmad Fatoum wrote:
> Hello Sascha,
> 
> On 5/11/26 2:07 PM, Sascha Hauer wrote:
> > eMMC HS400 transitions through HS and 8-bit DDR per JEDEC, on top of
> > a card already tuned in HS200. Wire that up in the core:
> > 
> > - mmc_select_max_dtr() now records EXT_CSD_CARD_TYPE_HS400_{1_8V,1_2V}
> >   in mmc_avail_type when both the host (mmc-hs400-1_8v / mmc-hs400-1_2v
> >   in DT) and the card advertise it. HS400 reuses hs200_max_dtr (200 MHz)
> >   since it's the same SDCLK rate, just DDR-sampled.
> > 
> > - mmc_set_bus_speed() treats HS200 and HS400 as the same rate tier.
> > 
> > - mmc_select_hs400() implements the JEDEC sequence:
> >     1. CMD6 EXT_CSD_HS_TIMING = HS
> >     2. host: MMC_TIMING_MMC_HS, clock = hs_max_dtr
> >     3. CMD6 EXT_CSD_BUS_WIDTH = EXT_CSD_DDR_BUS_WIDTH_8
> >     4. CMD6 EXT_CSD_HS_TIMING = HS400
> >     5. host: MMC_TIMING_MMC_HS400, clock back to 200 MHz
> > 
> >   Bails early if the card lacks HS400 capability or the bus isn't 8-bit.
> > 
> > - mci_startup_mmc() runs mmc_select_hs400() right after a successful
> >   HS200 tuning when EXT_CSD_CARD_TYPE_HS400 is in mmc_avail_type.
> > 
> > - mmc_card_hs400() helper added in mci.h, mirroring mmc_card_hs200().
> > 
> > Host drivers must additionally handle MMC_TIMING_MMC_HS400 in their
> > set_ios / set_clock paths (e.g. setting the controller-specific HS400
> > bit in HOST_CONTROL2, configuring data-strobe sampling). Without that
> > the core will run the transition but the host won't sample correctly.
> 
> This patch is missing the downgrade code. If HS400 doesn't work out, we
> should fallback to HS200.

If a switch to HS400 fails we do not know in which mode the card
actually is, so we do not have a reliable way to talk to the card. Is it
DDR or SDR? So our only chance would be to re-do the whole card
initialization.

> > @@ -1783,6 +1786,18 @@ static void mmc_select_max_dtr(struct mci *mci)
> >  		avail_type |= EXT_CSD_CARD_TYPE_HS200_1_2V;
> >  	}
> >  
> > +	if ((caps2 & MMC_CAP2_HS400_1_8V) &&
> 
> This bit is not decoded in mci_print_caps (same or _1_2V)

Ok, will add.

Sascha

--
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list