Bootstrap

Freescale i.MX 6 MNC平台移植BT/WIFI驱动

       此项目之前移植到Android6.0.1版本。基本系统可以起来了。现在要调一下WiFi和Bluetooth。此板上用的是Broadcom BCM89335的WiFi和Bluetooth二合一芯片。WiFi通过4线SDIO和SoC相连接,Bluetooth通过UART和SoC相连接。芯片的框图如下:

 

       WiFi部分的电路图如下:

 

       SoC侧接的是SD3的SD3_DAT0 ~SD3_DAT3, SD3_CLK及SD3_CMD。

 

       根据电路图,WL_REG_ON接到SoC的A19(NANDF_D4)PIN,查IOMux_Tool,此PIN对应的GPIO为GPIO2_4。

 

配置WiFi 相关的DTS及Kernel

       有了以上数据,就可以开始配置DTS文件了。修改/kernel_imx/arch/arm/boot/imx6dq-sabresd.dtsi文件。找到WL_REG_ON的配置wlreg_on,修改gpio的值为gpio2_4。

              wlreg_on:fixedregulator@100 {

                     compatible= "regulator-fixed";

                     regulator-min-microvolt= <5000000>;

                     regulator-max-microvolt= <5000000>;

                     regulator-name= "wlreg_on";

-            gpio = <&gpio4 7 0>;

+            gpio = <&gpio2 4 0>;

           startup-delay-us = <100>;

           enable-active-high;

      };

 

       找到SDIO 3的PIN配置pinctl_usdhc3,把DAT4~DAT7删除,增加GPIO2_4为GPIO模式。

              pinctrl_usdhc3:usdhc3grp {

                     fsl,pins= <

                            MX6QDL_PAD_SD3_CMD__SD3_CMD           0x17059

                            MX6QDL_PAD_SD3_CLK__SD3_CLK             0x10059

                            MX6QDL_PAD_SD3_DAT0__SD3_DATA0       0x17059

                            MX6QDL_PAD_SD3_DAT1__SD3_DATA1       0x17059

                            MX6QDL_PAD_SD3_DAT2__SD3_DATA2       0x17059

                            MX6QDL_PAD_SD3_DAT3__SD3_DATA3       0x17059

-               MX6QDL_PAD_SD3_DAT4__SD3_DATA4         0x17059

-               MX6QDL_PAD_SD3_DAT5__SD3_DATA5         0x17059

-               MX6QDL_PAD_SD3_DAT6__SD3_DATA6         0x17059

-                MX6QDL_PAD_SD3_DAT7__SD3_DATA7          0x17059

+               MX6QDL_PAD_NANDF_D4__GPIO2_IO04       0x13069  /* WL_REG_ON */

          >;

 

       找到SDIO3 的配置usdhc3,把bus-width改为4,增加wifi-host。

&usdhc3 {

       pinctrl-names= "default";

       pinctrl-0= <&pinctrl_usdhc3>;

-    bus-width = <8>;

+    bus-width = <4>;

       cd-gpios= <&gpio2 0 0>;

       wp-gpios= <&gpio2 1 0>;

       no-1-8-v;

+     wifi-host;

+     pm-ignore-notify;

       keep-power-in-suspend;

       enable-sdio-wakeup;

       status= "okay";

};

 

       另外搜索到usdhc5中也写了wifi-host,把它删除。

&uart5 {

    pinctrl-names = "default";

    pinctrl-0 = <&pinctrl_uart5_1>;

@@ -1070,25 +1084,25 @@

       cd-gpios = <&gpio2 2 0>;

       wp-gpios = <&gpio2 3 0>;

       no-1-8-v;

-       wifi-host;

-       pm-ignore-notify;

       keep-power-in-suspend;

        enable-sdio-wakeup;

-       status = "okay";

+       status = "disabled";

 };

 

       wifi-host标志是驱动程序用来识别此SDIO是否连接有WiFi模块的标志。具体代码可参考drivers/mmc/host/sdhci-esdhc-imx.c文件中的sdhci_esdhc_imx_probe_dt()函数。

       if (of_get_property(np, "wifi-host",NULL)) {

                wifi_mmc_host = host->mmc;

                dev_info(mmc_dev(host->mmc),"assigned as wifi host\n");

       }

 

       if (of_get_property(np, "pm-ignore-notify", NULL)) {

                host->mmc->pm_caps |=MMC_PM_IGNORE_PM_NOTIFY;

        }

 

       所以为了避免出现干扰,系统中只保留了一个wifi-host的SDIO配置。

 

       配置Kernel配置文件arch/arm/comfigs/imx_v7_android_defconfig文件。把CONFIG_BCMDHD打开,其它的没用的关闭。

CONFIG_USB_NET_CDC_EEM=y

-CONFIG_ATH_CARDS=m

-CONFIG_ATH6KL=m

-CONFIG_ATH6KL_SDIO=m

-# CONFIG_BCMDHD is notset

+# CONFIG_ATH_CARDSis not set

+# CONFIG_ATH6KL isnot set

+# CONFIG_ATH6KL_SDIOis not set

+CONFIG_BCMDHD=y

 CONFIG_BCMDHD_SDIO=y

 CONFIG_BCMDHD_FW_PATH="/system/etc/firmware/bcm/fw_bcmdhd.bin"

 CONFIG_BCMDHD_NVRAM_PATH="/system/etc/firmware/bcm/bcmdhd.cal"

-CONFIG_BRCMFMAC=m

-CONFIG_RTL8821AS=m

+CONFIG_BRCMFMAC=y

+# CONFIG_RTL8821ASis not set

 #CONFIG_INPUT_MOUSEDEV_PSAUX is not set

 

       至此,Kernel部分的配置算完成了。接下来需要移植驱动了。

 

移植Supplicant

       从Broadcom网上下载了最新的驱动文件包BCM89335_DHD_141_91_FW_AARD01SRC41_6_37_39_38_Supp_126_wapi.7z,解开看了一下,主要分两部分,Supplicant和Driver,决定先移植Supplicant。

 

       Supplicant也分为两类,一种是支持WAPI的,另一个是不支持的,为了简单起见,选择了HOSTAP_REL_0_8_0_126.tar.gz这个不支持WAPI的版本。解开移到external目录下。

 

       tar zxvf HOSTAP_REL_0_8_0_126.tar.gz

       mv HOSTAP_REL_0_8_0_126  external/

 

       看了一下里面的移植说明,建立符号链接

       cd external/HOSTAP_REL_0_8_0_126/libbcmhd

       ln -s ../src .

 

       因为原先系统中已经有了一份wpa_supplicant,所以默认应该不会被编译到,或者会把模块重定义,所以需要先把系统中老的wpa_supplicant屏蔽掉。修改external/wpa_supplicant/Android.mk文件。注释掉编译。

--- a/external/wpa_supplicant_8/Android.mk

+++ b/external/wpa_supplicant_8/Android.mk

@@ -1,9 +1,9 @@

 LOCAL_PATH:= $(call my-dir)

 

-ifndefWPA_SUPPLICANT_VERSION

-WPA_SUPPLICANT_VERSION:= VER_0_8_X

-endif

-ifeq($(WPA_SUPPLICANT_VERSION),$(filter$(WPA_SUPPLICANT_VERSION),VER_0_8_X VER_0_8_UNITE))

+#ifndefWPA_SUPPLICANT_VERSION

+#WPA_SUPPLICANT_VERSION:= VER_0_8_X

+##endif

+ifneq($(WP

;