Ubuntu – SD card reader on Linux: SPI or SD protocol underneath

driverssd cardUbuntu

I've a notebook with a SD card reader and I was wondering if the GNU/Linux driver is using the SPI protocol or the proprietary SD protocol (one or four bits). I'm asking this because I'm testing a SPI based SD card reader device I'm working on and when I check the reading speed on my notebook it reads a card at 6MB/s…
Another thing, I would like to take a look to the driver sources, do you know where can I find them?

Thanks in advance!

Best Answer

Without looking at the kernel source, that would depend on the specific SD chip and its kernel driver. You should look at datasheets and the kernel source. For example, on my laptop:

$ lspci | grep SD
15:00.2 SD Host controller: Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter (rev 21)

Presumably, the chip implements the SD state machine in hardware, and some chip-to-host interface (PCI, in the case of mine). The specifics of the chip-to-card connection may be abstracted out by the chip, but it's likely the choice can be influenced by the host. The kernel is likely to go with the fastest means available, unless there's a known bug.

Update: checked the kernel source. If a card supports 4-bit transfers, they're enabled automatically. You can see this in drivers/mmc/core/mmc.c, function mmc_init_card(). For Linux 2.6.38, line 489 seems to activate high speed transfers, and line 535 seems to activate 4-bit-wide transfers. Don't let the ‘mmc’ confuse you. This directory contains the drivers that handle SD (including SDIO) cards as well as MMC.

Related Question