world leader in high performance signal processing
Trace: » spi_mmc

SPI MMC Driver

For general information on MMC cards, see the MMC Card page.

Order The MMC/SD SPI addon card depicted above can be ordered worldwide by checking out the buy_stuff.

In order to operate the SD/MMC Cards in SPI Mode 3 it is recommended to have 10kOhm Pull-Up Resistors to VDD on Blackfin SPI_SSELx, SPI_SCK, SPI_MISO and SPI_MOSI.

Kernel Configuration

We use the mmc-spi driver in mainline kernel, i.e., drivers/mmc/host/mmc_spi.c. As a result, SDHC (SD High Capacity) card is supported.

Enable Blackfin SPI controller driver:

SPI support  --->
    *** SPI Master Controller Drivers *** 
    {*}   SPI controller driver for ADI Blackfin5xx

Enable the mmc-spi driver:

MMC/SD/SDIO card support  ---> 
    <*>   MMC block device driver (NEW)
    [*]     Use bounce buffer for simple hosts (NEW)
    <*>   MMC/SD/SDIO over SPI 

Add SPI device configure in bfin_spi_board_info[] structure in board file (e.g, arch/blackfin/mach-bf537/boards/stamp.c)

static struct spi_board_info bfin_spi_board_info[] __initdata = {
#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
                .modalias = "mmc_spi",
                .max_speed_hz = 20000000,     /* max spi clock (SCK) speed in HZ */
                .bus_num = 0,
                .chip_select = 4,
                .platform_data = &bfin_mmc_spi_pdata,
                .controller_data = &mmc_spi_chip_info,
                .mode = SPI_MODE_3,
#if defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE)
static int bfin_mmc_spi_init(struct device *dev,
        irqreturn_t (*detect_int)(int, void *), void *data)
        return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,
                IRQF_TRIGGER_FALLING, "mmc-spi-detect", data);
static void bfin_mmc_spi_exit(struct device *dev, void *data)
        free_irq(MMC_SPI_CARD_DETECT_INT, data);
static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
        .init = bfin_mmc_spi_init,
        .exit = bfin_mmc_spi_exit,
        .detect_delay = 100, /* msecs */
static struct bfin5xx_spi_chip  mmc_spi_chip_info = {
        .enable_dma = 0,
        .bits_per_word = 8,

Switch setting

On MMC/SD addon Card, turn on one of the switch to choose a spi chip select for add on card.

PF pin Switch setting
PF1 2
PF2 3
PF3 4
PF4 5
PF5 6
PF6 7
PF7 8

Besides the spi chip select, the mmc card also use a gpio as card detection signal. In this hardware implementation, it is PF5 and there is no switch for user to change this setting


File System Support

Configure the kernel, application and switch according to the requirements above. Make and download the image to stamp board.

Enable File System in kernel:
        File systems  --->
            <*> Second extended fs support
            [ ]   Ext2 extended attributes
                DOS/FAT/NT Filesystems  --->
                       <*> MSDOS fs support
                       <*> VFAT (Windows-95) fs support
                       (437) Default codepage for FAT
                       (iso8859-1) Default iocharset for FAT
                Native Language Support  --->
                       --- Base native language support
                       (iso8859-1) Default NLS Option
                       <*>   Codepage 437 (United States, Canada)
                       <*>   NLS ISO 8859-1  (Latin 1; Western European Languages)
Configure uclinux-dist to add the FS applications:
        Filesystem Applications  --->
                [*] fdisk
                [*] e2fsck
                [*] mke2fs
                [*] mkdosfs

The mmc-spi block device name is changed from e.g: ”/dev/spi_mmc1” to ”/dev/mmcblk0p1”. Kernel message when booting:

mmc_spi spi0.4: ASSUMING 3.2-3.4 V slot power                                   
mmc_spi spi0.4: SD/MMC host mmc0, no DMA, no WP, no poweroff                    
mmc_spi spi0.4: requested mode not fully supported                              
mmc_spi spi0.4: can't change chip-select polarity  

Insert a new SDHC card:

mmc_spi spi0.4: requested mode not fully supported                      
mmc_spi spi0.4: can't change chip-select polarity                               
mmc0: host does not support reading read-only switch. assuming write-enable.    
mmc0: new SDHC card on SPI                                                      
mmcblk0: mmc0:0000 SDC   3.51 GiB                                               
 mmcblk0: p1 p2   

root:/> ls /dev/mmcblk0p*                                                       
/dev/mmcblk0p1  /dev/mmcblk0p2  


  • System Setting
Board Version CCLK SCLK Kernel Version Toolchain Version SD Card
BF537 STAMP-2.1 - Rev 0.2 500MHz 100MHz 2.6.28-rc2-ADI-2009R1-pre-svn5938 gcc 4.1.2 (svn) Transend SDHC 8GB class 6
  • Kernel Configuration
SPI DMA Max Clock Speed
Disable 20 MHz
Test Case 1: Bonnie++ on Ext2
root:/> mkfs.ext2 /dev/mmcblk0p1
root:/> mount /dev/mmcblk0p1 /mnt/
root:/> bonnie++ -u root -d /mnt/
  • Result:
Version  1.94       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
blackfin       300M    43  88   569   3   343   2   114  85   817   3  68.1   3
Latency              1000ms    8516ms    7159ms     216ms     243ms     539ms
Version  1.94       ------Sequential Create------ --------Random Create--------
blackfin            -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16   185  78  7049  99  1124  26   190  79  7474 100   487  58
Latency             87999us    4000us    4000us     115ms    4000us    4000us