4.3 SPI
The ATWILC device driver identifies the SPI port that is to be used for communication by
passing the Linux SPI registration API, spi_register_driver( )
, after
calling module_spi_driver( )
.
The variable of_match_table
of the structure spi_driver
is
used to specify an appropriate .compatible
parameter.
The ATWILC device’s spi_driver is defined below 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 make sure 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";
};
};