lkml.org 
[lkml]   [2021]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [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@gmail.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

\
 
 \ /
  Last update: 2021-11-27 03:39    [W:0.131 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site