5.3 SPI Configuration
- The WILCS02 users can refer to SPI Mode of SDIO.
- For WILCS02, enable WILC SDIO along with MMC over the SPI feature as described in Config MMC-SPI, instead of enabling the WILC SPI Module.
The ATWILC device driver identifies the SPI port used for communication by passing the Linux SPI registration API, spi_register_driver( ), after calling module_spi_driver( ). The variable of_match_table within the spi_driver structure specifies an appropriate .compatible parameter. The ATWILC device’s spi_driver is defined in the spi.c file.
static const struct of_device_id wilc_of_match[] = {
{ .compatible = "microchip,wilc1000", },
{ .compatible = "microchip,wilc3000", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, wilc_of_match);
static const struct dev_pm_ops wilc_spi_pm_ops = {
.suspend = wilc_spi_suspend,
.resume = wilc_spi_resume,
};
static struct spi_driver wilc_spi_driver = {
.driver = {
.name = MODALIAS,
.of_match_table = wilc_of_match,
.pm = &wilc_spi_pm_ops,
},
.probe = wilc_bus_probe,
.remove = wilc_bus_remove,
};The user must ensure that the .compatible parameter defined in of_device_id wilc_of_match[] is defined in the board’s device tree file that describes the board.
For example, the SAMA5D4's device tree at91-sama5d4_xplained.dts file in the kernel_tree/arch/arm/boot/dts path is modified to match the driver, as shown below. In addition, the SPI clock was changed to improve communication with the host processor. Therefore, the spi-max-frequency property must be changed appropriately under the corresponding SPI device node.
spi1: spi@fc018000 {
cs-gpios = <&pioB 21 0>;
status = "okay";
wilc_spi@0 {
compatible = "microchip,wilc1000", "microchip,wilc3000";
spi-max-frequency = <48000000>;
reg = <0>;
interrupt-parent = <&pioB>;
interrupts = <26 0>;
reset-gpios = <&pioE 21 0>;
chip_en-gpios = <&pioB 27 0>;
status = "okay";
};
};