I have a Debian 7.0 Linux 3.2 embedded ARM TI AM335x system. This is a custom board we've developed, but the SD card section at least is the same as the development board. There are some vendor-specific SD card commands I'd like to issue to the card, namely reading some SMART data using CMD56.
Is there any way to send commands to the SD card controller and read the response from userspace?
Yes, there are vendor-specific SD card commands you can read SMART data from SD card to your device using CMD56.
The Host must be able to support vendor command “CMD61” and “CMD56”. And it needs to have 5ms delay for FW busy time between issue CMD61 and CMD56.
Paul.

Your driver is
omap_hsmmc
according to http://processors.wiki.ti.com/index.php/AM335x_MMC/SD_Driver%27s_Guide some info also in https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/ti-omap-hsmmc.txtAfter some web searching for SMART monitoring support in sd cards, I get the search query
mmc smartctl
(becausesmartctl
is name of SMART monitoring utility for *ATA in Linux, andmmc
is the kernel subsystem to implement MMC, SD, SDHC cards and controllers. I found the bug filled against some mobile PC OS, https://code.google.com/p/chromium/issues/detail?id=315380 by Gwendal GrignouIt sounds like the
mmc-utils
it the tool of choice to implement SMART for SD cards. There is home git ofmmc-utils
on kernel.org: http://git.kernel.org/cgit/linux/kernel/git/cjb/mmc-utils.git/tree/I see no "SMART" here, but the mmc-utils/mmc_cmds.c has code to send custom commands to the card by using
ioctl(fd, MMC_IOC_CMD, (struct mmc_ioc_cmd*) &ioctl_data)
with fd pointing to correctmmcblkX
device (I hope this works with most SD controllers). Code by Johan RUDHOLM (from st-ericsson, 2012, GPLv2):Some documentation and examples for MMC_IOC_CMD were posted in LKML by Shashidhar Hiremath at 20 Dec 14:54 2011 "[PATCH 1/1] mmc: User Application for testing SD/MMC Commands and extra IOCTL Command for MMC card reset"
The official userAPI (uapi) for
struct mmc_ioc_cmd
is in linux source treeinclude/uapi/linux/mmc/ioctl.h
:The simplest way is mmap the memory space of SD controller,then write command of sd controller's data sheet to controller.