1、协议切换流程
如果参数中S18R为1,且响应中S18A为1,此时为3.3V状态,主机便可以发送CMD11进行电压切换,其他情况下不能执行CMD11
int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr)
(2)sd卡在接收到CMD11命令后,会把data[0:3]拉低,等待1ms确保拉低
if (host->ops->card_busy && !host->ops->card_busy(host)) {
host->ops->set_ios(host, ios);
.set_ios = sdhci_set_ios,(实现详见第4节)
mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180)
host->ios.signal_voltage = signal_voltage;
host->ops->start_signal_voltage_switch(host, &host->ios)
sdhci_start_signal_voltage_switch
switch (ios->signal_voltage) {
/* Set 1.8V Signal Enable in the Host Control2 register to 0 */
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
mmc_regulator_set_vqmmc(mmc, ios);
mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,min_uV, volt, max_uV);
ret = mmc_regulator_set_vqmmc(mmc, ios);
mmc_regulator_set_voltage_if_supported(mmc->supply.vqmmc,1700000, 1800000, 1950000);
/*Enable 1.8V Signal Enable in the Host Control*/
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
resent_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
return !(present_state & SDHCI_DATA_0_LVL_MASK);【#define SDHCI_DATA_0_LVL_MASK>0x00100000】
vmmc代表卡的电压,一般是3.3V,可以进行gpio开关控制
vqmmc代表的是信号线bus上的上拉电压,以及控制器的sd卡bank电压,可以切换为1.8和3.3V
控制器和总线的上拉电阻受1.8/3.3V的切换控制,sd卡为3.3V不变,可以开关
host->ops->set_ios(host, ios);
void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)