From: Michael Hennerich <michael.hennerich@analog.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Jonathan Cameron <jic23@kernel.org>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Hartmut Knaack" <knaack.h@gmx.de>,
"Paul Cercueil" <paul.cercueil@analog.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Paweł Moll" <pawel.moll@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"ijc+devicetree@hellion.org.uk" <ijc+devicetree@hellion.org.uk>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Alexandre Courbot" <gnurou@gmail.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v2] iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs
Date: Mon, 21 Mar 2016 15:07:23 +0100 [thread overview]
Message-ID: <56F0001B.9010608@analog.com> (raw)
In-Reply-To: <CACRpkdap_8YGCAvNeK7_0H2MDDnwQ9QDJH4O2SzEkDmczPGtLg@mail.gmail.com>
On 03/11/2016 05:28 PM, Linus Walleij wrote:
> On Sun, Feb 28, 2016 at 12:50 AM, Jonathan Cameron <jic23@kernel.org> wrote:
>
>>> +Analog Devices AD5592R/AD5593R DAC/ADC device driver
>>> +
>>> +Required properties for the AD5592R:
>>> + - compatible: Must be "adi,ad5592r"
>>> + - reg: SPI chip select number for the device
>>> + - spi-max-frequency: Max SPI frequency to use (< 30000000)
>>> + - spi-cpol: The AD5592R requires inverse clock polarity (CPOL) mode
>
> If this should be a gpiochip, this shall also be reflected in the
> device tree bindings and the example in the bindings by
> stating gpio-controller; and #gpio-cells, referring to
> the binding in gpio/gpio.txt so consumers can pick a GPIO
> from this device.
Hi Linus,
Thanks for the feedback.
- Will add this to the documentation.
>
> I haven't seen the original patch, please mail the next version
> to me so I can take a look.
>
>>> +config AD5592R_BASE
>>> + tristate
>>> +
>>> +config AD5592R
>>> + tristate "Analog Devices AD5592R ADC/DAC driver"
>>> + depends on SPI_MASTER
>>> + depends on OF
>>> + select AD5592R_BASE
>>> + help
>>> + Say yes here to build support for Analog Devices AD5592R
>>> + Digital to Analog / Analog to Digital Converter.
>>> +
>>> + To compile this driver as a module, choose M here: the
>>> + module will be called ad5592r.
>>> +
>>> +config AD5593R
>>> + tristate "Analog Devices AD5593R ADC/DAC driver"
>>> + depends on I2C
>>> + depends on OF
>>> + select AD5592R_BASE
>>> + help
>>> + Say yes here to build support for Analog Devices AD5593R
>>> + Digital to Analog / Analog to Digital Converter.
>>> +
>>> + To compile this driver as a module, choose M here: the
>>> + module will be called ad5593r.
>>> +
>
> I guess something here should select GPIOLIB
> and depend of OF_GPIO
That reminds me - On my dev tree I removed to the depends on OF from
kconfig. But I haven't rebased this commit into my for_upstream branch.
I tried to avoid any OF dependency in the driver by using the
linux/property API.
I'll add select GPIOLIB - and gpio/Kconfig will select OF_GPIO if OF.
>
>>> +#ifdef CONFIG_GPIOLIB
>
> Naaaaah really? Just select GPIOLIB and get rid of ifdeffery.
> It's cool to have gpios available.
Convinced me.
>
>>> +static int ad5592r_gpio_request(struct gpio_chip *chip, unsigned offset)
>>> +{
>>> + struct ad5592r_state *st = gpiochip_get_data(chip);
>>> +
>>> + if (!(st->gpio_map & BIT(offset))) {
>>> + dev_err(st->dev, "GPIO %d is reserved by alternate function\n",
>>> + offset);
>
> This gpio_map looks a bit like pin control.
>
> It might be overkill to use all of the pinctrl subsystem,
> we have circumvented it in other places.
I think it's overkill too.
>
>>> + return -ENODEV;
>>> + }
>>> +
>>> + if (offset >= chip->ngpio)
>>> + return -EINVAL;
>
> gpiolib already guards against this I think.
Then I drop it
>
>>> +static int ad5592r_gpio_init(struct ad5592r_state *st)
>>> +{
>>> + st->gpiochip.label = dev_name(st->dev);
>>> + st->gpiochip.base = -1;
>>> + st->gpiochip.ngpio = 8;
>>> + st->gpiochip.parent = st->dev;
>>> + st->gpiochip.can_sleep = true;
>>> + st->gpiochip.direction_input = ad5592r_gpio_direction_input;
>>> + st->gpiochip.direction_output = ad5592r_gpio_direction_output;
>>> + st->gpiochip.get = ad5592r_gpio_get;
>>> + st->gpiochip.set = ad5592r_gpio_set;
>>> + st->gpiochip.request = ad5592r_gpio_request;
>>> + st->gpiochip.owner = THIS_MODULE;
>>> +
>>> + mutex_init(&st->gpio_lock);
>>> +
>>> + return gpiochip_add_data(&st->gpiochip, st);
>
> The gpiolib should be fine with the of_node from the parent so
> looks fine.
>
>>> + mutex_lock(&iio_dev->mlock);
>>> + st->ops->reg_write(st, AD5592R_REG_RESET, 0xdac);
>>> + mutex_unlock(&iio_dev->mlock);
>
> What's that? (0xdac)? Clever magic?
Clever magic - to avoid accidental resets.
>
>>> + case CH_MODE_DAC_AND_ADC:
>>> + dac |= BIT(i);
>>> + adc |= BIT(i);
>>> + break;
>>> +
>>> + case CH_MODE_UNUSED_PULL_DOWN:
>>> + pulldown |= BIT(i);
>>> + break;
>>> +
>>> + case CH_MODE_UNUSED_OUT_TRISTATE:
>>> + tristate |= BIT(i);
>>> + break;
>>> +
>>> + case CH_MODE_UNUSED_OUT_LOW:
>>> + st->gpio_out |= BIT(i);
>>> + break;
>>> +
>>> + case CH_MODE_UNUSED_OUT_HIGH:
>>> + st->gpio_out |= BIT(i);
>>> + st->gpio_val |= BIT(i);
>>> + break;
>>> +
>>> + case CH_MODE_GPIO_OPEN_DRAIN:
>>> + open_drain |= BIT(i);
>
> Deja-vu with include/linux/pinctrl/pinconf-generic.h
>
> We call tristate "bias high impedance".
>
> Yours,
> Linus Walleij
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
next prev parent reply other threads:[~2016-03-21 14:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 13:36 [PATCH v2] iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs michael.hennerich
2016-02-27 17:50 ` Jonathan Cameron
2016-03-02 16:21 ` Michael Hennerich
2016-03-05 17:58 ` Jonathan Cameron
2016-03-07 12:25 ` Michael Hennerich
2016-03-11 16:28 ` Linus Walleij
2016-03-21 14:07 ` Michael Hennerich [this message]
2016-03-22 10:50 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F0001B.9010608@analog.com \
--to=michael.hennerich@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=gnurou@gmail.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=paul.cercueil@analog.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).