Lines Matching refs:card

76 	struct mmc_card *card;  member
83 void mmc_decode_cid(struct mmc_card *card) in mmc_decode_cid() argument
85 u32 *resp = card->raw_cid; in mmc_decode_cid()
91 add_device_randomness(&card->raw_cid, sizeof(card->raw_cid)); in mmc_decode_cid()
97 card->cid.manfid = UNSTUFF_BITS(resp, 120, 8); in mmc_decode_cid()
98 card->cid.oemid = UNSTUFF_BITS(resp, 104, 16); in mmc_decode_cid()
99 card->cid.prod_name[0] = UNSTUFF_BITS(resp, 96, 8); in mmc_decode_cid()
100 card->cid.prod_name[1] = UNSTUFF_BITS(resp, 88, 8); in mmc_decode_cid()
101 card->cid.prod_name[2] = UNSTUFF_BITS(resp, 80, 8); in mmc_decode_cid()
102 card->cid.prod_name[3] = UNSTUFF_BITS(resp, 72, 8); in mmc_decode_cid()
103 card->cid.prod_name[4] = UNSTUFF_BITS(resp, 64, 8); in mmc_decode_cid()
104 card->cid.hwrev = UNSTUFF_BITS(resp, 60, 4); in mmc_decode_cid()
105 card->cid.fwrev = UNSTUFF_BITS(resp, 56, 4); in mmc_decode_cid()
106 card->cid.serial = UNSTUFF_BITS(resp, 24, 32); in mmc_decode_cid()
107 card->cid.year = UNSTUFF_BITS(resp, 12, 8); in mmc_decode_cid()
108 card->cid.month = UNSTUFF_BITS(resp, 8, 4); in mmc_decode_cid()
110 card->cid.year += 2000; /* SD cards year offset */ in mmc_decode_cid()
116 static int mmc_decode_csd(struct mmc_card *card) in mmc_decode_csd() argument
118 struct mmc_csd *csd = &card->csd; in mmc_decode_csd()
120 u32 *resp = card->raw_csd; in mmc_decode_csd()
157 mmc_card_set_readonly(card); in mmc_decode_csd()
166 mmc_card_set_blockaddr(card); in mmc_decode_csd()
179 mmc_card_set_ext_capacity(card); in mmc_decode_csd()
194 mmc_card_set_readonly(card); in mmc_decode_csd()
198 mmc_hostname(card->host), csd_struct); in mmc_decode_csd()
202 card->erase_size = csd->erase_size; in mmc_decode_csd()
210 static int mmc_decode_scr(struct mmc_card *card) in mmc_decode_scr() argument
212 struct sd_scr *scr = &card->scr; in mmc_decode_scr()
216 resp[3] = card->raw_scr[1]; in mmc_decode_scr()
217 resp[2] = card->raw_scr[0]; in mmc_decode_scr()
222 mmc_hostname(card->host), scr_struct); in mmc_decode_scr()
238 card->erased_byte = 0xFF; in mmc_decode_scr()
240 card->erased_byte = 0x0; in mmc_decode_scr()
250 pr_err("%s: invalid bus width\n", mmc_hostname(card->host)); in mmc_decode_scr()
260 static int mmc_read_ssr(struct mmc_card *card) in mmc_read_ssr() argument
268 if (!(card->csd.cmdclass & CCC_APP_SPEC)) { in mmc_read_ssr()
270 mmc_hostname(card->host)); in mmc_read_ssr()
274 raw_ssr = kmalloc(sizeof(card->raw_ssr), GFP_KERNEL); in mmc_read_ssr()
278 if (mmc_app_sd_status(card, raw_ssr)) { in mmc_read_ssr()
280 mmc_hostname(card->host)); in mmc_read_ssr()
286 card->raw_ssr[i] = be32_to_cpu(raw_ssr[i]); in mmc_read_ssr()
294 au = UNSTUFF_BITS(card->raw_ssr, 428 - 384, 4); in mmc_read_ssr()
296 if (au <= 9 || card->scr.sda_spec3) { in mmc_read_ssr()
297 card->ssr.au = sd_au_size[au]; in mmc_read_ssr()
298 es = UNSTUFF_BITS(card->raw_ssr, 408 - 384, 16); in mmc_read_ssr()
299 et = UNSTUFF_BITS(card->raw_ssr, 402 - 384, 6); in mmc_read_ssr()
301 eo = UNSTUFF_BITS(card->raw_ssr, 400 - 384, 2); in mmc_read_ssr()
302 card->ssr.erase_timeout = (et * 1000) / es; in mmc_read_ssr()
303 card->ssr.erase_offset = eo * 1000; in mmc_read_ssr()
307 mmc_hostname(card->host)); in mmc_read_ssr()
314 resp[3] = card->raw_ssr[6]; in mmc_read_ssr()
316 card->erase_arg = (card->scr.sda_specx && discard_support) ? in mmc_read_ssr()
325 static int mmc_read_switch(struct mmc_card *card) in mmc_read_switch() argument
330 if (card->scr.sda_vsn < SCR_SPEC_VER_1) in mmc_read_switch()
333 if (!(card->csd.cmdclass & CCC_SWITCH)) { in mmc_read_switch()
335 mmc_hostname(card->host)); in mmc_read_switch()
348 err = mmc_sd_switch(card, 0, 0, 0, status); in mmc_read_switch()
358 mmc_hostname(card->host)); in mmc_read_switch()
365 card->sw_caps.hs_max_dtr = HIGH_SPEED_MAX_DTR; in mmc_read_switch()
367 if (card->scr.sda_spec3) { in mmc_read_switch()
368 card->sw_caps.sd3_bus_mode = status[13]; in mmc_read_switch()
370 card->sw_caps.sd3_drv_type = status[9]; in mmc_read_switch()
371 card->sw_caps.sd3_curr_limit = status[7] | status[6] << 8; in mmc_read_switch()
383 int mmc_sd_switch_hs(struct mmc_card *card) in mmc_sd_switch_hs() argument
388 if (card->scr.sda_vsn < SCR_SPEC_VER_1) in mmc_sd_switch_hs()
391 if (!(card->csd.cmdclass & CCC_SWITCH)) in mmc_sd_switch_hs()
394 if (!(card->host->caps & MMC_CAP_SD_HIGHSPEED)) in mmc_sd_switch_hs()
397 if (card->sw_caps.hs_max_dtr == 0) in mmc_sd_switch_hs()
404 err = mmc_sd_switch(card, 1, 0, HIGH_SPEED_BUS_SPEED, status); in mmc_sd_switch_hs()
410 mmc_hostname(card->host)); in mmc_sd_switch_hs()
422 static int sd_select_driver_type(struct mmc_card *card, u8 *status) in sd_select_driver_type() argument
427 card->drive_strength = 0; in sd_select_driver_type()
429 card_drv_type = card->sw_caps.sd3_drv_type | SD_DRIVER_TYPE_B; in sd_select_driver_type()
431 drive_strength = mmc_select_drive_strength(card, in sd_select_driver_type()
432 card->sw_caps.uhs_max_dtr, in sd_select_driver_type()
436 err = mmc_sd_switch(card, 1, 2, drive_strength, status); in sd_select_driver_type()
441 mmc_hostname(card->host)); in sd_select_driver_type()
444 card->drive_strength = drive_strength; in sd_select_driver_type()
448 mmc_set_driver_type(card->host, drv_type); in sd_select_driver_type()
453 static void sd_update_bus_speed_mode(struct mmc_card *card) in sd_update_bus_speed_mode() argument
459 if (!mmc_host_uhs(card->host)) { in sd_update_bus_speed_mode()
460 card->sd_bus_speed = 0; in sd_update_bus_speed_mode()
464 if ((card->host->caps & MMC_CAP_UHS_SDR104) && in sd_update_bus_speed_mode()
465 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR104)) { in sd_update_bus_speed_mode()
466 card->sd_bus_speed = UHS_SDR104_BUS_SPEED; in sd_update_bus_speed_mode()
467 } else if ((card->host->caps & MMC_CAP_UHS_DDR50) && in sd_update_bus_speed_mode()
468 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_DDR50)) { in sd_update_bus_speed_mode()
469 card->sd_bus_speed = UHS_DDR50_BUS_SPEED; in sd_update_bus_speed_mode()
470 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | in sd_update_bus_speed_mode()
471 MMC_CAP_UHS_SDR50)) && (card->sw_caps.sd3_bus_mode & in sd_update_bus_speed_mode()
473 card->sd_bus_speed = UHS_SDR50_BUS_SPEED; in sd_update_bus_speed_mode()
474 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | in sd_update_bus_speed_mode()
476 (card->sw_caps.sd3_bus_mode & SD_MODE_UHS_SDR25)) { in sd_update_bus_speed_mode()
477 card->sd_bus_speed = UHS_SDR25_BUS_SPEED; in sd_update_bus_speed_mode()
478 } else if ((card->host->caps & (MMC_CAP_UHS_SDR104 | in sd_update_bus_speed_mode()
480 MMC_CAP_UHS_SDR12)) && (card->sw_caps.sd3_bus_mode & in sd_update_bus_speed_mode()
482 card->sd_bus_speed = UHS_SDR12_BUS_SPEED; in sd_update_bus_speed_mode()
486 static int sd_set_bus_speed_mode(struct mmc_card *card, u8 *status) in sd_set_bus_speed_mode() argument
491 switch (card->sd_bus_speed) { in sd_set_bus_speed_mode()
494 card->sw_caps.uhs_max_dtr = UHS_SDR104_MAX_DTR; in sd_set_bus_speed_mode()
498 card->sw_caps.uhs_max_dtr = UHS_DDR50_MAX_DTR; in sd_set_bus_speed_mode()
502 card->sw_caps.uhs_max_dtr = UHS_SDR50_MAX_DTR; in sd_set_bus_speed_mode()
506 card->sw_caps.uhs_max_dtr = UHS_SDR25_MAX_DTR; in sd_set_bus_speed_mode()
510 card->sw_caps.uhs_max_dtr = UHS_SDR12_MAX_DTR; in sd_set_bus_speed_mode()
516 err = mmc_sd_switch(card, 1, 0, card->sd_bus_speed, status); in sd_set_bus_speed_mode()
520 if ((status[16] & 0xF) != card->sd_bus_speed) in sd_set_bus_speed_mode()
522 mmc_hostname(card->host)); in sd_set_bus_speed_mode()
524 mmc_set_timing(card->host, timing); in sd_set_bus_speed_mode()
525 mmc_set_clock(card->host, card->sw_caps.uhs_max_dtr); in sd_set_bus_speed_mode()
556 static int sd_set_current_limit(struct mmc_card *card, u8 *status) in sd_set_current_limit() argument
567 if ((card->sd_bus_speed != UHS_SDR50_BUS_SPEED) && in sd_set_current_limit()
568 (card->sd_bus_speed != UHS_SDR104_BUS_SPEED) && in sd_set_current_limit()
569 (card->sd_bus_speed != UHS_DDR50_BUS_SPEED)) in sd_set_current_limit()
576 max_current = sd_get_host_max_current(card->host); in sd_set_current_limit()
594 card->sw_caps.sd3_curr_limit & SD_MAX_CURRENT_800) in sd_set_current_limit()
597 card->sw_caps.sd3_curr_limit & SD_MAX_CURRENT_600) in sd_set_current_limit()
600 card->sw_caps.sd3_curr_limit & SD_MAX_CURRENT_400) in sd_set_current_limit()
603 card->sw_caps.sd3_curr_limit & SD_MAX_CURRENT_200) in sd_set_current_limit()
607 err = mmc_sd_switch(card, 1, 3, current_limit, status); in sd_set_current_limit()
613 mmc_hostname(card->host)); in sd_set_current_limit()
623 static int mmc_sd_init_uhs_card(struct mmc_card *card) in mmc_sd_init_uhs_card() argument
628 if (!(card->csd.cmdclass & CCC_SWITCH)) in mmc_sd_init_uhs_card()
636 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); in mmc_sd_init_uhs_card()
640 mmc_set_bus_width(card->host, MMC_BUS_WIDTH_4); in mmc_sd_init_uhs_card()
646 sd_update_bus_speed_mode(card); in mmc_sd_init_uhs_card()
649 err = sd_select_driver_type(card, status); in mmc_sd_init_uhs_card()
654 err = sd_set_current_limit(card, status); in mmc_sd_init_uhs_card()
659 err = sd_set_bus_speed_mode(card, status); in mmc_sd_init_uhs_card()
667 if (!mmc_host_is_spi(card->host) && in mmc_sd_init_uhs_card()
668 (card->host->ios.timing == MMC_TIMING_UHS_SDR50 || in mmc_sd_init_uhs_card()
669 card->host->ios.timing == MMC_TIMING_UHS_DDR50 || in mmc_sd_init_uhs_card()
670 card->host->ios.timing == MMC_TIMING_UHS_SDR104)) { in mmc_sd_init_uhs_card()
671 err = mmc_execute_tuning(card); in mmc_sd_init_uhs_card()
680 if (err && card->host->ios.timing == MMC_TIMING_UHS_DDR50) { in mmc_sd_init_uhs_card()
682 mmc_hostname(card->host)); in mmc_sd_init_uhs_card()
693 MMC_DEV_ATTR(cid, "%08x%08x%08x%08x\n", card->raw_cid[0], card->raw_cid[1],
694 card->raw_cid[2], card->raw_cid[3]);
695 MMC_DEV_ATTR(csd, "%08x%08x%08x%08x\n", card->raw_csd[0], card->raw_csd[1],
696 card->raw_csd[2], card->raw_csd[3]);
697 MMC_DEV_ATTR(scr, "%08x%08x\n", card->raw_scr[0], card->raw_scr[1]);
700 card->raw_ssr[0], card->raw_ssr[1], card->raw_ssr[2],
701 card->raw_ssr[3], card->raw_ssr[4], card->raw_ssr[5],
702 card->raw_ssr[6], card->raw_ssr[7], card->raw_ssr[8],
703 card->raw_ssr[9], card->raw_ssr[10], card->raw_ssr[11],
704 card->raw_ssr[12], card->raw_ssr[13], card->raw_ssr[14],
705 card->raw_ssr[15]);
706 MMC_DEV_ATTR(date, "%02d/%04d\n", card->cid.month, card->cid.year);
707 MMC_DEV_ATTR(erase_size, "%u\n", card->erase_size << 9);
708 MMC_DEV_ATTR(preferred_erase_size, "%u\n", card->pref_erase << 9);
709 MMC_DEV_ATTR(fwrev, "0x%x\n", card->cid.fwrev);
710 MMC_DEV_ATTR(hwrev, "0x%x\n", card->cid.hwrev);
711 MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
712 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
713 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
714 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
715 MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
716 MMC_DEV_ATTR(rca, "0x%04x\n", card->rca);
722 struct mmc_card *card = mmc_dev_to_card(dev); in mmc_dsr_show() local
723 struct mmc_host *host = card->host; in mmc_dsr_show()
725 if (card->csd.dsr_imp && host->dsr_req) in mmc_dsr_show()
733 MMC_DEV_ATTR(vendor, "0x%04x\n", card->cis.vendor);
734 MMC_DEV_ATTR(device, "0x%04x\n", card->cis.device);
735 MMC_DEV_ATTR(revision, "%u.%u\n", card->major_rev, card->minor_rev);
740 struct mmc_card *card = mmc_dev_to_card(dev); \
742 if (num > card->num_info) \
744 if (!card->info[num - 1][0]) \
746 return sysfs_emit(buf, "%s\n", card->info[num - 1]); \
786 struct mmc_card *card = mmc_dev_to_card(dev); in sd_std_is_visible() local
796 ) &&!mmc_card_sd_combo(card)) in sd_std_is_visible()
889 int mmc_sd_get_csd(struct mmc_card *card) in mmc_sd_get_csd() argument
896 err = mmc_send_csd(card, card->raw_csd); in mmc_sd_get_csd()
900 err = mmc_decode_csd(card); in mmc_sd_get_csd()
927 int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card, in mmc_sd_setup_card() argument
936 err = mmc_app_send_scr(card); in mmc_sd_setup_card()
940 err = mmc_decode_scr(card); in mmc_sd_setup_card()
947 err = mmc_read_ssr(card); in mmc_sd_setup_card()
952 mmc_init_erase(card); in mmc_sd_setup_card()
959 err = mmc_read_switch(card); in mmc_sd_setup_card()
985 mmc_card_set_readonly(card); in mmc_sd_setup_card()
992 unsigned mmc_sd_get_max_clock(struct mmc_card *card) in mmc_sd_get_max_clock() argument
996 if (mmc_card_hs(card)) { in mmc_sd_get_max_clock()
997 if (max_dtr > card->sw_caps.hs_max_dtr) in mmc_sd_get_max_clock()
998 max_dtr = card->sw_caps.hs_max_dtr; in mmc_sd_get_max_clock()
999 } else if (max_dtr > card->csd.max_dtr) { in mmc_sd_get_max_clock()
1000 max_dtr = card->csd.max_dtr; in mmc_sd_get_max_clock()
1006 static bool mmc_sd_card_using_v18(struct mmc_card *card) in mmc_sd_card_using_v18() argument
1014 return card->sw_caps.sd3_bus_mode & in mmc_sd_card_using_v18()
1018 static int sd_write_ext_reg(struct mmc_card *card, u8 fno, u8 page, u16 offset, in sd_write_ext_reg() argument
1021 struct mmc_host *host = card->host; in sd_write_ext_reg()
1059 mmc_set_data_timeout(&data, card); in sd_write_ext_reg()
1078 static int sd_read_ext_reg(struct mmc_card *card, u8 fno, u8 page, in sd_read_ext_reg() argument
1094 return mmc_send_adtc_data(card, card->host, SD_READ_EXTR_SINGLE, in sd_read_ext_reg()
1098 static int sd_parse_ext_reg_power(struct mmc_card *card, u8 fno, u8 page, in sd_parse_ext_reg_power() argument
1109 err = sd_read_ext_reg(card, fno, page, offset, 512, reg_buf); in sd_parse_ext_reg_power()
1112 mmc_hostname(card->host), err); in sd_parse_ext_reg_power()
1117 card->ext_power.rev = reg_buf[0] & 0xf; in sd_parse_ext_reg_power()
1121 card->ext_power.feature_support |= SD_EXT_POWER_OFF_NOTIFY; in sd_parse_ext_reg_power()
1125 card->ext_power.feature_support |= SD_EXT_POWER_SUSTENANCE; in sd_parse_ext_reg_power()
1129 card->ext_power.feature_support |= SD_EXT_POWER_DOWN_MODE; in sd_parse_ext_reg_power()
1131 card->ext_power.fno = fno; in sd_parse_ext_reg_power()
1132 card->ext_power.page = page; in sd_parse_ext_reg_power()
1133 card->ext_power.offset = offset; in sd_parse_ext_reg_power()
1140 static int sd_parse_ext_reg_perf(struct mmc_card *card, u8 fno, u8 page, in sd_parse_ext_reg_perf() argument
1150 err = sd_read_ext_reg(card, fno, page, offset, 512, reg_buf); in sd_parse_ext_reg_perf()
1153 mmc_hostname(card->host), err); in sd_parse_ext_reg_perf()
1158 card->ext_perf.rev = reg_buf[0]; in sd_parse_ext_reg_perf()
1162 card->ext_perf.feature_support |= SD_EXT_PERF_FX_EVENT; in sd_parse_ext_reg_perf()
1166 card->ext_perf.feature_support |= SD_EXT_PERF_CARD_MAINT; in sd_parse_ext_reg_perf()
1170 card->ext_perf.feature_support |= SD_EXT_PERF_HOST_MAINT; in sd_parse_ext_reg_perf()
1174 card->ext_perf.feature_support |= SD_EXT_PERF_CACHE; in sd_parse_ext_reg_perf()
1178 card->ext_perf.feature_support |= SD_EXT_PERF_CMD_QUEUE; in sd_parse_ext_reg_perf()
1180 card->ext_perf.fno = fno; in sd_parse_ext_reg_perf()
1181 card->ext_perf.page = page; in sd_parse_ext_reg_perf()
1182 card->ext_perf.offset = offset; in sd_parse_ext_reg_perf()
1189 static int sd_parse_ext_reg(struct mmc_card *card, u8 *gen_info_buf, in sd_parse_ext_reg() argument
1231 return sd_parse_ext_reg_power(card, fno, page, offset); in sd_parse_ext_reg()
1235 return sd_parse_ext_reg_perf(card, fno, page, offset); in sd_parse_ext_reg()
1240 static int sd_read_ext_regs(struct mmc_card *card) in sd_read_ext_regs() argument
1246 if (mmc_host_is_spi(card->host)) in sd_read_ext_regs()
1249 if (!(card->scr.cmds & SD_SCR_CMD48_SUPPORT)) in sd_read_ext_regs()
1260 err = sd_read_ext_reg(card, 0, 0, 0, 512, gen_info_buf); in sd_read_ext_regs()
1263 mmc_hostname(card->host), err); in sd_read_ext_regs()
1284 mmc_hostname(card->host)); in sd_read_ext_regs()
1294 err = sd_parse_ext_reg(card, gen_info_buf, &next_ext_addr); in sd_read_ext_regs()
1297 mmc_hostname(card->host), err); in sd_read_ext_regs()
1309 return host->card->ext_perf.feature_enabled & SD_EXT_PERF_CACHE; in sd_cache_enabled()
1314 struct mmc_card *card = host->card; in sd_flush_cache() local
1330 fno = card->ext_perf.fno; in sd_flush_cache()
1331 page = card->ext_perf.page; in sd_flush_cache()
1332 offset = card->ext_perf.offset + 261; in sd_flush_cache()
1334 err = sd_write_ext_reg(card, fno, page, offset, BIT(0)); in sd_flush_cache()
1341 err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false, in sd_flush_cache()
1350 err = sd_read_ext_reg(card, fno, page, offset, 1, reg_buf); in sd_flush_cache()
1364 static int sd_enable_cache(struct mmc_card *card) in sd_enable_cache() argument
1369 card->ext_perf.feature_enabled &= ~SD_EXT_PERF_CACHE; in sd_enable_cache()
1379 err = sd_write_ext_reg(card, card->ext_perf.fno, card->ext_perf.page, in sd_enable_cache()
1380 card->ext_perf.offset + 260, BIT(0)); in sd_enable_cache()
1383 mmc_hostname(card->host), err); in sd_enable_cache()
1387 err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false, in sd_enable_cache()
1390 card->ext_perf.feature_enabled |= SD_EXT_PERF_CACHE; in sd_enable_cache()
1406 struct mmc_card *card; in mmc_sd_init_card() local
1425 card = oldcard; in mmc_sd_init_card()
1430 card = mmc_alloc_card(host, &sd_type); in mmc_sd_init_card()
1431 if (IS_ERR(card)) in mmc_sd_init_card()
1432 return PTR_ERR(card); in mmc_sd_init_card()
1434 card->ocr = ocr; in mmc_sd_init_card()
1435 card->type = MMC_TYPE_SD; in mmc_sd_init_card()
1436 memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); in mmc_sd_init_card()
1443 host->ops->init_card(host, card); in mmc_sd_init_card()
1449 err = mmc_send_relative_addr(host, &card->rca); in mmc_sd_init_card()
1455 err = mmc_sd_get_csd(card); in mmc_sd_init_card()
1459 mmc_decode_cid(card); in mmc_sd_init_card()
1466 if (card->csd.dsr_imp && host->dsr_req) in mmc_sd_init_card()
1473 err = mmc_select_card(card); in mmc_sd_init_card()
1478 err = mmc_sd_setup_card(host, card, oldcard != NULL); in mmc_sd_init_card()
1488 mmc_sd_card_using_v18(card) && in mmc_sd_init_card()
1491 mmc_sd_init_uhs_card(card)) { in mmc_sd_init_card()
1495 mmc_remove_card(card); in mmc_sd_init_card()
1503 err = mmc_sd_init_uhs_card(card); in mmc_sd_init_card()
1510 err = mmc_sd_switch_hs(card); in mmc_sd_init_card()
1512 mmc_set_timing(card->host, MMC_TIMING_SD_HS); in mmc_sd_init_card()
1519 mmc_set_clock(host, mmc_sd_get_max_clock(card)); in mmc_sd_init_card()
1525 (card->scr.bus_widths & SD_SCR_BUS_WIDTH_4)) { in mmc_sd_init_card()
1526 err = mmc_app_set_bus_width(card, MMC_BUS_WIDTH_4); in mmc_sd_init_card()
1536 err = sd_read_ext_regs(card); in mmc_sd_init_card()
1542 if (card->ext_perf.feature_support & SD_EXT_PERF_CACHE) { in mmc_sd_init_card()
1543 err = sd_enable_cache(card); in mmc_sd_init_card()
1549 err = host->cqe_ops->cqe_enable(host, card); in mmc_sd_init_card()
1566 host->card = card; in mmc_sd_init_card()
1571 mmc_remove_card(card); in mmc_sd_init_card()
1581 mmc_remove_card(host->card); in mmc_sd_remove()
1582 host->card = NULL; in mmc_sd_remove()
1590 return mmc_send_status(host->card, NULL); in mmc_sd_alive()
1600 mmc_get_card(host->card, NULL); in mmc_sd_detect()
1607 mmc_put_card(host->card, NULL); in mmc_sd_detect()
1619 static int sd_can_poweroff_notify(struct mmc_card *card) in sd_can_poweroff_notify() argument
1621 return card->ext_power.feature_support & SD_EXT_POWER_OFF_NOTIFY; in sd_can_poweroff_notify()
1627 struct mmc_card *card = data->card; in sd_busy_poweroff_notify_cb() local
1635 err = sd_read_ext_reg(card, card->ext_power.fno, card->ext_power.page, in sd_busy_poweroff_notify_cb()
1636 card->ext_power.offset + 1, 1, data->reg_buf); in sd_busy_poweroff_notify_cb()
1639 mmc_hostname(card->host), err); in sd_busy_poweroff_notify_cb()
1647 static int sd_poweroff_notify(struct mmc_card *card) in sd_poweroff_notify() argument
1661 err = sd_write_ext_reg(card, card->ext_power.fno, card->ext_power.page, in sd_poweroff_notify()
1662 card->ext_power.offset + 2, BIT(0)); in sd_poweroff_notify()
1665 mmc_hostname(card->host), err); in sd_poweroff_notify()
1670 err = mmc_poll_for_busy(card, SD_WRITE_EXTR_SINGLE_TIMEOUT_MS, false, in sd_poweroff_notify()
1675 cb_data.card = card; in sd_poweroff_notify()
1677 err = __mmc_poll_for_busy(card->host, 0, SD_POWEROFF_NOTIFY_TIMEOUT_MS, in sd_poweroff_notify()
1687 struct mmc_card *card = host->card; in _mmc_sd_suspend() local
1692 if (mmc_card_suspended(card)) in _mmc_sd_suspend()
1695 if (sd_can_poweroff_notify(card)) in _mmc_sd_suspend()
1696 err = sd_poweroff_notify(card); in _mmc_sd_suspend()
1702 mmc_card_set_suspended(card); in _mmc_sd_suspend()
1719 pm_runtime_disable(&host->card->dev); in mmc_sd_suspend()
1720 pm_runtime_set_suspended(&host->card->dev); in mmc_sd_suspend()
1736 if (!mmc_card_suspended(host->card)) in _mmc_sd_resume()
1739 mmc_power_up(host, host->card->ocr); in _mmc_sd_resume()
1740 err = mmc_sd_init_card(host, host->card->ocr, host->card); in _mmc_sd_resume()
1741 mmc_card_clr_suspended(host->card); in _mmc_sd_resume()
1753 pm_runtime_enable(&host->card->dev); in mmc_sd_resume()
1792 mmc_power_cycle(host, host->card->ocr); in mmc_sd_hw_reset()
1793 return mmc_sd_init_card(host, host->card->ocr, host->card); in mmc_sd_hw_reset()
1863 err = mmc_add_card(host->card); in mmc_attach_sd()
1871 mmc_remove_card(host->card); in mmc_attach_sd()
1872 host->card = NULL; in mmc_attach_sd()