未验证 提交 59b98df9 编写于 作者: O openharmony_ci 提交者: Gitee

!3830 【OpenHarmony开源贡献者计划2022】SDIO相关格式及表达问题

Merge pull request !3830 from king_he/sdio-1
...@@ -2,22 +2,23 @@ ...@@ -2,22 +2,23 @@
## Overview<a name="section1155271783811"></a> ## Overview<a name="section1155271783811"></a>
- Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface. Secure Digital Input/Output \(SDIO\) is a peripheral interface evolved from the Secure Digital \(SD\) memory card interface. The SDIO interface is compatible with SD memory cards and can be connected to devices that support the SDIO interface.
- SDIO is widely used. Currently, many smartphones support SDIO, and many SDIO peripherals are developed for connections to smartphones. Common SDIO peripherals include WLAN, GPS, cameras, and Bluetooth.
- The SDIO bus has two ends, named host and device. All communication starts when the host sends a command. The device can communicate with the host as long as it can parse the command of the host. An SDIO host can connect to multiple devices, as shown in the figure below.
- CLK signal: clock signal sent from the host to the device SDIO is widely used. Currently, many smartphones support SDIO, and many SDIO peripherals are developed for connections to smartphones. Common SDIO peripherals include WLAN, GPS, cameras, and Bluetooth.
- VDD signal: power signal
- VSS signal: ground signal
- D0-3 signal: four data lines. The DAT1 signal cable is multiplexed as the interrupt line. In 1-bit mode, DAT0 is used to transmit data. In 4-bit mode, DAT0 to DAT3 are used to transmit data.
- CMD signal: used by the host to send commands and the device to respond to commands.
**Figure 1** Connections between the host and devices in SDIO<a name="fig1185316527498"></a> The SDIO bus has two ends, named host and device. All communication starts when the host sends a command. The device can communicate with the host as long as it can parse the command of the host. An SDIO host can connect to multiple devices, as shown in the figure below.
- CLK signal: clock signal sent from the host to the device
- VDD signal: power signal
- VSS signal: ground signal
- D0-3 signal: four data lines. The DAT1 signal cable is multiplexed as the interrupt line. In 1-bit mode, DAT0 is used to transmit data. In 4-bit mode, DAT0 to DAT3 are used to transmit data.
- CMD signal: used by the host to send commands and the device to respond to commands.
**Figure 1** Connections between the host and devices in SDIO<a name="fig1185316527498"></a>
![](figures/en-us_image_0000001160971556.png)
- The SDIO interface defines a set of common methods for operating an SDIO device, including opening and closing an SDIO controller, exclusively claiming and releasing the host, enabling and disabling devices, claiming and releasing an SDIO IRQ, reading and writing data based on SDIO, and obtaining and setting common information. ![](figures/en-us_image_0000001160971556.png)
The SDIO interface defines a set of common methods for operating an SDIO device, including opening and closing an SDIO controller, exclusively claiming and releasing the host, enabling and disabling devices, claiming and releasing an SDIO IRQ, reading and writing data based on SDIO, and obtaining and setting common information.
## Available APIs<a name="section12601496259"></a> ## Available APIs<a name="section12601496259"></a>
...@@ -141,7 +142,7 @@ ...@@ -141,7 +142,7 @@
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE:** >![](../public_sys-resources/icon-note.gif) **NOTE:**<br>
>All functions provided in this document can be called only in kernel mode. >All functions provided in this document can be called only in kernel mode.
## Usage Guidelines<a name="section1878939192515"></a> ## Usage Guidelines<a name="section1878939192515"></a>
...@@ -1048,4 +1049,3 @@ ENABLE_ERR: ...@@ -1048,4 +1049,3 @@ ENABLE_ERR:
SdioClose(handle); SdioClose(handle);
} }
``` ```
\ No newline at end of file
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## Overview<a name="section1347805272150053"></a> ## Overview<a name="section1347805272150053"></a>
A Secure Digital Input Output \(SDIO\) card is an extension of the SD specification to cover I/O functions. SD and SDIO are called multimedia card \(MMCs\). In the Hardware Driver Foundation \(HDF\) framework, the SDIO module uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage. A Secure Digital Input Output \(SDIO\) card is an extension of the SD specification to cover I/O functions. SD and SDIO cards are called multimedia cards \(MMCs\). In the Hardware Driver Foundation \(HDF\) framework, the SDIO module uses the independent service mode for API adaptation. In this mode, each device independently publishes a device service to handle external access requests. After receiving an access request from an API, the device manager extracts the parameters in the request to call the internal method of the target device. In the independent service mode, the service management capabilities of the HDFDeviceManager can be directly used. However, you need to configure a device node for each device, which increases the memory usage.
**Figure 1** Independent service mode<a name="fig124181331222"></a> **Figure 1** Independent service mode<a name="fig124181331222"></a>
![](figures/independent-service-mode.png "independent-service-mode-12") ![](figures/independent-service-mode.png "independent-service-mode-12")
...@@ -263,8 +263,7 @@ struct SdioDeviceOps { ...@@ -263,8 +263,7 @@ struct SdioDeviceOps {
</tbody> </tbody>
</table> </table>
>![](../public_sys-resources/icon-note.gif) **NOTE** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>CommonInfo includes the following information: >CommonInfo includes the following information:
>- **maxBlockNum**: specifies the maximum number of blocks in a request. >- **maxBlockNum**: specifies the maximum number of blocks in a request.
>- **maxBlockSize**: specifies the maximum number of bytes in a block. >- **maxBlockSize**: specifies the maximum number of bytes in a block.
...@@ -290,8 +289,7 @@ The SDIO module adaptation involves the following steps: ...@@ -290,8 +289,7 @@ The SDIO module adaptation involves the following steps:
- Initialize **SdioDevice**. - Initialize **SdioDevice**.
- Instantiate **SdioDeviceOps** in the **SdioDevice** object. - Instantiate **SdioDeviceOps** in the **SdioDevice** object.
>![](../public_sys-resources/icon-note.gif) **NOTE** >![](../public_sys-resources/icon-note.gif) **NOTE**<br>
>For details, see [Available APIs](#available-apis). >For details, see [Available APIs](#available-apis).
...@@ -315,7 +313,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -315,7 +313,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
.Bind = Hi35xxLinuxSdioBind, // See the Bind function. .Bind = Hi35xxLinuxSdioBind, // See the Bind function.
.Init = Hi35xxLinuxSdioInit, // See the Init function. .Init = Hi35xxLinuxSdioInit, // See the Init function.
.Release = Hi35xxLinuxSdioRelease// See the Release function. .Release = Hi35xxLinuxSdioRelease// See the Release function.
.moduleName = "HDF_PLATFORM_SDIO",// (Mandatory) The value must be the same as that of moduleName in the .hcs file. .moduleName = "HDF_PLATFORM_SDIO",// (Mandatory) The value must be the same as that of moduleName in the **.hcs** file.
}; };
// Call HDF_INIT to register the driver entry with the HDF. // Call HDF_INIT to register the driver entry with the HDF.
HDF_INIT(g_sdioDriverEntry); HDF_INIT(g_sdioDriverEntry);
...@@ -357,8 +355,8 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -357,8 +355,8 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
sdio_config { sdio_config {
template sdio_controller { template sdio_controller {
match_attr = ""; match_attr = "";
hostId = 2; // (Mandatory) It is set to 2. For details, see mmc_config.hcs. hostId = 2; // (Mandatory) Set the value to 2. For details, see mmc_config.hcs.
devType = 2; // (Mandatory) It is set to 2. For details, see mmc_config.hcs. devType = 2; // (Mandatory) Set the value to 2. For details, see mmc_config.hcs.
} }
controller_0x2dd1 :: sdio_controller { controller_0x2dd1 :: sdio_controller {
match_attr = "hisilicon_hi35xx_sdio_0";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs. match_attr = "hisilicon_hi35xx_sdio_0";// (Mandatory) The value must be the same as that of deviceMatchAttr in device_info.hcs.
...@@ -427,7 +425,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -427,7 +425,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the **.hcs** configuration file information.
Return values: Return values:
...@@ -513,7 +511,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -513,7 +511,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the **.hcs** configuration file information.
Return values: Return values:
...@@ -536,7 +534,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -536,7 +534,7 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
Input parameters: Input parameters:
**HdfDeviceObject**, an interface parameter exposed by the driver, contains the .hcs configuration file information. **HdfDeviceObject**, an interface parameter exposed by the driver, contains the **.hcs** configuration file information.
Return values: Return values:
...@@ -556,5 +554,3 @@ The following uses **sdio\_adapter.c** as an example to present the contents t ...@@ -556,5 +554,3 @@ The following uses **sdio\_adapter.c** as an example to present the contents t
Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service);// (Mandatory) Custom function for releasing memory. A forced conversion from HdfDeviceObject to MmcCntlr is involved. Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service);// (Mandatory) Custom function for releasing memory. A forced conversion from HdfDeviceObject to MmcCntlr is involved.
} }
``` ```
\ No newline at end of file
...@@ -3,22 +3,22 @@ ...@@ -3,22 +3,22 @@
## 概述 ## 概述
- SDIO是安全数字输入输出接口(Secure Digital Input and Output)的缩写,是从SD内存卡接口的基础上演化出来的一种外设接口。SDIO接口兼容以前的SD内存卡,并且可以连接支持SDIO接口的设备。 SDIO是安全数字输入输出接口(Secure Digital Input and Output)的缩写,是从SD内存卡接口的基础上演化出来的一种外设接口。SDIO接口兼容以前的SD内存卡,并且可以连接支持SDIO接口的设备。
- SDIO的应用比较广泛,目前,有许多手机都支持SDIO功能,并且很多SDIO外设也被开发出来,使得手机外接外设更加容易。常见的SDIO外设有WLAN、GPS、CAMERA、蓝牙等。 SDIO的应用比较广泛,目前,有许多手机都支持SDIO功能,并且很多SDIO外设也被开发出来,使得手机外接外设更加容易。常见的SDIO外设有WLAN、GPS、CAMERA、蓝牙等。
- SDIO总线有两端,其中一端是主机端(HOST),另一端是设备端(DEVICE)。所有的通信都是由HOST端发出命令开始的,在DEVICE端只要能解析HOST的命令,就可以同HOST进行通信了。SDIO的HOST可以连接多个DEVICE,如下图所示: SDIO总线有两端,其中一端是主机端(HOST),另一端是设备端(DEVICE)。所有的通信都是由HOST端发出命令开始的,在DEVICE端只要能解析HOST的命令,就可以同HOST进行通信了。SDIO的HOST可以连接多个DEVICE,如下图所示:
- CLK信号:HOST给DEVICE的时钟信号。 - CLK信号:HOST给DEVICE的时钟信号。
- VDD信号:电源信号。 - VDD信号:电源信号。
- VSS信号:Ground信号。 - VSS信号:Ground信号。
- D0-3信号:4条数据线,其中,DAT1信号线复用为中断线,在1BIT模式下DAT0用来传输数据,在4BIT模式下DAT0-DAT3用来传输数据。 - D0-3信号:4条数据线,其中,DAT1信号线复用为中断线,在1BIT模式下DAT0用来传输数据,在4BIT模式下DAT0-DAT3用来传输数据。
- CMD信号:用于HOST发送命令和DEVICE回复响应。 - CMD信号:用于HOST发送命令和DEVICE回复响应。
**图1** SDIO的HOST-DEVICE连接示意图 **图1** SDIO的HOST-DEVICE连接示意图
![image](figures/SDIO的HOST-DEVICE连接示意图.png "SDIO的HOST-DEVICE连接示意图") ![image](figures/SDIO的HOST-DEVICE连接示意图.png "SDIO的HOST-DEVICE连接示意图")
- SDIO接口定义了操作SDIO的通用方法集合,包括打开/关闭SDIO控制器、独占/释放HOST、使能/去使能设备、申请/释放中断、读写、获取/设置公共信息等。 SDIO接口定义了操作SDIO的通用方法集合,包括打开/关闭SDIO控制器、独占/释放HOST、使能/去使能设备、申请/释放中断、读写、获取/设置公共信息等。
## 接口说明 ## 接口说明
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
| SDIO使能/去使能功能设备接口 | -&nbsp;SdioEnableFunc:使能SDIO功能设备<br/>-&nbsp;SdioDisableFunc:去使能SDIO功能设备 | | SDIO使能/去使能功能设备接口 | -&nbsp;SdioEnableFunc:使能SDIO功能设备<br/>-&nbsp;SdioDisableFunc:去使能SDIO功能设备 |
| SDIO申请/释放中断接口 | -&nbsp;SdioClaimIrq:申请中断<br/>-&nbsp;SdioReleaseIrq:释放中断 | | SDIO申请/释放中断接口 | -&nbsp;SdioClaimIrq:申请中断<br/>-&nbsp;SdioReleaseIrq:释放中断 |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**<br>
> 本文涉及的所有接口,目前只支持在内核态使用,不支持在用户态使用。 > 本文涉及的所有接口,目前只支持在内核态使用,不支持在用户态使用。
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## 概述 ## 概述
SDIO由SD卡发展而来,被统称为mmc(MultiMediaCard),相关技术差别不大,在HDF框架中,SDIO的接口适配模式采用独立服务模式,在这种模式下,每一个设备对象会独立发布一个设备服务来处理外部访问,设备管理器收到API的访问请求之后,通过提取该请求的参数,达到调用实际设备对象的相应内部方法的目的。独立服务模式可以直接借助HDFDeviceManager的服务管理能力,但需要为每个设备单独配置设备节点,增加内存占用。 SDIO由SD卡发展而来,被统称为mmc(MultiMediaCard),相关技术差别不大。在HDF框架中,SDIO的接口适配模式采用独立服务模式。在这种模式下,每一个设备对象会独立发布一个设备服务来处理外部访问,设备管理器收到API的访问请求之后,通过提取该请求的参数,达到调用实际设备对象的相应内部方法的目的。独立服务模式可以直接借助HDFDeviceManager的服务管理能力,但需要为每个设备单独配置设备节点,增加内存占用。
**图1** SDIO独立服务模式结构图 **图1** SDIO独立服务模式结构图
...@@ -42,26 +42,26 @@ struct SdioDeviceOps { ...@@ -42,26 +42,26 @@ struct SdioDeviceOps {
| 函数 | 入参 | 出参 | 返回值 | 功能 | | 函数 | 入参 | 出参 | 返回值 | 功能 |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| incrAddrReadBytes | dev:&nbsp;结构体指针,SDIO设备控制器;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小 | data:&nbsp;uint8_t指针,传出值; | HDF_STATUS相关状态 | 从指定的SDIO地址增量读取给定长度的数据 | | incrAddrReadBytes | dev:结构体指针,SDIO设备控制器<br>addr:uint32_t,地址值<br>size:uint32_t,大小 | data:uint8_t指针,传出值 | HDF_STATUS相关状态 | 从指定的SDIO地址增量读取给定长度的数据 |
| incrAddrWriteBytes | dev:&nbsp;结构体指针,SDIO设备控制器;data:&nbsp;uint8_t指针,传入值;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小 | 无 | HDF_STATUS相关状态 | 将给定长度的数据增量写入指定的SDIO地址 | | incrAddrWriteBytes | dev:结构体指针,SDIO设备控制器<br>data:uint8_t指针,传入值<br>addr:uint32_t,地址值<br>size:uint32_t,大小 | 无 | HDF_STATUS相关状态 | 将给定长度的数据增量写入指定的SDIO地址 |
| fixedAddrReadBytes | dev:&nbsp;结构体指针,SDIO设备控制器;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小;scatterLen:&nbsp;uint32_t,数据长度; | data:&nbsp;uint8_t指针,传出值; | HDF_STATUS相关状态 | 从固定SDIO地址读取给定长度的数据。 | | fixedAddrReadBytes | dev:结构体指针,SDIO设备控制器<br>addr:uint32_t,地址值<br>size:uint32_t,大小<br>scatterLen:uint32_t,数据长度 | data:uint8_t指针,传出值 | HDF_STATUS相关状态 | 从固定SDIO地址读取给定长度的数据。 |
| fixedAddrWriteBytes | dev:&nbsp;结构体指针,SDIO设备控制器;data:&nbsp;uint8_t指针,传入值;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小;scatterLen:&nbsp;uint32_t,数据长度; | 无 | HDF_STATUS相关状态 | 将给定长度的数据写入固定SDIO地址 | | fixedAddrWriteBytes | dev:结构体指针,SDIO设备控制器<br>data:uint8_t指针,传入值<br>addr:uint32_t,地址值<br>size:uint32_t,大小<br>scatterLen:uint32_t,数据长度 | 无 | HDF_STATUS相关状态 | 将给定长度的数据写入固定SDIO地址 |
| func0ReadBytes | dev:&nbsp;结构体指针,SDIO设备控制器;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小; | data:&nbsp;uint8_t指针,传出值; | HDF_STATUS相关状态 | 从SDIO函数0的地址空间读取给定长度的数据。 | | func0ReadBytes | dev:结构体指针,SDIO设备控制器<br>addr:uint32_t,地址值<br>size:uint32_t,大小 | data:uint8_t指针,传出值 | HDF_STATUS相关状态 | 从SDIO函数0的地址空间读取给定长度的数据。 |
| func0WriteBytes | dev:&nbsp;结构体指针,SDIO设备控制器;data:&nbsp;uint8_t指针,传入值;addr:&nbsp;uint32_t,地址值;size:&nbsp;uint32_t,大小; | 无 | HDF_STATUS相关状态 | 将给定长度的数据写入SDIO函数0的地址空间。 | | func0WriteBytes | dev:结构体指针,SDIO设备控制器<br>data:uint8_t指针,传入值<br>addr:uint32_t,地址值<br>size:uint32_t,大小 | 无 | HDF_STATUS相关状态 | 将给定长度的数据写入SDIO函数0的地址空间。 |
| setBlockSize | dev:&nbsp;结构体指针,SDIO设备控制器;blockSize:&nbsp;uint32_t,Block大小 | 无 | HDF_STATUS相关状态 | 设置block大小 | | setBlockSize | dev:结构体指针,SDIO设备控制器<br>blockSize:uint32_t,Block大小 | 无 | HDF_STATUS相关状态 | 设置block大小 |
| getCommonInfo | dev:&nbsp;联合体指针,SDIO设备控制器;infoType:&nbsp;uint32_t,info类型; | info:&nbsp;结构体指针,传出SdioFuncInfo信息; | HDF_STATUS相关状态 | 获取CommonInfo,说明见下 | | getCommonInfo | dev:联合体指针,SDIO设备控制器<br>infoType:uint32_t,info类型 | info:结构体指针,传出SdioFuncInfo信息 | HDF_STATUS相关状态 | 获取CommonInfo,说明见下 |
| setCommonInfo | dev:&nbsp;结构体指针,SDIO设备控制器;info:&nbsp;联合体指针,SdioFuncInfo信息传入;infoType:&nbsp;uint32_t,info类型; | 无 | HDF_STATUS相关状态 | 设置CommonInfo,说明见下 | | setCommonInfo | dev:结构体指针,SDIO设备控制器<br>info:联合体指针,SdioFuncInfo信息传入<br>infoType:uint32_t,info类型 | 无 | HDF_STATUS相关状态 | 设置CommonInfo,说明见下 |
| flushData | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 当SDIO需要重新初始化或发生意外错误时调用的函数 | | flushData | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 当SDIO需要重新初始化或发生意外错误时调用的函数 |
| enableFunc | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 使能SDIO设备 | | enableFunc | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 使能SDIO设备 |
| disableFunc | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 去使能SDIO设备 | | disableFunc | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 去使能SDIO设备 |
| claimIrq | dev:&nbsp;结构体指针,SDIO设备控制器;irqHandler:&nbsp;void函数指针; | 无 | HDF_STATUS相关状态 | 注册SDIO中断 | | claimIrq | dev:结构体指针,SDIO设备控制器<br>irqHandler:void函数指针 | 无 | HDF_STATUS相关状态 | 注册SDIO中断 |
| releaseIrq | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 释放SDIO中断 | | releaseIrq | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 释放SDIO中断 |
| findFunc | dev:&nbsp;结构体指针,SDIO设备控制器;configData:&nbsp;结构体指针,&nbsp;SDIO函数关键信息 | 无 | HDF_STATUS相关状态 | 寻找匹配的funcNum | | findFunc | dev:结构体指针,SDIO设备控制器<br>configData:结构体指针,SDIO函数关键信息 | 无 | HDF_STATUS相关状态 | 寻找匹配的funcNum |
| claimHost | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 独占HOST | | claimHost | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 独占HOST |
| releaseHost | dev:&nbsp;结构体指针,SDIO设备控制器; | 无 | HDF_STATUS相关状态 | 释放HOST | | releaseHost | dev:结构体指针,SDIO设备控制器 | 无 | HDF_STATUS相关状态 | 释放HOST |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**<br>
> CommonInfo包括maxBlockNum(单个request中最大block数), maxBlockSize(单个block最大字节数), maxRequestSize(单个Request最大字节数), enTimeout(最大超时时间,毫秒), funcNum(功能编号1~7), irqCap(IRQ capabilities), (void \*)data. > CommonInfo包括maxBlockNum(单个request中最大block数), maxBlockSize(单个block最大字节数), maxRequestSize(单个Request最大字节数), enTimeout(最大超时时间,毫秒), funcNum(功能编号1~7), irqCap(IRQ capabilities), (void \*)data.
## 开发步骤 ## 开发步骤
...@@ -79,7 +79,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -79,7 +79,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
3. **实例化SDIO控制器对象:** 3. **实例化SDIO控制器对象:**
- 初始化SdioDevice成员。 - 初始化SdioDevice成员。
- 实例化SdioDevice成员SdioDeviceOps。 - 实例化SdioDevice成员SdioDeviceOps。
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**<br>
> 实例化SdioDevice成员SdioDeviceOps,其定义和成员说明见[接口说明](#接口说明)。 > 实例化SdioDevice成员SdioDeviceOps,其定义和成员说明见[接口说明](#接口说明)。
4. **驱动调试:** 4. **驱动调试:**
...@@ -98,12 +98,12 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -98,12 +98,12 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
``` ```
struct HdfDriverEntry g_sdioDriverEntry = { struct HdfDriverEntry g_sdioDriverEntry = {
.moduleVersion = 1, .moduleVersion = 1,
.Bind = Hi35xxLinuxSdioBind, //见Bind参考 .Bind = Hi35xxLinuxSdioBind, // 见Bind参考
.Init = Hi35xxLinuxSdioInit, //见Init参考 .Init = Hi35xxLinuxSdioInit, // 见Init参考
.Release = Hi35xxLinuxSdioRelease,//见Release参考 .Release = Hi35xxLinuxSdioRelease,// 见Release参考
.moduleName = "HDF_PLATFORM_SDIO",//【必要 且与 HCS文件中里面的moduleName匹配】 .moduleName = "HDF_PLATFORM_SDIO",// 【必要,且与HCS文件中里面的moduleName匹配】
}; };
//调用HDF_INIT将驱动入口注册到HDF框架中 // 调用HDF_INIT将驱动入口注册到HDF框架中
HDF_INIT(g_sdioDriverEntry); HDF_INIT(g_sdioDriverEntry);
``` ```
...@@ -124,9 +124,9 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -124,9 +124,9 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
policy = 1; policy = 1;
priority = 70; priority = 70;
permission = 0644; permission = 0644;
moduleName = "HDF_PLATFORM_SDIO"; //【必要】用于指定驱动名称,需要与驱动Entry中的moduleName一致; moduleName = "HDF_PLATFORM_SDIO"; // 【必要】用于指定驱动名称,需要与驱动Entry中的moduleName一致;
serviceName = "HDF_PLATFORM_MMC_2"; //【必要】驱动对外发布服务的名称,必须唯一 serviceName = "HDF_PLATFORM_MMC_2"; // 【必要】驱动对外发布服务的名称,必须唯一
deviceMatchAttr = "hisilicon_hi35xx_sdio_0";//【必要】用于配置控制器私有数据,要与sdio_config.hcs中对应控制器保持一致 deviceMatchAttr = "hisilicon_hi35xx_sdio_0";// 【必要】用于配置控制器私有数据,要与sdio_config.hcs中对应控制器保持一致
} }
} }
} }
...@@ -143,11 +143,11 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -143,11 +143,11 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
sdio_config { sdio_config {
template sdio_controller { template sdio_controller {
match_attr = ""; match_attr = "";
hostId = 2; //【必要】模式固定为2,在mmc_config.hcs有介绍 hostId = 2; // 【必要】模式固定为2,在mmc_config.hcs有介绍
devType = 2; //【必要】模式固定为2,在mmc_config.hcs有介绍 devType = 2; // 【必要】模式固定为2,在mmc_config.hcs有介绍
} }
controller_0x2dd1 :: sdio_controller { controller_0x2dd1 :: sdio_controller {
match_attr = "hisilicon_hi35xx_sdio_0";//【必要】需要和device_info.hcs中的deviceMatchAttr值一致 match_attr = "hisilicon_hi35xx_sdio_0";// 【必要】需要和device_info.hcs中的deviceMatchAttr值一致
} }
} }
} }
...@@ -170,7 +170,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -170,7 +170,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
void *data; // 私有数据 void *data; // 私有数据
} SdioFuncInfo; } SdioFuncInfo;
//SdioDevice是核心层控制器结构体,其中的成员在Bind函数中会被赋值 // SdioDevice是核心层控制器结构体,其中的成员在Bind函数中会被赋值
struct SdioDevice { struct SdioDevice {
struct SdDevice sd; struct SdDevice sd;
struct SdioDeviceOps *sdioOps; struct SdioDeviceOps *sdioOps;
...@@ -212,11 +212,11 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -212,11 +212,11 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
入参: 入参:
HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 HdfDeviceObject是整个驱动对外暴露的接口参数,具备HCS配置文件的信息。
返回值: 返回值:
HDF_STATUS相关状态 (下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf_base.h中HDF_STATUS 定义)。 HDF_STATUS相关状态(下表为部分展示,如需使用其他状态,可见//drivers/framework/include/utils/hdf_base.h中HDF_STATUS 定义)。
**表2** Bind函数入参及返回值 **表2** Bind函数入参及返回值
| 状态(值) | 问题描述 | | 状态(值) | 问题描述 |
...@@ -241,18 +241,18 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -241,18 +241,18 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
... ...
cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr));// 分配内存 cntlr = (struct MmcCntlr *)OsalMemCalloc(sizeof(struct MmcCntlr));// 分配内存
... ...
cntlr->ops = &g_sdioCntlrOps; //【必要】struct MmcCntlrOps g_sdioCntlrOps={ cntlr->ops = &g_sdioCntlrOps; // 【必要】struct MmcCntlrOps g_sdioCntlrOps={
// .rescanSdioDev = Hi35xxLinuxSdioRescan,}; // .rescanSdioDev = Hi35xxLinuxSdioRescan,};
cntlr->hdfDevObj = obj; //【必要】使HdfDeviceObject与MmcCntlr可以相互转化的前提 cntlr->hdfDevObj = obj; // 【必要】使HdfDeviceObject与MmcCntlr可以相互转化的前提
obj->service = &cntlr->service;//【必要】使HdfDeviceObject与MmcCntlr可以相互转化的前提 obj->service = &cntlr->service;// 【必要】使HdfDeviceObject与MmcCntlr可以相互转化的前提
ret = Hi35xxLinuxSdioCntlrParse(cntlr, obj);//【必要】初始化cntlr 的 index, devType, 失败则 goto _ERR; ret = Hi35xxLinuxSdioCntlrParse(cntlr, obj);//【必要】初始化cntlr 的 index, devType, 失败则 goto _ERR;
... ...
ret = MmcCntlrAdd(cntlr); //【必要】调用核心层mmc_core.c的函数, 失败则 goto _ERR; ret = MmcCntlrAdd(cntlr); // 【必要】调用核心层mmc_core.c的函数, 失败则 goto _ERR;
... ...
ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType);//【必要】调用核心层mmc_core.c的函数, 失败则 goto _ERR; ret = MmcCntlrAllocDev(cntlr, (enum MmcDevType)cntlr->devType);// 【必要】调用核心层mmc_core.c的函数, 失败则 goto _ERR;
... ...
MmcDeviceAddOps(cntlr->curDev, &g_sdioDeviceOps);//【必要】调用核心层mmc_core.c的函数, 钩子函数挂载 MmcDeviceAddOps(cntlr->curDev, &g_sdioDeviceOps);// 【必要】调用核心层mmc_core.c的函数, 钩子函数挂载
HDF_LOGD("Hi35xxLinuxSdioBind: Success!"); HDF_LOGD("Hi35xxLinuxSdioBind: Success!");
return HDF_SUCCESS; return HDF_SUCCESS;
...@@ -267,7 +267,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -267,7 +267,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
入参: 入参:
HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 HdfDeviceObject是整个驱动对外暴露的接口参数,具备HCS配置文件的信息。
返回值: 返回值:
...@@ -281,7 +281,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -281,7 +281,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
``` ```
static int32_t Hi35xxLinuxSdioInit(struct HdfDeviceObject *obj) static int32_t Hi35xxLinuxSdioInit(struct HdfDeviceObject *obj)
{ {
(void)obj;//无操作,可根据厂商需要添加 (void)obj;// 无操作,可根据厂商需要添加
HDF_LOGD("Hi35xxLinuxSdioInit: Success!"); HDF_LOGD("Hi35xxLinuxSdioInit: Success!");
return HDF_SUCCESS; return HDF_SUCCESS;
} }
...@@ -290,7 +290,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -290,7 +290,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
入参: 入参:
HdfDeviceObject 是整个驱动对外暴露的接口参数,具备 HCS 配置文件的信息。 HdfDeviceObject是整个驱动对外暴露的接口参数,具备HCS配置文件的信息。
返回值: 返回值:
...@@ -298,7 +298,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -298,7 +298,7 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
函数说明: 函数说明:
释放内存和删除控制器,该函数需要在驱动入口结构体中赋值给 Release 接口, 当HDF框架调用Init函数初始化驱动失败时,可以调用 Release 释放驱动资源。所有强制转换获取相应对象的操作前提是在Bind函数中具备对应赋值的操作。 释放内存和删除控制器,该函数需要在驱动入口结构体中赋值给 Release 接口,当HDF框架调用Init函数初始化驱动失败时,可以调用Release释放驱动资源。所有强制转换获取相应对象的操作前提是在Bind函数中具备对应赋值的操作。
``` ```
...@@ -307,6 +307,6 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动 ...@@ -307,6 +307,6 @@ SDIO模块适配HDF框架的三个环节是配置属性文件,实例化驱动
if (obj == NULL) { if (obj == NULL) {
return; return;
} }
Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service);//【必要】自定义的内存释放函数,这里有HdfDeviceObject到MmcCntlr的强制转化 Hi35xxLinuxSdioDeleteCntlr((struct MmcCntlr *)obj->service);// 【必要】自定义的内存释放函数,这里有HdfDeviceObject到MmcCntlr的强制转化
} }
``` ```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册