RK3399添加8822cs模块驱动
WIFI调试:
1.修改WIFI配置的dts: rk3399-xxxx.dtsi
wireless-wlan {
compatible = "wlan-platdata";
rockchip,grf = <&grf>;
wifi_chip_type = "rtl8822cs";
sdio_vref = <1800>;
WIFI,host_wake_irq = <&gpio0 3 GPIO_ACTIVE_HIGH>; /* GPIO0_a3 */
status = "okay";
};
2.添加驱动
将供应商提供的驱动放在目录:kernel\drivers\net\wireless\rockchip_wlan\
修改当前目录下makefile:
obj-$(CONFIG_RTL8822CS) += rtl8822cs/
修改kconfig:
source "drivers/net/wireless/rockchip_wlan/rtl8822cs/Kconfig"
修改rtl8822cs/makefile:
CONFIG_PLATFORM_I386_PC=n
CONFIG_PLATFORM_ARM_RK3188=y
make ARCH=arm64 menuconfig 添加勾选
Device Drivers --->
[*] Network device support --->
[*] Wireless LAN --->
[*] Rockchip Wireless LAN support --->
3.添加芯片类型枚举:
kernel/net/rfkill/rfkill-wlan.c
在int get_wifi_chip_type(void)添加
} else if (strcmp(wifi_chip_type_string, "rtl8822cs") == 0) {
type = WIFI_RTL8822CS;
kernel/include/linux/rfkill-wlan.h
添加芯片枚举:
enum {
WIFI_RK901,
WIFI_RK903,
WIFI_AP6181,
WIFI_AP6210,
WIFI_AP6XXX_SERIES,
WIFI_RTL8188EU,
WIFI_RTL8192DU,
WIFI_RTL8723AS,
WIFI_RTL8723BS,
WIFI_RTL8822CS,
WIFI_RTL8812AU,
WIFI_RTL8822CS,
WIFI_RTL_SERIES,
WIFI_ESP8089,
TYPE_MAX,
};
4. 然后编译内核 编译出8822cs.ko
5.上层VID PID加进去,命令查看后调整正确。
cat /sys/bus/sdio/devices/mmc2:0001:1/uevent
DRIVER=rtl88x2cs
SDIO_CLASS=07
SDIO_ID=024C:C822
MODALIAS=sdio:c07v024CdC822
这一步如果devices目录下没有节点 可以检查下硬件。
添加: \hardware\libhardware_legacy\wifi\rk_wifi_ctrl.c
static wifi_device supported_wifi_devices[] = {
+ {"RTL8822CS", "024c:c822"},
{"RTL8188FU", "0bda:f179"},
{"RTL8822BU", "0bda:b82c"},
{"RTL8189ES", "024c:8179"},
ALOGD("PCIE WIFI identify sucess");
else {
ALOGD("maybe there is no usb wifi or sdio or pcie wifi,set default wifi module Brocom APXXX");
- strcpy(recoginze_wifi_chip, "APXXX");
+ strcpy(recoginze_wifi_chip, "RTL8822CS");
identify_sucess = 1 ;
}
}
diff --git a/wifi/wifi.c b/wifi/wifi.c
index 04da01c..73d0f5d 100755
--- a/wifi/wifi.c
+++ b/wifi/wifi.c
@@ -95,6 +95,7 @@ extern int ifc_down(const char *name);
#define RTL8192DU_DRIVER_MODULE_PATH "/system/lib/modules/8192du.ko"
#define RTL8812AU_DRIVER_MODULE_PATH "/system/lib/modules/8812au.ko"
#define RTL8822BE_DRIVER_MODULE_PATH "/system/lib/modules/8822be.ko"
+#define RTL8822CS_DRIVER_MODULE_PATH "/system/lib/modules/8822cs.ko"
#define SSV6051_DRIVER_MODULE_PATH "/system/lib/modules/ssv6051.ko"
#define ESP8089_DRIVER_MODULE_PATH "/system/lib/modules/esp8089.ko"
#define BCM_DRIVER_MODULE_PATH "/system/lib/modules/bcmdhd.ko"
@@ -112,6 +113,7 @@ extern int ifc_down(const char *name);
#define RTL8189FS_DRIVER_MODULE_NAME "8189fs"
#define RTL8192DU_DRIVER_MODULE_NAME "8192du"
#define RTL8812AU_DRIVER_MODULE_NAME "8812au"
+#define RTL8812AU_DRIVER_MODULE_NAME "8822cs"
#define SSV6051_DRIVER_MODULE_NAME "ssv6051"
#define ESP8089_DRIVER_MODULE_NAME "esp8089"
#define BCM_DRIVER_MODULE_NAME "bcmdhd"
@@ -206,6 +208,7 @@ wifi_ko_file_name module_list[] =
{"RTL8189ES", RTL8189ES_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
{"RTL8723BS", RTL8723BS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
{"RTL8723CS", RTL8723CS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
+ {"RTL8822CS", RTL8822CS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
{"RTL8723DS", RTL8723DS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
{"RTL8812AU", RTL8812AU_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
{"RTL8189FS", RTL8189FS_DRIVER_MODULE_PATH, UNKKOWN_DRIVER_MODULE_ARG},
蓝牙调试:
替换供应商给的./hardware/realtek/rtkbt目录
在替换:rtl8822cs_config rtl8822cs_fw 两个文件
整体make 编译一下烧录
调试命令:
cat /sys/bus/sdio/devices/mmc2:0001:1/uevent //可查看SDIO设备ID
cat /sys/kernel/debug/mmcx/ios //可查看WIFI_sdio 相关信息
logcat | grep WifiHW //查看WIFI加载信息
WIFI 芯片识别流程
1. 开机对 wifi 模块上电,并自动进行扫描 sdio 操作。
2. 系统启动打开 wifi 操作时, 分别对系统 sys/bus/sdio(sdio wifi), sys/bus/usb(usb wifi),
sys/bus/pic (pcie wifi )文件系统下的 uevent 进行读取。
3. 获取到 wifi 芯片 vid pid 加载相应的 wifi ko 驱动。
4. 识别到 wifi 类型后加载不同的 wpa_supplicant 参数启动 wifi。