nuttx/drivers/mmcsd
Justin Hammond 56070e94df drivers/mmcsd: Switch SD cards into high speed.
The SD path never performs the CMD6 switch its eMMC counterpart has
performed for years, so an SD card is left in default speed and every
host clocked accordingly, at 25MHz rather than the 50MHz the card
supports.  A TODO in this file has asked for it since 2010; this removes
it.

A host asks for the switch by reporting SDIO_CAPS_SD_HS_MODE, which
mirrors the eMMC capability beside it.  The switch is attempted once the
bus is at the default transfer rate and the wide bus is selected, and
the card's own answer decides the outcome: the 64 byte status block
reports the function actually selected, and a card that cannot do what
was asked says so there rather than failing the command.  Cards below
version 1.10 of the physical layer specification are not asked, since
CMD6 postdates them.

Only a confirmed switch reaches the host, as the new
CLOCK_SD_TRANSFER_4BIT_HS rate.  That is a rate rather than a flag on an
existing one because the host is clocked twice during initialization,
once before the switch can have happened, and a host that cannot tell
the two apart would run a card in default speed past its rated 25MHz.
The enumerator is added last, so no existing driver's switch statement
changes meaning, and the rate reaches only a host that reported the new
capability, which none in tree does.

Every failure path is survivable: a card that declines, a card too old
to ask, and a host that never asks all stay at the default rate.

Documents the two capabilities and the clock rates a lower half has to
handle.

The MMC/SD documentation was three sentences and a pointer to the SDIO
page, so it said nothing about how a card is registered, how the bus width
and clock are negotiated, or what any of the configuration options do.  It
now covers those, the ioctl interface and /proc/mmcsd, and the high speed
switch this commit adds is described where somebody looking for it would
look rather than only in the SDIO lower half page.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
2026-08-18 09:38:45 +08:00
..
CMakeLists.txt drivers/mmcsd: Aligned Cmake with Make 2025-12-09 14:25:40 -03:00
Kconfig sched/sleep: replace all Signal-based sleep implement to Scheduled sleep 2025-10-17 14:05:02 +08:00
Make.defs drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
mmcsd.h drivers/mmcsd: Switch SD cards into high speed. 2026-08-18 09:38:45 +08:00
mmcsd_csd.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
mmcsd_debug.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
mmcsd_extcsd.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
mmcsd_procfs.c !include/fcntl.h: align open flags with Linux values 2026-06-30 13:43:44 +08:00
mmcsd_sdio.c drivers/mmcsd: Switch SD cards into high speed. 2026-08-18 09:38:45 +08:00
mmcsd_sdio.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
mmcsd_spi.c libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-07-16 23:37:22 +08:00
mmcsd_spi.h drivers: migrate to SPDX identifier 2024-11-06 18:02:25 +08:00
sdio.c include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00