aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/sd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/core/sd.c')
-rw-r--r--drivers/mmc/core/sd.c63
1 files changed, 55 insertions, 8 deletions
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 918477c490b..1240684083f 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -19,11 +19,10 @@
19 19
20#include "core.h" 20#include "core.h"
21#include "sysfs.h" 21#include "sysfs.h"
22#include "bus.h"
22#include "mmc_ops.h" 23#include "mmc_ops.h"
23#include "sd_ops.h" 24#include "sd_ops.h"
24 25
25#include "core.h"
26
27static const unsigned int tran_exp[] = { 26static const unsigned int tran_exp[] = {
28 10000, 100000, 1000000, 10000000, 27 10000, 100000, 1000000, 10000000,
29 0, 0, 0, 0 28 0, 0, 0, 0
@@ -487,8 +486,7 @@ static void mmc_sd_detect(struct mmc_host *host)
487 mmc_release_host(host); 486 mmc_release_host(host);
488 487
489 if (err != MMC_ERR_NONE) { 488 if (err != MMC_ERR_NONE) {
490 mmc_remove_card(host->card); 489 mmc_sd_remove(host);
491 host->card = NULL;
492 490
493 mmc_claim_host(host); 491 mmc_claim_host(host);
494 mmc_detach_bus(host); 492 mmc_detach_bus(host);
@@ -496,6 +494,55 @@ static void mmc_sd_detect(struct mmc_host *host)
496 } 494 }
497} 495}
498 496
497MMC_ATTR_FN(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
498 card->raw_cid[2], card->raw_cid[3]);
499MMC_ATTR_FN(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
500 card->raw_csd[2], card->raw_csd[3]);
501MMC_ATTR_FN(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
502MMC_ATTR_FN(date, "%02d/%04d\n", card->cid.month, card->cid.year);
503MMC_ATTR_FN(fwrev, "0x%x\n", card->cid.fwrev);
504MMC_ATTR_FN(hwrev, "0x%x\n", card->cid.hwrev);
505MMC_ATTR_FN(manfid, "0x%06x\n", card->cid.manfid);
506MMC_ATTR_FN(name, "%s\n", card->cid.prod_name);
507MMC_ATTR_FN(oemid, "0x%04x\n", card->cid.oemid);
508MMC_ATTR_FN(serial, "0x%08x\n", card->cid.serial);
509
510static struct device_attribute mmc_sd_dev_attrs[] = {
511 MMC_ATTR_RO(cid),
512 MMC_ATTR_RO(csd),
513 MMC_ATTR_RO(scr),
514 MMC_ATTR_RO(date),
515 MMC_ATTR_RO(fwrev),
516 MMC_ATTR_RO(hwrev),
517 MMC_ATTR_RO(manfid),
518 MMC_ATTR_RO(name),
519 MMC_ATTR_RO(oemid),
520 MMC_ATTR_RO(serial),
521 __ATTR_NULL,
522};
523
524/*
525 * Adds sysfs entries as relevant.
526 */
527static int mmc_sd_sysfs_add(struct mmc_host *host, struct mmc_card *card)
528{
529 int ret;
530
531 ret = mmc_add_attrs(card, mmc_sd_dev_attrs);
532 if (ret < 0)
533 return ret;
534
535 return 0;
536}
537
538/*
539 * Removes the sysfs entries added by mmc_sysfs_add().
540 */
541static void mmc_sd_sysfs_remove(struct mmc_host *host, struct mmc_card *card)
542{
543 mmc_remove_attrs(card, mmc_sd_dev_attrs);
544}
545
499#ifdef CONFIG_MMC_UNSAFE_RESUME 546#ifdef CONFIG_MMC_UNSAFE_RESUME
500 547
501/* 548/*
@@ -529,9 +576,7 @@ static void mmc_sd_resume(struct mmc_host *host)
529 576
530 err = mmc_sd_init_card(host, host->ocr, host->card); 577 err = mmc_sd_init_card(host, host->ocr, host->card);
531 if (err != MMC_ERR_NONE) { 578 if (err != MMC_ERR_NONE) {
532 mmc_remove_card(host->card); 579 mmc_sd_remove(host);
533 host->card = NULL;
534
535 mmc_detach_bus(host); 580 mmc_detach_bus(host);
536 } 581 }
537 582
@@ -548,6 +593,8 @@ static void mmc_sd_resume(struct mmc_host *host)
548static const struct mmc_bus_ops mmc_sd_ops = { 593static const struct mmc_bus_ops mmc_sd_ops = {
549 .remove = mmc_sd_remove, 594 .remove = mmc_sd_remove,
550 .detect = mmc_sd_detect, 595 .detect = mmc_sd_detect,
596 .sysfs_add = mmc_sd_sysfs_add,
597 .sysfs_remove = mmc_sd_sysfs_remove,
551 .suspend = mmc_sd_suspend, 598 .suspend = mmc_sd_suspend,
552 .resume = mmc_sd_resume, 599 .resume = mmc_sd_resume,
553}; 600};
@@ -599,7 +646,7 @@ int mmc_attach_sd(struct mmc_host *host, u32 ocr)
599 646
600 mmc_release_host(host); 647 mmc_release_host(host);
601 648
602 err = mmc_register_card(host->card); 649 err = mmc_add_card(host->card);
603 if (err) 650 if (err)
604 goto reclaim_host; 651 goto reclaim_host;
605 652