diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/card/block.c | 122 | ||||
-rw-r--r-- | drivers/mmc/core/core.c | 77 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 18 | ||||
-rw-r--r-- | drivers/mmc/host/Makefile | 3 | ||||
-rw-r--r-- | drivers/mmc/host/at91_mci.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/atmel-mci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/imxmmc.c | 459 | ||||
-rw-r--r-- | drivers/mmc/host/imxmmc.h | 37 | ||||
-rw-r--r-- | drivers/mmc/host/mmc_spi.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/mmci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/of_mmc_spi.c | 149 | ||||
-rw-r--r-- | drivers/mmc/host/omap.c | 7 | ||||
-rw-r--r-- | drivers/mmc/host/pxamci.c | 9 | ||||
-rw-r--r-- | drivers/mmc/host/ricoh_mmc.c | 17 | ||||
-rw-r--r-- | drivers/mmc/host/s3cmci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-pci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.c | 17 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.h | 2 | ||||
-rw-r--r-- | drivers/mmc/host/sdricoh_cs.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.c | 3 |
20 files changed, 643 insertions, 297 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 3d067c35185d..45b1f430685f 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -145,7 +145,7 @@ struct mmc_blk_request { | |||
145 | static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) | 145 | static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) |
146 | { | 146 | { |
147 | int err; | 147 | int err; |
148 | u32 blocks; | 148 | __be32 blocks; |
149 | 149 | ||
150 | struct mmc_request mrq; | 150 | struct mmc_request mrq; |
151 | struct mmc_command cmd; | 151 | struct mmc_command cmd; |
@@ -204,9 +204,24 @@ static u32 mmc_sd_num_wr_blocks(struct mmc_card *card) | |||
204 | if (cmd.error || data.error) | 204 | if (cmd.error || data.error) |
205 | return (u32)-1; | 205 | return (u32)-1; |
206 | 206 | ||
207 | blocks = ntohl(blocks); | 207 | return ntohl(blocks); |
208 | } | ||
209 | |||
210 | static u32 get_card_status(struct mmc_card *card, struct request *req) | ||
211 | { | ||
212 | struct mmc_command cmd; | ||
213 | int err; | ||
208 | 214 | ||
209 | return blocks; | 215 | memset(&cmd, 0, sizeof(struct mmc_command)); |
216 | cmd.opcode = MMC_SEND_STATUS; | ||
217 | if (!mmc_host_is_spi(card->host)) | ||
218 | cmd.arg = card->rca << 16; | ||
219 | cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC; | ||
220 | err = mmc_wait_for_cmd(card->host, &cmd, 0); | ||
221 | if (err) | ||
222 | printk(KERN_ERR "%s: error %d sending status comand", | ||
223 | req->rq_disk->disk_name, err); | ||
224 | return cmd.resp[0]; | ||
210 | } | 225 | } |
211 | 226 | ||
212 | static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | 227 | static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) |
@@ -214,13 +229,13 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
214 | struct mmc_blk_data *md = mq->data; | 229 | struct mmc_blk_data *md = mq->data; |
215 | struct mmc_card *card = md->queue.card; | 230 | struct mmc_card *card = md->queue.card; |
216 | struct mmc_blk_request brq; | 231 | struct mmc_blk_request brq; |
217 | int ret = 1; | 232 | int ret = 1, disable_multi = 0; |
218 | 233 | ||
219 | mmc_claim_host(card->host); | 234 | mmc_claim_host(card->host); |
220 | 235 | ||
221 | do { | 236 | do { |
222 | struct mmc_command cmd; | 237 | struct mmc_command cmd; |
223 | u32 readcmd, writecmd; | 238 | u32 readcmd, writecmd, status = 0; |
224 | 239 | ||
225 | memset(&brq, 0, sizeof(struct mmc_blk_request)); | 240 | memset(&brq, 0, sizeof(struct mmc_blk_request)); |
226 | brq.mrq.cmd = &brq.cmd; | 241 | brq.mrq.cmd = &brq.cmd; |
@@ -236,6 +251,14 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
236 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; | 251 | brq.stop.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC; |
237 | brq.data.blocks = req->nr_sectors; | 252 | brq.data.blocks = req->nr_sectors; |
238 | 253 | ||
254 | /* | ||
255 | * After a read error, we redo the request one sector at a time | ||
256 | * in order to accurately determine which sectors can be read | ||
257 | * successfully. | ||
258 | */ | ||
259 | if (disable_multi && brq.data.blocks > 1) | ||
260 | brq.data.blocks = 1; | ||
261 | |||
239 | if (brq.data.blocks > 1) { | 262 | if (brq.data.blocks > 1) { |
240 | /* SPI multiblock writes terminate using a special | 263 | /* SPI multiblock writes terminate using a special |
241 | * token, not a STOP_TRANSMISSION request. | 264 | * token, not a STOP_TRANSMISSION request. |
@@ -264,6 +287,25 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
264 | brq.data.sg = mq->sg; | 287 | brq.data.sg = mq->sg; |
265 | brq.data.sg_len = mmc_queue_map_sg(mq); | 288 | brq.data.sg_len = mmc_queue_map_sg(mq); |
266 | 289 | ||
290 | /* | ||
291 | * Adjust the sg list so it is the same size as the | ||
292 | * request. | ||
293 | */ | ||
294 | if (brq.data.blocks != req->nr_sectors) { | ||
295 | int i, data_size = brq.data.blocks << 9; | ||
296 | struct scatterlist *sg; | ||
297 | |||
298 | for_each_sg(brq.data.sg, sg, brq.data.sg_len, i) { | ||
299 | data_size -= sg->length; | ||
300 | if (data_size <= 0) { | ||
301 | sg->length += data_size; | ||
302 | i++; | ||
303 | break; | ||
304 | } | ||
305 | } | ||
306 | brq.data.sg_len = i; | ||
307 | } | ||
308 | |||
267 | mmc_queue_bounce_pre(mq); | 309 | mmc_queue_bounce_pre(mq); |
268 | 310 | ||
269 | mmc_wait_for_req(card->host, &brq.mrq); | 311 | mmc_wait_for_req(card->host, &brq.mrq); |
@@ -275,19 +317,40 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
275 | * until later as we need to wait for the card to leave | 317 | * until later as we need to wait for the card to leave |
276 | * programming mode even when things go wrong. | 318 | * programming mode even when things go wrong. |
277 | */ | 319 | */ |
320 | if (brq.cmd.error || brq.data.error || brq.stop.error) { | ||
321 | if (brq.data.blocks > 1 && rq_data_dir(req) == READ) { | ||
322 | /* Redo read one sector at a time */ | ||
323 | printk(KERN_WARNING "%s: retrying using single " | ||
324 | "block read\n", req->rq_disk->disk_name); | ||
325 | disable_multi = 1; | ||
326 | continue; | ||
327 | } | ||
328 | status = get_card_status(card, req); | ||
329 | } | ||
330 | |||
278 | if (brq.cmd.error) { | 331 | if (brq.cmd.error) { |
279 | printk(KERN_ERR "%s: error %d sending read/write command\n", | 332 | printk(KERN_ERR "%s: error %d sending read/write " |
280 | req->rq_disk->disk_name, brq.cmd.error); | 333 | "command, response %#x, card status %#x\n", |
334 | req->rq_disk->disk_name, brq.cmd.error, | ||
335 | brq.cmd.resp[0], status); | ||
281 | } | 336 | } |
282 | 337 | ||
283 | if (brq.data.error) { | 338 | if (brq.data.error) { |
284 | printk(KERN_ERR "%s: error %d transferring data\n", | 339 | if (brq.data.error == -ETIMEDOUT && brq.mrq.stop) |
285 | req->rq_disk->disk_name, brq.data.error); | 340 | /* 'Stop' response contains card status */ |
341 | status = brq.mrq.stop->resp[0]; | ||
342 | printk(KERN_ERR "%s: error %d transferring data," | ||
343 | " sector %u, nr %u, card status %#x\n", | ||
344 | req->rq_disk->disk_name, brq.data.error, | ||
345 | (unsigned)req->sector, | ||
346 | (unsigned)req->nr_sectors, status); | ||
286 | } | 347 | } |
287 | 348 | ||
288 | if (brq.stop.error) { | 349 | if (brq.stop.error) { |
289 | printk(KERN_ERR "%s: error %d sending stop command\n", | 350 | printk(KERN_ERR "%s: error %d sending stop command, " |
290 | req->rq_disk->disk_name, brq.stop.error); | 351 | "response %#x, card status %#x\n", |
352 | req->rq_disk->disk_name, brq.stop.error, | ||
353 | brq.stop.resp[0], status); | ||
291 | } | 354 | } |
292 | 355 | ||
293 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { | 356 | if (!mmc_host_is_spi(card->host) && rq_data_dir(req) != READ) { |
@@ -320,8 +383,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
320 | #endif | 383 | #endif |
321 | } | 384 | } |
322 | 385 | ||
323 | if (brq.cmd.error || brq.data.error || brq.stop.error) | 386 | if (brq.cmd.error || brq.stop.error || brq.data.error) { |
387 | if (rq_data_dir(req) == READ) { | ||
388 | /* | ||
389 | * After an error, we redo I/O one sector at a | ||
390 | * time, so we only reach here after trying to | ||
391 | * read a single sector. | ||
392 | */ | ||
393 | spin_lock_irq(&md->lock); | ||
394 | ret = __blk_end_request(req, -EIO, brq.data.blksz); | ||
395 | spin_unlock_irq(&md->lock); | ||
396 | continue; | ||
397 | } | ||
324 | goto cmd_err; | 398 | goto cmd_err; |
399 | } | ||
325 | 400 | ||
326 | /* | 401 | /* |
327 | * A block was successfully transferred. | 402 | * A block was successfully transferred. |
@@ -343,25 +418,20 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
343 | * If the card is not SD, we can still ok written sectors | 418 | * If the card is not SD, we can still ok written sectors |
344 | * as reported by the controller (which might be less than | 419 | * as reported by the controller (which might be less than |
345 | * the real number of written sectors, but never more). | 420 | * the real number of written sectors, but never more). |
346 | * | ||
347 | * For reads we just fail the entire chunk as that should | ||
348 | * be safe in all cases. | ||
349 | */ | 421 | */ |
350 | if (rq_data_dir(req) != READ) { | 422 | if (mmc_card_sd(card)) { |
351 | if (mmc_card_sd(card)) { | 423 | u32 blocks; |
352 | u32 blocks; | ||
353 | 424 | ||
354 | blocks = mmc_sd_num_wr_blocks(card); | 425 | blocks = mmc_sd_num_wr_blocks(card); |
355 | if (blocks != (u32)-1) { | 426 | if (blocks != (u32)-1) { |
356 | spin_lock_irq(&md->lock); | ||
357 | ret = __blk_end_request(req, 0, blocks << 9); | ||
358 | spin_unlock_irq(&md->lock); | ||
359 | } | ||
360 | } else { | ||
361 | spin_lock_irq(&md->lock); | 427 | spin_lock_irq(&md->lock); |
362 | ret = __blk_end_request(req, 0, brq.data.bytes_xfered); | 428 | ret = __blk_end_request(req, 0, blocks << 9); |
363 | spin_unlock_irq(&md->lock); | 429 | spin_unlock_irq(&md->lock); |
364 | } | 430 | } |
431 | } else { | ||
432 | spin_lock_irq(&md->lock); | ||
433 | ret = __blk_end_request(req, 0, brq.data.bytes_xfered); | ||
434 | spin_unlock_irq(&md->lock); | ||
365 | } | 435 | } |
366 | 436 | ||
367 | mmc_release_host(card->host); | 437 | mmc_release_host(card->host); |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index f7284b905eb3..df6ce4a06cf3 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/err.h> | 20 | #include <linux/err.h> |
21 | #include <linux/leds.h> | 21 | #include <linux/leds.h> |
22 | #include <linux/scatterlist.h> | 22 | #include <linux/scatterlist.h> |
23 | #include <linux/log2.h> | ||
23 | 24 | ||
24 | #include <linux/mmc/card.h> | 25 | #include <linux/mmc/card.h> |
25 | #include <linux/mmc/host.h> | 26 | #include <linux/mmc/host.h> |
@@ -448,6 +449,80 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width) | |||
448 | mmc_set_ios(host); | 449 | mmc_set_ios(host); |
449 | } | 450 | } |
450 | 451 | ||
452 | /** | ||
453 | * mmc_vdd_to_ocrbitnum - Convert a voltage to the OCR bit number | ||
454 | * @vdd: voltage (mV) | ||
455 | * @low_bits: prefer low bits in boundary cases | ||
456 | * | ||
457 | * This function returns the OCR bit number according to the provided @vdd | ||
458 | * value. If conversion is not possible a negative errno value returned. | ||
459 | * | ||
460 | * Depending on the @low_bits flag the function prefers low or high OCR bits | ||
461 | * on boundary voltages. For example, | ||
462 | * with @low_bits = true, 3300 mV translates to ilog2(MMC_VDD_32_33); | ||
463 | * with @low_bits = false, 3300 mV translates to ilog2(MMC_VDD_33_34); | ||
464 | * | ||
465 | * Any value in the [1951:1999] range translates to the ilog2(MMC_VDD_20_21). | ||
466 | */ | ||
467 | static int mmc_vdd_to_ocrbitnum(int vdd, bool low_bits) | ||
468 | { | ||
469 | const int max_bit = ilog2(MMC_VDD_35_36); | ||
470 | int bit; | ||
471 | |||
472 | if (vdd < 1650 || vdd > 3600) | ||
473 | return -EINVAL; | ||
474 | |||
475 | if (vdd >= 1650 && vdd <= 1950) | ||
476 | return ilog2(MMC_VDD_165_195); | ||
477 | |||
478 | if (low_bits) | ||
479 | vdd -= 1; | ||
480 | |||
481 | /* Base 2000 mV, step 100 mV, bit's base 8. */ | ||
482 | bit = (vdd - 2000) / 100 + 8; | ||
483 | if (bit > max_bit) | ||
484 | return max_bit; | ||
485 | return bit; | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * mmc_vddrange_to_ocrmask - Convert a voltage range to the OCR mask | ||
490 | * @vdd_min: minimum voltage value (mV) | ||
491 | * @vdd_max: maximum voltage value (mV) | ||
492 | * | ||
493 | * This function returns the OCR mask bits according to the provided @vdd_min | ||
494 | * and @vdd_max values. If conversion is not possible the function returns 0. | ||
495 | * | ||
496 | * Notes wrt boundary cases: | ||
497 | * This function sets the OCR bits for all boundary voltages, for example | ||
498 | * [3300:3400] range is translated to MMC_VDD_32_33 | MMC_VDD_33_34 | | ||
499 | * MMC_VDD_34_35 mask. | ||
500 | */ | ||
501 | u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max) | ||
502 | { | ||
503 | u32 mask = 0; | ||
504 | |||
505 | if (vdd_max < vdd_min) | ||
506 | return 0; | ||
507 | |||
508 | /* Prefer high bits for the boundary vdd_max values. */ | ||
509 | vdd_max = mmc_vdd_to_ocrbitnum(vdd_max, false); | ||
510 | if (vdd_max < 0) | ||
511 | return 0; | ||
512 | |||
513 | /* Prefer low bits for the boundary vdd_min values. */ | ||
514 | vdd_min = mmc_vdd_to_ocrbitnum(vdd_min, true); | ||
515 | if (vdd_min < 0) | ||
516 | return 0; | ||
517 | |||
518 | /* Fill the mask, from max bit to min bit. */ | ||
519 | while (vdd_max >= vdd_min) | ||
520 | mask |= 1 << vdd_max--; | ||
521 | |||
522 | return mask; | ||
523 | } | ||
524 | EXPORT_SYMBOL(mmc_vddrange_to_ocrmask); | ||
525 | |||
451 | /* | 526 | /* |
452 | * Mask off any voltages we don't support and select | 527 | * Mask off any voltages we don't support and select |
453 | * the lowest voltage | 528 | * the lowest voltage |
@@ -467,6 +542,8 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) | |||
467 | host->ios.vdd = bit; | 542 | host->ios.vdd = bit; |
468 | mmc_set_ios(host); | 543 | mmc_set_ios(host); |
469 | } else { | 544 | } else { |
545 | pr_warning("%s: host doesn't support card's voltages\n", | ||
546 | mmc_hostname(host)); | ||
470 | ocr = 0; | 547 | ocr = 0; |
471 | } | 548 | } |
472 | 549 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index fdd7c760be8c..c232d11a7ed4 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -434,13 +434,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
434 | * Activate wide bus (if supported). | 434 | * Activate wide bus (if supported). |
435 | */ | 435 | */ |
436 | if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) && | 436 | if ((card->csd.mmca_vsn >= CSD_SPEC_VER_4) && |
437 | (host->caps & MMC_CAP_4_BIT_DATA)) { | 437 | (host->caps & (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA))) { |
438 | unsigned ext_csd_bit, bus_width; | ||
439 | |||
440 | if (host->caps & MMC_CAP_8_BIT_DATA) { | ||
441 | ext_csd_bit = EXT_CSD_BUS_WIDTH_8; | ||
442 | bus_width = MMC_BUS_WIDTH_8; | ||
443 | } else { | ||
444 | ext_csd_bit = EXT_CSD_BUS_WIDTH_4; | ||
445 | bus_width = MMC_BUS_WIDTH_4; | ||
446 | } | ||
447 | |||
438 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 448 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
439 | EXT_CSD_BUS_WIDTH, EXT_CSD_BUS_WIDTH_4); | 449 | EXT_CSD_BUS_WIDTH, ext_csd_bit); |
450 | |||
440 | if (err) | 451 | if (err) |
441 | goto free_card; | 452 | goto free_card; |
442 | 453 | ||
443 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); | 454 | mmc_set_bus_width(card->host, bus_width); |
444 | } | 455 | } |
445 | 456 | ||
446 | if (!oldcard) | 457 | if (!oldcard) |
@@ -624,4 +635,3 @@ err: | |||
624 | 635 | ||
625 | return err; | 636 | return err; |
626 | } | 637 | } |
627 | |||
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index c794cc5ce442..f4853288bbb1 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -19,6 +19,9 @@ obj-$(CONFIG_MMC_AT91) += at91_mci.o | |||
19 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o | 19 | obj-$(CONFIG_MMC_ATMELMCI) += atmel-mci.o |
20 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o | 20 | obj-$(CONFIG_MMC_TIFM_SD) += tifm_sd.o |
21 | obj-$(CONFIG_MMC_SPI) += mmc_spi.o | 21 | obj-$(CONFIG_MMC_SPI) += mmc_spi.o |
22 | ifeq ($(CONFIG_OF),y) | ||
23 | obj-$(CONFIG_MMC_SPI) += of_mmc_spi.o | ||
24 | endif | ||
22 | obj-$(CONFIG_MMC_S3C) += s3cmci.o | 25 | obj-$(CONFIG_MMC_S3C) += s3cmci.o |
23 | obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o | 26 | obj-$(CONFIG_MMC_SDRICOH_CS) += sdricoh_cs.o |
24 | obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o | 27 | obj-$(CONFIG_MMC_TMIO) += tmio_mmc.o |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 1f8b5b36222c..e556d42cc45a 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -1088,6 +1088,8 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1088 | goto fail0; | 1088 | goto fail0; |
1089 | } | 1089 | } |
1090 | 1090 | ||
1091 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
1092 | |||
1091 | platform_set_drvdata(pdev, mmc); | 1093 | platform_set_drvdata(pdev, mmc); |
1092 | 1094 | ||
1093 | /* | 1095 | /* |
@@ -1101,8 +1103,6 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1101 | 1103 | ||
1102 | mmc_add_host(mmc); | 1104 | mmc_add_host(mmc); |
1103 | 1105 | ||
1104 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
1105 | |||
1106 | /* | 1106 | /* |
1107 | * monitor card insertion/removal if we can | 1107 | * monitor card insertion/removal if we can |
1108 | */ | 1108 | */ |
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index 7a3f2436b011..1e97916914ad 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -25,8 +25,8 @@ | |||
25 | #include <linux/stat.h> | 25 | #include <linux/stat.h> |
26 | 26 | ||
27 | #include <linux/mmc/host.h> | 27 | #include <linux/mmc/host.h> |
28 | #include <linux/atmel-mci.h> | ||
28 | 29 | ||
29 | #include <asm/atmel-mci.h> | ||
30 | #include <asm/io.h> | 30 | #include <asm/io.h> |
31 | #include <asm/unaligned.h> | 31 | #include <asm/unaligned.h> |
32 | 32 | ||
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index 2f0fcdb869b7..eb29b1d933ac 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c | |||
@@ -10,20 +10,6 @@ | |||
10 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
12 | * | 12 | * |
13 | * 2005-04-17 Pavel Pisa <pisa@cmp.felk.cvut.cz> | ||
14 | * Changed to conform redesigned i.MX scatter gather DMA interface | ||
15 | * | ||
16 | * 2005-11-04 Pavel Pisa <pisa@cmp.felk.cvut.cz> | ||
17 | * Updated for 2.6.14 kernel | ||
18 | * | ||
19 | * 2005-12-13 Jay Monkman <jtm@smoothsmoothie.com> | ||
20 | * Found and corrected problems in the write path | ||
21 | * | ||
22 | * 2005-12-30 Pavel Pisa <pisa@cmp.felk.cvut.cz> | ||
23 | * The event handling rewritten right way in softirq. | ||
24 | * Added many ugly hacks and delays to overcome SDHC | ||
25 | * deficiencies | ||
26 | * | ||
27 | */ | 13 | */ |
28 | 14 | ||
29 | #include <linux/module.h> | 15 | #include <linux/module.h> |
@@ -37,9 +23,9 @@ | |||
37 | #include <linux/mmc/card.h> | 23 | #include <linux/mmc/card.h> |
38 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
39 | #include <linux/clk.h> | 25 | #include <linux/clk.h> |
26 | #include <linux/io.h> | ||
40 | 27 | ||
41 | #include <asm/dma.h> | 28 | #include <asm/dma.h> |
42 | #include <asm/io.h> | ||
43 | #include <asm/irq.h> | 29 | #include <asm/irq.h> |
44 | #include <asm/sizes.h> | 30 | #include <asm/sizes.h> |
45 | #include <mach/mmc.h> | 31 | #include <mach/mmc.h> |
@@ -50,17 +36,16 @@ | |||
50 | #define DRIVER_NAME "imx-mmc" | 36 | #define DRIVER_NAME "imx-mmc" |
51 | 37 | ||
52 | #define IMXMCI_INT_MASK_DEFAULT (INT_MASK_BUF_READY | INT_MASK_DATA_TRAN | \ | 38 | #define IMXMCI_INT_MASK_DEFAULT (INT_MASK_BUF_READY | INT_MASK_DATA_TRAN | \ |
53 | INT_MASK_WRITE_OP_DONE | INT_MASK_END_CMD_RES | \ | 39 | INT_MASK_WRITE_OP_DONE | INT_MASK_END_CMD_RES | \ |
54 | INT_MASK_AUTO_CARD_DETECT | INT_MASK_DAT0_EN | INT_MASK_SDIO) | 40 | INT_MASK_AUTO_CARD_DETECT | INT_MASK_DAT0_EN | INT_MASK_SDIO) |
55 | 41 | ||
56 | struct imxmci_host { | 42 | struct imxmci_host { |
57 | struct mmc_host *mmc; | 43 | struct mmc_host *mmc; |
58 | spinlock_t lock; | 44 | spinlock_t lock; |
59 | struct resource *res; | 45 | struct resource *res; |
46 | void __iomem *base; | ||
60 | int irq; | 47 | int irq; |
61 | imx_dmach_t dma; | 48 | imx_dmach_t dma; |
62 | unsigned int clkrt; | ||
63 | unsigned int cmdat; | ||
64 | volatile unsigned int imask; | 49 | volatile unsigned int imask; |
65 | unsigned int power_mode; | 50 | unsigned int power_mode; |
66 | unsigned int present; | 51 | unsigned int present; |
@@ -74,7 +59,7 @@ struct imxmci_host { | |||
74 | struct tasklet_struct tasklet; | 59 | struct tasklet_struct tasklet; |
75 | unsigned int status_reg; | 60 | unsigned int status_reg; |
76 | unsigned long pending_events; | 61 | unsigned long pending_events; |
77 | /* Next to fields are there for CPU driven transfers to overcome SDHC deficiencies */ | 62 | /* Next two fields are there for CPU driven transfers to overcome SDHC deficiencies */ |
78 | u16 *data_ptr; | 63 | u16 *data_ptr; |
79 | unsigned int data_cnt; | 64 | unsigned int data_cnt; |
80 | atomic_t stuck_timeout; | 65 | atomic_t stuck_timeout; |
@@ -114,14 +99,22 @@ struct imxmci_host { | |||
114 | static void imxmci_stop_clock(struct imxmci_host *host) | 99 | static void imxmci_stop_clock(struct imxmci_host *host) |
115 | { | 100 | { |
116 | int i = 0; | 101 | int i = 0; |
117 | MMC_STR_STP_CLK &= ~STR_STP_CLK_START_CLK; | 102 | u16 reg; |
118 | while(i < 0x1000) { | 103 | |
119 | if(!(i & 0x7f)) | 104 | reg = readw(host->base + MMC_REG_STR_STP_CLK); |
120 | MMC_STR_STP_CLK |= STR_STP_CLK_STOP_CLK; | 105 | writew(reg & ~STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK); |
106 | while (i < 0x1000) { | ||
107 | if (!(i & 0x7f)) { | ||
108 | reg = readw(host->base + MMC_REG_STR_STP_CLK); | ||
109 | writew(reg | STR_STP_CLK_STOP_CLK, | ||
110 | host->base + MMC_REG_STR_STP_CLK); | ||
111 | } | ||
121 | 112 | ||
122 | if(!(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN)) { | 113 | reg = readw(host->base + MMC_REG_STATUS); |
114 | if (!(reg & STATUS_CARD_BUS_CLK_RUN)) { | ||
123 | /* Check twice before cut */ | 115 | /* Check twice before cut */ |
124 | if(!(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN)) | 116 | reg = readw(host->base + MMC_REG_STATUS); |
117 | if (!(reg & STATUS_CARD_BUS_CLK_RUN)) | ||
125 | return; | 118 | return; |
126 | } | 119 | } |
127 | 120 | ||
@@ -135,8 +128,10 @@ static int imxmci_start_clock(struct imxmci_host *host) | |||
135 | unsigned int trials = 0; | 128 | unsigned int trials = 0; |
136 | unsigned int delay_limit = 128; | 129 | unsigned int delay_limit = 128; |
137 | unsigned long flags; | 130 | unsigned long flags; |
131 | u16 reg; | ||
138 | 132 | ||
139 | MMC_STR_STP_CLK &= ~STR_STP_CLK_STOP_CLK; | 133 | reg = readw(host->base + MMC_REG_STR_STP_CLK); |
134 | writew(reg & ~STR_STP_CLK_STOP_CLK, host->base + MMC_REG_STR_STP_CLK); | ||
140 | 135 | ||
141 | clear_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); | 136 | clear_bit(IMXMCI_PEND_STARTED_b, &host->pending_events); |
142 | 137 | ||
@@ -145,18 +140,21 @@ static int imxmci_start_clock(struct imxmci_host *host) | |||
145 | * then 6 delay loops, but during card detection (low clockrate) | 140 | * then 6 delay loops, but during card detection (low clockrate) |
146 | * it takes up to 5000 delay loops and sometimes fails for the first time | 141 | * it takes up to 5000 delay loops and sometimes fails for the first time |
147 | */ | 142 | */ |
148 | MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; | 143 | reg = readw(host->base + MMC_REG_STR_STP_CLK); |
144 | writew(reg | STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK); | ||
149 | 145 | ||
150 | do { | 146 | do { |
151 | unsigned int delay = delay_limit; | 147 | unsigned int delay = delay_limit; |
152 | 148 | ||
153 | while(delay--){ | 149 | while (delay--) { |
154 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) | 150 | reg = readw(host->base + MMC_REG_STATUS); |
151 | if (reg & STATUS_CARD_BUS_CLK_RUN) | ||
155 | /* Check twice before cut */ | 152 | /* Check twice before cut */ |
156 | if(MMC_STATUS & STATUS_CARD_BUS_CLK_RUN) | 153 | reg = readw(host->base + MMC_REG_STATUS); |
154 | if (reg & STATUS_CARD_BUS_CLK_RUN) | ||
157 | return 0; | 155 | return 0; |
158 | 156 | ||
159 | if(test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) | 157 | if (test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) |
160 | return 0; | 158 | return 0; |
161 | } | 159 | } |
162 | 160 | ||
@@ -167,58 +165,59 @@ static int imxmci_start_clock(struct imxmci_host *host) | |||
167 | * IRQ or schedule delays this function execution and the clocks has | 165 | * IRQ or schedule delays this function execution and the clocks has |
168 | * been already stopped by other means (response processing, SDHC HW) | 166 | * been already stopped by other means (response processing, SDHC HW) |
169 | */ | 167 | */ |
170 | if(!test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) | 168 | if (!test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) { |
171 | MMC_STR_STP_CLK |= STR_STP_CLK_START_CLK; | 169 | reg = readw(host->base + MMC_REG_STR_STP_CLK); |
170 | writew(reg | STR_STP_CLK_START_CLK, | ||
171 | host->base + MMC_REG_STR_STP_CLK); | ||
172 | } | ||
172 | local_irq_restore(flags); | 173 | local_irq_restore(flags); |
173 | 174 | ||
174 | } while(++trials<256); | 175 | } while (++trials < 256); |
175 | 176 | ||
176 | dev_err(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); | 177 | dev_err(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n"); |
177 | 178 | ||
178 | return -1; | 179 | return -1; |
179 | } | 180 | } |
180 | 181 | ||
181 | static void imxmci_softreset(void) | 182 | static void imxmci_softreset(struct imxmci_host *host) |
182 | { | 183 | { |
184 | int i; | ||
185 | |||
183 | /* reset sequence */ | 186 | /* reset sequence */ |
184 | MMC_STR_STP_CLK = 0x8; | 187 | writew(0x08, host->base + MMC_REG_STR_STP_CLK); |
185 | MMC_STR_STP_CLK = 0xD; | 188 | writew(0x0D, host->base + MMC_REG_STR_STP_CLK); |
186 | MMC_STR_STP_CLK = 0x5; | 189 | |
187 | MMC_STR_STP_CLK = 0x5; | 190 | for (i = 0; i < 8; i++) |
188 | MMC_STR_STP_CLK = 0x5; | 191 | writew(0x05, host->base + MMC_REG_STR_STP_CLK); |
189 | MMC_STR_STP_CLK = 0x5; | 192 | |
190 | MMC_STR_STP_CLK = 0x5; | 193 | writew(0xff, host->base + MMC_REG_RES_TO); |
191 | MMC_STR_STP_CLK = 0x5; | 194 | writew(512, host->base + MMC_REG_BLK_LEN); |
192 | MMC_STR_STP_CLK = 0x5; | 195 | writew(1, host->base + MMC_REG_NOB); |
193 | MMC_STR_STP_CLK = 0x5; | ||
194 | |||
195 | MMC_RES_TO = 0xff; | ||
196 | MMC_BLK_LEN = 512; | ||
197 | MMC_NOB = 1; | ||
198 | } | 196 | } |
199 | 197 | ||
200 | static int imxmci_busy_wait_for_status(struct imxmci_host *host, | 198 | static int imxmci_busy_wait_for_status(struct imxmci_host *host, |
201 | unsigned int *pstat, unsigned int stat_mask, | 199 | unsigned int *pstat, unsigned int stat_mask, |
202 | int timeout, const char *where) | 200 | int timeout, const char *where) |
203 | { | 201 | { |
204 | int loops=0; | 202 | int loops = 0; |
205 | while(!(*pstat & stat_mask)) { | 203 | |
206 | loops+=2; | 204 | while (!(*pstat & stat_mask)) { |
207 | if(loops >= timeout) { | 205 | loops += 2; |
206 | if (loops >= timeout) { | ||
208 | dev_dbg(mmc_dev(host->mmc), "busy wait timeout in %s, STATUS = 0x%x (0x%x)\n", | 207 | dev_dbg(mmc_dev(host->mmc), "busy wait timeout in %s, STATUS = 0x%x (0x%x)\n", |
209 | where, *pstat, stat_mask); | 208 | where, *pstat, stat_mask); |
210 | return -1; | 209 | return -1; |
211 | } | 210 | } |
212 | udelay(2); | 211 | udelay(2); |
213 | *pstat |= MMC_STATUS; | 212 | *pstat |= readw(host->base + MMC_REG_STATUS); |
214 | } | 213 | } |
215 | if(!loops) | 214 | if (!loops) |
216 | return 0; | 215 | return 0; |
217 | 216 | ||
218 | /* The busy-wait is expected there for clock <8MHz due to SDHC hardware flaws */ | 217 | /* The busy-wait is expected there for clock <8MHz due to SDHC hardware flaws */ |
219 | if(!(stat_mask & STATUS_END_CMD_RESP) || (host->mmc->ios.clock>=8000000)) | 218 | if (!(stat_mask & STATUS_END_CMD_RESP) || (host->mmc->ios.clock >= 8000000)) |
220 | dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n", | 219 | dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n", |
221 | loops, where, *pstat, stat_mask); | 220 | loops, where, *pstat, stat_mask); |
222 | return loops; | 221 | return loops; |
223 | } | 222 | } |
224 | 223 | ||
@@ -235,8 +234,8 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
235 | host->data = data; | 234 | host->data = data; |
236 | data->bytes_xfered = 0; | 235 | data->bytes_xfered = 0; |
237 | 236 | ||
238 | MMC_NOB = nob; | 237 | writew(nob, host->base + MMC_REG_NOB); |
239 | MMC_BLK_LEN = blksz; | 238 | writew(blksz, host->base + MMC_REG_BLK_LEN); |
240 | 239 | ||
241 | /* | 240 | /* |
242 | * DMA cannot be used for small block sizes, we have to use CPU driven transfers otherwise. | 241 | * DMA cannot be used for small block sizes, we have to use CPU driven transfers otherwise. |
@@ -252,14 +251,14 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
252 | host->dma_dir = DMA_FROM_DEVICE; | 251 | host->dma_dir = DMA_FROM_DEVICE; |
253 | 252 | ||
254 | /* Hack to enable read SCR */ | 253 | /* Hack to enable read SCR */ |
255 | MMC_NOB = 1; | 254 | writew(1, host->base + MMC_REG_NOB); |
256 | MMC_BLK_LEN = 512; | 255 | writew(512, host->base + MMC_REG_BLK_LEN); |
257 | } else { | 256 | } else { |
258 | host->dma_dir = DMA_TO_DEVICE; | 257 | host->dma_dir = DMA_TO_DEVICE; |
259 | } | 258 | } |
260 | 259 | ||
261 | /* Convert back to virtual address */ | 260 | /* Convert back to virtual address */ |
262 | host->data_ptr = (u16*)sg_virt(data->sg); | 261 | host->data_ptr = (u16 *)sg_virt(data->sg); |
263 | host->data_cnt = 0; | 262 | host->data_cnt = 0; |
264 | 263 | ||
265 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); | 264 | clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events); |
@@ -271,10 +270,11 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
271 | if (data->flags & MMC_DATA_READ) { | 270 | if (data->flags & MMC_DATA_READ) { |
272 | host->dma_dir = DMA_FROM_DEVICE; | 271 | host->dma_dir = DMA_FROM_DEVICE; |
273 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | 272 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, |
274 | data->sg_len, host->dma_dir); | 273 | data->sg_len, host->dma_dir); |
275 | 274 | ||
276 | imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz, | 275 | imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz, |
277 | host->res->start + MMC_BUFFER_ACCESS_OFS, DMA_MODE_READ); | 276 | host->res->start + MMC_REG_BUFFER_ACCESS, |
277 | DMA_MODE_READ); | ||
278 | 278 | ||
279 | /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_READ, IMX_DMA_WIDTH_16, CCR_REN);*/ | 279 | /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_READ, IMX_DMA_WIDTH_16, CCR_REN);*/ |
280 | CCR(host->dma) = CCR_DMOD_LINEAR | CCR_DSIZ_32 | CCR_SMOD_FIFO | CCR_SSIZ_16 | CCR_REN; | 280 | CCR(host->dma) = CCR_DMOD_LINEAR | CCR_DSIZ_32 | CCR_SMOD_FIFO | CCR_SSIZ_16 | CCR_REN; |
@@ -282,10 +282,11 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
282 | host->dma_dir = DMA_TO_DEVICE; | 282 | host->dma_dir = DMA_TO_DEVICE; |
283 | 283 | ||
284 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, | 284 | host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg, |
285 | data->sg_len, host->dma_dir); | 285 | data->sg_len, host->dma_dir); |
286 | 286 | ||
287 | imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz, | 287 | imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz, |
288 | host->res->start + MMC_BUFFER_ACCESS_OFS, DMA_MODE_WRITE); | 288 | host->res->start + MMC_REG_BUFFER_ACCESS, |
289 | DMA_MODE_WRITE); | ||
289 | 290 | ||
290 | /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_WRITE, IMX_DMA_WIDTH_16, CCR_REN);*/ | 291 | /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_WRITE, IMX_DMA_WIDTH_16, CCR_REN);*/ |
291 | CCR(host->dma) = CCR_SMOD_LINEAR | CCR_SSIZ_32 | CCR_DMOD_FIFO | CCR_DSIZ_16 | CCR_REN; | 292 | CCR(host->dma) = CCR_SMOD_LINEAR | CCR_SSIZ_32 | CCR_DMOD_FIFO | CCR_DSIZ_16 | CCR_REN; |
@@ -293,12 +294,12 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
293 | 294 | ||
294 | #if 1 /* This code is there only for consistency checking and can be disabled in future */ | 295 | #if 1 /* This code is there only for consistency checking and can be disabled in future */ |
295 | host->dma_size = 0; | 296 | host->dma_size = 0; |
296 | for(i=0; i<host->dma_nents; i++) | 297 | for (i = 0; i < host->dma_nents; i++) |
297 | host->dma_size+=data->sg[i].length; | 298 | host->dma_size += data->sg[i].length; |
298 | 299 | ||
299 | if (datasz > host->dma_size) { | 300 | if (datasz > host->dma_size) { |
300 | dev_err(mmc_dev(host->mmc), "imxmci_setup_data datasz 0x%x > 0x%x dm_size\n", | 301 | dev_err(mmc_dev(host->mmc), "imxmci_setup_data datasz 0x%x > 0x%x dm_size\n", |
301 | datasz, host->dma_size); | 302 | datasz, host->dma_size); |
302 | } | 303 | } |
303 | #endif | 304 | #endif |
304 | 305 | ||
@@ -306,7 +307,7 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
306 | 307 | ||
307 | wmb(); | 308 | wmb(); |
308 | 309 | ||
309 | if(host->actual_bus_width == MMC_BUS_WIDTH_4) | 310 | if (host->actual_bus_width == MMC_BUS_WIDTH_4) |
310 | BLR(host->dma) = 0; /* burst 64 byte read / 64 bytes write */ | 311 | BLR(host->dma) = 0; /* burst 64 byte read / 64 bytes write */ |
311 | else | 312 | else |
312 | BLR(host->dma) = 16; /* burst 16 byte read / 16 bytes write */ | 313 | BLR(host->dma) = 16; /* burst 16 byte read / 16 bytes write */ |
@@ -317,9 +318,8 @@ static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data) | |||
317 | clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events); | 318 | clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events); |
318 | 319 | ||
319 | /* start DMA engine for read, write is delayed after initial response */ | 320 | /* start DMA engine for read, write is delayed after initial response */ |
320 | if (host->dma_dir == DMA_FROM_DEVICE) { | 321 | if (host->dma_dir == DMA_FROM_DEVICE) |
321 | imx_dma_enable(host->dma); | 322 | imx_dma_enable(host->dma); |
322 | } | ||
323 | } | 323 | } |
324 | 324 | ||
325 | static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, unsigned int cmdat) | 325 | static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, unsigned int cmdat) |
@@ -351,16 +351,16 @@ static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, | |||
351 | break; | 351 | break; |
352 | } | 352 | } |
353 | 353 | ||
354 | if ( test_and_clear_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events) ) | 354 | if (test_and_clear_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events)) |
355 | cmdat |= CMD_DAT_CONT_INIT; /* This command needs init */ | 355 | cmdat |= CMD_DAT_CONT_INIT; /* This command needs init */ |
356 | 356 | ||
357 | if ( host->actual_bus_width == MMC_BUS_WIDTH_4 ) | 357 | if (host->actual_bus_width == MMC_BUS_WIDTH_4) |
358 | cmdat |= CMD_DAT_CONT_BUS_WIDTH_4; | 358 | cmdat |= CMD_DAT_CONT_BUS_WIDTH_4; |
359 | 359 | ||
360 | MMC_CMD = cmd->opcode; | 360 | writew(cmd->opcode, host->base + MMC_REG_CMD); |
361 | MMC_ARGH = cmd->arg >> 16; | 361 | writew(cmd->arg >> 16, host->base + MMC_REG_ARGH); |
362 | MMC_ARGL = cmd->arg & 0xffff; | 362 | writew(cmd->arg & 0xffff, host->base + MMC_REG_ARGL); |
363 | MMC_CMD_DAT_CONT = cmdat; | 363 | writew(cmdat, host->base + MMC_REG_CMD_DAT_CONT); |
364 | 364 | ||
365 | atomic_set(&host->stuck_timeout, 0); | 365 | atomic_set(&host->stuck_timeout, 0); |
366 | set_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events); | 366 | set_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events); |
@@ -368,18 +368,18 @@ static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, | |||
368 | 368 | ||
369 | imask = IMXMCI_INT_MASK_DEFAULT; | 369 | imask = IMXMCI_INT_MASK_DEFAULT; |
370 | imask &= ~INT_MASK_END_CMD_RES; | 370 | imask &= ~INT_MASK_END_CMD_RES; |
371 | if ( cmdat & CMD_DAT_CONT_DATA_ENABLE ) { | 371 | if (cmdat & CMD_DAT_CONT_DATA_ENABLE) { |
372 | /*imask &= ~INT_MASK_BUF_READY;*/ | 372 | /* imask &= ~INT_MASK_BUF_READY; */ |
373 | imask &= ~INT_MASK_DATA_TRAN; | 373 | imask &= ~INT_MASK_DATA_TRAN; |
374 | if ( cmdat & CMD_DAT_CONT_WRITE ) | 374 | if (cmdat & CMD_DAT_CONT_WRITE) |
375 | imask &= ~INT_MASK_WRITE_OP_DONE; | 375 | imask &= ~INT_MASK_WRITE_OP_DONE; |
376 | if(test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) | 376 | if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) |
377 | imask &= ~INT_MASK_BUF_READY; | 377 | imask &= ~INT_MASK_BUF_READY; |
378 | } | 378 | } |
379 | 379 | ||
380 | spin_lock_irqsave(&host->lock, flags); | 380 | spin_lock_irqsave(&host->lock, flags); |
381 | host->imask = imask; | 381 | host->imask = imask; |
382 | MMC_INT_MASK = host->imask; | 382 | writew(host->imask, host->base + MMC_REG_INT_MASK); |
383 | spin_unlock_irqrestore(&host->lock, flags); | 383 | spin_unlock_irqrestore(&host->lock, flags); |
384 | 384 | ||
385 | dev_dbg(mmc_dev(host->mmc), "CMD%02d (0x%02x) mask set to 0x%04x\n", | 385 | dev_dbg(mmc_dev(host->mmc), "CMD%02d (0x%02x) mask set to 0x%04x\n", |
@@ -395,14 +395,14 @@ static void imxmci_finish_request(struct imxmci_host *host, struct mmc_request * | |||
395 | spin_lock_irqsave(&host->lock, flags); | 395 | spin_lock_irqsave(&host->lock, flags); |
396 | 396 | ||
397 | host->pending_events &= ~(IMXMCI_PEND_WAIT_RESP_m | IMXMCI_PEND_DMA_END_m | | 397 | host->pending_events &= ~(IMXMCI_PEND_WAIT_RESP_m | IMXMCI_PEND_DMA_END_m | |
398 | IMXMCI_PEND_DMA_DATA_m | IMXMCI_PEND_CPU_DATA_m); | 398 | IMXMCI_PEND_DMA_DATA_m | IMXMCI_PEND_CPU_DATA_m); |
399 | 399 | ||
400 | host->imask = IMXMCI_INT_MASK_DEFAULT; | 400 | host->imask = IMXMCI_INT_MASK_DEFAULT; |
401 | MMC_INT_MASK = host->imask; | 401 | writew(host->imask, host->base + MMC_REG_INT_MASK); |
402 | 402 | ||
403 | spin_unlock_irqrestore(&host->lock, flags); | 403 | spin_unlock_irqrestore(&host->lock, flags); |
404 | 404 | ||
405 | if(req && req->cmd) | 405 | if (req && req->cmd) |
406 | host->prev_cmd_code = req->cmd->opcode; | 406 | host->prev_cmd_code = req->cmd->opcode; |
407 | 407 | ||
408 | host->req = NULL; | 408 | host->req = NULL; |
@@ -416,17 +416,17 @@ static int imxmci_finish_data(struct imxmci_host *host, unsigned int stat) | |||
416 | struct mmc_data *data = host->data; | 416 | struct mmc_data *data = host->data; |
417 | int data_error; | 417 | int data_error; |
418 | 418 | ||
419 | if(test_and_clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)){ | 419 | if (test_and_clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) { |
420 | imx_dma_disable(host->dma); | 420 | imx_dma_disable(host->dma); |
421 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents, | 421 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents, |
422 | host->dma_dir); | 422 | host->dma_dir); |
423 | } | 423 | } |
424 | 424 | ||
425 | if ( stat & STATUS_ERR_MASK ) { | 425 | if (stat & STATUS_ERR_MASK) { |
426 | dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",stat); | 426 | dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n", stat); |
427 | if(stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR)) | 427 | if (stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR)) |
428 | data->error = -EILSEQ; | 428 | data->error = -EILSEQ; |
429 | else if(stat & STATUS_TIME_OUT_READ) | 429 | else if (stat & STATUS_TIME_OUT_READ) |
430 | data->error = -ETIMEDOUT; | 430 | data->error = -ETIMEDOUT; |
431 | else | 431 | else |
432 | data->error = -EIO; | 432 | data->error = -EIO; |
@@ -445,7 +445,7 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat) | |||
445 | { | 445 | { |
446 | struct mmc_command *cmd = host->cmd; | 446 | struct mmc_command *cmd = host->cmd; |
447 | int i; | 447 | int i; |
448 | u32 a,b,c; | 448 | u32 a, b, c; |
449 | struct mmc_data *data = host->data; | 449 | struct mmc_data *data = host->data; |
450 | 450 | ||
451 | if (!cmd) | 451 | if (!cmd) |
@@ -461,18 +461,18 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat) | |||
461 | cmd->error = -EILSEQ; | 461 | cmd->error = -EILSEQ; |
462 | } | 462 | } |
463 | 463 | ||
464 | if(cmd->flags & MMC_RSP_PRESENT) { | 464 | if (cmd->flags & MMC_RSP_PRESENT) { |
465 | if(cmd->flags & MMC_RSP_136) { | 465 | if (cmd->flags & MMC_RSP_136) { |
466 | for (i = 0; i < 4; i++) { | 466 | for (i = 0; i < 4; i++) { |
467 | u32 a = MMC_RES_FIFO & 0xffff; | 467 | a = readw(host->base + MMC_REG_RES_FIFO); |
468 | u32 b = MMC_RES_FIFO & 0xffff; | 468 | b = readw(host->base + MMC_REG_RES_FIFO); |
469 | cmd->resp[i] = a<<16 | b; | 469 | cmd->resp[i] = a << 16 | b; |
470 | } | 470 | } |
471 | } else { | 471 | } else { |
472 | a = MMC_RES_FIFO & 0xffff; | 472 | a = readw(host->base + MMC_REG_RES_FIFO); |
473 | b = MMC_RES_FIFO & 0xffff; | 473 | b = readw(host->base + MMC_REG_RES_FIFO); |
474 | c = MMC_RES_FIFO & 0xffff; | 474 | c = readw(host->base + MMC_REG_RES_FIFO); |
475 | cmd->resp[0] = a<<24 | b<<8 | c>>8; | 475 | cmd->resp[0] = a << 24 | b << 8 | c >> 8; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
@@ -484,36 +484,34 @@ static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat) | |||
484 | 484 | ||
485 | /* Wait for FIFO to be empty before starting DMA write */ | 485 | /* Wait for FIFO to be empty before starting DMA write */ |
486 | 486 | ||
487 | stat = MMC_STATUS; | 487 | stat = readw(host->base + MMC_REG_STATUS); |
488 | if(imxmci_busy_wait_for_status(host, &stat, | 488 | if (imxmci_busy_wait_for_status(host, &stat, |
489 | STATUS_APPL_BUFF_FE, | 489 | STATUS_APPL_BUFF_FE, |
490 | 40, "imxmci_cmd_done DMA WR") < 0) { | 490 | 40, "imxmci_cmd_done DMA WR") < 0) { |
491 | cmd->error = -EIO; | 491 | cmd->error = -EIO; |
492 | imxmci_finish_data(host, stat); | 492 | imxmci_finish_data(host, stat); |
493 | if(host->req) | 493 | if (host->req) |
494 | imxmci_finish_request(host, host->req); | 494 | imxmci_finish_request(host, host->req); |
495 | dev_warn(mmc_dev(host->mmc), "STATUS = 0x%04x\n", | 495 | dev_warn(mmc_dev(host->mmc), "STATUS = 0x%04x\n", |
496 | stat); | 496 | stat); |
497 | return 0; | 497 | return 0; |
498 | } | 498 | } |
499 | 499 | ||
500 | if(test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) { | 500 | if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) |
501 | imx_dma_enable(host->dma); | 501 | imx_dma_enable(host->dma); |
502 | } | ||
503 | } | 502 | } |
504 | } else { | 503 | } else { |
505 | struct mmc_request *req; | 504 | struct mmc_request *req; |
506 | imxmci_stop_clock(host); | 505 | imxmci_stop_clock(host); |
507 | req = host->req; | 506 | req = host->req; |
508 | 507 | ||
509 | if(data) | 508 | if (data) |
510 | imxmci_finish_data(host, stat); | 509 | imxmci_finish_data(host, stat); |
511 | 510 | ||
512 | if( req ) { | 511 | if (req) |
513 | imxmci_finish_request(host, req); | 512 | imxmci_finish_request(host, req); |
514 | } else { | 513 | else |
515 | dev_warn(mmc_dev(host->mmc), "imxmci_cmd_done: no request to finish\n"); | 514 | dev_warn(mmc_dev(host->mmc), "imxmci_cmd_done: no request to finish\n"); |
516 | } | ||
517 | } | 515 | } |
518 | 516 | ||
519 | return 1; | 517 | return 1; |
@@ -535,11 +533,10 @@ static int imxmci_data_done(struct imxmci_host *host, unsigned int stat) | |||
535 | } else { | 533 | } else { |
536 | struct mmc_request *req; | 534 | struct mmc_request *req; |
537 | req = host->req; | 535 | req = host->req; |
538 | if( req ) { | 536 | if (req) |
539 | imxmci_finish_request(host, req); | 537 | imxmci_finish_request(host, req); |
540 | } else { | 538 | else |
541 | dev_warn(mmc_dev(host->mmc), "imxmci_data_done: no request to finish\n"); | 539 | dev_warn(mmc_dev(host->mmc), "imxmci_data_done: no request to finish\n"); |
542 | } | ||
543 | } | 540 | } |
544 | 541 | ||
545 | return 1; | 542 | return 1; |
@@ -552,7 +549,7 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat) | |||
552 | int trans_done = 0; | 549 | int trans_done = 0; |
553 | unsigned int stat = *pstat; | 550 | unsigned int stat = *pstat; |
554 | 551 | ||
555 | if(host->actual_bus_width != MMC_BUS_WIDTH_4) | 552 | if (host->actual_bus_width != MMC_BUS_WIDTH_4) |
556 | burst_len = 16; | 553 | burst_len = 16; |
557 | else | 554 | else |
558 | burst_len = 64; | 555 | burst_len = 64; |
@@ -563,44 +560,44 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat) | |||
563 | 560 | ||
564 | udelay(20); /* required for clocks < 8MHz*/ | 561 | udelay(20); /* required for clocks < 8MHz*/ |
565 | 562 | ||
566 | if(host->dma_dir == DMA_FROM_DEVICE) { | 563 | if (host->dma_dir == DMA_FROM_DEVICE) { |
567 | imxmci_busy_wait_for_status(host, &stat, | 564 | imxmci_busy_wait_for_status(host, &stat, |
568 | STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE | | 565 | STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE | |
569 | STATUS_TIME_OUT_READ, | 566 | STATUS_TIME_OUT_READ, |
570 | 50, "imxmci_cpu_driven_data read"); | 567 | 50, "imxmci_cpu_driven_data read"); |
571 | 568 | ||
572 | while((stat & (STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE)) && | 569 | while ((stat & (STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE)) && |
573 | !(stat & STATUS_TIME_OUT_READ) && | 570 | !(stat & STATUS_TIME_OUT_READ) && |
574 | (host->data_cnt < 512)) { | 571 | (host->data_cnt < 512)) { |
575 | 572 | ||
576 | udelay(20); /* required for clocks < 8MHz*/ | 573 | udelay(20); /* required for clocks < 8MHz*/ |
577 | 574 | ||
578 | for(i = burst_len; i>=2 ; i-=2) { | 575 | for (i = burst_len; i >= 2 ; i -= 2) { |
579 | u16 data; | 576 | u16 data; |
580 | data = MMC_BUFFER_ACCESS; | 577 | data = readw(host->base + MMC_REG_BUFFER_ACCESS); |
581 | udelay(10); /* required for clocks < 8MHz*/ | 578 | udelay(10); /* required for clocks < 8MHz*/ |
582 | if(host->data_cnt+2 <= host->dma_size) { | 579 | if (host->data_cnt+2 <= host->dma_size) { |
583 | *(host->data_ptr++) = data; | 580 | *(host->data_ptr++) = data; |
584 | } else { | 581 | } else { |
585 | if(host->data_cnt < host->dma_size) | 582 | if (host->data_cnt < host->dma_size) |
586 | *(u8*)(host->data_ptr) = data; | 583 | *(u8 *)(host->data_ptr) = data; |
587 | } | 584 | } |
588 | host->data_cnt += 2; | 585 | host->data_cnt += 2; |
589 | } | 586 | } |
590 | 587 | ||
591 | stat = MMC_STATUS; | 588 | stat = readw(host->base + MMC_REG_STATUS); |
592 | 589 | ||
593 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read %d burst %d STATUS = 0x%x\n", | 590 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read %d burst %d STATUS = 0x%x\n", |
594 | host->data_cnt, burst_len, stat); | 591 | host->data_cnt, burst_len, stat); |
595 | } | 592 | } |
596 | 593 | ||
597 | if((stat & STATUS_DATA_TRANS_DONE) && (host->data_cnt >= 512)) | 594 | if ((stat & STATUS_DATA_TRANS_DONE) && (host->data_cnt >= 512)) |
598 | trans_done = 1; | 595 | trans_done = 1; |
599 | 596 | ||
600 | if(host->dma_size & 0x1ff) | 597 | if (host->dma_size & 0x1ff) |
601 | stat &= ~STATUS_CRC_READ_ERR; | 598 | stat &= ~STATUS_CRC_READ_ERR; |
602 | 599 | ||
603 | if(stat & STATUS_TIME_OUT_READ) { | 600 | if (stat & STATUS_TIME_OUT_READ) { |
604 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read timeout STATUS = 0x%x\n", | 601 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read timeout STATUS = 0x%x\n", |
605 | stat); | 602 | stat); |
606 | trans_done = -1; | 603 | trans_done = -1; |
@@ -608,12 +605,12 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat) | |||
608 | 605 | ||
609 | } else { | 606 | } else { |
610 | imxmci_busy_wait_for_status(host, &stat, | 607 | imxmci_busy_wait_for_status(host, &stat, |
611 | STATUS_APPL_BUFF_FE, | 608 | STATUS_APPL_BUFF_FE, |
612 | 20, "imxmci_cpu_driven_data write"); | 609 | 20, "imxmci_cpu_driven_data write"); |
613 | 610 | ||
614 | while((stat & STATUS_APPL_BUFF_FE) && | 611 | while ((stat & STATUS_APPL_BUFF_FE) && |
615 | (host->data_cnt < host->dma_size)) { | 612 | (host->data_cnt < host->dma_size)) { |
616 | if(burst_len >= host->dma_size - host->data_cnt) { | 613 | if (burst_len >= host->dma_size - host->data_cnt) { |
617 | burst_len = host->dma_size - host->data_cnt; | 614 | burst_len = host->dma_size - host->data_cnt; |
618 | host->data_cnt = host->dma_size; | 615 | host->data_cnt = host->dma_size; |
619 | trans_done = 1; | 616 | trans_done = 1; |
@@ -621,10 +618,10 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat) | |||
621 | host->data_cnt += burst_len; | 618 | host->data_cnt += burst_len; |
622 | } | 619 | } |
623 | 620 | ||
624 | for(i = burst_len; i>0 ; i-=2) | 621 | for (i = burst_len; i > 0 ; i -= 2) |
625 | MMC_BUFFER_ACCESS = *(host->data_ptr++); | 622 | writew(*(host->data_ptr++), host->base + MMC_REG_BUFFER_ACCESS); |
626 | 623 | ||
627 | stat = MMC_STATUS; | 624 | stat = readw(host->base + MMC_REG_STATUS); |
628 | 625 | ||
629 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data write burst %d STATUS = 0x%x\n", | 626 | dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data write burst %d STATUS = 0x%x\n", |
630 | burst_len, stat); | 627 | burst_len, stat); |
@@ -639,7 +636,7 @@ static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat) | |||
639 | static void imxmci_dma_irq(int dma, void *devid) | 636 | static void imxmci_dma_irq(int dma, void *devid) |
640 | { | 637 | { |
641 | struct imxmci_host *host = devid; | 638 | struct imxmci_host *host = devid; |
642 | uint32_t stat = MMC_STATUS; | 639 | u32 stat = readw(host->base + MMC_REG_STATUS); |
643 | 640 | ||
644 | atomic_set(&host->stuck_timeout, 0); | 641 | atomic_set(&host->stuck_timeout, 0); |
645 | host->status_reg = stat; | 642 | host->status_reg = stat; |
@@ -650,10 +647,11 @@ static void imxmci_dma_irq(int dma, void *devid) | |||
650 | static irqreturn_t imxmci_irq(int irq, void *devid) | 647 | static irqreturn_t imxmci_irq(int irq, void *devid) |
651 | { | 648 | { |
652 | struct imxmci_host *host = devid; | 649 | struct imxmci_host *host = devid; |
653 | uint32_t stat = MMC_STATUS; | 650 | u32 stat = readw(host->base + MMC_REG_STATUS); |
654 | int handled = 1; | 651 | int handled = 1; |
655 | 652 | ||
656 | MMC_INT_MASK = host->imask | INT_MASK_SDIO | INT_MASK_AUTO_CARD_DETECT; | 653 | writew(host->imask | INT_MASK_SDIO | INT_MASK_AUTO_CARD_DETECT, |
654 | host->base + MMC_REG_INT_MASK); | ||
657 | 655 | ||
658 | atomic_set(&host->stuck_timeout, 0); | 656 | atomic_set(&host->stuck_timeout, 0); |
659 | host->status_reg = stat; | 657 | host->status_reg = stat; |
@@ -671,10 +669,10 @@ static void imxmci_tasklet_fnc(unsigned long data) | |||
671 | unsigned int data_dir_mask = 0; /* STATUS_WR_CRC_ERROR_CODE_MASK */ | 669 | unsigned int data_dir_mask = 0; /* STATUS_WR_CRC_ERROR_CODE_MASK */ |
672 | int timeout = 0; | 670 | int timeout = 0; |
673 | 671 | ||
674 | if(atomic_read(&host->stuck_timeout) > 4) { | 672 | if (atomic_read(&host->stuck_timeout) > 4) { |
675 | char *what; | 673 | char *what; |
676 | timeout = 1; | 674 | timeout = 1; |
677 | stat = MMC_STATUS; | 675 | stat = readw(host->base + MMC_REG_STATUS); |
678 | host->status_reg = stat; | 676 | host->status_reg = stat; |
679 | if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) | 677 | if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) |
680 | if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) | 678 | if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) |
@@ -683,29 +681,37 @@ static void imxmci_tasklet_fnc(unsigned long data) | |||
683 | what = "RESP"; | 681 | what = "RESP"; |
684 | else | 682 | else |
685 | if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) | 683 | if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) |
686 | if(test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events)) | 684 | if (test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events)) |
687 | what = "DATA"; | 685 | what = "DATA"; |
688 | else | 686 | else |
689 | what = "DMA"; | 687 | what = "DMA"; |
690 | else | 688 | else |
691 | what = "???"; | 689 | what = "???"; |
692 | 690 | ||
693 | dev_err(mmc_dev(host->mmc), "%s TIMEOUT, hardware stucked STATUS = 0x%04x IMASK = 0x%04x\n", | 691 | dev_err(mmc_dev(host->mmc), |
694 | what, stat, MMC_INT_MASK); | 692 | "%s TIMEOUT, hardware stucked STATUS = 0x%04x IMASK = 0x%04x\n", |
695 | dev_err(mmc_dev(host->mmc), "CMD_DAT_CONT = 0x%04x, MMC_BLK_LEN = 0x%04x, MMC_NOB = 0x%04x, DMA_CCR = 0x%08x\n", | 693 | what, stat, |
696 | MMC_CMD_DAT_CONT, MMC_BLK_LEN, MMC_NOB, CCR(host->dma)); | 694 | readw(host->base + MMC_REG_INT_MASK)); |
695 | dev_err(mmc_dev(host->mmc), | ||
696 | "CMD_DAT_CONT = 0x%04x, MMC_BLK_LEN = 0x%04x, MMC_NOB = 0x%04x, DMA_CCR = 0x%08x\n", | ||
697 | readw(host->base + MMC_REG_CMD_DAT_CONT), | ||
698 | readw(host->base + MMC_REG_BLK_LEN), | ||
699 | readw(host->base + MMC_REG_NOB), | ||
700 | CCR(host->dma)); | ||
697 | dev_err(mmc_dev(host->mmc), "CMD%d, prevCMD%d, bus %d-bit, dma_size = 0x%x\n", | 701 | dev_err(mmc_dev(host->mmc), "CMD%d, prevCMD%d, bus %d-bit, dma_size = 0x%x\n", |
698 | host->cmd?host->cmd->opcode:0, host->prev_cmd_code, 1<<host->actual_bus_width, host->dma_size); | 702 | host->cmd ? host->cmd->opcode : 0, |
703 | host->prev_cmd_code, | ||
704 | 1 << host->actual_bus_width, host->dma_size); | ||
699 | } | 705 | } |
700 | 706 | ||
701 | if(!host->present || timeout) | 707 | if (!host->present || timeout) |
702 | host->status_reg = STATUS_TIME_OUT_RESP | STATUS_TIME_OUT_READ | | 708 | host->status_reg = STATUS_TIME_OUT_RESP | STATUS_TIME_OUT_READ | |
703 | STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR; | 709 | STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR; |
704 | 710 | ||
705 | if(test_bit(IMXMCI_PEND_IRQ_b, &host->pending_events) || timeout) { | 711 | if (test_bit(IMXMCI_PEND_IRQ_b, &host->pending_events) || timeout) { |
706 | clear_bit(IMXMCI_PEND_IRQ_b, &host->pending_events); | 712 | clear_bit(IMXMCI_PEND_IRQ_b, &host->pending_events); |
707 | 713 | ||
708 | stat = MMC_STATUS; | 714 | stat = readw(host->base + MMC_REG_STATUS); |
709 | /* | 715 | /* |
710 | * This is not required in theory, but there is chance to miss some flag | 716 | * This is not required in theory, but there is chance to miss some flag |
711 | * which clears automatically by mask write, FreeScale original code keeps | 717 | * which clears automatically by mask write, FreeScale original code keeps |
@@ -713,63 +719,62 @@ static void imxmci_tasklet_fnc(unsigned long data) | |||
713 | */ | 719 | */ |
714 | stat |= host->status_reg; | 720 | stat |= host->status_reg; |
715 | 721 | ||
716 | if(test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) | 722 | if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) |
717 | stat &= ~STATUS_CRC_READ_ERR; | 723 | stat &= ~STATUS_CRC_READ_ERR; |
718 | 724 | ||
719 | if(test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) { | 725 | if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) { |
720 | imxmci_busy_wait_for_status(host, &stat, | 726 | imxmci_busy_wait_for_status(host, &stat, |
721 | STATUS_END_CMD_RESP | STATUS_ERR_MASK, | 727 | STATUS_END_CMD_RESP | STATUS_ERR_MASK, |
722 | 20, "imxmci_tasklet_fnc resp (ERRATUM #4)"); | 728 | 20, "imxmci_tasklet_fnc resp (ERRATUM #4)"); |
723 | } | 729 | } |
724 | 730 | ||
725 | if(stat & (STATUS_END_CMD_RESP | STATUS_ERR_MASK)) { | 731 | if (stat & (STATUS_END_CMD_RESP | STATUS_ERR_MASK)) { |
726 | if(test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) | 732 | if (test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) |
727 | imxmci_cmd_done(host, stat); | 733 | imxmci_cmd_done(host, stat); |
728 | if(host->data && (stat & STATUS_ERR_MASK)) | 734 | if (host->data && (stat & STATUS_ERR_MASK)) |
729 | imxmci_data_done(host, stat); | 735 | imxmci_data_done(host, stat); |
730 | } | 736 | } |
731 | 737 | ||
732 | if(test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) { | 738 | if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) { |
733 | stat |= MMC_STATUS; | 739 | stat |= readw(host->base + MMC_REG_STATUS); |
734 | if(imxmci_cpu_driven_data(host, &stat)){ | 740 | if (imxmci_cpu_driven_data(host, &stat)) { |
735 | if(test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) | 741 | if (test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) |
736 | imxmci_cmd_done(host, stat); | 742 | imxmci_cmd_done(host, stat); |
737 | atomic_clear_mask(IMXMCI_PEND_IRQ_m|IMXMCI_PEND_CPU_DATA_m, | 743 | atomic_clear_mask(IMXMCI_PEND_IRQ_m|IMXMCI_PEND_CPU_DATA_m, |
738 | &host->pending_events); | 744 | &host->pending_events); |
739 | imxmci_data_done(host, stat); | 745 | imxmci_data_done(host, stat); |
740 | } | 746 | } |
741 | } | 747 | } |
742 | } | 748 | } |
743 | 749 | ||
744 | if(test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events) && | 750 | if (test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events) && |
745 | !test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) { | 751 | !test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) { |
746 | 752 | ||
747 | stat = MMC_STATUS; | 753 | stat = readw(host->base + MMC_REG_STATUS); |
748 | /* Same as above */ | 754 | /* Same as above */ |
749 | stat |= host->status_reg; | 755 | stat |= host->status_reg; |
750 | 756 | ||
751 | if(host->dma_dir == DMA_TO_DEVICE) { | 757 | if (host->dma_dir == DMA_TO_DEVICE) |
752 | data_dir_mask = STATUS_WRITE_OP_DONE; | 758 | data_dir_mask = STATUS_WRITE_OP_DONE; |
753 | } else { | 759 | else |
754 | data_dir_mask = STATUS_DATA_TRANS_DONE; | 760 | data_dir_mask = STATUS_DATA_TRANS_DONE; |
755 | } | ||
756 | 761 | ||
757 | if(stat & data_dir_mask) { | 762 | if (stat & data_dir_mask) { |
758 | clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events); | 763 | clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events); |
759 | imxmci_data_done(host, stat); | 764 | imxmci_data_done(host, stat); |
760 | } | 765 | } |
761 | } | 766 | } |
762 | 767 | ||
763 | if(test_and_clear_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events)) { | 768 | if (test_and_clear_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events)) { |
764 | 769 | ||
765 | if(host->cmd) | 770 | if (host->cmd) |
766 | imxmci_cmd_done(host, STATUS_TIME_OUT_RESP); | 771 | imxmci_cmd_done(host, STATUS_TIME_OUT_RESP); |
767 | 772 | ||
768 | if(host->data) | 773 | if (host->data) |
769 | imxmci_data_done(host, STATUS_TIME_OUT_READ | | 774 | imxmci_data_done(host, STATUS_TIME_OUT_READ | |
770 | STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR); | 775 | STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR); |
771 | 776 | ||
772 | if(host->req) | 777 | if (host->req) |
773 | imxmci_finish_request(host, host->req); | 778 | imxmci_finish_request(host, host->req); |
774 | 779 | ||
775 | mmc_detect_change(host->mmc, msecs_to_jiffies(100)); | 780 | mmc_detect_change(host->mmc, msecs_to_jiffies(100)); |
@@ -796,9 +801,8 @@ static void imxmci_request(struct mmc_host *mmc, struct mmc_request *req) | |||
796 | if (req->data->flags & MMC_DATA_WRITE) | 801 | if (req->data->flags & MMC_DATA_WRITE) |
797 | cmdat |= CMD_DAT_CONT_WRITE; | 802 | cmdat |= CMD_DAT_CONT_WRITE; |
798 | 803 | ||
799 | if (req->data->flags & MMC_DATA_STREAM) { | 804 | if (req->data->flags & MMC_DATA_STREAM) |
800 | cmdat |= CMD_DAT_CONT_STREAM_BLOCK; | 805 | cmdat |= CMD_DAT_CONT_STREAM_BLOCK; |
801 | } | ||
802 | } | 806 | } |
803 | 807 | ||
804 | imxmci_start_cmd(host, req->cmd, cmdat); | 808 | imxmci_start_cmd(host, req->cmd, cmdat); |
@@ -811,36 +815,37 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
811 | struct imxmci_host *host = mmc_priv(mmc); | 815 | struct imxmci_host *host = mmc_priv(mmc); |
812 | int prescaler; | 816 | int prescaler; |
813 | 817 | ||
814 | if( ios->bus_width==MMC_BUS_WIDTH_4 ) { | 818 | if (ios->bus_width == MMC_BUS_WIDTH_4) { |
815 | host->actual_bus_width = MMC_BUS_WIDTH_4; | 819 | host->actual_bus_width = MMC_BUS_WIDTH_4; |
816 | imx_gpio_mode(PB11_PF_SD_DAT3); | 820 | imx_gpio_mode(PB11_PF_SD_DAT3); |
817 | }else{ | 821 | } else { |
818 | host->actual_bus_width = MMC_BUS_WIDTH_1; | 822 | host->actual_bus_width = MMC_BUS_WIDTH_1; |
819 | imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11); | 823 | imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11); |
820 | } | 824 | } |
821 | 825 | ||
822 | if ( host->power_mode != ios->power_mode ) { | 826 | if (host->power_mode != ios->power_mode) { |
823 | switch (ios->power_mode) { | 827 | switch (ios->power_mode) { |
824 | case MMC_POWER_OFF: | 828 | case MMC_POWER_OFF: |
825 | break; | 829 | break; |
826 | case MMC_POWER_UP: | 830 | case MMC_POWER_UP: |
827 | set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events); | 831 | set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events); |
828 | break; | 832 | break; |
829 | case MMC_POWER_ON: | 833 | case MMC_POWER_ON: |
830 | break; | 834 | break; |
831 | } | 835 | } |
832 | host->power_mode = ios->power_mode; | 836 | host->power_mode = ios->power_mode; |
833 | } | 837 | } |
834 | 838 | ||
835 | if ( ios->clock ) { | 839 | if (ios->clock) { |
836 | unsigned int clk; | 840 | unsigned int clk; |
841 | u16 reg; | ||
837 | 842 | ||
838 | /* The prescaler is 5 for PERCLK2 equal to 96MHz | 843 | /* The prescaler is 5 for PERCLK2 equal to 96MHz |
839 | * then 96MHz / 5 = 19.2 MHz | 844 | * then 96MHz / 5 = 19.2 MHz |
840 | */ | 845 | */ |
841 | clk = clk_get_rate(host->clk); | 846 | clk = clk_get_rate(host->clk); |
842 | prescaler=(clk+(CLK_RATE*7)/8)/CLK_RATE; | 847 | prescaler = (clk + (CLK_RATE * 7) / 8) / CLK_RATE; |
843 | switch(prescaler) { | 848 | switch (prescaler) { |
844 | case 0: | 849 | case 0: |
845 | case 1: prescaler = 0; | 850 | case 1: prescaler = 0; |
846 | break; | 851 | break; |
@@ -858,24 +863,29 @@ static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
858 | dev_dbg(mmc_dev(host->mmc), "PERCLK2 %d MHz -> prescaler %d\n", | 863 | dev_dbg(mmc_dev(host->mmc), "PERCLK2 %d MHz -> prescaler %d\n", |
859 | clk, prescaler); | 864 | clk, prescaler); |
860 | 865 | ||
861 | for(clk=0; clk<8; clk++) { | 866 | for (clk = 0; clk < 8; clk++) { |
862 | int x; | 867 | int x; |
863 | x = CLK_RATE / (1<<clk); | 868 | x = CLK_RATE / (1 << clk); |
864 | if( x <= ios->clock) | 869 | if (x <= ios->clock) |
865 | break; | 870 | break; |
866 | } | 871 | } |
867 | 872 | ||
868 | MMC_STR_STP_CLK |= STR_STP_CLK_ENABLE; /* enable controller */ | 873 | /* enable controller */ |
874 | reg = readw(host->base + MMC_REG_STR_STP_CLK); | ||
875 | writew(reg | STR_STP_CLK_ENABLE, | ||
876 | host->base + MMC_REG_STR_STP_CLK); | ||
869 | 877 | ||
870 | imxmci_stop_clock(host); | 878 | imxmci_stop_clock(host); |
871 | MMC_CLK_RATE = (prescaler<<3) | clk; | 879 | writew((prescaler << 3) | clk, host->base + MMC_REG_CLK_RATE); |
872 | /* | 880 | /* |
873 | * Under my understanding, clock should not be started there, because it would | 881 | * Under my understanding, clock should not be started there, because it would |
874 | * initiate SDHC sequencer and send last or random command into card | 882 | * initiate SDHC sequencer and send last or random command into card |
875 | */ | 883 | */ |
876 | /*imxmci_start_clock(host);*/ | 884 | /* imxmci_start_clock(host); */ |
877 | 885 | ||
878 | dev_dbg(mmc_dev(host->mmc), "MMC_CLK_RATE: 0x%08x\n", MMC_CLK_RATE); | 886 | dev_dbg(mmc_dev(host->mmc), |
887 | "MMC_CLK_RATE: 0x%08x\n", | ||
888 | readw(host->base + MMC_REG_CLK_RATE)); | ||
879 | } else { | 889 | } else { |
880 | imxmci_stop_clock(host); | 890 | imxmci_stop_clock(host); |
881 | } | 891 | } |
@@ -915,10 +925,10 @@ static void imxmci_check_status(unsigned long data) | |||
915 | tasklet_schedule(&host->tasklet); | 925 | tasklet_schedule(&host->tasklet); |
916 | } | 926 | } |
917 | 927 | ||
918 | if(test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events) || | 928 | if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events) || |
919 | test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) { | 929 | test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) { |
920 | atomic_inc(&host->stuck_timeout); | 930 | atomic_inc(&host->stuck_timeout); |
921 | if(atomic_read(&host->stuck_timeout) > 4) | 931 | if (atomic_read(&host->stuck_timeout) > 4) |
922 | tasklet_schedule(&host->tasklet); | 932 | tasklet_schedule(&host->tasklet); |
923 | } else { | 933 | } else { |
924 | atomic_set(&host->stuck_timeout, 0); | 934 | atomic_set(&host->stuck_timeout, 0); |
@@ -934,6 +944,7 @@ static int imxmci_probe(struct platform_device *pdev) | |||
934 | struct imxmci_host *host = NULL; | 944 | struct imxmci_host *host = NULL; |
935 | struct resource *r; | 945 | struct resource *r; |
936 | int ret = 0, irq; | 946 | int ret = 0, irq; |
947 | u16 rev_no; | ||
937 | 948 | ||
938 | printk(KERN_INFO "i.MX mmc driver\n"); | 949 | printk(KERN_INFO "i.MX mmc driver\n"); |
939 | 950 | ||
@@ -942,7 +953,8 @@ static int imxmci_probe(struct platform_device *pdev) | |||
942 | if (!r || irq < 0) | 953 | if (!r || irq < 0) |
943 | return -ENXIO; | 954 | return -ENXIO; |
944 | 955 | ||
945 | if (!request_mem_region(r->start, 0x100, pdev->name)) | 956 | r = request_mem_region(r->start, resource_size(r), pdev->name); |
957 | if (!r) | ||
946 | return -EBUSY; | 958 | return -EBUSY; |
947 | 959 | ||
948 | mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev); | 960 | mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev); |
@@ -966,6 +978,12 @@ static int imxmci_probe(struct platform_device *pdev) | |||
966 | mmc->max_blk_count = 65535; | 978 | mmc->max_blk_count = 65535; |
967 | 979 | ||
968 | host = mmc_priv(mmc); | 980 | host = mmc_priv(mmc); |
981 | host->base = ioremap(r->start, resource_size(r)); | ||
982 | if (!host->base) { | ||
983 | ret = -ENOMEM; | ||
984 | goto out; | ||
985 | } | ||
986 | |||
969 | host->mmc = mmc; | 987 | host->mmc = mmc; |
970 | host->dma_allocated = 0; | 988 | host->dma_allocated = 0; |
971 | host->pdata = pdev->dev.platform_data; | 989 | host->pdata = pdev->dev.platform_data; |
@@ -993,18 +1011,20 @@ static int imxmci_probe(struct platform_device *pdev) | |||
993 | imx_gpio_mode(PB12_PF_SD_CLK); | 1011 | imx_gpio_mode(PB12_PF_SD_CLK); |
994 | imx_gpio_mode(PB13_PF_SD_CMD); | 1012 | imx_gpio_mode(PB13_PF_SD_CMD); |
995 | 1013 | ||
996 | imxmci_softreset(); | 1014 | imxmci_softreset(host); |
997 | 1015 | ||
998 | if ( MMC_REV_NO != 0x390 ) { | 1016 | rev_no = readw(host->base + MMC_REG_REV_NO); |
1017 | if (rev_no != 0x390) { | ||
999 | dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n", | 1018 | dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n", |
1000 | MMC_REV_NO); | 1019 | readw(host->base + MMC_REG_REV_NO)); |
1001 | goto out; | 1020 | goto out; |
1002 | } | 1021 | } |
1003 | 1022 | ||
1004 | MMC_READ_TO = 0x2db4; /* recommended in data sheet */ | 1023 | /* recommended in data sheet */ |
1024 | writew(0x2db4, host->base + MMC_REG_READ_TO); | ||
1005 | 1025 | ||
1006 | host->imask = IMXMCI_INT_MASK_DEFAULT; | 1026 | host->imask = IMXMCI_INT_MASK_DEFAULT; |
1007 | MMC_INT_MASK = host->imask; | 1027 | writew(host->imask, host->base + MMC_REG_INT_MASK); |
1008 | 1028 | ||
1009 | host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW); | 1029 | host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW); |
1010 | if(host->dma < 0) { | 1030 | if(host->dma < 0) { |
@@ -1012,7 +1032,7 @@ static int imxmci_probe(struct platform_device *pdev) | |||
1012 | ret = -EBUSY; | 1032 | ret = -EBUSY; |
1013 | goto out; | 1033 | goto out; |
1014 | } | 1034 | } |
1015 | host->dma_allocated=1; | 1035 | host->dma_allocated = 1; |
1016 | imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host); | 1036 | imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host); |
1017 | 1037 | ||
1018 | tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host); | 1038 | tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host); |
@@ -1032,7 +1052,7 @@ static int imxmci_probe(struct platform_device *pdev) | |||
1032 | host->timer.data = (unsigned long)host; | 1052 | host->timer.data = (unsigned long)host; |
1033 | host->timer.function = imxmci_check_status; | 1053 | host->timer.function = imxmci_check_status; |
1034 | add_timer(&host->timer); | 1054 | add_timer(&host->timer); |
1035 | mod_timer(&host->timer, jiffies + (HZ>>1)); | 1055 | mod_timer(&host->timer, jiffies + (HZ >> 1)); |
1036 | 1056 | ||
1037 | platform_set_drvdata(pdev, mmc); | 1057 | platform_set_drvdata(pdev, mmc); |
1038 | 1058 | ||
@@ -1042,18 +1062,20 @@ static int imxmci_probe(struct platform_device *pdev) | |||
1042 | 1062 | ||
1043 | out: | 1063 | out: |
1044 | if (host) { | 1064 | if (host) { |
1045 | if(host->dma_allocated){ | 1065 | if (host->dma_allocated) { |
1046 | imx_dma_free(host->dma); | 1066 | imx_dma_free(host->dma); |
1047 | host->dma_allocated=0; | 1067 | host->dma_allocated = 0; |
1048 | } | 1068 | } |
1049 | if (host->clk) { | 1069 | if (host->clk) { |
1050 | clk_disable(host->clk); | 1070 | clk_disable(host->clk); |
1051 | clk_put(host->clk); | 1071 | clk_put(host->clk); |
1052 | } | 1072 | } |
1073 | if (host->base) | ||
1074 | iounmap(host->base); | ||
1053 | } | 1075 | } |
1054 | if (mmc) | 1076 | if (mmc) |
1055 | mmc_free_host(mmc); | 1077 | mmc_free_host(mmc); |
1056 | release_mem_region(r->start, 0x100); | 1078 | release_mem_region(r->start, resource_size(r)); |
1057 | return ret; | 1079 | return ret; |
1058 | } | 1080 | } |
1059 | 1081 | ||
@@ -1072,9 +1094,10 @@ static int imxmci_remove(struct platform_device *pdev) | |||
1072 | mmc_remove_host(mmc); | 1094 | mmc_remove_host(mmc); |
1073 | 1095 | ||
1074 | free_irq(host->irq, host); | 1096 | free_irq(host->irq, host); |
1075 | if(host->dma_allocated){ | 1097 | iounmap(host->base); |
1098 | if (host->dma_allocated) { | ||
1076 | imx_dma_free(host->dma); | 1099 | imx_dma_free(host->dma); |
1077 | host->dma_allocated=0; | 1100 | host->dma_allocated = 0; |
1078 | } | 1101 | } |
1079 | 1102 | ||
1080 | tasklet_kill(&host->tasklet); | 1103 | tasklet_kill(&host->tasklet); |
@@ -1082,7 +1105,7 @@ static int imxmci_remove(struct platform_device *pdev) | |||
1082 | clk_disable(host->clk); | 1105 | clk_disable(host->clk); |
1083 | clk_put(host->clk); | 1106 | clk_put(host->clk); |
1084 | 1107 | ||
1085 | release_mem_region(host->res->start, 0x100); | 1108 | release_mem_region(host->res->start, resource_size(host->res)); |
1086 | 1109 | ||
1087 | mmc_free_host(mmc); | 1110 | mmc_free_host(mmc); |
1088 | } | 1111 | } |
@@ -1109,7 +1132,7 @@ static int imxmci_resume(struct platform_device *dev) | |||
1109 | 1132 | ||
1110 | if (mmc) { | 1133 | if (mmc) { |
1111 | host = mmc_priv(mmc); | 1134 | host = mmc_priv(mmc); |
1112 | if(host) | 1135 | if (host) |
1113 | set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events); | 1136 | set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events); |
1114 | ret = mmc_resume_host(mmc); | 1137 | ret = mmc_resume_host(mmc); |
1115 | } | 1138 | } |
diff --git a/drivers/mmc/host/imxmmc.h b/drivers/mmc/host/imxmmc.h index e5339e334dbb..09d5d4ee3a77 100644 --- a/drivers/mmc/host/imxmmc.h +++ b/drivers/mmc/host/imxmmc.h | |||
@@ -1,24 +1,21 @@ | |||
1 | #define MMC_REG_STR_STP_CLK 0x00 | ||
2 | #define MMC_REG_STATUS 0x04 | ||
3 | #define MMC_REG_CLK_RATE 0x08 | ||
4 | #define MMC_REG_CMD_DAT_CONT 0x0C | ||
5 | #define MMC_REG_RES_TO 0x10 | ||
6 | #define MMC_REG_READ_TO 0x14 | ||
7 | #define MMC_REG_BLK_LEN 0x18 | ||
8 | #define MMC_REG_NOB 0x1C | ||
9 | #define MMC_REG_REV_NO 0x20 | ||
10 | #define MMC_REG_INT_MASK 0x24 | ||
11 | #define MMC_REG_CMD 0x28 | ||
12 | #define MMC_REG_ARGH 0x2C | ||
13 | #define MMC_REG_ARGL 0x30 | ||
14 | #define MMC_REG_RES_FIFO 0x34 | ||
15 | #define MMC_REG_BUFFER_ACCESS 0x38 | ||
1 | 16 | ||
2 | # define __REG16(x) (*((volatile u16 *)IO_ADDRESS(x))) | 17 | #define STR_STP_CLK_IPG_CLK_GATE_DIS (1<<15) |
3 | 18 | #define STR_STP_CLK_IPG_PERCLK_GATE_DIS (1<<14) | |
4 | #define MMC_STR_STP_CLK __REG16(IMX_MMC_BASE + 0x00) | ||
5 | #define MMC_STATUS __REG16(IMX_MMC_BASE + 0x04) | ||
6 | #define MMC_CLK_RATE __REG16(IMX_MMC_BASE + 0x08) | ||
7 | #define MMC_CMD_DAT_CONT __REG16(IMX_MMC_BASE + 0x0C) | ||
8 | #define MMC_RES_TO __REG16(IMX_MMC_BASE + 0x10) | ||
9 | #define MMC_READ_TO __REG16(IMX_MMC_BASE + 0x14) | ||
10 | #define MMC_BLK_LEN __REG16(IMX_MMC_BASE + 0x18) | ||
11 | #define MMC_NOB __REG16(IMX_MMC_BASE + 0x1C) | ||
12 | #define MMC_REV_NO __REG16(IMX_MMC_BASE + 0x20) | ||
13 | #define MMC_INT_MASK __REG16(IMX_MMC_BASE + 0x24) | ||
14 | #define MMC_CMD __REG16(IMX_MMC_BASE + 0x28) | ||
15 | #define MMC_ARGH __REG16(IMX_MMC_BASE + 0x2C) | ||
16 | #define MMC_ARGL __REG16(IMX_MMC_BASE + 0x30) | ||
17 | #define MMC_RES_FIFO __REG16(IMX_MMC_BASE + 0x34) | ||
18 | #define MMC_BUFFER_ACCESS __REG16(IMX_MMC_BASE + 0x38) | ||
19 | #define MMC_BUFFER_ACCESS_OFS 0x38 | ||
20 | |||
21 | |||
22 | #define STR_STP_CLK_ENDIAN (1<<5) | 19 | #define STR_STP_CLK_ENDIAN (1<<5) |
23 | #define STR_STP_CLK_RESET (1<<3) | 20 | #define STR_STP_CLK_RESET (1<<3) |
24 | #define STR_STP_CLK_ENABLE (1<<2) | 21 | #define STR_STP_CLK_ENABLE (1<<2) |
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index ad00e1632317..87e211df68ac 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -1285,7 +1285,7 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1285 | /* Platform data is used to hook up things like card sensing | 1285 | /* Platform data is used to hook up things like card sensing |
1286 | * and power switching gpios. | 1286 | * and power switching gpios. |
1287 | */ | 1287 | */ |
1288 | host->pdata = spi->dev.platform_data; | 1288 | host->pdata = mmc_spi_get_pdata(spi); |
1289 | if (host->pdata) | 1289 | if (host->pdata) |
1290 | mmc->ocr_avail = host->pdata->ocr_mask; | 1290 | mmc->ocr_avail = host->pdata->ocr_mask; |
1291 | if (!mmc->ocr_avail) { | 1291 | if (!mmc->ocr_avail) { |
@@ -1368,6 +1368,7 @@ fail_glue_init: | |||
1368 | 1368 | ||
1369 | fail_nobuf1: | 1369 | fail_nobuf1: |
1370 | mmc_free_host(mmc); | 1370 | mmc_free_host(mmc); |
1371 | mmc_spi_put_pdata(spi); | ||
1371 | dev_set_drvdata(&spi->dev, NULL); | 1372 | dev_set_drvdata(&spi->dev, NULL); |
1372 | 1373 | ||
1373 | nomem: | 1374 | nomem: |
@@ -1402,6 +1403,7 @@ static int __devexit mmc_spi_remove(struct spi_device *spi) | |||
1402 | 1403 | ||
1403 | spi->max_speed_hz = mmc->f_max; | 1404 | spi->max_speed_hz = mmc->f_max; |
1404 | mmc_free_host(mmc); | 1405 | mmc_free_host(mmc); |
1406 | mmc_spi_put_pdata(spi); | ||
1405 | dev_set_drvdata(&spi->dev, NULL); | 1407 | dev_set_drvdata(&spi->dev, NULL); |
1406 | } | 1408 | } |
1407 | return 0; | 1409 | return 0; |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 2fadf323c696..1bcbdd6763ac 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -500,7 +500,7 @@ static int mmci_probe(struct amba_device *dev, void *id) | |||
500 | } | 500 | } |
501 | 501 | ||
502 | host = mmc_priv(mmc); | 502 | host = mmc_priv(mmc); |
503 | host->clk = clk_get(&dev->dev, "MCLK"); | 503 | host->clk = clk_get(&dev->dev, NULL); |
504 | if (IS_ERR(host->clk)) { | 504 | if (IS_ERR(host->clk)) { |
505 | ret = PTR_ERR(host->clk); | 505 | ret = PTR_ERR(host->clk); |
506 | host->clk = NULL; | 506 | host->clk = NULL; |
diff --git a/drivers/mmc/host/of_mmc_spi.c b/drivers/mmc/host/of_mmc_spi.c new file mode 100644 index 000000000000..fb2921f8099d --- /dev/null +++ b/drivers/mmc/host/of_mmc_spi.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * OpenFirmware bindings for the MMC-over-SPI driver | ||
3 | * | ||
4 | * Copyright (c) MontaVista Software, Inc. 2008. | ||
5 | * | ||
6 | * Author: Anton Vorontsov <avorontsov@ru.mvista.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms of the GNU General Public License as published by the | ||
10 | * Free Software Foundation; either version 2 of the License, or (at your | ||
11 | * option) any later version. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/module.h> | ||
16 | #include <linux/device.h> | ||
17 | #include <linux/gpio.h> | ||
18 | #include <linux/of.h> | ||
19 | #include <linux/of_gpio.h> | ||
20 | #include <linux/spi/spi.h> | ||
21 | #include <linux/spi/mmc_spi.h> | ||
22 | #include <linux/mmc/core.h> | ||
23 | #include <linux/mmc/host.h> | ||
24 | |||
25 | enum { | ||
26 | CD_GPIO = 0, | ||
27 | WP_GPIO, | ||
28 | NUM_GPIOS, | ||
29 | }; | ||
30 | |||
31 | struct of_mmc_spi { | ||
32 | int gpios[NUM_GPIOS]; | ||
33 | bool alow_gpios[NUM_GPIOS]; | ||
34 | struct mmc_spi_platform_data pdata; | ||
35 | }; | ||
36 | |||
37 | static struct of_mmc_spi *to_of_mmc_spi(struct device *dev) | ||
38 | { | ||
39 | return container_of(dev->platform_data, struct of_mmc_spi, pdata); | ||
40 | } | ||
41 | |||
42 | static int of_mmc_spi_read_gpio(struct device *dev, int gpio_num) | ||
43 | { | ||
44 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
45 | bool active_low = oms->alow_gpios[gpio_num]; | ||
46 | bool value = gpio_get_value(oms->gpios[gpio_num]); | ||
47 | |||
48 | return active_low ^ value; | ||
49 | } | ||
50 | |||
51 | static int of_mmc_spi_get_cd(struct device *dev) | ||
52 | { | ||
53 | return of_mmc_spi_read_gpio(dev, CD_GPIO); | ||
54 | } | ||
55 | |||
56 | static int of_mmc_spi_get_ro(struct device *dev) | ||
57 | { | ||
58 | return of_mmc_spi_read_gpio(dev, WP_GPIO); | ||
59 | } | ||
60 | |||
61 | struct mmc_spi_platform_data *mmc_spi_get_pdata(struct spi_device *spi) | ||
62 | { | ||
63 | struct device *dev = &spi->dev; | ||
64 | struct device_node *np = dev_archdata_get_node(&dev->archdata); | ||
65 | struct of_mmc_spi *oms; | ||
66 | const u32 *voltage_ranges; | ||
67 | int num_ranges; | ||
68 | int i; | ||
69 | int ret = -EINVAL; | ||
70 | |||
71 | if (dev->platform_data || !np) | ||
72 | return dev->platform_data; | ||
73 | |||
74 | oms = kzalloc(sizeof(*oms), GFP_KERNEL); | ||
75 | if (!oms) | ||
76 | return NULL; | ||
77 | |||
78 | voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges); | ||
79 | num_ranges = num_ranges / sizeof(*voltage_ranges) / 2; | ||
80 | if (!voltage_ranges || !num_ranges) { | ||
81 | dev_err(dev, "OF: voltage-ranges unspecified\n"); | ||
82 | goto err_ocr; | ||
83 | } | ||
84 | |||
85 | for (i = 0; i < num_ranges; i++) { | ||
86 | const int j = i * 2; | ||
87 | u32 mask; | ||
88 | |||
89 | mask = mmc_vddrange_to_ocrmask(voltage_ranges[j], | ||
90 | voltage_ranges[j + 1]); | ||
91 | if (!mask) { | ||
92 | ret = -EINVAL; | ||
93 | dev_err(dev, "OF: voltage-range #%d is invalid\n", i); | ||
94 | goto err_ocr; | ||
95 | } | ||
96 | oms->pdata.ocr_mask |= mask; | ||
97 | } | ||
98 | |||
99 | for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { | ||
100 | enum of_gpio_flags gpio_flags; | ||
101 | |||
102 | oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags); | ||
103 | if (!gpio_is_valid(oms->gpios[i])) | ||
104 | continue; | ||
105 | |||
106 | ret = gpio_request(oms->gpios[i], dev->bus_id); | ||
107 | if (ret < 0) { | ||
108 | oms->gpios[i] = -EINVAL; | ||
109 | continue; | ||
110 | } | ||
111 | |||
112 | if (gpio_flags & OF_GPIO_ACTIVE_LOW) | ||
113 | oms->alow_gpios[i] = true; | ||
114 | } | ||
115 | |||
116 | if (gpio_is_valid(oms->gpios[CD_GPIO])) | ||
117 | oms->pdata.get_cd = of_mmc_spi_get_cd; | ||
118 | if (gpio_is_valid(oms->gpios[WP_GPIO])) | ||
119 | oms->pdata.get_ro = of_mmc_spi_get_ro; | ||
120 | |||
121 | /* We don't support interrupts yet, let's poll. */ | ||
122 | oms->pdata.caps |= MMC_CAP_NEEDS_POLL; | ||
123 | |||
124 | dev->platform_data = &oms->pdata; | ||
125 | return dev->platform_data; | ||
126 | err_ocr: | ||
127 | kfree(oms); | ||
128 | return NULL; | ||
129 | } | ||
130 | EXPORT_SYMBOL(mmc_spi_get_pdata); | ||
131 | |||
132 | void mmc_spi_put_pdata(struct spi_device *spi) | ||
133 | { | ||
134 | struct device *dev = &spi->dev; | ||
135 | struct device_node *np = dev_archdata_get_node(&dev->archdata); | ||
136 | struct of_mmc_spi *oms = to_of_mmc_spi(dev); | ||
137 | int i; | ||
138 | |||
139 | if (!dev->platform_data || !np) | ||
140 | return; | ||
141 | |||
142 | for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { | ||
143 | if (gpio_is_valid(oms->gpios[i])) | ||
144 | gpio_free(oms->gpios[i]); | ||
145 | } | ||
146 | kfree(oms); | ||
147 | dev->platform_data = NULL; | ||
148 | } | ||
149 | EXPORT_SYMBOL(mmc_spi_put_pdata); | ||
diff --git a/drivers/mmc/host/omap.c b/drivers/mmc/host/omap.c index 1b9fc3c6b875..67d7b7fef084 100644 --- a/drivers/mmc/host/omap.c +++ b/drivers/mmc/host/omap.c | |||
@@ -1015,7 +1015,7 @@ static int mmc_omap_get_dma_channel(struct mmc_omap_host *host, struct mmc_data | |||
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | if (is_read) { | 1017 | if (is_read) { |
1018 | if (host->id == 1) { | 1018 | if (host->id == 0) { |
1019 | sync_dev = OMAP_DMA_MMC_RX; | 1019 | sync_dev = OMAP_DMA_MMC_RX; |
1020 | dma_dev_name = "MMC1 read"; | 1020 | dma_dev_name = "MMC1 read"; |
1021 | } else { | 1021 | } else { |
@@ -1023,7 +1023,7 @@ static int mmc_omap_get_dma_channel(struct mmc_omap_host *host, struct mmc_data | |||
1023 | dma_dev_name = "MMC2 read"; | 1023 | dma_dev_name = "MMC2 read"; |
1024 | } | 1024 | } |
1025 | } else { | 1025 | } else { |
1026 | if (host->id == 1) { | 1026 | if (host->id == 0) { |
1027 | sync_dev = OMAP_DMA_MMC_TX; | 1027 | sync_dev = OMAP_DMA_MMC_TX; |
1028 | dma_dev_name = "MMC1 write"; | 1028 | dma_dev_name = "MMC1 write"; |
1029 | } else { | 1029 | } else { |
@@ -1317,7 +1317,7 @@ static int __init mmc_omap_new_slot(struct mmc_omap_host *host, int id) | |||
1317 | host->slots[id] = slot; | 1317 | host->slots[id] = slot; |
1318 | 1318 | ||
1319 | mmc->caps = 0; | 1319 | mmc->caps = 0; |
1320 | if (host->pdata->conf.wire4) | 1320 | if (host->pdata->slots[id].wires >= 4) |
1321 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 1321 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
1322 | 1322 | ||
1323 | mmc->ops = &mmc_omap_ops; | 1323 | mmc->ops = &mmc_omap_ops; |
@@ -1451,6 +1451,7 @@ static int __init mmc_omap_probe(struct platform_device *pdev) | |||
1451 | host->irq = irq; | 1451 | host->irq = irq; |
1452 | 1452 | ||
1453 | host->use_dma = 1; | 1453 | host->use_dma = 1; |
1454 | host->dev->dma_mask = &pdata->dma_mask; | ||
1454 | host->dma_ch = -1; | 1455 | host->dma_ch = -1; |
1455 | 1456 | ||
1456 | host->irq = irq; | 1457 | host->irq = irq; |
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c index ebfaa9960939..3c5483b75da4 100644 --- a/drivers/mmc/host/pxamci.c +++ b/drivers/mmc/host/pxamci.c | |||
@@ -26,11 +26,12 @@ | |||
26 | #include <linux/clk.h> | 26 | #include <linux/clk.h> |
27 | #include <linux/err.h> | 27 | #include <linux/err.h> |
28 | #include <linux/mmc/host.h> | 28 | #include <linux/mmc/host.h> |
29 | #include <linux/io.h> | ||
29 | 30 | ||
30 | #include <asm/dma.h> | ||
31 | #include <asm/io.h> | ||
32 | #include <asm/sizes.h> | 31 | #include <asm/sizes.h> |
33 | 32 | ||
33 | #include <mach/dma.h> | ||
34 | #include <mach/hardware.h> | ||
34 | #include <mach/pxa-regs.h> | 35 | #include <mach/pxa-regs.h> |
35 | #include <mach/mmc.h> | 36 | #include <mach/mmc.h> |
36 | 37 | ||
@@ -282,7 +283,7 @@ static int pxamci_data_done(struct pxamci_host *host, unsigned int stat) | |||
282 | return 0; | 283 | return 0; |
283 | 284 | ||
284 | DCSR(host->dma) = 0; | 285 | DCSR(host->dma) = 0; |
285 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len, | 286 | dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, |
286 | host->dma_dir); | 287 | host->dma_dir); |
287 | 288 | ||
288 | if (stat & STAT_READ_TIME_OUT) | 289 | if (stat & STAT_READ_TIME_OUT) |
@@ -533,7 +534,7 @@ static int pxamci_probe(struct platform_device *pdev) | |||
533 | host->pdata = pdev->dev.platform_data; | 534 | host->pdata = pdev->dev.platform_data; |
534 | host->clkrt = CLKRT_OFF; | 535 | host->clkrt = CLKRT_OFF; |
535 | 536 | ||
536 | host->clk = clk_get(&pdev->dev, "MMCCLK"); | 537 | host->clk = clk_get(&pdev->dev, NULL); |
537 | if (IS_ERR(host->clk)) { | 538 | if (IS_ERR(host->clk)) { |
538 | ret = PTR_ERR(host->clk); | 539 | ret = PTR_ERR(host->clk); |
539 | host->clk = NULL; | 540 | host->clk = NULL; |
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c index a16d7609e4ee..be9e7b32b34e 100644 --- a/drivers/mmc/host/ricoh_mmc.c +++ b/drivers/mmc/host/ricoh_mmc.c | |||
@@ -11,9 +11,10 @@ | |||
11 | 11 | ||
12 | /* | 12 | /* |
13 | * This is a conceptually ridiculous driver, but it is required by the way | 13 | * This is a conceptually ridiculous driver, but it is required by the way |
14 | * the Ricoh multi-function R5C832 works. This chip implements firewire | 14 | * the Ricoh multi-function chips (R5CXXX) work. These chips implement |
15 | * and four different memory card controllers. Two of those controllers are | 15 | * the four main memory card controllers (SD, MMC, MS, xD) and one or both |
16 | * an SDHCI controller and a proprietary MMC controller. The linux SDHCI | 16 | * of cardbus or firewire. It happens that they implement SD and MMC |
17 | * support as separate controllers (and PCI functions). The linux SDHCI | ||
17 | * driver supports MMC cards but the chip detects MMC cards in hardware | 18 | * driver supports MMC cards but the chip detects MMC cards in hardware |
18 | * and directs them to the MMC controller - so the SDHCI driver never sees | 19 | * and directs them to the MMC controller - so the SDHCI driver never sees |
19 | * them. To get around this, we must disable the useless MMC controller. | 20 | * them. To get around this, we must disable the useless MMC controller. |
@@ -21,8 +22,10 @@ | |||
21 | * a detection event occurs immediately, even if the MMC card is already | 22 | * a detection event occurs immediately, even if the MMC card is already |
22 | * in the reader. | 23 | * in the reader. |
23 | * | 24 | * |
24 | * The relevant registers live on the firewire function, so this is unavoidably | 25 | * It seems to be the case that the relevant PCI registers to deactivate the |
25 | * ugly. Such is life. | 26 | * MMC controller live on PCI function 0, which might be the cardbus controller |
27 | * or the firewire controller, depending on the particular chip in question. As | ||
28 | * such, it makes what this driver has to do unavoidably ugly. Such is life. | ||
26 | */ | 29 | */ |
27 | 30 | ||
28 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
@@ -143,6 +146,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
143 | pci_get_device(PCI_VENDOR_ID_RICOH, | 146 | pci_get_device(PCI_VENDOR_ID_RICOH, |
144 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { | 147 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { |
145 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | 148 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
149 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
146 | pdev->bus == fw_dev->bus) { | 150 | pdev->bus == fw_dev->bus) { |
147 | if (ricoh_mmc_disable(fw_dev) != 0) | 151 | if (ricoh_mmc_disable(fw_dev) != 0) |
148 | return -ENODEV; | 152 | return -ENODEV; |
@@ -160,6 +164,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
160 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, | 164 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, |
161 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { | 165 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { |
162 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | 166 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && |
167 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
163 | pdev->bus == fw_dev->bus) { | 168 | pdev->bus == fw_dev->bus) { |
164 | if (ricoh_mmc_disable(fw_dev) != 0) | 169 | if (ricoh_mmc_disable(fw_dev) != 0) |
165 | return -ENODEV; | 170 | return -ENODEV; |
@@ -172,7 +177,7 @@ static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | |||
172 | 177 | ||
173 | if (!ctrlfound) { | 178 | if (!ctrlfound) { |
174 | printk(KERN_WARNING DRIVER_NAME | 179 | printk(KERN_WARNING DRIVER_NAME |
175 | ": Main firewire function not found. Cannot disable controller.\n"); | 180 | ": Main Ricoh function not found. Cannot disable controller.\n"); |
176 | return -ENODEV; | 181 | return -ENODEV; |
177 | } | 182 | } |
178 | 183 | ||
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index 3b2085b57769..fcc98a4cce3c 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <mach/regs-sdi.h> | 25 | #include <mach/regs-sdi.h> |
26 | #include <mach/regs-gpio.h> | 26 | #include <mach/regs-gpio.h> |
27 | 27 | ||
28 | #include <asm/plat-s3c24xx/mci.h> | 28 | #include <plat/mci.h> |
29 | 29 | ||
30 | #include "s3cmci.h" | 30 | #include "s3cmci.h" |
31 | 31 | ||
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 9bd7026b0021..f07255cb17ee 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -545,7 +545,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
545 | } | 545 | } |
546 | 546 | ||
547 | addr = pci_resource_start(pdev, bar); | 547 | addr = pci_resource_start(pdev, bar); |
548 | host->ioaddr = ioremap_nocache(addr, pci_resource_len(pdev, bar)); | 548 | host->ioaddr = pci_ioremap_bar(pdev, bar); |
549 | if (!host->ioaddr) { | 549 | if (!host->ioaddr) { |
550 | dev_err(&pdev->dev, "failed to remap registers\n"); | 550 | dev_err(&pdev->dev, "failed to remap registers\n"); |
551 | goto release; | 551 | goto release; |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4d010a984bed..6b2d1f99af67 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -30,6 +30,11 @@ | |||
30 | #define DBG(f, x...) \ | 30 | #define DBG(f, x...) \ |
31 | pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) | 31 | pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x) |
32 | 32 | ||
33 | #if defined(CONFIG_LEDS_CLASS) || (defined(CONFIG_LEDS_CLASS_MODULE) && \ | ||
34 | defined(CONFIG_MMC_SDHCI_MODULE)) | ||
35 | #define SDHCI_USE_LEDS_CLASS | ||
36 | #endif | ||
37 | |||
33 | static unsigned int debug_quirks = 0; | 38 | static unsigned int debug_quirks = 0; |
34 | 39 | ||
35 | static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *); | 40 | static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *); |
@@ -149,7 +154,7 @@ static void sdhci_deactivate_led(struct sdhci_host *host) | |||
149 | writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); | 154 | writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL); |
150 | } | 155 | } |
151 | 156 | ||
152 | #ifdef CONFIG_LEDS_CLASS | 157 | #ifdef SDHCI_USE_LEDS_CLASS |
153 | static void sdhci_led_control(struct led_classdev *led, | 158 | static void sdhci_led_control(struct led_classdev *led, |
154 | enum led_brightness brightness) | 159 | enum led_brightness brightness) |
155 | { | 160 | { |
@@ -994,7 +999,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
994 | 999 | ||
995 | WARN_ON(host->mrq != NULL); | 1000 | WARN_ON(host->mrq != NULL); |
996 | 1001 | ||
997 | #ifndef CONFIG_LEDS_CLASS | 1002 | #ifndef SDHCI_USE_LEDS_CLASS |
998 | sdhci_activate_led(host); | 1003 | sdhci_activate_led(host); |
999 | #endif | 1004 | #endif |
1000 | 1005 | ||
@@ -1201,7 +1206,7 @@ static void sdhci_tasklet_finish(unsigned long param) | |||
1201 | host->cmd = NULL; | 1206 | host->cmd = NULL; |
1202 | host->data = NULL; | 1207 | host->data = NULL; |
1203 | 1208 | ||
1204 | #ifndef CONFIG_LEDS_CLASS | 1209 | #ifndef SDHCI_USE_LEDS_CLASS |
1205 | sdhci_deactivate_led(host); | 1210 | sdhci_deactivate_led(host); |
1206 | #endif | 1211 | #endif |
1207 | 1212 | ||
@@ -1717,7 +1722,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1717 | sdhci_dumpregs(host); | 1722 | sdhci_dumpregs(host); |
1718 | #endif | 1723 | #endif |
1719 | 1724 | ||
1720 | #ifdef CONFIG_LEDS_CLASS | 1725 | #ifdef SDHCI_USE_LEDS_CLASS |
1721 | host->led.name = mmc_hostname(mmc); | 1726 | host->led.name = mmc_hostname(mmc); |
1722 | host->led.brightness = LED_OFF; | 1727 | host->led.brightness = LED_OFF; |
1723 | host->led.default_trigger = mmc_hostname(mmc); | 1728 | host->led.default_trigger = mmc_hostname(mmc); |
@@ -1739,7 +1744,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1739 | 1744 | ||
1740 | return 0; | 1745 | return 0; |
1741 | 1746 | ||
1742 | #ifdef CONFIG_LEDS_CLASS | 1747 | #ifdef SDHCI_USE_LEDS_CLASS |
1743 | reset: | 1748 | reset: |
1744 | sdhci_reset(host, SDHCI_RESET_ALL); | 1749 | sdhci_reset(host, SDHCI_RESET_ALL); |
1745 | free_irq(host->irq, host); | 1750 | free_irq(host->irq, host); |
@@ -1775,7 +1780,7 @@ void sdhci_remove_host(struct sdhci_host *host, int dead) | |||
1775 | 1780 | ||
1776 | mmc_remove_host(host->mmc); | 1781 | mmc_remove_host(host->mmc); |
1777 | 1782 | ||
1778 | #ifdef CONFIG_LEDS_CLASS | 1783 | #ifdef SDHCI_USE_LEDS_CLASS |
1779 | led_classdev_unregister(&host->led); | 1784 | led_classdev_unregister(&host->led); |
1780 | #endif | 1785 | #endif |
1781 | 1786 | ||
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 31f4b1528e76..3efba2363941 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -220,7 +220,7 @@ struct sdhci_host { | |||
220 | struct mmc_host *mmc; /* MMC structure */ | 220 | struct mmc_host *mmc; /* MMC structure */ |
221 | u64 dma_mask; /* custom DMA mask */ | 221 | u64 dma_mask; /* custom DMA mask */ |
222 | 222 | ||
223 | #ifdef CONFIG_LEDS_CLASS | 223 | #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) |
224 | struct led_classdev led; /* LED control */ | 224 | struct led_classdev led; /* LED control */ |
225 | #endif | 225 | #endif |
226 | 226 | ||
diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c index 1df44d966bdb..cb41e9c3ac07 100644 --- a/drivers/mmc/host/sdricoh_cs.c +++ b/drivers/mmc/host/sdricoh_cs.c | |||
@@ -82,6 +82,8 @@ static struct pcmcia_device_id pcmcia_ids[] = { | |||
82 | /* vendor and device strings followed by their crc32 hashes */ | 82 | /* vendor and device strings followed by their crc32 hashes */ |
83 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed, | 83 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay1Controller", 0xd9f522ed, |
84 | 0xc3901202), | 84 | 0xc3901202), |
85 | PCMCIA_DEVICE_PROD_ID12("RICOH", "Bay Controller", 0xd9f522ed, | ||
86 | 0xace80909), | ||
85 | PCMCIA_DEVICE_NULL, | 87 | PCMCIA_DEVICE_NULL, |
86 | }; | 88 | }; |
87 | 89 | ||
@@ -463,7 +465,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev, | |||
463 | 465 | ||
464 | err: | 466 | err: |
465 | if (iobase) | 467 | if (iobase) |
466 | iounmap(iobase); | 468 | pci_iounmap(pci_dev, iobase); |
467 | if (mmc) | 469 | if (mmc) |
468 | mmc_free_host(mmc); | 470 | mmc_free_host(mmc); |
469 | 471 | ||
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index 95430b81ec11..6a7a61904833 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c | |||
@@ -224,7 +224,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host) | |||
224 | { | 224 | { |
225 | void __iomem *ctl = host->ctl; | 225 | void __iomem *ctl = host->ctl; |
226 | struct mmc_data *data = host->data; | 226 | struct mmc_data *data = host->data; |
227 | struct mmc_command *stop = data->stop; | 227 | struct mmc_command *stop; |
228 | 228 | ||
229 | host->data = NULL; | 229 | host->data = NULL; |
230 | 230 | ||
@@ -232,6 +232,7 @@ static inline void tmio_mmc_data_irq(struct tmio_mmc_host *host) | |||
232 | pr_debug("Spurious data end IRQ\n"); | 232 | pr_debug("Spurious data end IRQ\n"); |
233 | return; | 233 | return; |
234 | } | 234 | } |
235 | stop = data->stop; | ||
235 | 236 | ||
236 | /* FIXME - return correct transfer count on errors */ | 237 | /* FIXME - return correct transfer count on errors */ |
237 | if (!data->error) | 238 | if (!data->error) |