[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230915141549.GA3658872-robh@kernel.org>
Date: Fri, 15 Sep 2023 09:15:49 -0500
From: Rob Herring <robh@...nel.org>
To: Linus Walleij <linus.walleij@...aro.org>
Cc: Jan Kundrát <jan.kundrat@...net.cz>,
Pavel Machek <pavel@....cz>, Lee Jones <lee@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Jacek Anaszewski <jacek.anaszewski@...il.com>,
linux-leds@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] leds: triggers: gpio: Rewrite to use trigger-sources
On Tue, Sep 12, 2023 at 03:44:31PM +0200, Linus Walleij wrote:
> By providing a GPIO line as "trigger-sources" in the FWNODE
> (such as from the device tree) and combining with the
> GPIO trigger, we can support a GPIO LED trigger in a natural
> way from the hardware description instead of using the
> custom sysfs and deprecated global GPIO numberspace.
>
> Example:
>
> gpio: gpio@0 {
> compatible "my-gpio";
> gpio-controller;
> #gpio-cells = <2>;
> interrupt-controller;
> #interrupt-cells = <2>;
> #trigger-source-cells = <2>;
> };
>
> leds {
> compatible = "gpio-leds";
> led-my-gpio {
> label = "device:blue:myled";
> gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
> default-state = "off";
> linux,default-trigger = "gpio";
> trigger-sources = <&gpio 1 GPIO_ACTIVE_HIGH>;
> };
> };
>
> Make this the norm, unmark the driver as broken.
>
> Delete the sysfs handling of GPIOs.
>
> Since GPIO descriptors inherently can describe inversion,
> the inversion handling can just be deleted.
>
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
> ---
[...]
> @@ -167,16 +78,47 @@ ATTRIBUTE_GROUPS(gpio_trig);
> static int gpio_trig_activate(struct led_classdev *led)
> {
> struct gpio_trig_data *gpio_data;
> + struct device *dev = led->dev;
> + int ret;
>
> gpio_data = kzalloc(sizeof(*gpio_data), GFP_KERNEL);
> if (!gpio_data)
> return -ENOMEM;
>
> - gpio_data->led = led;
> - gpio_data->gpio = -ENOENT;
> + /*
> + * The generic property "trigger-sources" is followed,
> + * and we hope that this is a GPIO.
> + */
> + gpio_data->gpiod = fwnode_gpiod_get_index(dev->fwnode,
> + "trigger-sources",
> + 0, GPIOD_IN,
> + "led-trigger");
Isn't this going to look for "trigger-sources-gpio" and
""trigger-sources-gpios"?
Rob
Powered by blists - more mailing lists