/** *mmc_regulator_get_ocrmask-returnmaskofsupportedvoltages *@supply:regulatortouse * *Thisreturnseitheranegativeerrno,oramaskofvoltagesthat *canbeprovidedtoMMC/SD/SDIOdevicesusingthespecifiedvoltage *regulator.Thiswouldnormallybecalledbeforeregisteringthe *MMChostadapter.
*/ staticint mmc_regulator_get_ocrmask(struct regulator *supply)
{ int result = 0; int count; int i; int vdd_uV; int vdd_mV;
count = regulator_count_voltages(supply); if (count < 0) return count;
for (i = 0; i < count; i++) {
vdd_uV = regulator_list_voltage(supply, i); if (vdd_uV <= 0) continue;
vdd_mV = vdd_uV / 1000;
result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
}
if (!result) {
vdd_uV = regulator_get_voltage(supply); if (vdd_uV <= 0) return vdd_uV;
vdd_mV = vdd_uV / 1000;
result = mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
}
return result;
}
/** *mmc_regulator_set_ocr-setregulatortomatchhost->iosvoltage *@mmc:thehosttoregulate *@supply:regulatortouse *@vdd_bit:zeroforpoweroff,elseabitnumber(host->ios.vdd) * *Returnszeroonsuccess,elsenegativeerrno. * *MMChostdriversmayusethistoenableordisablearegulatorusing *aparticularsupplyvoltage.Thiswouldnormallybecalledfromthe *set_ios()method.
*/ int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsignedshort vdd_bit)
{ int result = 0; int min_uV, max_uV;
if (IS_ERR(supply)) return0;
if (vdd_bit) {
mmc_ocrbitnum_to_vdd(vdd_bit, &min_uV, &max_uV);
result = regulator_set_voltage(supply, min_uV, max_uV); if (result == 0 && !mmc->regulator_enabled) {
result = regulator_enable(supply); if (!result)
mmc->regulator_enabled = true;
}
} elseif (mmc->regulator_enabled) {
result = regulator_disable(supply); if (result == 0)
mmc->regulator_enabled = false;
}
if (result)
dev_err(mmc_dev(mmc), "could not set regulator OCR (%d)\n", result); return result;
}
EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr);
staticint mmc_regulator_set_voltage_if_supported(struct regulator *regulator, int min_uV, int target_uV, int max_uV)
{ int current_uV;
/* *Checkifsupportedfirsttoavoiderrorssincewemaytryseveral *signallevelsduringpowerupanddon'twanttoshowerrors.
*/ if (!regulator_is_supported_voltage(regulator, min_uV, max_uV)) return -EINVAL;
if (IS_ERR(mmc->supply.vmmc)) { if (PTR_ERR(mmc->supply.vmmc) == -EPROBE_DEFER) return dev_err_probe(dev, -EPROBE_DEFER, "vmmc regulator not available\n");
dev_dbg(dev, "No vmmc regulator found\n");
} else {
ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc); if (ret > 0)
mmc->ocr_avail = ret; else
dev_warn(dev, "Failed getting OCR mask: %d\n", ret);
}
if (IS_ERR(mmc->supply.vqmmc)) { if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER) return dev_err_probe(dev, -EPROBE_DEFER, "vqmmc regulator not available\n");
dev_dbg(dev, "No vqmmc regulator found\n");
}
if (IS_ERR(mmc->supply.vqmmc2)) { if (PTR_ERR(mmc->supply.vqmmc2) == -EPROBE_DEFER) return -EPROBE_DEFER;
dev_dbg(dev, "No vqmmc2 regulator found\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.