/** * Change transfer frequency for an MMC card * @param mci MCI instance * @return Transaction status (0 on success) */ static int mmc_change_freq(struct mci *mci) { char cardtype; int err; mci->ext_csd = xmalloc(512); mci->card_caps = 0; /* Only version 4 supports high-speed */ if (mci->version < MMC_VERSION_4) return 0; mci->card_caps |= MMC_MODE_4BIT; err = mci_send_ext_csd(mci, mci->ext_csd); if (err) { dev_dbg(mci->mci_dev, "Preparing for frequency setup failed: %d\n", err); return err; } cardtype = mci->ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK; err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1); if (err) { dev_dbg(mci->mci_dev, "MMC frequency changing failed: %d\n", err); return err; } /* Now check to see that it worked */ err = mci_send_ext_csd(mci, mci->ext_csd); if (err) { dev_dbg(mci->mci_dev, "Verifying frequency change failed: %d\n", err); return err; } /* No high-speed support */ if (!mci->ext_csd[EXT_CSD_HS_TIMING]) { dev_dbg(mci->mci_dev, "No high-speed support\n"); return 0; } /* High Speed is set, there are two types: 52MHz and 26MHz */ if (cardtype & EXT_CSD_CARD_TYPE_52) mci->card_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; else mci->card_caps |= MMC_MODE_HS; return 0; }
/** * Change transfer frequency for an MMC card * @param mci MCI instance * @return Transaction status (0 on success) */ static int mmc_change_freq(struct mci *mci) { char cardtype; int err; mci->ext_csd = xmalloc(512); mci->card_caps = 0; /* Only version 4 supports high-speed */ if (mci->version < MMC_VERSION_4) return 0; mci->card_caps |= MMC_CAP_4_BIT_DATA; err = mci_send_ext_csd(mci, mci->ext_csd); if (err) { dev_dbg(&mci->dev, "Preparing for frequency setup failed: %d\n", err); return err; } cardtype = mci->ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK; err = mci_switch(mci, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1); if (err) { dev_dbg(&mci->dev, "MMC frequency changing failed: %d\n", err); return err; } /* Now check to see that it worked */ err = mci_send_ext_csd(mci, mci->ext_csd); if (err) { dev_dbg(&mci->dev, "Verifying frequency change failed: %d\n", err); return err; } /* No high-speed support */ if (!mci->ext_csd[EXT_CSD_HS_TIMING]) { dev_dbg(&mci->dev, "No high-speed support\n"); return 0; } /* High Speed is set, there are two types: 52MHz and 26MHz */ if (cardtype & EXT_CSD_CARD_TYPE_52) mci->card_caps |= MMC_CAP_MMC_HIGHSPEED_52MHZ | MMC_CAP_MMC_HIGHSPEED; else mci->card_caps |= MMC_CAP_MMC_HIGHSPEED; if (IS_ENABLED(CONFIG_MCI_MMC_BOOT_PARTITIONS) && mci->ext_csd[EXT_CSD_REV] >= 3 && mci->ext_csd[EXT_CSD_BOOT_MULT]) { int idx; unsigned int part_size; for (idx = 0; idx < MMC_NUM_BOOT_PARTITION; idx++) { char *name, *partname; part_size = mci->ext_csd[EXT_CSD_BOOT_MULT] << 17; partname = asprintf("boot%d", idx); name = asprintf("%s.%s", mci->cdevname, partname); mci_part_add(mci, part_size, EXT_CSD_PART_CONFIG_ACC_BOOT0 + idx, name, partname, idx, true, MMC_BLK_DATA_AREA_BOOT); } mci->ext_csd_part_config = mci->ext_csd[EXT_CSD_PART_CONFIG]; mci->bootpart = (mci->ext_csd_part_config >> 3) & 0x7; }