diff options
-rw-r--r-- | drivers/mmc/core/sdio_ops.c | 37 | ||||
-rw-r--r-- | drivers/mmc/core/sdio_ops.h | 2 | ||||
-rw-r--r-- | include/linux/mmc/core.h | 1 | ||||
-rw-r--r-- | include/linux/mmc/sdio.h | 34 |
4 files changed, 74 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 @@ | |||
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 | ||
51 | int 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 d8c982976f19..f0e9d69e5ce8 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 | ||
15 | int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); | 15 | int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr); |
16 | int 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 | ||
diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h index 8faa436c5571..43a92736be63 100644 --- a/include/linux/mmc/core.h +++ b/include/linux/mmc/core.h | |||
@@ -42,6 +42,7 @@ struct mmc_command { | |||
42 | #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) | 42 | #define MMC_RSP_R2 (MMC_RSP_PRESENT|MMC_RSP_136|MMC_RSP_CRC) |
43 | #define MMC_RSP_R3 (MMC_RSP_PRESENT) | 43 | #define MMC_RSP_R3 (MMC_RSP_PRESENT) |
44 | #define MMC_RSP_R4 (MMC_RSP_PRESENT) | 44 | #define MMC_RSP_R4 (MMC_RSP_PRESENT) |
45 | #define MMC_RSP_R5 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | ||
45 | #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | 46 | #define MMC_RSP_R6 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
46 | #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) | 47 | #define MMC_RSP_R7 (MMC_RSP_PRESENT|MMC_RSP_CRC|MMC_RSP_OPCODE) |
47 | 48 | ||
diff --git a/include/linux/mmc/sdio.h b/include/linux/mmc/sdio.h index d1a0b15cdfdf..e5f06de7d527 100644 --- a/include/linux/mmc/sdio.h +++ b/include/linux/mmc/sdio.h | |||
@@ -14,6 +14,40 @@ | |||
14 | 14 | ||
15 | /* SDIO commands type argument response */ | 15 | /* SDIO commands type argument response */ |
16 | #define SD_IO_SEND_OP_COND 5 /* bcr [23:0] OCR R4 */ | 16 | #define SD_IO_SEND_OP_COND 5 /* bcr [23:0] OCR R4 */ |
17 | #define SD_IO_RW_DIRECT 52 /* ac [31:0] See below R5 */ | ||
18 | |||
19 | /* | ||
20 | * SD_IO_RW_DIRECT argument format: | ||
21 | * | ||
22 | * [31] R/W flag | ||
23 | * [30:28] Function number | ||
24 | * [27] RAW flag | ||
25 | * [25:9] Register address | ||
26 | * [7:0] Data | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | SDIO status in R5 | ||
31 | Type | ||
32 | e : error bit | ||
33 | s : status bit | ||
34 | r : detected and set for the actual command response | ||
35 | x : detected and set during command execution. the host must poll | ||
36 | the card by sending status command in order to read these bits. | ||
37 | Clear condition | ||
38 | a : according to the card state | ||
39 | b : always related to the previous command. Reception of | ||
40 | a valid command will clear it (with a delay of one command) | ||
41 | c : clear by read | ||
42 | */ | ||
43 | |||
44 | #define R5_COM_CRC_ERROR (1 << 15) /* er, b */ | ||
45 | #define R5_ILLEGAL_COMMAND (1 << 14) /* er, b */ | ||
46 | #define R5_ERROR (1 << 11) /* erx, c */ | ||
47 | #define R5_FUNCTION_NUMBER (1 << 9) /* er, c */ | ||
48 | #define R5_OUT_OF_RANGE (1 << 8) /* er, c */ | ||
49 | #define R5_STATUS(x) (x & 0xCB00) | ||
50 | #define R5_IO_CURRENT_STATE(x) ((x & 0x3000) >> 12) /* s, b */ | ||
17 | 51 | ||
18 | #endif | 52 | #endif |
19 | 53 | ||