WiFi Driver Construction

Follow the steps below to port the WiFi driver:
  1. Place the bcmdhd driver code under /linux/driver/net/wireless directory to build the bcmdhd driver.
  2. Add the following content to /linux/driver/net/wireless/Makefile:
    obj-$(CONFIG_BCMDHD) += bcmdhd/
  3. Add the following content to /linux/driver/net/wireless/Kconfig:
    source "drivers/net/wireless/bcmdhd/Kconfig"
  4. Add following content under the SDIO node of DTS:
    &sdio1 {
        ...   
        max-frequency = <50000000>;
        address-cells = <1>;
        size-cells = <0>;
        bus-width = <4>;
        cap-sd-highspeed;
        gpio_wl_reg_on= <&ext_gpio 1 GPIO_ACTIVE_LOW>; // Power up/down internal regulators used by WiFi section
        ...
        status = "okay";
    
        brcmf: bcmdhd_wlan {
            compatible = "bcmdhd_wlan";
            gpio_wl_host_wake = <&gpioa 3 GPIO_ATIVE_HIGH>;//WL_HOST_WAKE
        };
    };
    The following code block displays the SDIO node reference:
    &sdio1 {
    max-frequency = <25000000>;
    card-detect-delay = <300>;
    post-power-on-delay-ms = <200>;
    #address-cells = <1>;
        #size-cells = <0>;
        bus-width = <4>;
        cap-power-off-card;
        supports-sdio;
        ignore-pm-notify;
        keep-power-in-suspend;
        cap-sdio-irq;
        gpio_wl_reg_on = <&ext_gpio 1 GPIO_ACTIVE_LOW>;
    no-sd;
    no-mmc;
        non-removable;
        pinctrl-names = "default";
        pinctrl-0 = <&sdcard1_pins>;
        status = "okay";
    
        brcmf: bcmdhd_wlan {
            compatible = "bcmdhd_wlan";
            gpio_wl_host_wake = <&gpioa 3 GPIO_ACTIVE_HIGH>;
        };
    };
  5. Add control over gpio_wl_reg_on in mmc driver detection function:
    static int dw_mci_starfive_probe(struct platform_device *pdev)
    {
    	…
    gpio_wl_reg_on = of_get_named_gpio(pdev->dev.of_node,
     "gpio_wl_reg_on", 0);
    	if (gpio_wl_reg_on >= 0) {
    		ret = gpio_request(gpio_wl_reg_on, "WL_REG_ON");
    		if (ret < 0) {
    			dev_err(&pdev->dev, "gpio_request(%d) for WL_REG_ON failed %d\n",
    				 gpio_wl_reg_on, ret);
    			gpio_wl_reg_on = -1;
    			return -EINVAL;
    		}
    		ret = gpio_direction_output(gpio_wl_reg_on, 0);
    		if (ret) {
    			dev_err(&pdev->dev, "WL_REG_ON didn't output high\n");
    			return -EIO;
    		}
    		mdelay(10);
    		ret = gpio_direction_output(gpio_wl_reg_on, 1);
    		if (ret) {
    			dev_err(&pdev->dev, "WL_REG_ON didn't output high\n");
    			return -EIO;
    		}
    		mdelay(10);
    	}
    	…
  6. Place the WiFi firmware and configuration file to the specified directory: According to the configuration of the 5th step in Kernel Menu Configuration, place the WiFi firmware (fw_bcm4345c5_ag.bin) and configuration file (nvram_ap6256.txt) to Firmware path and NVRAM path.