diff options
author | Ben Gardiner <bengardiner@nanometrics.ca> | 2013-05-30 17:12:47 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-06-27 11:11:05 -0400 |
commit | 27c357db04350b75b0fceaae8bfb9ce99c50866b (patch) | |
tree | 8f5584624417decc86f9c9ff9aaede61ea784d0b | |
parent | a6cd98de8b158029ca6b9c1e961729dc83a7144c (diff) | |
download | mmc-utils-27c357db04350b75b0fceaae8bfb9ce99c50866b.tar.gz |
Support SEND_STATUS command
mmc status get </path/to/mmcblkX>
Signed-off-by: Ben Gardiner <bengardiner@nanometrics.ca>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | mmc.c | 5 | ||||
-rw-r--r-- | mmc.h | 2 | ||||
-rw-r--r-- | mmc_cmds.c | 47 | ||||
-rw-r--r-- | mmc_cmds.h | 1 |
4 files changed, 55 insertions, 0 deletions
@@ -70,6 +70,11 @@ static struct Command commands[] = { "Set the eMMC data sector size to 4KB by disabling emulation on\n<device>.", NULL }, + { do_status_get, -1, + "status get", "<device>\n" + "Print the response to STATUS_SEND (CMD13).", + NULL + }, { do_write_boot_en, -3, "bootpart enable", "<boot_partition> " "<send_ack> " "<device>\n" "Enable the boot partition for the <device>.\nTo receive acknowledgment of boot from the card set <send_ack>\nto 1, else set it to 0.", @@ -26,6 +26,8 @@ /* From kernel linux/mmc/mmc.h */ #define MMC_SWITCH 6 /* ac [31:0] See below R1b */ #define MMC_SEND_EXT_CSD 8 /* adtc R1 */ +#define MMC_SEND_STATUS 13 /* ac [31:16] RCA R1 */ +#define R1_SWITCH_ERROR (1 << 7) /* sx, c */ #define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */ /* @@ -72,6 +72,25 @@ int write_extcsd_value(int fd, __u8 index, __u8 value) return ret; } +int send_status(int fd, __u32 *response) +{ + int ret = 0; + struct mmc_ioc_cmd idata; + + memset(&idata, 0, sizeof(idata)); + idata.opcode = MMC_SEND_STATUS; + idata.arg = (1 << 16); + idata.flags = MMC_RSP_R1 | MMC_CMD_AC; + + ret = ioctl(fd, MMC_IOC_CMD, &idata); + if (ret) + perror("ioctl"); + + *response = idata.response[0]; + + return ret; +} + void print_writeprotect_status(__u8 *ext_csd) { __u8 reg; @@ -377,6 +396,34 @@ int do_write_bkops_en(int nargs, char **argv) return ret; } +int do_status_get(int nargs, char **argv) +{ + __u32 response; + int fd, ret; + char *device; + + CHECK(nargs != 2, "Usage: mmc status get </path/to/mmcblkX>\n", + exit(1)); + + device = argv[1]; + + fd = open(device, O_RDWR); + if (fd < 0) { + perror("open"); + exit(1); + } + + ret = send_status(fd, &response); + if (ret) { + fprintf(stderr, "Could not read response to SEND_STATUS from %s\n", device); + exit(1); + } + + printf("SEND_STATUS response: 0x%08x\n", response); + + return ret; +} + int do_read_extcsd(int nargs, char **argv) { __u8 ext_csd[512], ext_csd_rev, reg; @@ -25,3 +25,4 @@ int do_write_bkops_en(int nargs, char **argv); int do_hwreset_en(int nargs, char **argv); int do_hwreset_dis(int nargs, char **argv); int do_sanitize(int nargs, char **argv); +int do_status_get(int nargs, char **argv); |