Commit eec6e3ee authored by Michał Mirosław's avatar Michał Mirosław Committed by Greg Kroah-Hartman

staging: wfx: add proper "compatible" string

Add "compatible" string matching "vendor,chip" template and proper
GPIO flags handling. Keep support for old name and reset polarity
for older devicetrees.

Cc: stable@vger.kernel.org   # d3a5bcb4 ("gpio: add gpiod_toggle_active_low()")
Cc: stable@vger.kernel.org
Fixes: 0096214a ("staging: wfx: add support for I/O access")
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/0e6dda06f145676861860f073a53dc95987c7ab5.1581416843.git.mirq-linux@rere.qmqm.plSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e2525a95
...@@ -6,7 +6,7 @@ SPI ...@@ -6,7 +6,7 @@ SPI
You have to declare the WFxxx chip in your device tree. You have to declare the WFxxx chip in your device tree.
Required properties: Required properties:
- compatible: Should be "silabs,wfx-spi" - compatible: Should be "silabs,wf200"
- reg: Chip select address of device - reg: Chip select address of device
- spi-max-frequency: Maximum SPI clocking speed of device in Hz - spi-max-frequency: Maximum SPI clocking speed of device in Hz
- interrupts-extended: Should contain interrupt line (interrupt-parent + - interrupts-extended: Should contain interrupt line (interrupt-parent +
...@@ -15,6 +15,7 @@ Required properties: ...@@ -15,6 +15,7 @@ Required properties:
Optional properties: Optional properties:
- reset-gpios: phandle of gpio that will be used to reset chip during probe. - reset-gpios: phandle of gpio that will be used to reset chip during probe.
Without this property, you may encounter issues with warm boot. Without this property, you may encounter issues with warm boot.
(Legacy: when compatible == "silabs,wfx-spi", the gpio is inverted.)
Please consult Documentation/devicetree/bindings/spi/spi-bus.txt for optional Please consult Documentation/devicetree/bindings/spi/spi-bus.txt for optional
SPI connection related properties, SPI connection related properties,
...@@ -23,12 +24,12 @@ Example: ...@@ -23,12 +24,12 @@ Example:
&spi1 { &spi1 {
wfx { wfx {
compatible = "silabs,wfx-spi"; compatible = "silabs,wf200";
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&wfx_irq &wfx_gpios>; pinctrl-0 = <&wfx_irq &wfx_gpios>;
interrupts-extended = <&gpio 16 IRQ_TYPE_EDGE_RISING>; interrupts-extended = <&gpio 16 IRQ_TYPE_EDGE_RISING>;
wakeup-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; wakeup-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio 13 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
reg = <0>; reg = <0>;
spi-max-frequency = <42000000>; spi-max-frequency = <42000000>;
}; };
......
...@@ -27,6 +27,8 @@ MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none."); ...@@ -27,6 +27,8 @@ MODULE_PARM_DESC(gpio_reset, "gpio number for reset. -1 for none.");
#define SET_WRITE 0x7FFF /* usage: and operation */ #define SET_WRITE 0x7FFF /* usage: and operation */
#define SET_READ 0x8000 /* usage: or operation */ #define SET_READ 0x8000 /* usage: or operation */
#define WFX_RESET_INVERTED 1
static const struct wfx_platform_data wfx_spi_pdata = { static const struct wfx_platform_data wfx_spi_pdata = {
.file_fw = "wfm_wf200", .file_fw = "wfm_wf200",
.file_pds = "wf200.pds", .file_pds = "wf200.pds",
...@@ -206,9 +208,11 @@ static int wfx_spi_probe(struct spi_device *func) ...@@ -206,9 +208,11 @@ static int wfx_spi_probe(struct spi_device *func)
if (!bus->gpio_reset) { if (!bus->gpio_reset) {
dev_warn(&func->dev, "try to load firmware anyway\n"); dev_warn(&func->dev, "try to load firmware anyway\n");
} else { } else {
gpiod_set_value(bus->gpio_reset, 0); if (spi_get_device_id(func)->driver_data & WFX_RESET_INVERTED)
udelay(100); gpiod_toggle_active_low(bus->gpio_reset);
gpiod_set_value(bus->gpio_reset, 1); gpiod_set_value(bus->gpio_reset, 1);
udelay(100);
gpiod_set_value(bus->gpio_reset, 0);
udelay(2000); udelay(2000);
} }
...@@ -245,14 +249,16 @@ static int wfx_spi_remove(struct spi_device *func) ...@@ -245,14 +249,16 @@ static int wfx_spi_remove(struct spi_device *func)
* stripped. * stripped.
*/ */
static const struct spi_device_id wfx_spi_id[] = { static const struct spi_device_id wfx_spi_id[] = {
{ "wfx-spi", 0 }, { "wfx-spi", WFX_RESET_INVERTED },
{ "wf200", 0 },
{ }, { },
}; };
MODULE_DEVICE_TABLE(spi, wfx_spi_id); MODULE_DEVICE_TABLE(spi, wfx_spi_id);
#ifdef CONFIG_OF #ifdef CONFIG_OF
static const struct of_device_id wfx_spi_of_match[] = { static const struct of_device_id wfx_spi_of_match[] = {
{ .compatible = "silabs,wfx-spi" }, { .compatible = "silabs,wfx-spi", .data = (void *)WFX_RESET_INVERTED },
{ .compatible = "silabs,wf200" },
{ }, { },
}; };
MODULE_DEVICE_TABLE(of, wfx_spi_of_match); MODULE_DEVICE_TABLE(of, wfx_spi_of_match);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment