aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sdio_ops.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core/sdio_ops.c')
-rw-r--r--drivers/mmc/core/sdio_ops.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c
index 4eb7825fd1a7..dea36d9c22e6 100644
--- a/drivers/mmc/core/sdio_ops.c
+++ b/drivers/mmc/core/sdio_ops.c
@@ -67,13 +67,13 @@ int mmc_send_io_op_cond(struct mmc_host *host, u32 ocr, u32 *rocr)
67 return err; 67 return err;
68} 68}
69 69
70int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn, 70static int mmc_io_rw_direct_host(struct mmc_host *host, int write, unsigned fn,
71 unsigned addr, u8 in, u8* out) 71 unsigned addr, u8 in, u8 *out)
72{ 72{
73 struct mmc_command cmd; 73 struct mmc_command cmd;
74 int err; 74 int err;
75 75
76 BUG_ON(!card); 76 BUG_ON(!host);
77 BUG_ON(fn > 7); 77 BUG_ON(fn > 7);
78 78
79 /* sanity check */ 79 /* sanity check */
@@ -90,11 +90,11 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
90 cmd.arg |= in; 90 cmd.arg |= in;
91 cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC; 91 cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_AC;
92 92
93 err = mmc_wait_for_cmd(card->host, &cmd, 0); 93 err = mmc_wait_for_cmd(host, &cmd, 0);
94 if (err) 94 if (err)
95 return err; 95 return err;
96 96
97 if (mmc_host_is_spi(card->host)) { 97 if (mmc_host_is_spi(host)) {
98 /* host driver already reported errors */ 98 /* host driver already reported errors */
99 } else { 99 } else {
100 if (cmd.resp[0] & R5_ERROR) 100 if (cmd.resp[0] & R5_ERROR)
@@ -106,7 +106,7 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
106 } 106 }
107 107
108 if (out) { 108 if (out) {
109 if (mmc_host_is_spi(card->host)) 109 if (mmc_host_is_spi(host))
110 *out = (cmd.resp[0] >> 8) & 0xFF; 110 *out = (cmd.resp[0] >> 8) & 0xFF;
111 else 111 else
112 *out = cmd.resp[0] & 0xFF; 112 *out = cmd.resp[0] & 0xFF;
@@ -115,6 +115,13 @@ int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
115 return 0; 115 return 0;
116} 116}
117 117
118int mmc_io_rw_direct(struct mmc_card *card, int write, unsigned fn,
119 unsigned addr, u8 in, u8 *out)
120{
121 BUG_ON(!card);
122 return mmc_io_rw_direct_host(card->host, write, fn, addr, in, out);
123}
124
118int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, 125int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
119 unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz) 126 unsigned addr, int incr_addr, u8 *buf, unsigned blocks, unsigned blksz)
120{ 127{
@@ -182,3 +189,20 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn,
182 return 0; 189 return 0;
183} 190}
184 191
192int sdio_reset(struct mmc_host *host)
193{
194 int ret;
195 u8 abort;
196
197 /* SDIO Simplified Specification V2.0, 4.4 Reset for SDIO */
198
199 ret = mmc_io_rw_direct_host(host, 0, 0, SDIO_CCCR_ABORT, 0, &abort);
200 if (ret)
201 abort = 0x08;
202 else
203 abort |= 0x08;
204
205 ret = mmc_io_rw_direct_host(host, 1, 0, SDIO_CCCR_ABORT, abort, NULL);
206 return ret;
207}
208