Lines Matching full:card

19 #include <linux/mmc/card.h>
23 #include "card.h"
57 static int mmc_decode_cid(struct mmc_card *card) in mmc_decode_cid() argument
59 u32 *resp = card->raw_cid; in mmc_decode_cid()
62 * Add the raw card ID (cid) data to the entropy pool. It doesn't in mmc_decode_cid()
65 add_device_randomness(&card->raw_cid, sizeof(card->raw_cid)); in mmc_decode_cid()
71 switch (card->csd.mmca_vsn) { in mmc_decode_cid()
74 card->cid.manfid = unstuff_bits(resp, 104, 24); in mmc_decode_cid()
75 card->cid.prod_name[0] = unstuff_bits(resp, 96, 8); in mmc_decode_cid()
76 card->cid.prod_name[1] = unstuff_bits(resp, 88, 8); in mmc_decode_cid()
77 card->cid.prod_name[2] = unstuff_bits(resp, 80, 8); in mmc_decode_cid()
78 card->cid.prod_name[3] = unstuff_bits(resp, 72, 8); in mmc_decode_cid()
79 card->cid.prod_name[4] = unstuff_bits(resp, 64, 8); in mmc_decode_cid()
80 card->cid.prod_name[5] = unstuff_bits(resp, 56, 8); in mmc_decode_cid()
81 card->cid.prod_name[6] = unstuff_bits(resp, 48, 8); in mmc_decode_cid()
82 card->cid.hwrev = unstuff_bits(resp, 44, 4); in mmc_decode_cid()
83 card->cid.fwrev = unstuff_bits(resp, 40, 4); in mmc_decode_cid()
84 card->cid.serial = unstuff_bits(resp, 16, 24); in mmc_decode_cid()
85 card->cid.month = unstuff_bits(resp, 12, 4); in mmc_decode_cid()
86 card->cid.year = unstuff_bits(resp, 8, 4) + 1997; in mmc_decode_cid()
92 card->cid.manfid = unstuff_bits(resp, 120, 8); in mmc_decode_cid()
93 card->cid.oemid = unstuff_bits(resp, 104, 16); in mmc_decode_cid()
94 card->cid.prod_name[0] = unstuff_bits(resp, 96, 8); in mmc_decode_cid()
95 card->cid.prod_name[1] = unstuff_bits(resp, 88, 8); in mmc_decode_cid()
96 card->cid.prod_name[2] = unstuff_bits(resp, 80, 8); in mmc_decode_cid()
97 card->cid.prod_name[3] = unstuff_bits(resp, 72, 8); in mmc_decode_cid()
98 card->cid.prod_name[4] = unstuff_bits(resp, 64, 8); in mmc_decode_cid()
99 card->cid.prod_name[5] = unstuff_bits(resp, 56, 8); in mmc_decode_cid()
100 card->cid.prv = unstuff_bits(resp, 48, 8); in mmc_decode_cid()
101 card->cid.serial = unstuff_bits(resp, 16, 32); in mmc_decode_cid()
102 card->cid.month = unstuff_bits(resp, 12, 4); in mmc_decode_cid()
103 card->cid.year = unstuff_bits(resp, 8, 4) + 1997; in mmc_decode_cid()
107 pr_err("%s: card has unknown MMCA version %d\n", in mmc_decode_cid()
108 mmc_hostname(card->host), card->csd.mmca_vsn); in mmc_decode_cid()
115 static void mmc_set_erase_size(struct mmc_card *card) in mmc_set_erase_size() argument
117 if (card->ext_csd.erase_group_def & 1) in mmc_set_erase_size()
118 card->erase_size = card->ext_csd.hc_erase_size; in mmc_set_erase_size()
120 card->erase_size = card->csd.erase_size; in mmc_set_erase_size()
122 mmc_init_erase(card); in mmc_set_erase_size()
126 static void mmc_set_wp_grp_size(struct mmc_card *card) in mmc_set_wp_grp_size() argument
128 if (card->ext_csd.erase_group_def & 1) in mmc_set_wp_grp_size()
129 card->wp_grp_size = card->ext_csd.hc_erase_size * in mmc_set_wp_grp_size()
130 card->ext_csd.raw_hc_erase_gap_size; in mmc_set_wp_grp_size()
132 card->wp_grp_size = card->csd.erase_size * in mmc_set_wp_grp_size()
133 (card->csd.wp_grp_size + 1); in mmc_set_wp_grp_size()
137 * Given a 128-bit response, decode to our card CSD structure.
139 static int mmc_decode_csd(struct mmc_card *card) in mmc_decode_csd() argument
141 struct mmc_csd *csd = &card->csd; in mmc_decode_csd()
143 u32 *resp = card->raw_csd; in mmc_decode_csd()
153 mmc_hostname(card->host), csd->structure); in mmc_decode_csd()
192 static void mmc_select_card_type(struct mmc_card *card) in mmc_select_card_type() argument
194 struct mmc_host *host = card->host; in mmc_select_card_type()
195 u8 card_type = card->ext_csd.raw_card_type; in mmc_select_card_type()
249 card->ext_csd.strobe_support && in mmc_select_card_type()
253 card->ext_csd.hs_max_dtr = hs_max_dtr; in mmc_select_card_type()
254 card->ext_csd.hs200_max_dtr = hs200_max_dtr; in mmc_select_card_type()
255 card->mmc_avail_type = avail_type; in mmc_select_card_type()
258 static void mmc_manage_enhanced_area(struct mmc_card *card, u8 *ext_csd) in mmc_manage_enhanced_area() argument
265 card->ext_csd.enhanced_area_offset = -EINVAL; in mmc_manage_enhanced_area()
266 card->ext_csd.enhanced_area_size = -EINVAL; in mmc_manage_enhanced_area()
270 * card has the Enhanced area enabled. If so, export enhanced in mmc_manage_enhanced_area()
275 if (card->ext_csd.partition_setting_completed) { in mmc_manage_enhanced_area()
284 card->ext_csd.enhanced_area_offset = in mmc_manage_enhanced_area()
289 if (mmc_card_blockaddr(card)) in mmc_manage_enhanced_area()
290 card->ext_csd.enhanced_area_offset <<= 9; in mmc_manage_enhanced_area()
294 card->ext_csd.enhanced_area_size = in mmc_manage_enhanced_area()
297 card->ext_csd.enhanced_area_size *= in mmc_manage_enhanced_area()
299 card->ext_csd.enhanced_area_size <<= 9; in mmc_manage_enhanced_area()
302 mmc_hostname(card->host)); in mmc_manage_enhanced_area()
307 static void mmc_part_add(struct mmc_card *card, u64 size, in mmc_part_add() argument
311 card->part[card->nr_parts].size = size; in mmc_part_add()
312 card->part[card->nr_parts].part_cfg = part_cfg; in mmc_part_add()
313 sprintf(card->part[card->nr_parts].name, name, idx); in mmc_part_add()
314 card->part[card->nr_parts].force_ro = ro; in mmc_part_add()
315 card->part[card->nr_parts].area_type = area_type; in mmc_part_add()
316 card->nr_parts++; in mmc_part_add()
319 static void mmc_manage_gp_partitions(struct mmc_card *card, u8 *ext_csd) in mmc_manage_gp_partitions() argument
342 if (card->ext_csd.partition_setting_completed == 0) { in mmc_manage_gp_partitions()
344 mmc_hostname(card->host)); in mmc_manage_gp_partitions()
354 mmc_part_add(card, part_size << 19, in mmc_manage_gp_partitions()
368 static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) in mmc_decode_ext_csd() argument
376 card->ext_csd.raw_ext_csd_structure = ext_csd[EXT_CSD_STRUCTURE]; in mmc_decode_ext_csd()
377 if (card->csd.structure == 3) { in mmc_decode_ext_csd()
378 if (card->ext_csd.raw_ext_csd_structure > 2) { in mmc_decode_ext_csd()
380 "version %d\n", mmc_hostname(card->host), in mmc_decode_ext_csd()
381 card->ext_csd.raw_ext_csd_structure); in mmc_decode_ext_csd()
387 np = mmc_of_find_child_device(card->host, 0); in mmc_decode_ext_csd()
388 if (np && of_device_is_compatible(np, "mmc-card")) in mmc_decode_ext_csd()
397 card->ext_csd.rev = ext_csd[EXT_CSD_REV]; in mmc_decode_ext_csd()
400 mmc_fixup_device(card, mmc_ext_csd_fixups); in mmc_decode_ext_csd()
402 card->ext_csd.raw_sectors[0] = ext_csd[EXT_CSD_SEC_CNT + 0]; in mmc_decode_ext_csd()
403 card->ext_csd.raw_sectors[1] = ext_csd[EXT_CSD_SEC_CNT + 1]; in mmc_decode_ext_csd()
404 card->ext_csd.raw_sectors[2] = ext_csd[EXT_CSD_SEC_CNT + 2]; in mmc_decode_ext_csd()
405 card->ext_csd.raw_sectors[3] = ext_csd[EXT_CSD_SEC_CNT + 3]; in mmc_decode_ext_csd()
406 if (card->ext_csd.rev >= 2) { in mmc_decode_ext_csd()
407 card->ext_csd.sectors = in mmc_decode_ext_csd()
414 if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) in mmc_decode_ext_csd()
415 mmc_card_set_blockaddr(card); in mmc_decode_ext_csd()
418 card->ext_csd.strobe_support = ext_csd[EXT_CSD_STROBE_SUPPORT]; in mmc_decode_ext_csd()
419 card->ext_csd.raw_card_type = ext_csd[EXT_CSD_CARD_TYPE]; in mmc_decode_ext_csd()
421 card->ext_csd.raw_s_a_timeout = ext_csd[EXT_CSD_S_A_TIMEOUT]; in mmc_decode_ext_csd()
422 card->ext_csd.raw_erase_timeout_mult = in mmc_decode_ext_csd()
424 card->ext_csd.raw_hc_erase_grp_size = in mmc_decode_ext_csd()
426 card->ext_csd.raw_boot_mult = in mmc_decode_ext_csd()
428 if (card->ext_csd.rev >= 3) { in mmc_decode_ext_csd()
430 card->ext_csd.part_config = ext_csd[EXT_CSD_PART_CONFIG]; in mmc_decode_ext_csd()
433 card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME]; in mmc_decode_ext_csd()
437 card->ext_csd.sa_timeout = in mmc_decode_ext_csd()
439 card->ext_csd.erase_group_def = in mmc_decode_ext_csd()
441 card->ext_csd.hc_erase_timeout = 300 * in mmc_decode_ext_csd()
443 card->ext_csd.hc_erase_size = in mmc_decode_ext_csd()
446 card->ext_csd.rel_sectors = ext_csd[EXT_CSD_REL_WR_SEC_C]; in mmc_decode_ext_csd()
452 if (ext_csd[EXT_CSD_BOOT_MULT] && mmc_boot_partition_access(card->host)) { in mmc_decode_ext_csd()
455 mmc_part_add(card, part_size, in mmc_decode_ext_csd()
463 card->ext_csd.raw_hc_erase_gap_size = in mmc_decode_ext_csd()
465 card->ext_csd.raw_sec_trim_mult = in mmc_decode_ext_csd()
467 card->ext_csd.raw_sec_erase_mult = in mmc_decode_ext_csd()
469 card->ext_csd.raw_sec_feature_support = in mmc_decode_ext_csd()
471 card->ext_csd.raw_trim_mult = in mmc_decode_ext_csd()
473 card->ext_csd.raw_partition_support = ext_csd[EXT_CSD_PARTITION_SUPPORT]; in mmc_decode_ext_csd()
474 card->ext_csd.raw_driver_strength = ext_csd[EXT_CSD_DRIVER_STRENGTH]; in mmc_decode_ext_csd()
475 if (card->ext_csd.rev >= 4) { in mmc_decode_ext_csd()
478 card->ext_csd.partition_setting_completed = 1; in mmc_decode_ext_csd()
480 card->ext_csd.partition_setting_completed = 0; in mmc_decode_ext_csd()
482 mmc_manage_enhanced_area(card, ext_csd); in mmc_decode_ext_csd()
484 mmc_manage_gp_partitions(card, ext_csd); in mmc_decode_ext_csd()
486 card->ext_csd.sec_trim_mult = in mmc_decode_ext_csd()
488 card->ext_csd.sec_erase_mult = in mmc_decode_ext_csd()
490 card->ext_csd.sec_feature_support = in mmc_decode_ext_csd()
492 card->ext_csd.trim_timeout = 300 * in mmc_decode_ext_csd()
500 card->ext_csd.boot_ro_lock = ext_csd[EXT_CSD_BOOT_WP]; in mmc_decode_ext_csd()
501 card->ext_csd.boot_ro_lockable = true; in mmc_decode_ext_csd()
504 card->ext_csd.raw_pwr_cl_52_195 = in mmc_decode_ext_csd()
506 card->ext_csd.raw_pwr_cl_26_195 = in mmc_decode_ext_csd()
508 card->ext_csd.raw_pwr_cl_52_360 = in mmc_decode_ext_csd()
510 card->ext_csd.raw_pwr_cl_26_360 = in mmc_decode_ext_csd()
512 card->ext_csd.raw_pwr_cl_200_195 = in mmc_decode_ext_csd()
514 card->ext_csd.raw_pwr_cl_200_360 = in mmc_decode_ext_csd()
516 card->ext_csd.raw_pwr_cl_ddr_52_195 = in mmc_decode_ext_csd()
518 card->ext_csd.raw_pwr_cl_ddr_52_360 = in mmc_decode_ext_csd()
520 card->ext_csd.raw_pwr_cl_ddr_200_360 = in mmc_decode_ext_csd()
524 if (card->ext_csd.rev >= 5) { in mmc_decode_ext_csd()
526 if (card->cid.year < 2010) in mmc_decode_ext_csd()
527 card->cid.year += 16; in mmc_decode_ext_csd()
529 /* check whether the eMMC card supports BKOPS */ in mmc_decode_ext_csd()
531 card->ext_csd.bkops = 1; in mmc_decode_ext_csd()
532 card->ext_csd.man_bkops_en = in mmc_decode_ext_csd()
535 card->ext_csd.raw_bkops_status = in mmc_decode_ext_csd()
537 if (card->ext_csd.man_bkops_en) in mmc_decode_ext_csd()
539 mmc_hostname(card->host)); in mmc_decode_ext_csd()
540 card->ext_csd.auto_bkops_en = in mmc_decode_ext_csd()
543 if (card->ext_csd.auto_bkops_en) in mmc_decode_ext_csd()
545 mmc_hostname(card->host)); in mmc_decode_ext_csd()
548 /* check whether the eMMC card supports HPI */ in mmc_decode_ext_csd()
549 if (!mmc_card_broken_hpi(card) && in mmc_decode_ext_csd()
551 card->ext_csd.hpi = 1; in mmc_decode_ext_csd()
553 card->ext_csd.hpi_cmd = MMC_STOP_TRANSMISSION; in mmc_decode_ext_csd()
555 card->ext_csd.hpi_cmd = MMC_SEND_STATUS; in mmc_decode_ext_csd()
560 card->ext_csd.out_of_int_time = in mmc_decode_ext_csd()
564 card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM]; in mmc_decode_ext_csd()
565 card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION]; in mmc_decode_ext_csd()
570 card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT]; in mmc_decode_ext_csd()
571 if (ext_csd[EXT_CSD_RPMB_MULT] && mmc_host_cmd23(card->host)) { in mmc_decode_ext_csd()
572 mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17, in mmc_decode_ext_csd()
579 card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT]; in mmc_decode_ext_csd()
581 card->erased_byte = 0xFF; in mmc_decode_ext_csd()
583 card->erased_byte = 0x0; in mmc_decode_ext_csd()
586 card->ext_csd.generic_cmd6_time = DEFAULT_CMD6_TIMEOUT_MS; in mmc_decode_ext_csd()
587 if (card->ext_csd.rev >= 6) { in mmc_decode_ext_csd()
588 card->ext_csd.feature_support |= MMC_DISCARD_FEATURE; in mmc_decode_ext_csd()
590 card->ext_csd.generic_cmd6_time = 10 * in mmc_decode_ext_csd()
592 card->ext_csd.power_off_longtime = 10 * in mmc_decode_ext_csd()
595 card->ext_csd.cache_size = in mmc_decode_ext_csd()
602 card->ext_csd.data_sector_size = 4096; in mmc_decode_ext_csd()
604 card->ext_csd.data_sector_size = 512; in mmc_decode_ext_csd()
608 card->ext_csd.data_tag_unit_size = in mmc_decode_ext_csd()
610 (card->ext_csd.data_sector_size); in mmc_decode_ext_csd()
612 card->ext_csd.data_tag_unit_size = 0; in mmc_decode_ext_csd()
615 card->ext_csd.data_sector_size = 512; in mmc_decode_ext_csd()
623 if (!card->ext_csd.part_time) in mmc_decode_ext_csd()
624 card->ext_csd.part_time = card->ext_csd.generic_cmd6_time; in mmc_decode_ext_csd()
626 if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME) in mmc_decode_ext_csd()
627 card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME; in mmc_decode_ext_csd()
630 if (card->ext_csd.rev >= 7) { in mmc_decode_ext_csd()
631 memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION], in mmc_decode_ext_csd()
633 card->ext_csd.ffu_capable = in mmc_decode_ext_csd()
637 card->ext_csd.pre_eol_info = ext_csd[EXT_CSD_PRE_EOL_INFO]; in mmc_decode_ext_csd()
638 card->ext_csd.device_life_time_est_typ_a = in mmc_decode_ext_csd()
640 card->ext_csd.device_life_time_est_typ_b = in mmc_decode_ext_csd()
645 if (card->ext_csd.rev >= 8) { in mmc_decode_ext_csd()
646 card->ext_csd.cmdq_support = ext_csd[EXT_CSD_CMDQ_SUPPORT] & in mmc_decode_ext_csd()
648 card->ext_csd.cmdq_depth = (ext_csd[EXT_CSD_CMDQ_DEPTH] & in mmc_decode_ext_csd()
651 if (card->ext_csd.cmdq_depth <= 2) { in mmc_decode_ext_csd()
652 card->ext_csd.cmdq_support = false; in mmc_decode_ext_csd()
653 card->ext_csd.cmdq_depth = 0; in mmc_decode_ext_csd()
655 if (card->ext_csd.cmdq_support) { in mmc_decode_ext_csd()
657 mmc_hostname(card->host), in mmc_decode_ext_csd()
658 card->ext_csd.cmdq_depth); in mmc_decode_ext_csd()
660 card->ext_csd.enhanced_rpmb_supported = in mmc_decode_ext_csd()
661 (card->ext_csd.rel_param & in mmc_decode_ext_csd()
668 static int mmc_read_ext_csd(struct mmc_card *card) in mmc_read_ext_csd() argument
673 if (!mmc_can_ext_csd(card)) in mmc_read_ext_csd()
676 err = mmc_get_ext_csd(card, &ext_csd); in mmc_read_ext_csd()
678 /* If the host or the card can't do the switch, in mmc_read_ext_csd()
689 if (card->csd.capacity == (4096 * 512)) { in mmc_read_ext_csd()
690 pr_err("%s: unable to read EXT_CSD on a possible high capacity card. Card will be ignored.\n", in mmc_read_ext_csd()
691 mmc_hostname(card->host)); in mmc_read_ext_csd()
694 mmc_hostname(card->host)); in mmc_read_ext_csd()
701 err = mmc_decode_ext_csd(card, ext_csd); in mmc_read_ext_csd()
706 static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) in mmc_compare_ext_csds() argument
714 err = mmc_get_ext_csd(card, &bw_ext_csd); in mmc_compare_ext_csds()
719 err = !((card->ext_csd.raw_partition_support == in mmc_compare_ext_csds()
721 (card->ext_csd.raw_erased_mem_count == in mmc_compare_ext_csds()
723 (card->ext_csd.rev == in mmc_compare_ext_csds()
725 (card->ext_csd.raw_ext_csd_structure == in mmc_compare_ext_csds()
727 (card->ext_csd.raw_card_type == in mmc_compare_ext_csds()
729 (card->ext_csd.raw_s_a_timeout == in mmc_compare_ext_csds()
731 (card->ext_csd.raw_hc_erase_gap_size == in mmc_compare_ext_csds()
733 (card->ext_csd.raw_erase_timeout_mult == in mmc_compare_ext_csds()
735 (card->ext_csd.raw_hc_erase_grp_size == in mmc_compare_ext_csds()
737 (card->ext_csd.raw_sec_trim_mult == in mmc_compare_ext_csds()
739 (card->ext_csd.raw_sec_erase_mult == in mmc_compare_ext_csds()
741 (card->ext_csd.raw_sec_feature_support == in mmc_compare_ext_csds()
743 (card->ext_csd.raw_trim_mult == in mmc_compare_ext_csds()
745 (card->ext_csd.raw_sectors[0] == in mmc_compare_ext_csds()
747 (card->ext_csd.raw_sectors[1] == in mmc_compare_ext_csds()
749 (card->ext_csd.raw_sectors[2] == in mmc_compare_ext_csds()
751 (card->ext_csd.raw_sectors[3] == in mmc_compare_ext_csds()
753 (card->ext_csd.raw_pwr_cl_52_195 == in mmc_compare_ext_csds()
755 (card->ext_csd.raw_pwr_cl_26_195 == in mmc_compare_ext_csds()
757 (card->ext_csd.raw_pwr_cl_52_360 == in mmc_compare_ext_csds()
759 (card->ext_csd.raw_pwr_cl_26_360 == in mmc_compare_ext_csds()
761 (card->ext_csd.raw_pwr_cl_200_195 == in mmc_compare_ext_csds()
763 (card->ext_csd.raw_pwr_cl_200_360 == in mmc_compare_ext_csds()
765 (card->ext_csd.raw_pwr_cl_ddr_52_195 == in mmc_compare_ext_csds()
767 (card->ext_csd.raw_pwr_cl_ddr_52_360 == in mmc_compare_ext_csds()
769 (card->ext_csd.raw_pwr_cl_ddr_200_360 == in mmc_compare_ext_csds()
779 MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
780 card->raw_cid[2], card->raw_cid[3]);
781 MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
782 card->raw_csd[2], card->raw_csd[3]);
783 MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
784 MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9);
785 MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9);
786 MMC_DEV_ATTR(wp_grp_size, "%u\n", card->wp_grp_size << 9);
787 MMC_DEV_ATTR(ffu_capable, "%d\n", card->ext_csd.ffu_capable);
788 MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
789 MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
790 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
791 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
792 MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv);
793 MMC_DEV_ATTR(rev, "0x%x\n", card->ext_csd.rev);
794 MMC_DEV_ATTR(pre_eol_info, "0x%02x\n", card->ext_csd.pre_eol_info);
796 card->ext_csd.device_life_time_est_typ_a,
797 card->ext_csd.device_life_time_est_typ_b);
798 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
800 card->ext_csd.enhanced_area_offset);
801 MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
802 MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
804 card->ext_csd.enhanced_rpmb_supported);
805 MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
806 MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
807 MMC_DEV_ATTR(rca, "0x%04x\n", card->rca);
808 MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en);
814 struct mmc_card *card = mmc_dev_to_card(dev); in mmc_fwrev_show() local
816 if (card->ext_csd.rev < 7) in mmc_fwrev_show()
817 return sysfs_emit(buf, "0x%x\n", card->cid.fwrev); in mmc_fwrev_show()
820 card->ext_csd.fwrev); in mmc_fwrev_show()
829 struct mmc_card *card = mmc_dev_to_card(dev); in mmc_dsr_show() local
830 struct mmc_host *host = card->host; in mmc_dsr_show()
832 if (card->csd.dsr_imp && host->dsr_req) in mmc_dsr_show()
882 static int __mmc_select_powerclass(struct mmc_card *card, in __mmc_select_powerclass() argument
885 struct mmc_host *host = card->host; in __mmc_select_powerclass()
886 struct mmc_ext_csd *ext_csd = &card->ext_csd; in __mmc_select_powerclass()
936 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in __mmc_select_powerclass()
939 card->ext_csd.generic_cmd6_time); in __mmc_select_powerclass()
945 static int mmc_select_powerclass(struct mmc_card *card) in mmc_select_powerclass() argument
947 struct mmc_host *host = card->host; in mmc_select_powerclass()
952 if (!mmc_can_ext_csd(card)) in mmc_select_powerclass()
960 ddr = card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52; in mmc_select_powerclass()
968 err = __mmc_select_powerclass(card, ext_csd_bits); in mmc_select_powerclass()
979 static void mmc_set_bus_speed(struct mmc_card *card) in mmc_set_bus_speed() argument
983 if ((mmc_card_hs200(card) || mmc_card_hs400(card)) && in mmc_set_bus_speed()
984 max_dtr > card->ext_csd.hs200_max_dtr) in mmc_set_bus_speed()
985 max_dtr = card->ext_csd.hs200_max_dtr; in mmc_set_bus_speed()
986 else if (mmc_card_hs(card) && max_dtr > card->ext_csd.hs_max_dtr) in mmc_set_bus_speed()
987 max_dtr = card->ext_csd.hs_max_dtr; in mmc_set_bus_speed()
988 else if (max_dtr > card->csd.max_dtr) in mmc_set_bus_speed()
989 max_dtr = card->csd.max_dtr; in mmc_set_bus_speed()
991 mmc_set_clock(card->host, max_dtr); in mmc_set_bus_speed()
999 static int mmc_select_bus_width(struct mmc_card *card) in mmc_select_bus_width() argument
1011 struct mmc_host *host = card->host; in mmc_select_bus_width()
1015 if (!mmc_can_ext_csd(card) || in mmc_select_bus_width()
1035 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_bus_width()
1038 card->ext_csd.generic_cmd6_time); in mmc_select_bus_width()
1051 err = mmc_compare_ext_csds(card, bus_width); in mmc_select_bus_width()
1053 err = mmc_bus_test(card, bus_width); in mmc_select_bus_width()
1070 static int mmc_select_hs(struct mmc_card *card) in mmc_select_hs() argument
1074 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs()
1076 card->ext_csd.generic_cmd6_time, MMC_TIMING_MMC_HS, in mmc_select_hs()
1080 mmc_hostname(card->host), err); in mmc_select_hs()
1088 static int mmc_select_hs_ddr(struct mmc_card *card) in mmc_select_hs_ddr() argument
1090 struct mmc_host *host = card->host; in mmc_select_hs_ddr()
1094 if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52)) in mmc_select_hs_ddr()
1104 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs_ddr()
1107 card->ext_csd.generic_cmd6_time, in mmc_select_hs_ddr()
1125 * Even (e)MMC card can support 3.3v to 1.2v vccq, but not all in mmc_select_hs_ddr()
1141 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V) { in mmc_select_hs_ddr()
1147 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V && in mmc_select_hs_ddr()
1158 static int mmc_select_hs400(struct mmc_card *card) in mmc_select_hs400() argument
1160 struct mmc_host *host = card->host; in mmc_select_hs400()
1168 if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && in mmc_select_hs400()
1172 /* Switch card to HS mode */ in mmc_select_hs400()
1174 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400()
1176 card->ext_csd.generic_cmd6_time, 0, in mmc_select_hs400()
1192 max_dtr = card->ext_csd.hs_max_dtr; in mmc_select_hs400()
1195 err = mmc_switch_status(card, true); in mmc_select_hs400()
1202 /* Switch card to DDR */ in mmc_select_hs400()
1203 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400()
1206 card->ext_csd.generic_cmd6_time); in mmc_select_hs400()
1213 /* Switch card to HS400 */ in mmc_select_hs400()
1215 card->drive_strength << EXT_CSD_DRV_STR_SHIFT; in mmc_select_hs400()
1216 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400()
1218 card->ext_csd.generic_cmd6_time, 0, in mmc_select_hs400()
1228 mmc_set_bus_speed(card); in mmc_select_hs400()
1232 err = host->ops->execute_hs400_tuning(host, card); in mmc_select_hs400()
1241 err = mmc_switch_status(card, true); in mmc_select_hs400()
1248 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), in mmc_select_hs400()
1253 int mmc_hs200_to_hs400(struct mmc_card *card) in mmc_hs200_to_hs400() argument
1255 return mmc_select_hs400(card); in mmc_hs200_to_hs400()
1258 int mmc_hs400_to_hs200(struct mmc_card *card) in mmc_hs400_to_hs200() argument
1260 struct mmc_host *host = card->host; in mmc_hs400_to_hs200()
1266 max_dtr = card->ext_csd.hs_max_dtr; in mmc_hs400_to_hs200()
1271 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, in mmc_hs400_to_hs200()
1272 val, card->ext_csd.generic_cmd6_time, 0, in mmc_hs400_to_hs200()
1282 err = mmc_switch_status(card, true); in mmc_hs400_to_hs200()
1287 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, in mmc_hs400_to_hs200()
1288 EXT_CSD_BUS_WIDTH_8, card->ext_csd.generic_cmd6_time, in mmc_hs400_to_hs200()
1295 err = mmc_switch_status(card, true); in mmc_hs400_to_hs200()
1301 card->drive_strength << EXT_CSD_DRV_STR_SHIFT; in mmc_hs400_to_hs200()
1302 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, in mmc_hs400_to_hs200()
1303 val, card->ext_csd.generic_cmd6_time, 0, in mmc_hs400_to_hs200()
1315 err = mmc_switch_status(card, false); in mmc_hs400_to_hs200()
1319 mmc_set_bus_speed(card); in mmc_hs400_to_hs200()
1328 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), in mmc_hs400_to_hs200()
1333 static void mmc_select_driver_type(struct mmc_card *card) in mmc_select_driver_type() argument
1336 int fixed_drv_type = card->host->fixed_drv_type; in mmc_select_driver_type()
1338 card_drv_type = card->ext_csd.raw_driver_strength | in mmc_select_driver_type()
1345 drive_strength = mmc_select_drive_strength(card, in mmc_select_driver_type()
1346 card->ext_csd.hs200_max_dtr, in mmc_select_driver_type()
1349 card->drive_strength = drive_strength; in mmc_select_driver_type()
1352 mmc_set_driver_type(card->host, drv_type); in mmc_select_driver_type()
1355 static int mmc_select_hs400es(struct mmc_card *card) in mmc_select_hs400es() argument
1357 struct mmc_host *host = card->host; in mmc_select_hs400es()
1361 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V) in mmc_select_hs400es()
1364 if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_8V) in mmc_select_hs400es()
1367 /* If fails try again during next card power cycle */ in mmc_select_hs400es()
1371 err = mmc_select_bus_width(card); in mmc_select_hs400es()
1379 /* Switch card to HS mode */ in mmc_select_hs400es()
1380 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400es()
1382 card->ext_csd.generic_cmd6_time, 0, in mmc_select_hs400es()
1395 mmc_set_bus_speed(card); in mmc_select_hs400es()
1397 err = mmc_switch_status(card, true); in mmc_select_hs400es()
1401 /* Switch card to DDR with strobe bit */ in mmc_select_hs400es()
1403 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400es()
1406 card->ext_csd.generic_cmd6_time); in mmc_select_hs400es()
1413 mmc_select_driver_type(card); in mmc_select_hs400es()
1415 /* Switch card to HS400 */ in mmc_select_hs400es()
1417 card->drive_strength << EXT_CSD_DRV_STR_SHIFT; in mmc_select_hs400es()
1418 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs400es()
1420 card->ext_csd.generic_cmd6_time, 0, in mmc_select_hs400es()
1436 err = mmc_switch_status(card, true); in mmc_select_hs400es()
1443 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), in mmc_select_hs400es()
1455 static int mmc_select_hs200(struct mmc_card *card) in mmc_select_hs200() argument
1457 struct mmc_host *host = card->host; in mmc_select_hs200()
1463 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V) in mmc_select_hs200()
1466 if (err && card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_8V) in mmc_select_hs200()
1469 /* If fails try again during next card power cycle */ in mmc_select_hs200()
1473 mmc_select_driver_type(card); in mmc_select_hs200()
1479 err = mmc_select_bus_width(card); in mmc_select_hs200()
1482 card->drive_strength << EXT_CSD_DRV_STR_SHIFT; in mmc_select_hs200()
1483 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_select_hs200()
1485 card->ext_csd.generic_cmd6_time, 0, in mmc_select_hs200()
1499 mmc_set_clock(card->host, card->ext_csd.hs_max_dtr); in mmc_select_hs200()
1506 err = mmc_switch_status(card, false); in mmc_select_hs200()
1523 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), in mmc_select_hs200()
1532 static int mmc_select_timing(struct mmc_card *card) in mmc_select_timing() argument
1536 if (!mmc_can_ext_csd(card)) in mmc_select_timing()
1539 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) { in mmc_select_timing()
1540 err = mmc_select_hs400es(card); in mmc_select_timing()
1544 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200) { in mmc_select_timing()
1545 err = mmc_select_hs200(card); in mmc_select_timing()
1547 card->mmc_avail_type &= ~EXT_CSD_CARD_TYPE_HS200; in mmc_select_timing()
1552 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS) in mmc_select_timing()
1553 err = mmc_select_hs(card); in mmc_select_timing()
1564 mmc_set_bus_speed(card); in mmc_select_timing()
1572 static int mmc_hs200_tuning(struct mmc_card *card) in mmc_hs200_tuning() argument
1574 struct mmc_host *host = card->host; in mmc_hs200_tuning()
1580 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && in mmc_hs200_tuning()
1585 return mmc_execute_tuning(card); in mmc_hs200_tuning()
1589 * Handle the detection and initialisation of a card.
1591 * In the case of a resume, "oldcard" will contain the card
1597 struct mmc_card *card; in mmc_init_card() local
1632 * Fetch CID from card. in mmc_init_card()
1640 pr_debug("%s: Perhaps the card was replaced\n", in mmc_init_card()
1646 card = oldcard; in mmc_init_card()
1649 * Allocate card structure. in mmc_init_card()
1651 card = mmc_alloc_card(host, &mmc_type); in mmc_init_card()
1652 if (IS_ERR(card)) { in mmc_init_card()
1653 err = PTR_ERR(card); in mmc_init_card()
1657 card->ocr = ocr; in mmc_init_card()
1658 card->type = MMC_TYPE_MMC; in mmc_init_card()
1659 card->rca = 1; in mmc_init_card()
1660 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); in mmc_init_card()
1667 host->ops->init_card(host, card); in mmc_init_card()
1670 * For native busses: set card RCA and quit open drain mode. in mmc_init_card()
1673 err = mmc_set_relative_addr(card); in mmc_init_card()
1682 * Fetch CSD from card. in mmc_init_card()
1684 err = mmc_send_csd(card, card->raw_csd); in mmc_init_card()
1688 err = mmc_decode_csd(card); in mmc_init_card()
1691 err = mmc_decode_cid(card); in mmc_init_card()
1700 if (card->csd.dsr_imp && host->dsr_req) in mmc_init_card()
1704 * Select card, as all following commands rely on that. in mmc_init_card()
1707 err = mmc_select_card(card); in mmc_init_card()
1714 err = mmc_read_ext_csd(card); in mmc_init_card()
1725 mmc_card_set_blockaddr(card); in mmc_init_card()
1728 mmc_set_erase_size(card); in mmc_init_card()
1732 * Reselect the card type since host caps could have been changed when in mmc_init_card()
1733 * debugging even if the card is not new. in mmc_init_card()
1735 mmc_select_card_type(card); in mmc_init_card()
1738 if (card->ext_csd.rev >= 3) { in mmc_init_card()
1739 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_init_card()
1741 card->ext_csd.generic_cmd6_time); in mmc_init_card()
1752 card->ext_csd.enhanced_area_offset = -EINVAL; in mmc_init_card()
1753 card->ext_csd.enhanced_area_size = -EINVAL; in mmc_init_card()
1755 card->ext_csd.erase_group_def = 1; in mmc_init_card()
1761 mmc_set_erase_size(card); in mmc_init_card()
1764 mmc_set_wp_grp_size(card); in mmc_init_card()
1768 if (card->ext_csd.part_config & EXT_CSD_PART_CONFIG_ACC_MASK) { in mmc_init_card()
1769 card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK; in mmc_init_card()
1770 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONFIG, in mmc_init_card()
1771 card->ext_csd.part_config, in mmc_init_card()
1772 card->ext_csd.part_time); in mmc_init_card()
1780 if (card->ext_csd.rev >= 6) { in mmc_init_card()
1781 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_init_card()
1784 card->ext_csd.generic_cmd6_time); in mmc_init_card()
1793 card->ext_csd.power_off_notification = EXT_CSD_POWER_ON; in mmc_init_card()
1797 if (mmc_can_discard(card)) in mmc_init_card()
1798 card->erase_arg = MMC_DISCARD_ARG; in mmc_init_card()
1799 else if (mmc_can_trim(card)) in mmc_init_card()
1800 card->erase_arg = MMC_TRIM_ARG; in mmc_init_card()
1802 card->erase_arg = MMC_ERASE_ARG; in mmc_init_card()
1807 err = mmc_select_timing(card); in mmc_init_card()
1811 if (mmc_card_hs200(card)) { in mmc_init_card()
1814 err = mmc_hs200_tuning(card); in mmc_init_card()
1816 err = mmc_select_hs400(card); in mmc_init_card()
1822 } else if (mmc_card_hs400es(card)) { in mmc_init_card()
1824 err = host->ops->execute_hs400_tuning(host, card); in mmc_init_card()
1830 err = mmc_select_bus_width(card); in mmc_init_card()
1831 if (err > 0 && mmc_card_hs(card)) { in mmc_init_card()
1832 err = mmc_select_hs_ddr(card); in mmc_init_card()
1841 mmc_select_powerclass(card); in mmc_init_card()
1846 if (card->ext_csd.hpi) { in mmc_init_card()
1847 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_init_card()
1849 card->ext_csd.generic_cmd6_time); in mmc_init_card()
1854 mmc_hostname(card->host)); in mmc_init_card()
1855 card->ext_csd.hpi_en = 0; in mmc_init_card()
1857 card->ext_csd.hpi_en = 1; in mmc_init_card()
1868 if (card->ext_csd.cache_size > 0) { in mmc_init_card()
1871 timeout_ms = max(card->ext_csd.generic_cmd6_time, timeout_ms); in mmc_init_card()
1872 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_init_card()
1882 mmc_hostname(card->host), err); in mmc_init_card()
1883 card->ext_csd.cache_ctrl = 0; in mmc_init_card()
1885 card->ext_csd.cache_ctrl = 1; in mmc_init_card()
1893 card->ext_csd.cmdq_en = false; in mmc_init_card()
1894 if (card->ext_csd.cmdq_support && host->caps2 & MMC_CAP2_CQE) { in mmc_init_card()
1895 err = mmc_cmdq_enable(card); in mmc_init_card()
1900 mmc_hostname(card->host)); in mmc_init_card()
1901 card->ext_csd.cmdq_support = false; in mmc_init_card()
1902 card->ext_csd.cmdq_depth = 0; in mmc_init_card()
1910 card->reenable_cmdq = card->ext_csd.cmdq_en; in mmc_init_card()
1913 err = host->cqe_ops->cqe_enable(host, card); in mmc_init_card()
1917 if (card->ext_csd.cmdq_en) { in mmc_init_card()
1937 host->card = card; in mmc_init_card()
1943 mmc_remove_card(card); in mmc_init_card()
1948 static int mmc_can_sleep(struct mmc_card *card) in mmc_can_sleep() argument
1950 return card->ext_csd.rev >= 3; in mmc_can_sleep()
1964 struct mmc_card *card = host->card; in mmc_sleep() local
1965 unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000); in mmc_sleep()
1969 /* Re-tuning can't be done once the card is deselected */ in mmc_sleep()
1977 cmd.arg = card->rca << 16; in mmc_sleep()
1986 * If the host does not wait while the card signals busy, then we can in mmc_sleep()
2006 static int mmc_can_poweroff_notify(const struct mmc_card *card) in mmc_can_poweroff_notify() argument
2008 return card && in mmc_can_poweroff_notify()
2009 mmc_card_mmc(card) && in mmc_can_poweroff_notify()
2010 (card->ext_csd.power_off_notification == EXT_CSD_POWER_ON); in mmc_can_poweroff_notify()
2013 static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) in mmc_poweroff_notify() argument
2015 unsigned int timeout = card->ext_csd.generic_cmd6_time; in mmc_poweroff_notify()
2020 timeout = card->ext_csd.power_off_longtime; in mmc_poweroff_notify()
2022 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, in mmc_poweroff_notify()
2027 mmc_hostname(card->host), timeout); in mmc_poweroff_notify()
2030 card->ext_csd.power_off_notification = EXT_CSD_NO_POWER_NOTIFICATION; in mmc_poweroff_notify()
2036 * Host is being removed. Free up the current card.
2040 mmc_remove_card(host->card); in mmc_remove()
2041 host->card = NULL; in mmc_remove()
2045 * Card detection - card is alive.
2049 return mmc_send_status(host->card, NULL); in mmc_alive()
2053 * Card detection callback from host.
2059 mmc_get_card(host->card, NULL); in mmc_detect()
2062 * Just check if our card has been removed. in mmc_detect()
2066 mmc_put_card(host->card, NULL); in mmc_detect()
2080 return host->card->ext_csd.cache_size > 0 && in _mmc_cache_enabled()
2081 host->card->ext_csd.cache_ctrl & 1; in _mmc_cache_enabled()
2091 if (mmc_card_broken_cache_flush(host->card) && !host->card->written_flag) in _mmc_flush_cache()
2095 err = mmc_switch(host->card, EXT_CSD_CMD_SET_NORMAL, in _mmc_flush_cache()
2101 host->card->written_flag = false; in _mmc_flush_cache()
2115 if (mmc_card_suspended(host->card)) in _mmc_suspend()
2122 if (mmc_can_poweroff_notify(host->card) && in _mmc_suspend()
2125 err = mmc_poweroff_notify(host->card, notify_type); in _mmc_suspend()
2126 else if (mmc_can_sleep(host->card)) in _mmc_suspend()
2133 mmc_card_set_suspended(host->card); in _mmc_suspend()
2149 pm_runtime_disable(&host->card->dev); in mmc_suspend()
2150 pm_runtime_set_suspended(&host->card->dev); in mmc_suspend()
2157 * This function tries to determine if the same card is still present
2166 if (!mmc_card_suspended(host->card)) in _mmc_resume()
2169 mmc_power_up(host, host->card->ocr); in _mmc_resume()
2170 err = mmc_init_card(host, host->card->ocr, host->card); in _mmc_resume()
2171 mmc_card_clr_suspended(host->card); in _mmc_resume()
2186 * In a specific case for poweroff notify, we need to resume the card in mmc_shutdown()
2189 if (mmc_can_poweroff_notify(host->card) && in mmc_shutdown()
2204 pm_runtime_enable(&host->card->dev); in mmc_resume()
2241 static int mmc_can_reset(struct mmc_card *card) in mmc_can_reset() argument
2245 rst_n_function = card->ext_csd.rst_n_function; in mmc_can_reset()
2253 struct mmc_card *card = host->card; in _mmc_hw_reset() local
2262 mmc_can_reset(card)) { in _mmc_hw_reset()
2263 /* If the card accept RST_n signal, send it. */ in _mmc_hw_reset()
2270 mmc_power_cycle(host, card->ocr); in _mmc_hw_reset()
2273 return mmc_init_card(host, card->ocr, card); in _mmc_hw_reset()
2291 * Starting point for MMC card init.
2324 * Can we support the voltage of the card? in mmc_attach_mmc()
2332 * Detect and init the card. in mmc_attach_mmc()
2339 err = mmc_add_card(host->card); in mmc_attach_mmc()
2347 mmc_remove_card(host->card); in mmc_attach_mmc()
2349 host->card = NULL; in mmc_attach_mmc()
2353 pr_err("%s: error %d whilst initialising MMC card\n", in mmc_attach_mmc()