mmc_rescan_try_freq 简析

继之前的文章mmc_rescan之后,我们来分析一下mmc_rescan_try_freq,顾名思义,就是用不同的clock去尝试初始化与目标卡的连接。

static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
{
	host->f_init = freq; //根据mmc_recan函数传进来的参数知道,首先传进来的是400kHZ.一般mmc/sd/sdio的初始化时钟采用的是400kHZ.

#ifdef CONFIG_MMC_DEBUG
	pr_info("%s: %s: trying to init card at %u Hz\n",
		mmc_hostname(host), __func__, host->f_init);
#endif
1.	mmc_power_up(host); //上电,我们知道,在mmc_add_host时,会调用mmc_start_host,而那里首先是将host掉电的。这里上电。

	/*
	 * Some eMMCs (with VCCQ always on) may not be reset after power up, so
	 * do a hardware reset if possible.
	 */
	mmc_hw_reset_for_init(host); //复位硬件,可以选择性实现。

	/* Initialization should be done at 3.3 V I/O voltage. */
	mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, 0);//这里其实什么事情都没做,因为一般host控制器并不会实现host->ops->start_signal_voltage_switch

	/*
	 * sdio_reset sends CMD52 to reset card.  Since we do not know
	 * if the card is being re-initialized, just send it.  CMD52
	 * should be ignored by SD/eMMC cards.
	 */
	2. sdio_reset(host);//①如果目标卡是纯SD卡(对MMC卡不了解,所以不加评论),则目标卡不会应答,一般主机host的寄存器会报错,但是这个无关紧要,可以不理它。②如果目标卡是纯SDIO卡,那么这里就是复位SDIO卡,通过命令CMD52来实现的。③如果目标卡是SD卡和SDIO卡的组合卡,则需要先发送CMD52来复位SDIO卡,再复位SD卡,因为CMD52要先于CMD0发送。

When the host re-initializes both I/O and Memory controllers, it is strongly recommended that the host either execute a power reset (power off then on) or issues a reset commands to both controllers prior to any other operation. If the host chooses to use the reset commands, it shall issue CMD52 (I/O Reset) first, because it cannot issue CMD52 after CMD0 (see 4.4). After the reset, the host shall re-initialize both the I/O and Memory controller as defined in Figure 3-2.(协议)
	
	3. mmc_go_idle(host); //发送CMD0 复位SD卡。

	4. mmc_send_if_cond(host, host->ocr_avail); //为了支持sd version 2.0以上的sd卡,在初始化的过程中必须在发送ACMD41之前,先发送CMD8,CMD8一般是用于检测SD卡是否能运行在host提供的电压范围内。大家可能发现,这个调用过程没有检查是否出错,其实一般CMD8是用来辨别目标卡是否是高容量SD卡,如果是,CMD8 会有R7应答,R7应答中会有目标SD卡支持的电压范围以及CMD8中发送过去的“check pattern(一般是0xAA)”,否则,目标卡不会应答,在Linux 内核代码中,判断是这样的,如果应答,目标卡就是SD高容量卡,否则出现应答超时错误,就是标准SD卡!这里的调用,主要作用是为了在发送ACMD41之前发送CMD8,这是version 2.0及以上的规定顺序,后面还会有发送CMD8的地方,那里才是真正检测目标卡的类型的地方。
 

	/* Order's important: probe SDIO, then SD, then MMC */
	5 .if (!mmc_attach_sdio(host))
		return 0;
	6.if (!mmc_attach_sd(host))
		return 0;
	7.if (!mmc_attach_mmc(host))
		return 0;
	Linux 卡的探测顺序是:先辨别卡是否是sdio功能卡或者是sdio与sd卡的组合卡,然后辨别是否是SD卡,最后才会辨别是否是mmc卡。
	mmc_power_off(host); 
	return -EIO;
}


  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
pci_set_device函数的参数包括: 1. struct pci_dev *dev:指向pci设备结构体的指针,表示要设置的设备。 2. const struct pci_device_id *ent:指向pci设备ID结构体的指针,表示设备的ID信息。 3. const struct pci_device_id **ent_out:指向指针的指针,表示返回设备的ID信息。 4. bool probe:一个布尔值,表示是否调用pci设备的probe函数。 5. bool enable:一个布尔值,表示是否启用pci设备。 6. bool rescan:一个布尔值,表示是否重新扫描pci设备。 7. bool deferred_probe:一个布尔值,表示是否延迟probe函数的调用。 8. bool assign_all_bars:一个布尔值,表示是否为pci设备分配所有的BAR(Base Address Register)。 9. bool assign_all_msi: 一个布尔值,表示是否为pci设备分配所有的MSI(Message Signaled Interrupt)。 10. bool assign_all_msix: 一个布尔值,表示是否为pci设备分配所有的MSIX(Message Signaled Interrupts eXtended)。 11. bool reset_fn: 一个布尔值,表示是否重置pci设备的函数。 12. bool enable_ats: 一个布尔值,表示是否启用ATS(Address Translation Services)。 13. bool enable_acs: 一个布尔值,表示是否启用ACS(Access Control Services)。 14. bool enable_rom: 一个布尔值,表示是否启用pci设备的ROM(Read-Only Memory)。 15. bool ignore_hotplug: 一个布尔值,表示是否忽略pci设备的热插拔事件。 16. bool allow_unsupported_dma: 一个布尔值,表示是否允许使用不支持的DMA(Direct Memory Access)。 17. bool allow_aer: 一个布尔值,表示是否允许使用AER(Advanced Error Reporting)。 18. bool allow_intx_disable: 一个布尔值,表示是否允许禁用INTx(Interrupt Request)。 19. bool allow_mmconfig: 一个布尔值,表示是否允许使用MMCONFIG(Memory Mapped Configuration)。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值