summaryrefslogtreecommitdiff
path: root/drivers/mmc/core/sdio_ops.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-05-22 22:25:21 +0400
committerPierre Ossman <drzeus@drzeus.cx>2007-09-23 21:42:37 +0400
commitb2bcc798bbb482b2909801280f3c4aff8cbbf5be (patch)
tree74b1b4e6876fbc7187f67cc2b36ed03ae7c59acc /drivers/mmc/core/sdio_ops.c
parent5c4e6f1301649d5b29dd0f70e6da83e728ab5ca5 (diff)
downloadlinux-b2bcc798bbb482b2909801280f3c4aff8cbbf5be.tar.xz
mmc: implement SDIO IO_RW_DIRECT operation
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/core/sdio_ops.c')
-rw-r--r--drivers/mmc/core/sdio_ops.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index d6f9f9d85178..31233f7b55cd 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -10,6 +10,7 @@
*/
#include <linux/mmc/host.h>
+#include <linux/mmc/card.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
@@ -47,3 +48,39 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
return err;
}
+int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
+ unsigned addr, u8 in, u8* out)
+{
+ struct mmc_command cmd;
+ int err;
+
+ BUG_ON(!card);
+ BUG_ON(fn > 7);
+
+ memset(&cmd, 0, sizeof(struct mmc_command));
+
+ cmd.opcode = SD_IO_RW_DIRECT;
+ cmd.arg = write ? 0x80000000 : 0x00000000;
+ cmd.arg |= fn << 28;
+ cmd.arg |= (write && out) ? 0x08000000 : 0x00000000;
+ cmd.arg |= addr << 9;
+ cmd.arg |= in;
+ cmd.flags = MMC_RSP_R5 | MMC_CMD_AC;
+
+ err = mmc_wait_for_cmd(card->host, &cmd, 0);
+ if (err)
+ return err;
+
+ if (cmd.resp[0] & R5_ERROR)
+ return -EIO;
+ if (cmd.resp[0] & R5_FUNCTION_NUMBER)
+ return -EINVAL;
+ if (cmd.resp[0] & R5_OUT_OF_RANGE)
+ return -ERANGE;
+
+ if (out)
+ *out = cmd.resp[0] & 0xFF;
+
+ return 0;
+}
+