23 #define OCR_FASTBOOT (1<<29)
24 #define OCR_HCS (1<<30)
25 #define OCR_BUSY (1<<31)
27 #define RESP_CMD12 0x00000030
51 #define ALL_ERROR (TMIO_STAT_CMD_IDX_ERR | TMIO_STAT_CRCFAIL | \
52 TMIO_STAT_STOPBIT_ERR | TMIO_STAT_DATATIMEOUT | \
53 TMIO_STAT_RXOVERFLOW | TMIO_STAT_TXUNDERRUN | \
54 TMIO_STAT_CMDTIMEOUT | TMIO_STAT_ILL_ACCESS | \
57 static int sdhi_intr(
void __iomem *base)
69 sd_ctrl_write32(base,
CTL_STATUS, ~TMIO_STAT_CMDRESPEND);
71 TMIO_STAT_CMDRESPEND |
76 sd_ctrl_write32(base,
CTL_STATUS, ~TMIO_STAT_RXRDY);
83 sd_ctrl_write32(base,
CTL_STATUS, ~TMIO_STAT_DATAEND);
93 static int sdhi_boot_wait_resp_end(
void __iomem *base)
98 err = sdhi_intr(base);
108 #define CLK_MMC_ENABLE (1 << 8)
109 #define CLK_MMC_INIT (1 << 6)
111 static void sdhi_boot_mmc_clk_stop(
void __iomem *base)
120 static void sdhi_boot_mmc_clk_start(
void __iomem *base)
129 static void sdhi_boot_reset(
void __iomem *base)
143 static int sdhi_boot_mmc_set_ios(
void __iomem *base,
struct mmc_ios *ios)
155 sdhi_boot_mmc_clk_stop(base);
160 sdhi_boot_mmc_clk_start(base);
181 #define RESP_NONE 0x0300
182 #define RESP_R1 0x0400
183 #define RESP_R1B 0x0500
184 #define RESP_R2 0x0600
185 #define RESP_R3 0x0700
186 #define DATA_PRESENT 0x0800
187 #define TRANSFER_READ 0x1000
216 err = sdhi_boot_wait_resp_end(base);
225 static int sdhi_boot_do_read_single(
void __iomem *base,
int high_capacity,
226 unsigned long block,
unsigned short *
buf)
241 err = sdhi_boot_request(base, &
cmd);
250 err = sdhi_boot_wait_resp_end(base);
255 for (i = 0; i < TMIO_BBS /
sizeof(*buf); i++)
258 err = sdhi_boot_wait_resp_end(base);
272 for (i = 0; i <
count; i++) {
273 err = sdhi_boot_do_read_single(base, high_capacity, offset + i,
274 buf + (i * TMIO_BBS /
283 #define VOLTAGES (MMC_VDD_32_33 | MMC_VDD_33_34)
287 bool sd_v2 =
false, sd_v1_0 =
false;
289 int err, high_capacity = 0;
291 sdhi_boot_mmc_clk_stop(base);
292 sdhi_boot_reset(base);
300 err = sdhi_boot_mmc_set_ios(base, &ios);
312 err = sdhi_boot_request(base, &cmd);
324 err = sdhi_boot_request(base, &cmd);
325 if ((cmd.
resp[0] & 0xff) == 0xaa)
340 err = sdhi_boot_request(base, &cmd);
350 err = sdhi_boot_request(base, &cmd);
357 if (!err && timeout) {
365 if (!sd_v2 && !sd_v1_0) {
373 err = sdhi_boot_request(base, &cmd);
392 err = sdhi_boot_request(base, &cmd);
407 err = sdhi_boot_request(base, &cmd);
410 cid = cmd.
resp[0] >> 16;
419 err = sdhi_boot_request(base, &cmd);
432 err = sdhi_boot_request(base, &cmd);
443 err = sdhi_boot_request(base, &cmd);
448 return high_capacity;