This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM6467T and MicroSD Card over SPI

Other Parts Discussed in Thread: DA8XX, OMAP-L137

I have a custom board with a DM6467T, with a MicroSD card reader pinned out to the SPI interface.  I added the following to my board-dm6467t.c file:

static struct spi_board_info dm646x_evm_spi_info[] __initconst = {

  {

    .modalias = "mmc_spi",

    .max_speed_hz = 1 * 1000 * 1000,

    .bus_num = 0,

    .chip_select = 0,

    .mode = SPI_MODE_0,

  },

};

I get the following messages on boot (if I take the SD card out before booting, I get all the same messages, except the backtrace):

spi_davinci spi_davinci.0: DaVinci SPI driver in EDMA mode
Using RX channel = 17 , TX channel = 16 and event queue = 3
spi_davinci spi_davinci.0: Controller at 0xfec66800

...

mmc_spi spi0.0: ASSUMING SPI bus stays unshared!
mmc_spi spi0.0: ASSUMING 3.2-3.4 V slot power
mmc_spi spi0.0: SD/MMC host mmc0, no WP, no poweroff

...

mmc_spi spi0.0: can't change chip-select polarity

...

Backtrace:
[<c002a89c>] (dump_backtrace+0x0/0x114) from [<c02afdd0>] (dump_stack+0x18/0x1c)
 r7:c20d0400 r6:c20d0400 r5:c20d05c0 r4:00000000
[<c02afdb8>] (dump_stack+0x0/0x1c) from [<c01fde70>] (mmc_spi_request+0xa8/0x9d8)
[<c01fddc8>] (mmc_spi_request+0x0/0x9d8) from [<c01f61b0>] (mmc_wait_for_req+0x1f4/0x21c)
[<c01f5fbc>] (mmc_wait_for_req+0x0/0x21c) from [<c01f6244>] (mmc_wait_for_cmd+0x6c/0x7c)
 r7:00000000 r6:c20d0400 r5:c20c9f1c r4:c20c9ee4
[<c01f61d8>] (mmc_wait_for_cmd+0x0/0x7c) from [<c01fa0a8>] (mmc_reset_sdio+0x5c/0x6c)
 r7:c20c8000 r6:c20d0550 r5:c20d0400 r4:c20c9f1c
[<c01fa04c>] (mmc_reset_sdio+0x0/0x6c) from [<c01f5d80>] (mmc_rescan+0x24c/0x314)
 r5:60000013 r4:c20d0400
[<c01f5b34>] (mmc_rescan+0x0/0x314) from [<c00536dc>] (worker_thread+0x138/0x1f8)
 r6:c20b9a60 r5:c20d0550 r4:c20d0554
[<c00535a4>] (worker_thread+0x0/0x1f8) from [<c00574b8>] (kthread+0x88/0x90)
[<c0057430>] (kthread+0x0/0x90) from [<c004456c>] (do_exit+0x0/0x684)
 r7:00000000 r6:00000000 r5:00000000 r4:00000000

