aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-05-22 14:25:21 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-09-23 13:42:37 -0400
commitb2bcc798bbb482b2909801280f3c4aff8cbbf5be (patch)
tree74b1b4e6876fbc7187f67cc2b36ed03ae7c59acc /drivers/mmc
parent5c4e6f1301649d5b29dd0f70e6da83e728ab5ca5 (diff)
mmc: implement SDIO IO_RW_DIRECT operation
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/sdio_ops.c37
-rw-r--r--drivers/mmc/core/sdio_ops.h2
2 files changed, 39 insertions, 0 deletions
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index d6f9f9d8517..31233f7b55c 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -10,6 +10,7 @@
10 */ 10 */
11 11
12#include <linux/mmc/host.h> 12#include <linux/mmc/host.h>
13#include <linux/mmc/card.h>
13#include <linux/mmc/mmc.h> 14#include <linux/mmc/mmc.h>
14#include <linux/mmc/sdio.h> 15#include <linux/mmc/sdio.h>
15 16
@@ -47,3 +48,39 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
47 return err; 48 return err;
48} 49}
49 50
51int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
52 unsigned addr, u8 in, u8* out)
53{
54 struct mmc_command cmd;
55 int err;
56
57 BUG_ON(!card);
58 BUG_ON(fn > 7);
59
60 memset(&cmd, 0, sizeof(struct mmc_command));
61
62 cmd.opcode = SD_IO_RW_DIRECT;
63 cmd.arg = write ? 0x80000000 : 0x00000000;
64 cmd.arg |= fn << 28;
65 cmd.arg |= (write && out) ? 0x08000000 : 0x00000000;
66 cmd.arg |= addr << 9;
67 cmd.arg |= in;
68 cmd.flags = MMC_RSP_R5 | MMC_CMD_AC;
69
70 err = mmc_wait_for_cmd(card->host, &cmd, 0);
71 if (err)
72 return err;
73
74 if (cmd.resp[0] & R5_ERROR)
75 return -EIO;
76 if (cmd.resp[0] & R5_FUNCTION_NUMBER)
77 return -EINVAL;
78 if (cmd.resp[0] & R5_OUT_OF_RANGE)
79 return -ERANGE;
80
81 if (out)
82 *out = cmd.resp[0] & 0xFF;
83
84 return 0;
85}
86
diff --git a/drivers/mmc/core/sdio_ops.h b/drivers/mmc/core/sdio_ops.h
index d8c982976f1..f0e9d69e5ce 100644
--- a/drivers/mmc/core/sdio_ops.h
+++ b/drivers/mmc/core/sdio_ops.h
@@ -13,6 +13,8 @@
13#define _MMC_SDIO_OPS_H 13#define _MMC_SDIO_OPS_H
14 14
15int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); 15int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr);
16int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
17 unsigned addr, u8 in, u8* out);
16 18
17#endif 19#endif
18 20