初始化
1. 调用HCD’s XXX_Init
2. 调用 SDHCDAllocateContext() 来分配一段HC的上下文
a) Context 是总线驱动和HCD共享的
3. HCD 使用SDHCDSetXxx宏来填充这个上下文结构
a) 这个步骤是把HC向总线驱动描述一下
b) 包括函数指针,支持的电流,最大时钟,槽数目,SDIO的支持等等。
4. 调用 SDHCDRegisterHostController() 来把自己向总线驱动注册一下
5. 当总线驱动准备处理SD事件时,它会调用 HCD的init 函数(pContext->pInitHandler) (见SDHCDRegisterHostController__X函数)
6. 在初始化里,HCD还应该完成硬件和资源的初始化(IST等)
下面代码抄自MX31 BSP中SDHC驱动的SDH_Init函数中:
DWORD SDH_Init(DWORD dwContext) { // allocate the context status = SDHCDAllocateContext(SDH_SLOTS, &pHostContext); 。。。。。。 //Set a unique name for each host controller if (pController->ControllerIndex == 1) { SDHCDSetHCName(pHostContext, TEXT("MXARM11_1")); } else { SDHCDSetHCName(pHostContext, TEXT("MXARM11_2")); } // set init handler SDHCDSetControllerInitHandler(pHostContext,SDInitialize); // set deinit handler SDHCDSetControllerDeinitHandler(pHostContext, SDDeinitialize); // set the bus request handler SDHCDSetBusRequestHandler(pHostContext,SDHBusRequestHandler); // set the cancel I/O handler SDHCDSetCancelIOHandler(pHostContext, SDHCancelIoHandler); // set the slot option handler SDHCDSetSlotOptionHandler(pHostContext, SDHSlotOptionHandler); // now register the host controller status = SDHCDRegisterHostController(pHostContext); |
Slot Option Handler
l 总线驱动调用HCD的 SlotOptionHandler :
n SDHCDSetSlotPower –设置电压
n SDHCDSetSlotInterface – 设置时钟和总线宽度
n SDHCDEnableSDIOInterrupts
n SDHCDAckSDIOInterrupt
n SDHCDDisableSDIOInterrupts
l SDHCDGetWriteProtectStatus – HCD 必须查看SD存储卡是否开启写保护
l SDHCDQueryBlockCapability – 返回HCD的最大和最小块长度
总线要求
l 总线驱动把总线要求放入队列然后把它们传入HCD的 BusRequestHandler 函数
l HCD根据要求来做相应的动作—command/read/write, multi-block, 等.
l HCD 使用某种方式(DMA, PIO, busy-waiting等)来发送命令和数据
l HCD 调用SDHCDIndicateBusRequestComplete() 来通知总线驱动完成
l 总线驱动把完成事件入队列并提交下一个要求给HCD
l 总线驱动的调度线程将会通知产生要求的起始源事件完成了。
标准的WINCE SDHC驱动支持
l Standard Host Controller v1.0
n Tokyo Electron Devices – Ellen
n Toshiba - Pegasus
n TI PCI 7x21
n Ricoh R 5C 811 and R 5C 841
l Non-standard hosts
n Intel PXA-27x SOC (Mainstone II)
n Samsung SMDK-2410
n Freescale MX series
关于Standard Host Controller SDA Host Working Group (MSFT executive member) Defined Standard Host Register Specification to standardize the hardware interface from bus to controller Currently ratified to v1.0 by SDA executive committee MSFT strongly advocating this standard to all IHVs, ODMs, OEMs and Silicons |