If I change the SPI max frequency from 1MHz to 400KHz, I get the following message, regardless of whether a card is present or not. (and mmc_spi doesn't run):

spi_davinci spi_davinci.0: can't setup spi0.0, status -22

Any ideas?

  • Correction: behavior is the same regardless of MicroSD card presence at 1MHz as well.  I am using a SanDisk Extreme Pro MicroSDHC, 16GB.

  • With max_speed_hz set between 3MHz and 25MHz, it seems Linux detects the SD Card, based on the lack of detection errors seen below 3MHz.  A few minutes after booting, however, the following error and backtrace appears.  I have tried 3MHz, 7MHz, 10MHz, and 25MHz, all with the same behavior.  I have tried SPI_MODE_0 and SPI_MODE_3, with the same behavior.  I've tried a half dozen SD cards of different sizes and different classes, all with the same behavior.  And ideas on what may be happening?

    Error/backtrace shown below, followed by linux kernel board file excerpts., followed by menuconfig settings.


    INFO: task kmmcd:157 blocked for more than 120 seconds.
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    kmmcd         D c02b7d88     0   157      2 0x00000000
    Backtrace:
    [<c02b7a98>] (schedule+0x0/0x380) from [<c02b8454>] (schedule_timeout+0x24/0x220)
    [<c02b8430>] (schedule_timeout+0x0/0x220) from [<c02b82ac>] (wait_for_common+0xf4/0x1bc)
     r7:7fffffff r6:c20c7e34 r5:c20bd6c0 r4:c20c7df0
    [<c02b81b8>] (wait_for_common+0x0/0x1bc) from [<c02b8404>] (wait_for_completion+0x18/0x1c)
    [<c02b83ec>] (wait_for_completion+0x0/0x1c) from [<c01c42a8>] (spi_sync+0x4c/0x64)
    [<c01c425c>] (spi_sync+0x0/0x64) from [<c0204ee8>] (mmc_spi_readbytes+0x5c/0x64)
     r5:ffff8b5f r4:c216e5c0
    [<c0204e8c>] (mmc_spi_readbytes+0x0/0x64) from [<c0204f24>] (mmc_spi_skip+0x34/0x94)
     r5:ffff8b5f r4:0000001d
    [<c0204ef0>] (mmc_spi_skip+0x0/0x94) from [<c0205090>] (mmc_spi_set_ios+0x10c/0x360)
    [<c0204f84>] (mmc_spi_set_ios+0x0/0x360) from [<c01fc8ec>] (mmc_power_up+0x128/0x144)
    [<c01fc7c4>] (mmc_power_up+0x0/0x144) from [<c01fd6b8>] (mmc_rescan+0x244/0x314)
     r8:c01fd474 r7:c20c6000 r6:c216e550 r5:60000013 r4:c216e400
    [<c01fd474>] (mmc_rescan+0x0/0x314) from [<c00536dc>] (worker_thread+0x138/0x1f8)
     r6:c20a2a60 r5:c216e550 r4:c216e554
    [<c00535a4>] (worker_thread+0x0/0x1f8) from [<c00574b8>] (kthread+0x88/0x90)
    [<c0057430>] (kthread+0x0/0x90) from [<c004456c>] (do_exit+0x0/0x684)
     r7:00000000 r6:00000000 r5:00000000 r4:00000000
    INFO: task kmmcd:157 blocked for more than 120 seconds.
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    kmmcd         D c02b7d88     0   157      2 0x00000000


    ---------------------------------------------------------------------------------------------
    Here are the relevant contents of my board file.

    static struct mmc_spi_platform_data davinci_mmc_spi_pdata = {
            .detect_delay = 100,
            .powerup_msecs = 100,
            .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
    };

    static struct spi_board_info dm646x_evm_spi_info[] __initconst = {
        {
            .modalias    = "mmc_spi",
            .platform_data    = &davinci_mmc_spi_pdata,
            .max_speed_hz    = 3 * 1000 * 1000, // 10 * 1000 * 1000,    /* at 3v3 */
            .bus_num    = 0,
            .chip_select    = 0,
            .mode        = SPI_MODE_0, // or 0
        },
    };

    ---------------------------------------------------------------------------------------------
    Here are the menuconfig settings

    Device Drivers
      [*] SPI support -->
           <*> SPI controller driver for DaVinci/DA8xx SoC's
           -*- Utilities for Bitbanging SPI masters
      <*> MMC/SD/SDIO card support -->
           [*] MMC debugging
           <*> MMC block device driver
                [*] Use bounce buffer for simple hosts
           < > TI DAVINCI Multimedia Card Interface support (unselected, since DM6467T doesn't have MMC hardware interface, is this the right choice?)
           <*> MMC/SD/SDIO over SPIs

  • Hi,

    I have same result with kernel higher 3.4.91, error -22. For me, the problem comes from the edma queue  management. The first message is send but doesn't come back to the mmc_spi driver. The edma is set correctly, the error is generate by spi_sync_locked(), like the spi bus is locked after the first request.

    Do you progress from your side ?

    Arnaud

    [ 0.000000] Linux version 3.14.4-mixr (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-41) ) #97 PREEMPT Tue May 27 13:01:23 CEST 2014
    [ 0.000000] CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00057177
    [ 0.000000] Machine: DaVinci DA830/OMAP-L137/AM17x EVM
    [ 0.000000] DaVinci da830/omap-l137 rev2.0 variant 0x9
    [
    [ 1.651331] edma-dma-engine edma-dma-engine.0: allocated channel for 0:18
    [ 1.658168] dmaengine: __dma_request_channel: success (dma0chan18)
    [ 1.786444] edma-dma-engine edma-dma-engine.0: allocated channel for 0:19
    [ 1.793396] dmaengine: __dma_request_channel: success (dma0chan19)
    [ 1.799639] spi_davinci spi_davinci.1: DMA: supported
    [ 1.804867] spi_davinci spi_davinci.1: DMA: RX channel: 0x00000012, TX channel: 0x00000013, event queue: 0
    [ 2.048249] spi_davinci spi_davinci.1: registered master spi1
    [ 2.054797] spi_davinci spi_davinci.1: davinci_spi_chipselect BITBANG_CS_INACTIVE
    [ 2.063456] spi spi1.0: setup mode 3, 8 bits/w, 5000000 Hz max --> 0
    [ 2.071135] spi_davinci spi_davinci.1: registered child spi1.0
    [ 2.077043] spi_davinci spi_davinci.1: Controller at 0xfee12000
    [ 2.477744] mmc_spi spi1.0: setup mode 3, 8 bits/w, 5000000 Hz max --> 0
    [ 2.485150] mmc_spi spi1.0: ASSUMING 3.2-3.4 V slot power
    [ 2.491915] mmc0: clock 0Hz busmode 2 powermode 1 cs 1 Vdd 21 width 0 timing 0
    [ 2.499215] mmc_spi spi1.0: mmc_spi: power up (21)
    [ 2.520463] mmc0: clock 400000Hz busmode 2 powermode 2 cs 1 Vdd 21 width 0 timing 0
    [ 2.528194] mmc_spi spi1.0: mmc_spi: power on (21)
    [ 2.533368] edma-dma-engine edma-dma-engine.0: vchan c3013160: txd c31671e0[2]: submitted
    [ 2.541847] edma-dma-engine edma-dma-engine.0: vchan c3013250: txd c3167060[2]: submitted
    [ 2.550127] edma-dma-engine edma-dma-engine.0:
    [ 2.550127] pset[0]:
    [ 2.550127] chnum 18
    [ 2.550127] slot 18
    [ 2.550127] opt 00112000
    [ 2.550127] src 01e12040
    [ 2.550127] dst c31d60e0
    [ 2.550127] abcnt 001d0001
    [ 2.550127] ccnt 00000001
    [ 2.550127] bidx 00010000
    [ 2.550127] cidx 00010000
    [ 2.550127] lkrld ffffffff
    [ 2.583816] edma-dma-engine edma-dma-engine.0: first transfer starting 18
    [ 2.591587] edma-dma-engine edma-dma-engine.0:
    [ 2.591587] pset[0]:
    [ 2.591587] chnum 19
    [ 2.591587] slot 19
    [ 2.591587] opt 00113000
    [ 2.591587] src c31bd200
    [ 2.591587] dst 01e1203c
    [ 2.591587] abcnt 001d0001
    [ 2.591587] ccnt 00000001
    [ 2.591587] bidx 00000001
    [ 2.591587] cidx 00000001
    [ 2.591587] lkrld ffffffff
    [ 2.625301] edma-dma-engine edma-dma-engine.0: first transfer starting 19
    [ 2.632486] edma-dma-engine edma-dma-engine.0: Transfer complete, stopping channel 18
    [ 2.640382] edma-dma-engine edma-dma-engine.0: txd c31671e0[2]: marked complete
    [ 2.647737] edma-dma-engine edma-dma-engine.0: Transfer complete, stopping channel 19
    [ 2.655609] edma-dma-engine edma-dma-engine.0: txd c3167060[2]: marked complete
    [ 2.663382] edma-dma-engine edma-dma-engine.0: vchan c3013160: txd c3167120[3]: submitted
    [ 2.671787] edma-dma-engine edma-dma-engine.0: vchan c3013250: txd c3167060[3]: submitted
    [ 2.680064] edma-dma-engine edma-dma-engine.0:
    [ 2.680064] pset[0]:
    [ 2.680064] chnum 18
    [ 2.680064] slot 18
    [ 2.680064] opt 00112000
    [ 2.680064] src 01e12040
    [ 2.680064] dst c31d60e0
    [ 2.680064] abcnt 000a0001
    [ 2.680064] ccnt 00000001
    [ 2.680064] bidx 00010000
    [ 2.680064] cidx 00010000
    [ 2.680064] lkrld ffffffff
    [ 2.713755] edma-dma-engine edma-dma-engine.0: first transfer starting 18
    [ 2.720767] edma-dma-engine edma-dma-engine.0:
    [ 2.720767] pset[0]:
    [ 2.720767] chnum 19
    [ 2.720767] slot 19
    [ 2.720767] opt 00113000
    [ 2.720767] src c31bd200
    [ 2.720767] dst 01e1203c
    [ 2.720767] abcnt 000a0001
    [ 2.720767] ccnt 00000001
    [ 2.720767] bidx 00000001
    [ 2.720767] cidx 00000001
    [ 2.720767] lkrld ffffffff
    [ 2.754473] edma-dma-engine edma-dma-engine.0: first transfer starting 19
    [ 2.761500] edma-dma-engine edma-dma-engine.0: Transfer complete, stopping channel 18
    [ 2.769392] edma-dma-engine edma-dma-engine.0: txd c3167120[3]: marked complete
    [ 2.776747] edma-dma-engine edma-dma-engine.0: Transfer complete, stopping channel 19
    [ 2.784620] edma-dma-engine edma-dma-engine.0: txd c3167060[3]: marked complete
    [ 2.792255] mmc_spi spi1.0: setup: unsupported mode bits 4
    [ 2.797797] mmc_spi spi1.0: can't change chip-select polarity
    [ 2.812284] mmc_spi spi1.0: setup mode 3, 8 bits/w, 400000 Hz max --> 0
    [ 2.818953] mmc_spi spi1.0: mmc_spi: clock to 400000 Hz, 0
    [ 2.840455] mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
    [ 2.847283] mmc0: mmc_rescan_try_freq: trying to init card at 400000 Hz
    [ 2.857462] usbcore: registered new interface driver usbhid
    [ 2.863438] usbhid: USB HID core driver
    [ 2.867823] mmc0: starting CMD52 arg 00000c00 flags 00000195
    [ 2.883154] mmc_spi spi1.0: mmc_spi: CMD52, resp R2/R5
    [ 2.899906] spi_master spi1: failed to transfer one message from queue ... write returned -22
    [ 2.943759] mmc0: req done (CMD52): -22: 00000000 00000000 00000000 00000000
    [ 2.951183] mmc0: starting CMD52 arg 80000c08 flags 00000195
    [ 2.956918] mmc_spi spi1.0: mmc_spi: CMD52, resp R2/R5
    [ 2.979102] spi_master spi1: failed to transfer one message from queue ... write returned -22
    [ 2.995654] mmc0: req done (CMD52): -22: 00000000 00000000 00000000 00000000
    [ 3.006646] mmc0: starting CMD0 arg 00000000 flags 000000c0