Linux内核-Wi-Fi驱动移植

来自华清远见研发中心
FarSight讨论 | 贡献2020年7月28日 (二) 15:48的版本 实验目的

跳转至: 导航搜索

实验原理

FS-MP1A开发板蓝牙采用AP6236,WIFI蓝牙二合一芯片。WiFi部分通过SDIO接口与SoC进行数据交互。

59-1-1-1.png

在FS-MP1A开发板上sdmmc1用于连接sdcard,sdmmc2用于连接eMMC,sdmmc3则用于连接我们这里所用到的AP6236的WiFi接口。

sdmmc3的设备树配置可参考stm32mp157c-dk2.dts中的相关配置,需要重新调整sdmmc3所使用的管脚,AP_CK32KO管脚配置和BT_WIFI_RST管脚配置。

60-1-1-2.png

60-1-1-3.png

60-1-1-4.png

59-1-1-3.png

查看原理图得出AP6236数据管脚与STM32MP157A的管脚对应关系如下:

原理图网络编号 对应管脚 管脚功能 管脚功能码
SD3_DATA0 PF0 SDMMC3_D0 AF9
SD3_DATA1 PF4 SDMMC3_D1 AF9
SD3_DATA2 PD5 SDMMC3_D2 AF10
SD3_DATA3 PD7 SDMMC3_D3 AF10
SD3_CMD PD0 SDMMC3_CMD AF10
SD3_CLK PG15 SDMMC3_CK AF10
WL_REG_ON PD4 IO ANALOG
AP_CK32KO PI8 RTC_OUT2 ANALOG
  • WiFi设备树节点

参考文档:

Documentation/devicetree/bindings/net/wireless/brcm,bcm43xx-fmac.txt
Documentation/devicetree/bindings/mmc/mmc.txt

内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见:

arch/arm/boot/dts/stm32mp151.dtsi

stm32mp151中sdmmc3定义如下:

sdmmc3: sdmmc@48004000 {
    compatible = "arm,pl18x", "arm,primecell";
    arm,primecell-periphid = <0x00253180>;
    reg = <0x48004000 0x400>, <0x48005000 0x400>;
    interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
    interrupt-names = "cmd_irq";
    clocks = <&rcc SDMMC3_K>;
    clock-names = "apb_pclk";
    resets = <&rcc SDMMC3_R>;
    cap-sd-highspeed;
    cap-mmc-highspeed;
    max-frequency = <120000000>;
    status = "disabled";
};

上述代码只对sdmmc3做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。

参考文档或stm32mp157c-dk2.dts对于sdmmc2设备节点的描述,增加sdmmc3内容如下:

&sdmmc3 {
    arm,primecell-periphid = <0x10153180>;
    pinctrl-names = "default", "opendrain", "sleep";
    pinctrl-0 = <&sdmmc3_b4_wifi_pins_a>;
    pinctrl-1 = <&sdmmc3_b4_od_wifi_pins_a>;
    pinctrl-2 = <&sdmmc3_b4_sleep_wifi_pins_a>;
    non-removable;
    st,neg-edge;
    bus-width = <4>;
    vmmc-supply = <&v3v3>;
    mmc-pwrseq = <&wifi_pwrseq>;
    #address-cells = <1>;
    #size-cells = <0>;
    keep-power-in-suspend;
    status = "okay";

    brcmf: bcrmf@1 {
        reg = <1>;
        compatible = "brcm,bcm4329-fmac";
    };
};

这里用到了一个mmc-pwrseq管脚用于控制AP6236的电源,可以stm32mp157c-dk2.dts对于wifi_pwrseq设备节点的描述,增加wifi_pwrseq内容如下:

wifi_pwrseq: wifi-pwrseq {
    compatible = "mmc-pwrseq-simple";
    reset-gpios = <&gpiod 4 GPIO_ACTIVE_LOW>;
};

stm32mp15-pinctrl.dtsi对于sdmmc3的描述与FS-MP1A所使用管脚不一致,所以无法直接使用,需参考其增加如下内容:

