[PATCH v4] staging: wfx: Get descriptors for GPIOs
Jérôme Pouiller
jerome.pouiller at silabs.com
Wed Jul 1 07:10:04 UTC 2020
Hello Linus,
On Tuesday 30 June 2020 10:21:33 CEST Linus Walleij wrote:
>
> The code has the functionality to insert the GPIO lines using
> the global GPIO numbers through module parameters.
>
> As we are clearly deprecating the use of global GPIO numbers
> look up the GPIO descriptors from the device instead. This
> usually falls back to device hardware descriptions using e.g.
> device tree or ACPI. This device clearly supports device
> tree when used over SPI for example.
>
> For example, this can be supplied in the device tree like so:
>
> wfx at 0x01 {
> compatible = "silabs,wf200";
> reset-gpios = <&gpio0 1>;
> wakeup-gpios = <&gpio0 2>;
> };
>
> Cc: Jérôme Pouiller <jerome.pouiller at silabs.com>
> Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
> ---
> ChangeLog v3->v4:
> - Finally figured out how to compile this by selecting SPI
> host and deselecting MMC host.
Weird, it should be selectable if MMC or SPI is selected.
> - Initialize the reset GPIO as OUT_LOW
> - Initialize the wakeup GPIO as OUT_LOW
> - Drop one more desc_to_gpio()
> - Update the warning if GPIO is not found.
> ChangeLog v2->v3:
> - ERR_CAST not PTR_CAST
> ChangeLog v1->v2:
> - Fixed a cast and a variable name.
> - I still don't know how to compile this but hey the zeroday
> robot does.
> ---
> drivers/staging/wfx/bus_spi.c | 14 +++++------
> drivers/staging/wfx/main.c | 45 ++++-------------------------------
> drivers/staging/wfx/main.h | 2 --
> 3 files changed, 12 insertions(+), 49 deletions(-)
>
[...]
> diff --git a/drivers/staging/wfx/main.c b/drivers/staging/wfx/main.c
> index 6bd96f476388..3828a2652313 100644
> --- a/drivers/staging/wfx/main.c
> +++ b/drivers/staging/wfx/main.c
[...]
> @@ -340,7 +303,10 @@ struct wfx_dev *wfx_init_common(struct device *dev,
> memcpy(&wdev->pdata, pdata, sizeof(*pdata));
> of_property_read_string(dev->of_node, "config-file",
> &wdev->pdata.file_pds);
> - wdev->pdata.gpio_wakeup = wfx_get_gpio(dev, gpio_wakeup, "wakeup");
> + wdev->pdata.gpio_wakeup = devm_gpiod_get(dev, "wakeup", GPIOD_OUT_LOW);
> + if (IS_ERR(wdev->pdata.gpio_wakeup))
> + return ERR_CAST(wdev->pdata.gpio_wakeup);
> + gpiod_set_consumer_name(wdev->pdata.gpio_wakeup, "wfx wakeup");
In the original code, the gpio wakeup was not mandatory. But in this code,
wfx_init_common() will return an error if the gpio "wakeup" is not
defined.
> wfx_sl_fill_pdata(dev, &wdev->pdata);
>
> mutex_init(&wdev->conf_mutex);
[...]
--
Jérôme Pouiller
More information about the devel
mailing list