5.6 General Purpose IOs

The ATWILC1000/3000 device driver uses two GPIOs connected to CHIP_EN and RESET to control the chip power-up sequence. To port the driver to a new host, it is recommended that the corresponding GPIO numbers be updated.

The driver reads the corresponding GPIO numbers from the device tree file. If the GPIOs were not found in the device tree file, the driver uses the static definition of the GPIO numbers defined in wlan.h.

Use the following function to read the corresponding GPIO numbers from the device tree file:

Note: CHIP_EN and RESET GPIOs are used for WILC1000/3000 devices, but, for compatibility, these GPIOs must also be defined as dummy pin for WILCS02.
int wilc_of_parse_power_pins(struct wilc *wilc)
{
	static const struct wilc_power_gpios default_gpios[] = {
		{ .reset = GPIO_NUM_RESET,	.chip_en = GPIO_NUM_CHIP_EN, },
	};
	struct device_node *of = wilc->dt_dev->of_node;
	struct wilc_power *power = &wilc->power;
	const struct wilc_power_gpios *gpios = &default_gpios[0];
	int ret;

	power->gpios.reset = of_get_named_gpio(of, "reset-gpios", 0);
	if (!gpio_is_valid(power->gpios.reset))
		power->gpios.reset = gpios->reset;

	power->gpios.chip_en = of_get_named_gpio(of, "chip_en-gpios", 0);
	if (!gpio_is_valid(power->gpios.chip_en))
		power->gpios.chip_en = gpios->chip_en;

	if (!gpio_is_valid(power->gpios.chip_en) ||
			!gpio_is_valid(power->gpios.reset))
		return -EINVAL;

	ret = devm_gpio_request(wilc->dev, power->gpios.chip_en, "CHIP_EN");
	if (ret)
		return ret;

	ret = devm_gpio_request(wilc->dev, power->gpios.reset, "RESET");
	return ret;
}

A device tree overlay is used at runtime (by the bootloader in this case) to dynamically modify the device tree by adding nodes to the tree and making changes to properties in the existing tree. The WILC SDIO DT-Overlay files are present in the dt-overlay-mchp repo at the Linux4Microchip GitHub.

sama5d4_xplained/sama5d4_xplained_wilc_sdio.dtso file

&mmc1 {
 	#address-cells = <1>;
 	#size-cells = <0>;
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_mmc1_clk_cmd_dat0 &pinctrl_mmc1_dat1_3>;
 	mmc-pwrseq = <&wifi_pwrseq>;
 	non-removable;
 	bus-width = <4>;
 	status = "okay";
 	wifi: slot@0 {
		compatible = "microchip,wilc1000", "microchip,wilc3000", "atmel,wilc_sdio";
		reset-gpios = <&pioB 28 GPIO_ACTIVE_HIGH>;
		chip_en-gpios = <&pioC 30 GPIO_ACTIVE_HIGH>;
		interrupt-parent = <&pioC>;
		interrupts = <27 0>;
		reg = <0>;
		bus-width = <4>;
		status = "okay";
	 };
};

sama5d4_xplained/sama5d4_xplained_wilc_spi.dtso file

&spi1 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";

	wilc_spi: wilc_spi@0 {
		compatible = "microchip,wilc1000", "microchip,wilc3000";
		spi-max-frequency = <48000000>;
		reg = <0>;
		interrupt-parent = <&pioC>;
		interrupts = <27 0>;
		reset-gpios = <&pioB 28 0>;
		chip_en-gpios = <&pioC 30 0>;
		status = "okay";
	};
};
sama5d27_som1_ek/sama5d27_som1_ek_wilc_mmc_spi.dtso file.
&spi6 {
	#address-cells = <1>;
	#size-cells = <0>;
	cs-gpios = <&pioA PIN_PD0 GPIO_ACTIVE_LOW>;
	status = "okay";

	wifi@0 {
		compatible = "mmc-spi-slot";
		reg = <0>;
		spi-max-frequency = <50000000>;
		interrupt-parent = <&pioA>;
		interrupts = <PIN_PA25 0>;
		intr-gpios = <&pioA PIN_PB0 0>;
		cap-mmc-highspeed;
		cap-sd-highspeed;
	};
};

The following example illustrates the necessary modifications in DT-overlays for SPI and SDIO WILC1000/3000.

DT-Overlay file for SPI: GitHub Link

DT-Overlay files for SDIO: GitHub Link

DT-Overlay files for MMC-SPI (WILCS02): GitHub Link