304
304
if (card->ext_csd.rev >= 4) {
306
* Enhanced area feature support -- check whether the eMMC
307
* card has the Enhanced area enabled. If so, export enhanced
308
* area offset and size to user by adding sysfs interface.
310
if ((ext_csd[EXT_CSD_PARTITION_SUPPORT] & 0x2) &&
311
(ext_csd[EXT_CSD_PARTITION_ATTRIBUTE] & 0x1)) {
313
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE];
315
ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
317
card->ext_csd.enhanced_area_en = 1;
319
* calculate the enhanced data area offset, in bytes
321
card->ext_csd.enhanced_area_offset =
322
(ext_csd[139] << 24) + (ext_csd[138] << 16) +
323
(ext_csd[137] << 8) + ext_csd[136];
324
if (mmc_card_blockaddr(card))
325
card->ext_csd.enhanced_area_offset <<= 9;
327
* calculate the enhanced data area size, in kilobytes
329
card->ext_csd.enhanced_area_size =
330
(ext_csd[142] << 16) + (ext_csd[141] << 8) +
332
card->ext_csd.enhanced_area_size *=
333
(size_t)(hc_erase_grp_sz * hc_wp_grp_sz);
334
card->ext_csd.enhanced_area_size <<= 9;
337
* If the enhanced area is not enabled, disable these
340
card->ext_csd.enhanced_area_offset = -EINVAL;
341
card->ext_csd.enhanced_area_size = -EINVAL;
305
343
card->ext_csd.sec_trim_mult =
306
344
ext_csd[EXT_CSD_SEC_TRIM_MULT];
307
345
card->ext_csd.sec_erase_mult =
336
374
MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
337
375
MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
338
376
MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
377
MMC_DEV_ATTR(enhanced_area_offset, "%llu\n",
378
card->ext_csd.enhanced_area_offset);
379
MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
340
381
static struct attribute *mmc_std_attrs[] = {
341
382
&dev_attr_cid.attr,
391
435
mmc_go_idle(host);
393
437
/* The extra bit indicates that we support high capacity */
394
err = mmc_send_op_cond(host, ocr | (1 << 30), NULL);
438
err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr);
479
523
err = mmc_read_ext_csd(card);
527
/* If doing byte addressing, check if required to do sector
528
* addressing. Handle the case of <2GB cards needing sector
529
* addressing. See section 8.1 JEDEC Standard JED84-A441;
530
* ocr register has bit 30 set for sector addressing.
532
if (!(mmc_card_blockaddr(card)) && (rocr & (1<<30)))
533
mmc_card_set_blockaddr(card);
482
535
/* Erase size depends on CSD and Extended CSD */
483
536
mmc_set_erase_size(card);
540
* If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF
541
* bit. This bit will be lost every time after a reset or power off.
543
if (card->ext_csd.enhanced_area_en) {
544
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
545
EXT_CSD_ERASE_GROUP_DEF, 1);
547
if (err && err != -EBADMSG)
553
* Just disable enhanced area off & sz
554
* will try to enable ERASE_GROUP_DEF
555
* during next time reinit
557
card->ext_csd.enhanced_area_offset = -EINVAL;
558
card->ext_csd.enhanced_area_size = -EINVAL;
560
card->ext_csd.erase_group_def = 1;
562
* enable ERASE_GRP_DEF successfully.
563
* This will affect the erase size, so
564
* here need to reset erase size
566
mmc_set_erase_size(card);
487
571
* Activate high speed (if supported)
489
573
if ((card->ext_csd.hs_max_dtr != 0) &&