1、协议切换流程
2、CMD11
(1)ACMD41确认是否支持1.8V切换
如果参数中S18R为1,且响应中S18A为1,此时为3.3V状态,主机便可以发送CMD11进行电压切换,其他情况下不能执行CMD11
3、软件切换流程
int mmc_set_uhs_voltage(struct mmc_host *host, u32 ocr)
(1)发送CMD11(SD_SWITCH_VOLTAGE)
(2)sd卡在接收到CMD11命令后,会把data[0:3]拉低,等待1ms确保拉低
mmc_delay(1);
if (host->ops->card_busy && !host->ops->card_busy(host)) {
err = -EAGAIN;
}
(2)mmc_host_set_uhs_voltage
1)关闭clk
host->ios.clock = 0;
mmc_set_ios(host);
host->ops->set_ios(host, ios);
.set_ios = sdhci_set_ios,(实现详见第4节)
2)切换到1.8V
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) {
case MMC_SIGNAL_VOLTAGE_330:
/* Set 1.8V Signal Enable in the Host Control2 register to 0 */
ctrl &= ~SDHCI_CTRL_VDD_180;
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);
/* Wait for 5ms */
usleep_range(5000, 5500);
case MMC_SIGNAL_VOLTAGE_180:
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*/
ctrl |= SDHCI_CTRL_VDD_180;
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
3)等待10ms,协议规定是5ms
mmc_delay(10);
4)恢复clk
host->ios.clock = clock;
mmc_set_ios(host);
(3)延时1ms
mmc_delay(1);
(4)判断看card是否busy
host->ops->card_busy(host)
sdhci_card_busy
resent_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
return !(present_state & SDHCI_DATA_0_LVL_MASK);【#define SDHCI_DATA_0_LVL_MASK>0x00100000】
总结:
(1)软件切换的流程基本和协议的流程一致
(2)
vmmc代表卡的电压,一般是3.3V,可以进行gpio开关控制
vqmmc代表的是信号线bus上的上拉电压,以及控制器的sd卡bank电压,可以切换为1.8和3.3V
4、硬件电路
控制器和总线的上拉电阻受1.8/3.3V的切换控制,sd卡为3.3V不变,可以开关
5、
mmc_set_ios(host);
host->ops->set_ios(host, ios);
.set_ios = sdhci_set_ios
(1)
void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
....
....
}
1)set_power分支
一般的控制器并没有实现该接口
各个ip可以通过注册.set_power来实现电压切换
2)非set_power分支
文章来源:https://www.toymoban.com/news/detail-517414.html
从(1)和(2)的对比发现实际上2个分支走的内容是一样的文章来源地址https://www.toymoban.com/news/detail-517414.html
到了这里,关于09-sd卡的电压切换的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!