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.

AM3892 SDIO SD_CMD register transfer mode DDIR bit

Other Parts Discussed in Thread: AM3892, CCSTUDIO

I'm writing a BSP for an SD Card driver, and encountered an issue which is preventing me from reading data from the SD Card.

The SD Card driver is attempting to read the SCR from the card using CMD51. The driver indicates to my BSP that this is a read command, so my command setup is trying to set the DDIR bit in SD_CMD to indicate a read. (This bit reads back as zero after being "set", but bits 16 - 23 of the register read back properly)

The command transmits successfully, then the card driver calls my "read data" entry point, but at this point the SD_PSTATE register has WTA (Write Transfer Active) and BWE (Buffer Write Enable) set, instead of the expected RTA (Read Transfer Active) and BRE (Buffer Read Enable). This is presumably due to the DDIR bit not being set to 1.

I've tried accessing the transfer mode bits in SD_CMD as a separate 16-bit or 8-bit value, and changing the order of the accesses to the transfer mode bits and the "type" bits, but I'm still getting readback values that seem to indicate the controller is treating this command as a write instead of a read.

What do I need to do to get the DDIR data direction bit set properly, so that my "read" command is treated as a read operation?

  • Hi Philip,

    Make sure you are not in the middle of a transfer, as a write into SD_CARD[15:0] during data transfer has no effect.

    BR
    Pavel
  • The SD/SDIO registers are limited to 32-bit data accesses. 16-bit and 8-bit are not allowed and can corrupt register content.
  • You can also take for reference the u-boot code:
    u-boot/drivers/mmc/omap_hsmmc.c -> mmc_send_cmd()

    BR
    Pavel
  • Still not working.
    SD_IE and SD_ISE are set to 0x337f0001 for this command. I write 0x333a0010 to SD_CMD as a 32-bit value. My ISR processes a command complete without any other status bits set and posts a semaphore. The SD card driver pends on the semaphore, and reads an error code of "no error". It then calls the read data routine. I've setup a readback of selected registers for debug at this point. SD_CMD reads back 0x333a0000 (DDIR not set), and SD_PSTATE reads 0x01160506 (BWE and WTA instead of BRE and RTA).
  • Can I get a link to that file?
  • File is attached.

    4812.omap_hsmmc.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /*
    * (C) Copyright 2008
    * Texas Instruments, <www.ti.com>
    * Sukumar Ghorai <s-ghorai@ti.com>
    *
    * See file CREDITS for list of people who contributed to this
    * project.
    *
    * This program is free software; you can redistribute it and/or
    * modify it under the terms of the GNU General Public License as
    * published by the Free Software Foundation's version 2 of
    * the License.
    *
    * This program is distributed in the hope that it will be useful,
    * but WITHOUT ANY WARRANTY; without even the implied warranty of
    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    * GNU General Public License for more details.
    *
    * You should have received a copy of the GNU General Public License
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    BR
    Pavel

  • The whole u-boot code base is available at:
    http://arago-project.org/git/projects/u-boot-omap3.git?p=projects/u-boot-omap3.git;a=shortlog;h=refs/heads/ti81xx-master

    BR
    Pavel

  • Thanks for the file.

    I had hoped that in directing me to that particular file, you would provide a module that operates on the same SDIO controller that I'm working with.

    I assume that driver works fine on an OMAP, but I'm not running on an OMAP.

    I'm running on AM3892. The SDIO controllers are different. I need help with the one that's on the AM3892.

  • SDIO controllers in OMAP34xx and TI81XX devices are the same, only the base address is different. AM3892 is part of the TI81XX family of devices.

    The AM3892 SDIO related files in u-boot are:

    /arch/arm/include/asm/arch-ti81xx/mmc_host_def.h
    /drivers/mmc/omap_hsmmc.c

    BR
    Pavel
  • My mistake, I was looking at the wrong OMAP reference manual. I see that the OMAP34xx manual does indeed describe the same register set as the AM3892.
    Be that as it may, my original question stands. I believe I am writing the correct value to SD_CMD, as described in my post from 2 days ago. What might possibly be preventing me from getting the DDIR bit set when initiating a command with data present?
  • By the way, those path/file references aren't helping at all. Are you assuming I'm running on a Linux-based platform?
  • By the way, those path/file references aren't helping. Are you assuming I'm running on a Linux-based platform?
  • Philip,

    Are you working on AM389x custom board? Can you try this with the DM816x/AM389x TI EVM?

    We have also bare metal program example (CCStudio project, GEL file + C/H files) for DM814x MMC/SD/SDIO controller which might be in help:

    www.mistralsolutions.com/.../support-downloads

    Software -> Diagnostic software -> CCS_Test_code -> Base_Board -> sdmmc_card

    Test configures the DM814X SD Controller, detects and initialises the SD Card. The test writes an pattern to the first block of the sd card. The tests reads back the data written on the sd card and verifies it.

    BR
    Pavel
  • Philip Spies2 said:
    Are you assuming I'm running on a Linux-based platform?

    No, I do not. But u-boot mmc/sd/sdio code can be used as a reference for every BSP you are working on.

    BR
    Pavel