sdmmc3_b4_wifi_pins_a: sdmmc3-b4-wifi-0 {
    pins1 {
        pinmux = <STM32_PINMUX('F', 0, AF9)>, /* SDMMC3_D0 */
             <STM32_PINMUX('F', 4, AF9)>, /* SDMMC3_D1 */
             <STM32_PINMUX('D', 5, AF10)>, /* SDMMC3_D2 */
             <STM32_PINMUX('D', 7, AF10)>, /* SDMMC3_D3 */
             <STM32_PINMUX('D', 0, AF10)>; /* SDMMC3_CMD */
        slew-rate = <1>;
        drive-push-pull;
        bias-pull-up;
    };
    pins2 {
        pinmux = <STM32_PINMUX('G', 15, AF10)>; /* SDMMC3_CK */
        slew-rate = <2>;
        drive-push-pull;
        bias-pull-up;
    };
};

sdmmc3_b4_od_wifi_pins_a: sdmmc3-b4-od-wifi-0 {
    pins1 {
        pinmux = <STM32_PINMUX('F', 0, AF9)>, /* SDMMC3_D0 */
             <STM32_PINMUX('F', 4, AF9)>, /* SDMMC3_D1 */
             <STM32_PINMUX('D', 5, AF10)>, /* SDMMC3_D2 */
             <STM32_PINMUX('D', 7, AF10)>; /* SDMMC3_D3 */
        slew-rate = <1>;
        drive-push-pull;
        bias-pull-up;
    };
    pins2 {
        pinmux = <STM32_PINMUX('G', 15, AF10)>; /* SDMMC3_CK */
        slew-rate = <2>;
        drive-push-pull;
        bias-pull-up;
    };
    pins3 {
        pinmux = <STM32_PINMUX('D', 0, AF10)>; /* SDMMC2_CMD */
        slew-rate = <1>;
        drive-open-drain;
        bias-pull-up;
    };
};

sdmmc3_b4_sleep_wifi_pins_a: sdmmc3-b4-sleep-wifi-0 {
    pins {
        pinmux = <STM32_PINMUX('F', 0, ANALOG)>, /* SDMMC3_D0 */
             <STM32_PINMUX('F', 4, ANALOG)>, /* SDMMC3_D1 */
             <STM32_PINMUX('D', 5, ANALOG)>, /* SDMMC3_D2 */
             <STM32_PINMUX('D', 7, ANALOG)>, /* SDMMC3_D3 */
             <STM32_PINMUX('G', 15, ANALOG)>, /* SDMMC3_CK */
             <STM32_PINMUX('D', 0, ANALOG)>; /* SDMMC3_CMD */
    };
};

  • RTC节点

AP6236需要使用一个外部输入的32.768Hz的时钟源,因此我们需要使能RTC的外部32.768Hz功能

参考文档:

Documentation/devicetree/bindings/rtc/st,stm32-rtc.txt

内核中ST对STM32MP15x系列芯片的设备树资源了做了定义,可参见:

arch/arm/boot/dts/stm32mp151.dtsi

stm32mp151中rtc定义如下:

rtc: rtc@5c004000 {
    compatible = "st,stm32mp1-rtc";
    reg = <0x5c004000 0x400>;
    clocks = <&scmi0_clk CK_SCMI0_RTCAPB>,
         <&scmi0_clk CK_SCMI0_RTC>;
    clock-names = "pclk", "rtc_ck";
    interrupts-extended = <&exti 19 IRQ_TYPE_LEVEL_HIGH>;
    status = "disabled";
};

上述代码只对rtc做了基本的初始化,并没有针对不同的硬件设计做适配,所以需结合硬件补全设备树节点信息。

参考stm32mp157c-dk2.dts对于rtc设备节点的描述,需增加内容如下:

rtc {
 	  st,lsco = <RTC_OUT2_RMP>;
 	  pinctrl-0 = <&rtc_out2_rmp_pins_a>;
 	  pinctrl-names = "default";
   status = "okay";
};

实验目的

熟悉基于Linux操作系统下的WiFi设备驱动移植配置过程。

实验平台

实验步骤