[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdawb_WWdjg0J-AmXBk3N2JZUb1yptrqD4sOnh_+unwR1Q@mail.gmail.com>
Date: Sat, 27 Nov 2021 02:36:06 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Cosmin Tanislav <demonsingur@...il.com>
Cc: cosmin.tanislav@...log.com, Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <michael.hennerich@...log.com>,
Rob Herring <robh+dt@...nel.org>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Bartosz Golaszewski <brgl@...ev.pl>,
linux-gpio@...r.kernel.org, Michael Walle <michael@...le.cc>
Subject: Re: [PATCH v6 3/3] iio: addac: add AD74413R driver
Hi Cosmin,
thanks for your patch!
I noticed this has a GPIO chip inside of it :)
On Fri, Nov 26, 2021 at 5:03 PM Cosmin Tanislav <demonsingur@...il.com> wrote:
These:
> +static void ad74413r_gpio_set(struct gpio_chip *chip,
> + unsigned int offset, int val)
> +static void ad74413r_gpio_set_multiple(struct gpio_chip *chip,
> + unsigned long *mask,
> + unsigned long *bits)
> +static int ad74413r_gpio_get(struct gpio_chip *chip, unsigned int offset)
> +static int ad74413r_gpio_get_multiple(struct gpio_chip *chip,
> + unsigned long *mask,
> + unsigned long *bits)
(...)
> + if (st->num_gpo_gpios) {
> + st->gpo_gpiochip.owner = THIS_MODULE;
> + st->gpo_gpiochip.label = st->chip_info->name;
> + st->gpo_gpiochip.base = -1;
> + st->gpo_gpiochip.ngpio = st->num_gpo_gpios;
> + st->gpo_gpiochip.parent = st->dev;
> + st->gpo_gpiochip.can_sleep = true;
> + st->gpo_gpiochip.set = ad74413r_gpio_set;
> + st->gpo_gpiochip.set_multiple = ad74413r_gpio_set_multiple;
> + st->gpo_gpiochip.set_config = ad74413r_gpio_set_gpo_config;
> + st->gpo_gpiochip.get_direction =
> + ad74413r_gpio_get_gpo_direction;
> +
> + ret = devm_gpiochip_add_data(st->dev, &st->gpo_gpiochip, st);
> + if (ret)
> + return ret;
> + }
> +
> + if (st->num_comparator_gpios) {
> + st->comp_gpiochip.owner = THIS_MODULE;
> + st->comp_gpiochip.label = st->chip_info->name;
> + st->comp_gpiochip.base = -1;
> + st->comp_gpiochip.ngpio = st->num_comparator_gpios;
> + st->comp_gpiochip.parent = st->dev;
> + st->comp_gpiochip.can_sleep = true;
> + st->comp_gpiochip.get = ad74413r_gpio_get;
> + st->comp_gpiochip.get_multiple = ad74413r_gpio_get_multiple;
> + st->comp_gpiochip.set_config = ad74413r_gpio_set_comp_config;
> + st->comp_gpiochip.get_direction =
> + ad74413r_gpio_get_comp_direction;
Look a bit like the generic drivers/gpio/gpio-regmap.c
GPIO_REGMAP.
Example:
drivers/gpio/gpio-sl28cpld.c
drivers/pinctrl/bcm/pinctrl-bcm63xx.c
Or is it too particular for this?
I don't know if the regmap gpio can deal with adding a few functions
like a custom .set_config() on top of the templates to be honest, maybe
that is something we can fix in that case?
Cc:ing Michael Walle so he can pitch in if I'm onto something here or not.
Anyways the GPIO portions look good otherwise.
Yours,
Linus Walleij
Powered by blists - more mailing lists