概述
介绍
简单来说,sdio起源自sd标准,顾名思义就是sd的IO接口(interface)的意思,更具体的说明,sd本来是记忆卡的标准,但是现在也可以把SD卡拿来插上一些外围设备接口使用,这个就是就叫做sdio。
而且sdio本身是一种相当单纯的技术,通过sd的IO引脚来连接外部外围,并且通过sd的IO数据接位与外围传输数据,而且sd协会也推出很完整的sdio stack 驱动程序,使得sdio外围得开发与应用变得非常热门
这里我们要移植的是RTL8822cs的sdio WiFi 模块,将其移植到rk3308的板子上去。
设备树得修改
我们使用的是sdio接口的,所以我们需要先在设备树内支持相关配置,在自己板子相关的dts中引用sdio和wireless
wireless-wlan {
compatible = "wlan-platdata";
rockchip,grf = <&grf>;
wifi_chip_type = "rtl8822cs";
sdio_vref = <1800>;
WIFI,host_wake_irq = <&gpio4 RK_PB4 GPIO_ACTIVE_HIGH>;
status = "okay";
};
&sdio {
clock-frequency = <100000000>;
clock-freq-min-max = <200000 100000000>;
bus-width = <4>;
max-frequency = <150000000>;
cap-sd-highspeed;
cap-sdio-irq;
keep-power-in-suspend;
supports-sdio;
non-removable;
mmc-pwrseq = <&sdio_pwrseq>;
//sd-uhs-sdr104; //这句话需要屏蔽,不然会出错不上去
num-slots = <1>;
status = "okay";
};
rtl8822cs源码移植
移植源码包我们需要做以下步骤
(1)拷贝源码包到内核
将厂商提供的源码包放入内核内合适的地方,这里我放在kernel/drivers/net/wireless/rockchip_wlan/ 目录下并将其重命名为rtl8822cs
(2)修改kernel/drivers/net/wireless/rockchip_wlan/Makefile 将rtl8822cs加入
# SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_AP6XXX) += rkwifi/
obj-$(CONFIG_RTL8188EU) += rtl8188eu/
obj-$(CONFIG_RTL8188FU) += rtl8188fu/
obj-$(CONFIG_RTL8189ES) += rtl8189es/
obj-$(CONFIG_RTL8189FS) += rtl8189fs/
obj-$(CONFIG_RTL8723BS) += rtl8723bs/
obj-$(CONFIG_RTL8723BU) += rtl8723bu/
obj-$(CONFIG_RTL8723CS) += rtl8723cs/
obj-$(CONFIG_RTL8723DS) += rtl8723ds/
obj-$(CONFIG_RTL8822BE) += rtl8822be/
obj-$(CONFIG_SSV6051) += ssv6xxx/
obj-$(CONFIG_MVL88W8977) += mvl88w8977/
obj-$(CONFIG_WL_ROCKCHIP) += wifi_sys/rkwifi_sys_iface.o
obj-$(CONFIG_WL_ROCKCHIP) += rkwifi/rk_wifi_config.o
obj-$(CONFIG_CYW_BCMDHD) += cywdhd/
obj-$(CONFIG_RTL8822CS) += rtl8822cs/
(3)修改kernel/drivers/net/wireless/rockchip_wlan/Kconfig 将rtl8822cs加入配置
source "drivers/net/wireless/rockchip_wlan/rtl8188eu/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8188fu/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8189es/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8189fs/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723bs/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723bu/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723cs/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8723ds/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8822be/Kconfig"
source "drivers/net/wireless/rockchip_wlan/mvl88w8977/Kconfig"
source "drivers/net/wireless/rockchip_wlan/ssv6xxx/Kconfig"
source "drivers/net/wireless/rockchip_wlan/rtl8822cs/Kconfig"
(4)修改 drivers/net/wireless/rockchip_wlan/Kconfig/rtl8822cs 下的 Makefile 文件 将文件中的CONFIG_PLATFORM_I386_PC 的值修改为 n 将文件中的 ONFIG_PLATFORM_ARM_RK3188 的值修改为 y
这里说明下,由于这个Makefile内没有我这个rk3308芯片的支持,而我个人比较懒,所以这里使用的是rk3318的这个配置项
对rk3188相关的配置进行修改,主要是模块名,编译工具,和ARCH
(5)修改Kconfig
将源码内的kconfig修改为RTL8822CS,这里是厂商粗心写错成了RTL8822BS
(6)修改kernel/net/rfkill/rfkill-wlan.c 文件添加rtl8822cs相关
(7)修改kernel/include/linux/rfkill-wlan.h添加rtl8822cs相关配置
menuconfig 配置
(1)将移植的源码在内核配置中进行配置加载驱动
-> Device Drivers
-> Network device support (NETDEVICES [=y])
-> Wireless LAN (WLAN [=y])
-> Rockchip Wireless LAN support (WL_ROCKCHIP [=y])
(2)配置内核支持wifi sdio
-> Networking support (NET [=y])
-> Wireless (WIRELESS [=y])
由于sdio wifi 设备的特性,它首先是个网络设备,其次是一个块设备,在内核启动阶段是靠mmc去扫描sdio设备的,我们还需要将mmc配置进去,而如何找到我们这个sdio设备的mmc源码呢,这里需要先去设备树内找到对sdio的描述
sdio: dwmmc@ff4a0000 {
compatible = "rockchip,rk3308-dw-mshc", "rockchip,rk3288-dw-mshc";
reg = <0x0 0xff4a0000 0x0 0x4000>;
max-frequency = <150000000>;
bus-width = <4>;
clocks = <&cru HCLK_SDIO>, <&cru SCLK_SDIO>,
<&cru SCLK_SDIO_DRV>, <&cru SCLK_SDIO_SAMPLE>;
clock-names = "biu", "ciu", "ciu-drv", "ciu-sample";
fifo-depth = <0x100>;
interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&sdio_bus4 &sdio_cmd &sdio_clk>;
status = "disabled";
};
复制compatible 中的其中一个去grep看下那个源文件调用到了这个
$:~/NT31/kernel/drivers/mmc$ grep "rockchip,rk3308-dw-mshc" -nr
Binary file built-in.o matches
Binary file host/built-in.o matches
host/dw_mmc-rockchip.c:240: "rockchip,rk3308-dw-mshc"))
发现是dw_mmc-rockchip.c这个文件调用了,我们需要将这个文件配置进内核,不然不会有mmc去扫描sdio设备
-> Device Drivers
-> MMC/SD/SDIO card support (MMC [=y])
比较关键的选项是Networking support->Wireless下的 cfg80211 wireless extensions compatibility
和Device driver->MMC/SD/SDIO card support 下的SDIO UART/GPS class support 。
如果不按照上面的配置的话,装载sdio wifi的驱动时将会报有关80211的错误和sdio_claim_host()函数找不到的错误。
编译烧录
基本上wifi就移植完了,整体编译烧录进板子看下情况,发现内核启动时mmc报了-84的错误
[ 0.818171] mmc0: error -84 whilst initialising SDIO card
[ 0.830958] mmc_host mmc0: Bus speed (slot 0) = 300000Hz (slot req 300000Hz, actual 300000HZ div = 0)
[ 0.851540] dwmmc_rockchip ff4a0000.dwmmc: card claims to support voltages below defined range
[ 0.860002] FtlGcRefreshBlock 0x173
[ 0.860017] FtlGcRefreshBlock 0x2a5
[ 0.864506] mmc_host mmc0: Bus speed (slot 0) = 50000000Hz (slot req 50000000Hz, actual 50000000HZ div = 0)
查看发现84错误是提示时钟频率不对,在网上找了些资料都是说用最初的400k频率可以
&sdio {
clock-frequency = <100000000>;
clock-freq-min-max = <200000 100000000>;
bus-width = <4>;
max-frequency = <400000>; //修改频率为400k
cap-sd-highspeed;
cap-sdio-irq;
keep-power-in-suspend;
supports-sdio;
non-removable;
mmc-pwrseq = <&sdio_pwrseq>;
//sd-uhs-sdr104; //这句话需要屏蔽,不然会出错不上去
num-slots = <1>;
status = "okay";
};
启动后发现mmc0: new high speed SDIO card at address 0001
扫描到设备了
如何查看sdio是否检测到设备
/ # ls /sys/bus/sdio/devices/
mmc0:0001:1
查看devices目录下是否有文件有就说明找到了设备
最后
以上就是任性电源为你收集整理的sdio wifi 移植的全部内容,希望文章能够帮你解决sdio wifi 移植所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复