@@ -35,10 +36,11 @@ The LCD drivers are stored in **//drivers/framework/model/display/driver/panel*
...
@@ -35,10 +36,11 @@ The LCD drivers are stored in **//drivers/framework/model/display/driver/panel*
2. Configure and load the panel driver.
2. Configure and load the panel driver.
Modify the source code file **//vendor/vendor\_name/product\_name/config/device\_info/device\_info.hcs**. Add configurations for the device named **device\_lcd** for the display host.
Modify the source code file **//vendor/vendor_name/product_name/config/device_info/device_info.hcs**. Add configurations for the device named **device\_lcd** for the display host.
This section describes how to port a touchscreen driver. The touchscreen drivers are stored in the source code directory **//drivers/framework/model/input/driver/touchscreen**. To port a touchscreen driver, register a **ChipDevice** model instance with the system.
This section describes how to port a touchscreen driver. The touchscreen drivers are stored in the source code directory **//drivers/hdf_core/framework/model/input/driver/touchscreen**. To port a touchscreen driver, register a **ChipDevice** model instance with the system.
For details about how to develop a touchscreen driver, see [Touchscreen Development Guidelines](../driver/driver-peripherals-touch-des.md).
For details about how to develop a touchscreen driver, see [Touchscreen Development Guidelines](../driver/driver-peripherals-touch-des.md).
...
@@ -67,13 +69,14 @@ For details about how to develop a touchscreen driver, see [Touchscreen Develop
...
@@ -67,13 +69,14 @@ For details about how to develop a touchscreen driver, see [Touchscreen Develop
Create the **touch\_ic\_name.c** file in the **touchscreen** directory. Write the following content:
Create the **touch\_ic\_name.c** file in the **touchscreen** directory. Write the following content:
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p93980212554"><a name="p93980212554"></a><a name="p93980212554"></a>Reads data from the device and writes touch point data to <strong id="b576475914217"><a name="b576475914217"></a><a name="b576475914217"></a>device</strong> > <strong id="b976511597218"><a name="b976511597218"></a><a name="b976511597218"></a>driver</strong> > <strong id="b117661559162110"><a name="b117661559162110"></a><a name="b117661559162110"></a>frameData</strong>.</p>
All device information of the product is defined in the source code file **//vendor/vendor\_name/product\_name/config/device\_info/device\_info.hcs**. Modify the file and add configurations to the **device** named **device\_touch\_chip** in the **host** of the **input** command.
All device information of the product is defined in the source code file **//vendor/vendor_name/product_name/config/device_info/device_info.hcs**. Modify the file and add configurations to the **device** named **device\_touch\_chip** in the **host** of the **input** command.
As shown in Figure 1, the part on the left manages WLAN devices, and the part on the right manages WLAN traffic. The HDF WLAN framework abstracts these two parts. The porting process of the driver can be considered as the implementation of the APIs required by the two parts. These APIs are described as follows:
| API | Header File | Description |
| -------- | -------- | -------- |
| HdfChipDriverFactory | drivers\hdf_core\framework\include\wifi\hdf_wlan_chipdriver_manager.h | Factory of the ChipDriver, which is used to support multiple WLAN interfaces of a chip. |
| HdfChipDriver | drivers\hdf_core\framework\include\wifi\wifi_module.h | Manages a specific WLAN interface. |
| NetDeviceInterFace | drivers\hdf_core\framework\include\wifi\net_device.h | Communicates with the protocol stack, such as sending data and setting the status of network interfaces. |
As shown in [Figure 1](#fig155920160203), the part on the left manages WLAN devices, and the part on the right manages WLAN traffic. The HDF WLAN framework abstracts these two parts. The porting process of the driver can be considered as the implementation of the APIs required by the two parts. These APIs are described as follows:
> For details about the API development, see [WLAN Development Guidelines](../driver/driver-peripherals-external-des.md).
<tdclass="cellrowborder"valign="top"width="43.23432343234324%"headers="mcps1.1.4.1.3 "><pid="p26725514220"><aname="p26725514220"></a><aname="p26725514220"></a>Factory of the <strongid="b88841282246"><aname="b88841282246"></a><aname="b88841282246"></a>ChipDriver</strong>, which is used to support multiple WLAN interfaces of a chip.</p>
<tdclass="cellrowborder"valign="top"width="43.23432343234324%"headers="mcps1.1.4.1.3 "><pid="p26814555217"><aname="p26814555217"></a><aname="p26814555217"></a>Manages a specific WLAN interface.</p>
<tdclass="cellrowborder"valign="top"width="43.23432343234324%"headers="mcps1.1.4.1.3 "><pid="p368195513213"><aname="p368195513213"></a><aname="p368195513213"></a>Communicates with the protocol stack, such as sending data and setting the status of network interfaces.</p>
| int32_t (\*InitChip)(struct HdfWlanDevice \*device) | Initializes the chip. |
</th>
| int32_t (\*DeinitChip)(struct HdfWlanDevice \*device) | Deinitializes the chip. |
</tr>
| void (\*ReleaseFactory)(struct HdfChipDriverFactory \*factory) | Releases the **HdfChipDriverFactory** object. |
</thead>
| struct HdfChipDriver \*(\*Build)(struct HdfWlanDevice \*device, uint8_t ifIndex) | Creates an **HdfChipDriver**. In the input parameters, **device** indicates the device information, and **ifIndex** indicates the sequence number of this interface in the chip. |
| void (\*Release)(struct HdfChipDriver \*chipDriver) | Releases the chip driver. |
</td>
| uint8_t (\*GetMaxIFCount)(struct HdfChipDriverFactory \*factory) | Obtains the maximum number of interfaces supported by the current chip. |
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p457143320911"><a name="p457143320911"></a><a name="p457143320911"></a>Creates an <strong id="b118260459243"><a name="b118260459243"></a><a name="b118260459243"></a>HdfChipDriver</strong>. In the input parameters, <strong id="b28271845162411"><a name="b28271845162411"></a><a name="b28271845162411"></a>device</strong> indicates the device information, and <strong id="b16827144519241"><a name="b16827144519241"></a><a name="b16827144519241"></a>ifIndex</strong> indicates the sequence number of this interface in the chip.</p>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p14571334915"><a name="p14571334915"></a><a name="p14571334915"></a>Obtains the maximum number of interfaces supported by the current chip.</p>
</td>
</tr>
</tbody>
</table>
The **Build** method creates an **HdfChipDriver** object that manages the specified network interface. This object needs to provide the following methods:
The **Build** method creates an **HdfChipDriver** object that manages the specified network interface. This object needs to provide the following methods:
| int32_t (\*init)(struct HdfChipDriver \*chipDriver, NetDevice \*netDev) | Initializes the current network interface. The **NetDeviceInterFace** needs to be provided for the **netDev**. |
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p1310184012103"><a name="p1310184012103"></a><a name="p1310184012103"></a>Initializes the current network interface. The <strong id="b18435181416253"><a name="b18435181416253"></a><a name="b18435181416253"></a>NetDeviceInterFace</strong> needs to be provided for the <strong id="b1543511144251"><a name="b1543511144251"></a><a name="b1543511144251"></a>netDev</strong>.</p>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p810104013106"><a name="p810104013106"></a><a name="p810104013106"></a>Provides the interface set required for supporting the STA mode.</p>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p710184013105"><a name="p710184013105"></a><a name="p710184013105"></a>Provides the interface set required for supporting the AP mode.</p>
</td>
</tr>
</tbody>
</table>
2. Create a configuration file to describe the chips supported by the driver.
2. Create a configuration file to describe the chips supported by the driver.
Create a chip configuration file in the product configuration directory and save it to the source code path **//vendor/vendor\_name/product\_name/config/wifi/wlan\_chip\_chip\_name.hcs**.
Create a chip configuration file in the product configuration directory and save it to the source code path **//vendor/vendor\_name/product\_name/config/wifi/wlan\_chip\_chip\_name.hcs**.
The sample code is as follows:
```
```
root {
root {
wlan_config {
wlan_config {
chip_name :& chipList {
chip_name :& chipList {
chip_name :: chipInst {
chip_name :: chipInst {
match_attr = "hdf_wlan_chips_chip_name"; /* Indicates the configuration matching attribute, which is used to provide the configuration root of the driver.*/
match_attr = "hdf_wlan_chips_chip_name"; /* Indicates the configuration matching attribute, which is used to provide the configuration root of the driver. */
driverName = "driverName"; /* Indicates the driver name, which must be the same as that of driverName in HdfChipDriverFactory.*/
driverName = "driverName"; /* Indicates the driver name, which must be the same as that of driverName in HdfChipDriverFactory.*/
sdio {
sdio {
vendorId = 0xXXXX; /* your vendor id */
vendorId = 0xXXXX; /* your vendor id */
...
@@ -331,14 +217,17 @@ The porting procedure is as follows:
...
@@ -331,14 +217,17 @@ The porting procedure is as follows:
>Replace the values of **vendor\_name**, **product\_name**, and **chip\_name** in the path and file with the actual names.
>
>Set **vendorId** and **deviceId** to the actual vendor ID and chip ID, respectively.
> Replace the values of **vendor\_name**, **product\_name**, and **chip\_name** in the path and file with the actual names.
>
> Set **vendorId** and **deviceId** to the actual vendor ID and chip ID, respectively.
3. Edit the configuration file and load the driver.
3. Edit the configuration file and load the driver.
All device information of the product is defined in the source code file **//vendor/vendor\_name/product\_name/config/device\_info/device\_info.hcs**. Modify the file and add configurations to the **device** named **device\_wlan\_chips** in the **host** of the **network** command. The sample code is as follows:
All device information of the product is defined in the source code file **//vendor/vendor\_name/product\_name/config/device\_info/device\_info.hcs**. Modify the file and add configurations to the **device** named **device\_wlan\_chips** in the **host** of the **network** command. The sample code is as follows:
```
```
deviceN :: deviceNode {
deviceN :: deviceNode {
policy = 0;
policy = 0;
...
@@ -349,13 +238,15 @@ The porting procedure is as follows:
...
@@ -349,13 +238,15 @@ The porting procedure is as follows:
>Replace **chip\_name** with the actual chip name.
>
> Replace **chip\_name** with the actual chip name.
5. Modify the build script to enable the driver to participate in the kernel build.
5. Modify the build script to enable the driver to participate in the kernel build.
Add the following content to the end of the source code file **//device/vendor\_name/drivers/lite.mk**:
Add the following content to the end of the source code file **//device/vendor\_name/drivers/lite.mk**:
```
```
ifeq ($(LOSCFG_DRIVERS_HDF_WIFI_chip_name), y)
ifeq ($(LOSCFG_DRIVERS_HDF_WIFI_chip_name), y)
# After the build is complete, an object named hdf_wlan_chipdriver_chip_name needs to be linked. You are advised to use this name to prevent conflicts.
# After the build is complete, an object named hdf_wlan_chipdriver_chip_name needs to be linked. You are advised to use this name to prevent conflicts.
...
@@ -380,7 +273,8 @@ The porting procedure is as follows:
...
@@ -380,7 +273,8 @@ The porting procedure is as follows:
@@ -19,6 +19,7 @@ You can use the Bootloader provided by the chipset vendor or open-source U-Boot
...
@@ -19,6 +19,7 @@ You can use the Bootloader provided by the chipset vendor or open-source U-Boot
## Adaptation, Building, Burning, and Startup
## Adaptation, Building, Burning, and Startup
1. Prepare the kernel configuration files, especially the chipset-related configuration files.
1. Prepare the kernel configuration files, especially the chipset-related configuration files.
Source code directory of the configuration files: **kernel/linux/config/**
Source code directory of the configuration files: **kernel/linux/config/**
Create a **<*YOUR_CHIP*>_small_defconfig** file, such as **hi3516dv300_small_defconfig**, in the **linux-4.19/arch/arm/configs/** directory. The configuration file can be created by combining the general-purpose **small_common_defconfig** file and chipset-specific configurations.
Create a **<*YOUR_CHIP*>_small_defconfig** file, such as **hi3516dv300_small_defconfig**, in the **linux-4.19/arch/arm/configs/** directory. The configuration file can be created by combining the general-purpose **small_common_defconfig** file and chipset-specific configurations.
...
@@ -69,12 +70,19 @@ Based on the preceding process, the recommended verification procedure is as fol
...
@@ -69,12 +70,19 @@ Based on the preceding process, the recommended verification procedure is as fol
Create a root file system image **rootfs.img** by following instructions in [Building Procedures](../subsystems/subsys-build-all.md). As shown in the preceding figure, the startup process is closely related to the product configuration. You need to complete the following configuration when creating **rootfs.img**:
Create a root file system image **rootfs.img** by following instructions in [Building Procedures](../subsystems/subsys-build-all.md). As shown in the preceding figure, the startup process is closely related to the product configuration. You need to complete the following configuration when creating **rootfs.img**:
- Component configuration
- Component configuration
In the product component configuration file ***vendor*/{*company*}/{*product*}/config.json**, configure the **init** component of the startup subsystem and the **linux_4_1_9** component of the kernel subsystem.
In the product component configuration file ***vendor*/{*company*}/{*product*}/config.json**, configure the **init** component of the startup subsystem and the **linux_4_1_9** component of the kernel subsystem.
- System service configuration
- System service configuration
Modify the system service configuration file ***vendor*/{*company*}/{*product*}/init_configs/init_xxx.cfg** to start the shell service.
Modify the system service configuration file ***vendor*/{*company*}/{*product*}/init_configs/init_xxx.cfg** to start the shell service.
- File system configuration
- File system configuration
In the file system configuration file ***vendor*/{*company*}/{*product*}/fs.yml**, create the **/bin/sh -> mksh** and **/lib/ld-musl-arm.so.1 -> libc.so** soft links. These two files are the shell executable program and the c library on which the executable program depends, respectively.
In the file system configuration file ***vendor*/{*company*}/{*product*}/fs.yml**, create the **/bin/sh -> mksh** and **/lib/ld-musl-arm.so.1 -> libc.so** soft links. These two files are the shell executable program and the c library on which the executable program depends, respectively.
- Startup configuration
- Startup configuration
In the ***vendor*/{*company*}/{*product*}/init_configs/etc** directory, configure startup settings, including the **fstab**, **rsS**, and **S*xxx*** files. Configure the startup settings as needed.
In the ***vendor*/{*company*}/{*product*}/init_configs/etc** directory, configure startup settings, including the **fstab**, **rsS**, and **S*xxx*** files. Configure the startup settings as needed.
After the build is complete, check the **rootfs** content in the product compilation output directory to determine whether the generated **rootfs.img** file meets the expectation.
After the build is complete, check the **rootfs** content in the product compilation output directory to determine whether the generated **rootfs.img** file meets the expectation.
**ohos_version**: operating system version. This parameter is optional.
|board|(Mandatory) Development board name.|
|enable_ramdisk|(Mandatory) Whether to start the RAM disk.|
**device_company**: device manufacturer name. This parameter is required.
|kernel_type|(Optional) Kernel type.|
|kernel_version|(Optional) Kernel version. The values of both **kernel_type** and **kernel_version** are fixed in the standard system.|
**board**: board name. This parameter is required.
|subsystems|(Mandatory) Subsystem to enable. A subsystem can be treated as an independently built functional block.|
|product_company|Device manufacturer name. It is not set in the configuration, but in the directory name, next to the vendor name. It can be accessed from **build.gn script**.|
**enable_ramdisk**: whether to enable the RAM disk. This parameter is required.
**kernel_type**: kernel type. This parameter is optional.
**kernel_version**: kernel version. This parameter is optional. Both **kernel_type** and **kernel_version** are fixed.
**subsystems**: subsystem to enable. A subsystem can be treated as an independently built functional block. This parameter is required.
**product_company**: device manufacturer name. It is not set in the configuration, but in the directory name, next to the vendor name. It can be accessed from **build.gn script**.
You can find predefined subsystems in **//build/subsystem_config.json**. You can also customize subsystems.
You can find predefined subsystems in **//build/subsystem_config.json**. You can also customize subsystems.
...
@@ -89,7 +80,7 @@ Now, you need to port the Linux kernel to enable it to run successfully.
...
@@ -89,7 +80,7 @@ Now, you need to port the Linux kernel to enable it to run successfully.
### Adding a Kernel-built Subsystem to the SoC
### Adding a Kernel-built Subsystem to the SoC
Add the following subsystem configuration to the **//build/subsystem_config.json** file:
Modify the **//build/subsystem_config.json** file to add a subsystem. For example, if **product_name** is **MyProduct**, configure the **//vendor/MyProductVendor/MyProduct/config.json** file as follows:
```
```
...
@@ -140,17 +131,18 @@ Now start build, and check whether the kernel image is generated as expected.
...
@@ -140,17 +131,18 @@ Now start build, and check whether the kernel image is generated as expected.
1. Overview of user-mode boot process
1. Overview of user-mode boot process


When the system is powered on, the kernel loads and starts services and applications as follows:
When the system is powered on, the kernel loads and starts services and applications as follows:
1. The kernel loads the init process, which is specified by **cmdline** of the kernel when the bootloader starts the kernel, for example, **init=/init root/dev/xxx**.
1. The kernel loads the init process, which is specified by **cmdline** of the kernel when the bootloader starts the kernel, for example, **init=/init root/dev/xxx**.
2. After the init process is started, **tmpfs** and **procfs** are mounted and basic **dev** nodes are created to establish a basic root file system.
2. After the init process is started, **tmpfs** and **procfs** are mounted and basic **dev** nodes are created to establish a basic root file system.
3. The init process starts the ueventd process to listen for device hot-swap events in the kernel and creates **dev** nodes for related devices as well as partitions for the block device.
3. The init process starts the ueventd process to listen for device hot-swap events in the kernel and creates **dev** nodes for related devices as well as partitions for the block device.
4. After mounting partitions (**system** and **vendor**) of the block device, the init process scans for the init startup script of each system service and launches the respective service ability (SA).
4. After mounting partitions (**system** and **vendor**) of the block device, the init process scans for the init startup script of each system service and launches the respective service ability (SA).
5. Each SA registers with the samgr process, which serves as the service registration center. The samgr process assigns each SA with an ID, which will be used by an application to access the desired SA.
5. Each SA registers with the samgr process, which serves as the service registration center. The samgr process assigns each SA with an ID, which will be used by an application to access the desired SA.
6. The foundation process implements application lifecycle management. It is a special SA service process that provides the user program management framework and basic services.
6. The foundation process implements application lifecycle management. It is a special SA service process that provides the user program management framework and basic services.
7. The appspawn process directly spawns the application process, eliminating the need for the application to load the JS runtime environment. This reduces the application startup time.
7. The appspawn process directly spawns the application process, eliminating the need for the application to load the JS runtime environment. This reduces the application startup time.
2. init module
2. init module
...
@@ -158,7 +150,7 @@ Now start build, and check whether the kernel image is generated as expected.
...
@@ -158,7 +150,7 @@ Now start build, and check whether the kernel image is generated as expected.
When porting a new chip platform, you need to add the **/vendor/etc/init/init.{hardware}.cfg** file that contains the platform-level initialization configuration. This file is used to implement platform-level initialization, for example, installing the ko driver and configuring information on the related **/proc** nodes.
When porting a new chip platform, you need to add the **/vendor/etc/init/init.{hardware}.cfg** file that contains the platform-level initialization configuration. This file is used to implement platform-level initialization, for example, installing the ko driver and configuring information on the related **/proc** nodes.
The code of the init process is stored in the **//base/startup/init** directory. This process is the first process in the system and does not depend on other processes.
The code of the init process is stored in the **//base/startup/init_lite** directory. This process is the first process in the system and does not depend on other processes.
For details about how to develop the initialization configuration file, see [Startup](../subsystems/subsys-boot-overview.md).
For details about how to develop the initialization configuration file, see [Startup](../subsystems/subsys-boot-overview.md).
...
@@ -170,16 +162,16 @@ Now start build, and check whether the kernel image is generated as expected.
...
@@ -170,16 +162,16 @@ Now start build, and check whether the kernel image is generated as expected.
This section describes how to port a Liquid Crystal Display (LCD) driver. The hardware driver framework (HDF) designs a driver model for the LCD. To support an LCD, you must compile a driver, generate a model instance in the driver, and register the instance.
This section describes how to port a Liquid Crystal Display (LCD) driver. The hardware driver framework (HDF) designs a driver model for the LCD. To support an LCD, you must compile a driver, generate a model instance in the driver, and register the instance.
The LCD drivers are stored in the **//drivers/framework/model/display/driver/panel** directory.
The LCD drivers are stored in the **//drivers/hdf_core/framework/model/display/driver/panel** directory.
- Create a panel driver.
1. Create a panel driver.
In the **Init** method of the driver, call **RegisterPanel** to register the model instance.
In the **Init** method of the driver, call **RegisterPanel** to register the model instance. For example:
- Configure and load the panel driver. All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_lcd** to the host named **display**. Note: The value of **moduleName** must be the same as that in the panel driver.
2. Configure and load the panel driver. All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_lcd** to the host named **display**.
Note: The value of **moduleName** must be the same as that in the panel driver.
```
```
root {
root {
...
...
display :: host {
display :: host {
device_lcd :: device {
device_lcd :: device {
...
@@ -215,59 +208,60 @@ root {
...
@@ -215,59 +208,60 @@ root {
}
}
}
}
}
}
}
}
```
```
For details about driver development, see [LCD](../driver/driver-peripherals-lcd-des.md).
For details about driver development, see [LCD](../driver/driver-peripherals-lcd-des.md).
### Touchscreen
### Touchscreen
This section describes how to port a touchscreen driver. The touchscreen driver is stored in the **//drivers/framework/model/input/driver/touchscreen** directory. To port a touchscreen driver, register a **ChipDevice** model instance.
This section describes how to port a touchscreen driver. The touchscreen driver is stored in the **//drivers/hdf_core/framework/model/input/driver/touchscreen** directory. To port a touchscreen driver, register a **ChipDevice** model instance.
- Create a touchscreen driver.
1. Create a touchscreen driver.
Create the **touch_ic_name.c** file in the directory. Replace **ic_name** with the name of your chip. The file template is as follows:
Create the **touch_ic_name.c** file in the directory. Replace **ic_name** with the name of your chip. The file template is as follows:
Implement the following interfaces in **ChipDevice**:
| API| Description|
| API| Description|
| -------- | -------- |
| -------- | -------- |
| int32_t (\*Init)(ChipDevice \*device) | Initializes a touchscreen.|
| int32_t (\*Init)(ChipDevice \*device) | Initializes a touchscreen.|
| int32_t (\*Detect)(ChipDevice \*device) | Detects a touchscreen.|
| int32_t (\*Detect)(ChipDevice \*device) | Detects a touchscreen.|
| int32_t (\*Suspend)(ChipDevice \*device) | Suspends a touchscreen.|
| int32_t (\*Suspend)(ChipDevice \*device) | Suspends a touchscreen.|
| int32_t (\*Resume)(ChipDevice \*device) | Resumes a touchscreen.|
| int32_t (\*Resume)(ChipDevice \*device) | Resumes a touchscreen.|
| int32_t (\*DataHandle)(ChipDevice \*device) | Reads data from a touchscreen and writes the touch point data to **device** > **driver** > **frameData**.|
| int32_t (\*DataHandle)(ChipDevice \*device) | Reads data from a touchscreen and writes the touch point data to **device** > **driver** > **frameData**.|
| int32_t (\*UpdateFirmware)(ChipDevice \*device) | Upgrades the firmware.|
| int32_t (\*UpdateFirmware)(ChipDevice \*device) | Upgrades the firmware.|
- Configure the product and load the driver.
2. Configure the product and load the driver.
All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_touch_chip** to the host named **input**. Note: The value of **moduleName** must be the same as that in the touchscreen driver.
All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_touch_chip** to the host named **input**. Note: The value of **moduleName** must be the same as that in the touchscreen driver.
```
```
deviceN :: deviceNode {
deviceN :: deviceNode {
policy = 0;
policy = 0;
priority = 130;
priority = 130;
...
@@ -276,34 +270,34 @@ Implement the following APIs in **ChipDevice**:
...
@@ -276,34 +270,34 @@ Implement the following APIs in **ChipDevice**:
moduleName = "HDF_TOUCH_XXXX";
moduleName = "HDF_TOUCH_XXXX";
deviceMatchAttr = "touch_XXXX_configs";
deviceMatchAttr = "touch_XXXX_configs";
}
}
```
```
For details about driver development, see [Touchscreen](../driver/driver-peripherals-touch-des.md).
For details about driver development, see [Touchscreen](../driver/driver-peripherals-touch-des.md).
### WLAN
### WLAN
The WLAN driver is divided into two parts. One of the parts manages WLAN devices, and the other part manages WLAN traffic. HDF WLAN provides abstraction for the two parts. Currently, only the WLAN with the SDIO interface is supported.
The WLAN driver is divided into two parts. One of the parts manages WLAN devices, and the other part manages WLAN traffic. HDF WLAN provides abstraction for the two parts. Currently, only the WLAN with the SDIO interface is supported.
**Figure 1** WLAN chip
**Figure 1** WLAN chip


To support a chip, implement a **ChipDriver** for it. The major task is to implement the following interfaces provided by **HDF_WLAN_CORE** and **NetDevice**.
To support a chip, implement a **ChipDriver** for it. The major task is to implement the following interfaces provided by **HDF_WLAN_CORE** and **NetDevice**.
| API| Header File| Description|
| API| Header File| Description|
| -------- | -------- | -------- |
| -------- | -------- | -------- |
| HdfChipDriverFactory | //drivers/framework/include/wifi/hdf_wlan_chipdriver_manager.h | Supports multiple WLAN interfaces of a chip.|
| HdfChipDriverFactory | //drivers/hdf_core/framework/include/wifi/hdf_wlan_chipdriver_manager.h | Supports multiple WLAN interfaces of a chip.|
| HdfChipDriver | //drivers/framework/include/wifi/wifi_module.h | Manages a specific WLAN interface. Each WLAN interface corresponds to an **HdfChipDriver**.|
| HdfChipDriver | //drivers/hdf_core/framework/include/wifi/wifi_module.h | Manages a specific WLAN interface. Each WLAN interface corresponds to an **HdfChipDriver**.|
| NetDeviceInterFace | //drivers/framework/include/net/net_device.h | Communicates with the protocol stack, such as sending data and setting the status of network interfaces.|
| NetDeviceInterFace | //drivers/hdf_core/framework/include/net/net_device.h | Communicates with the protocol stack, such as sending data and setting the status of network interfaces.|
To port a WLAN driver, perform the following steps:
To port a WLAN driver, perform the following steps:
1. Create an HDF driver. You are advised to place the code file in the **//device/MySoCVendor/peripheral/wifi/chip_name/** directory. The file template is as follows:
1. Create an HDF driver. You are advised to place the code file in the **//device/MySoCVendor/peripheral/wifi/chip_name/** directory. The file template is as follows:
Create an **HdfChipDriverFactory** in the **CreateChipDriverFactory**. The APIs are as follows:
Create an **HdfChipDriverFactory** in the **CreateChipDriverFactory**. The APIs are as follows:
| API| Description|
| -------- | -------- |
| const char \*driverName | Indicates the driver name.|
| int32_t (\*InitChip)(struct HdfWlanDevice \*device) | Initializes a chip.|
| int32_t (\*DeinitChip)(struct HdfWlanDevice \*device) | Deinitializes a chip.|
| void (*ReleaseFactory)(struct HdfChipDriverFactory *factory) | Releases the **HdfChipDriverFactory** object.|
| struct HdfChipDriver *(_Build)(struct HdfWlanDevice \*device, uint8*t ifIndex) | Creates an **HdfChipDriver**. In the input parameters, **device** indicates the device information, and **ifIndex** indicates the sequence number of this interface in the chip.|
| void (*Release)(struct HdfChipDriver *chipDriver) | Releases the **HdfChipDriver**.|
| uint8_t (\*GetMaxIFCount)(struct HdfChipDriverFactory \*factory) | Obtains the maximum number of APIs supported by the current chip.|
Implement the following APIs in the **HdfChipDriver**.
| API| Description|
| API| Description|
| -------- | -------- |
| -------- | -------- |
| int32_t (\*init)(struct HdfChipDriver \*chipDriver, NetDevice \*netDev) | Initializes the current network interface. The **NetDeviceInterFace** needs to be provided for the **netDev**.|
| const char \*driverName | Indicates the driver name.|
| int32_t (\*deinit)(struct HdfChipDriver \*chipDriver, NetDevice \*netDev) | Deinitializes the current network interface.|
| int32_t (\*InitChip)(struct HdfWlanDevice \*device) | Initializes a chip.|
| struct HdfMac80211BaseOps \*ops | Provides the WLAN basic capability interface set.|
| int32_t (\*DeinitChip)(struct HdfWlanDevice \*device) | Deinitializes a chip.|
| struct HdfMac80211STAOps \*staOps | Provides the interface set required for supporting the standalone (STA) mode.|
| void (_ReleaseFactory)(struct HdfChipDriverFactory _factory) | Releases the **HdfChipDriverFactory** object.|
| struct HdfMac80211APOps \*apOps | Provides the interface set required for supporting the access point (AP) mode.|
| struct HdfChipDriver _(_Build)(struct HdfWlanDevice \*device, uint8_t ifIndex) | Creates an **HdfChipDriver**. In the input parameters, **device** indicates the device information, and **ifIndex** indicates the sequence number of this interface in the chip.|
| void (_Release)(struct HdfChipDriver _chipDriver) | Releases the **HdfChipDriver**.|
| uint8_t (\*GetMaxIFCount)(struct HdfChipDriverFactory \*factory) | Obtains the maximum number of APIs supported by the current chip.|
Implement the following APIs in the **HdfChipDriver**.
| API| Description|
| -------- | -------- |
| int32_t (\*init)(struct HdfChipDriver \*chipDriver, NetDevice \*netDev) | Initializes the current network interface. The **NetDeviceInterFace** needs to be provided for the **netDev**.|
| int32_t (\*deinit)(struct HdfChipDriver \*chipDriver, NetDevice \*netDev) | Deinitializes the current network interface.|
| struct HdfMac80211STAOps \*staOps | Provides the interface set required for supporting the standalone (STA) mode.|
| struct HdfMac80211APOps \*apOps | Provides the interface set required for supporting the access point (AP) mode.|
2. Compile the configuration file to describe the devices supported by the driver.
2. Compile the configuration file to describe the devices supported by the driver.
...
@@ -353,9 +349,8 @@ Implement the following APIs in the **HdfChipDriver**.
...
@@ -353,9 +349,8 @@ Implement the following APIs in the **HdfChipDriver**.
The sample code is as follows:
The sample code is as follows:
```
```
root {
root {
wlan_config {
wlan_config {
chip_name :& chipList {
chip_name :& chipList {
chip_name :: chipInst {
chip_name :: chipInst {
...
@@ -368,15 +363,16 @@ root {
...
@@ -368,15 +363,16 @@ root {
}
}
}
}
}
}
}
}
```
```
3. Edit the configuration file and load the driver.
3. Edit the configuration file and load the driver.
All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_wlan_chips** to the host named **network**. Note: The value of **moduleName** must be the same as that in the touchscreen driver.
All device information about the product is defined in the **//vendor/MyProductVendor/MyProduct/config/device_info/device_info.hcs** file. Modify the file by adding configurations for the device named **device_wlan_chips** to the host named **network**.
Note: The value of **moduleName** must be the same as that in the touchscreen driver.
```
```
deviceN :: deviceNode {
deviceN :: deviceNode {
policy = 0;
policy = 0;
preload = 2;
preload = 2;
...
@@ -384,34 +380,37 @@ root {
...
@@ -384,34 +380,37 @@ root {
deviceMatchAttr = "hdf_wlan_chips_chip_name";
deviceMatchAttr = "hdf_wlan_chips_chip_name";
serviceName = "driverName";
serviceName = "driverName";
}
}
```
```
4. Build the driver.
4. Build the driver.
- Create a kernel configuration menu. Create a **Kconfig** file in the **//device/MySoCVendor/peripheral** directory. The file template is as follows:
- Create a kernel configuration menu. Create a **Kconfig** file in the **//device/MySoCVendor/peripheral** directory. The file template is as follows:
```
```
config DRIVERS_WLAN_XXX
config DRIVERS_WLAN_XXX
bool "Enable XXX WLAN Host driver"
bool "Enable XXX WLAN Host driver"
default n
default n
depends on DRIVERS_HDF_WIFI
depends on DRIVERS_HDF_WIFI
help
help
Answer Y to enable XXX Host driver. Support chip xxx
Answer Y to enable XXX Host driver. Support chip xxx
```
```
Add the following sample code to the end of the **//drivers/adapter/khdf/linux/model/network/wifi/Kconfig** file to add the configuration menu to the kernel:
Add the following configuration to the end of the **//drivers/hdf_core/adapter/khdf/linux/model/network/wifi/Kconfig** file:
When **DRIVERS_WLAN_XXX** is enabled in the kernel, **makefile** in **//device/MySoCVendor/peripheral/build/standard/** is called. For details about the development, see [LED Peripheral Control](../guide/device-wlan-led-control.md).
When **DRIVERS_WLAN_XXX** is enabled in the kernel, **makefile** in **//device/MySoCVendor/peripheral/build/standard/** is called. For details about the development, see [LED Peripheral Control](../guide/device-wlan-led-control.md).