From: Lars-Peter Clausen <lars@metafoo.de>
To: Alexandre Courbot <gnurou@gmail.com>, Arnd Bergmann <arnd@arndb.de>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
Kukjin Kim <kgene.kim@samsung.com>,
Tomasz Figa <t.figa@samsung.com>,
Maurus Cuelenaere <mcuelenaere@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
Mark Brown <broonie@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/4] ASoC: s3c64xx/smartq: use dynamic registration
Date: Tue, 15 Jul 2014 09:58:05 +0200 [thread overview]
Message-ID: <53C4DF0D.8010208@metafoo.de> (raw)
In-Reply-To: <CAAVeFu+Z2xzUy6pGWu3H4MXdkBq39-USHbwNU9ih6AvvxPyu5A@mail.gmail.com>
On 07/15/2014 09:36 AM, Alexandre Courbot wrote:
> On Tue, Jul 15, 2014 at 4:19 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Monday 14 July 2014 19:36:24 Mark Brown wrote:
>>> On Mon, Jul 14, 2014 at 08:23:55PM +0200, Arnd Bergmann wrote:
>>>> On Monday 14 July 2014 18:18:12 Lars-Peter Clausen wrote:
>>>
>>>>> Yes. But now that you say it the gpiod_direction_output() call is missing
>>>>> from this patch.
>>>
>>>> I'm lost now. The GPIO_ACTIVE_HIGH I added comes from Documentation/gpio/board.txt
>>>> and as Linus Walleij explained to me the other day, the lookup is supposed
>>>> to replace devm_gpio_request_one(), which in turn replaced both the
>>>> gpio_request and the gpio_direction_output(). Do I need to put the
>>>> gpiod_direction_output() back or is there another interface for that when
>>>> registering the board gpios?
>>>
>>> Indeed. If you *do* need an explicit _output() then that sounds to me
>>> like we either need a gpiod_get_one() or an extension to the table,
>>> looking at the code it seems like this is indeed the case. We can set
>>> if the GPIO is active high/low, or open source/drain but there's no flag
>>> for the initial state.
>>
>> (adding Alexandre and the gpio list)
>>
>> GPIO people: any guidance on how a board file should set a gpio to
>> output/default-high in a GPIO_LOOKUP() table to replace a
>> devm_gpio_request_one() call in a device driver with devm_gpiod_get()?
>> Do we need to add an interface extension to do this, e.g. passing
>> GPIOF_OUT_INIT_HIGH as the flags rather than GPIO_ACTIVE_HIGH?
>
> The way I see it, GPIO mappings (whether they are done using the
> lookup tables, DT, or ACPI) should only care about details that are
> relevant to the device layout and that should be abstracted to the
> driver (e.g. whether the GPIO is active low or open drain) so drivers
> do not need to check X conditions every time they want to drive the
> GPIO.
>
> Direction and initial value, on the other hand, are clearly properties
> that ought to be set by the driver itself. Thus my expectation here
> would be that the driver sets the GPIO direction and initial value as
> soon as it gets it using gpiod_direction_output(). In other words,
> there is no replacement for gpio_request_one() with the gpiod
> interface. Is there any use-case that cannot be covered by calling
> gpiod_direction_output() right after gpiod_get()? AFAICT this is what
> gpio_request_one() was doing anyway.
I agree with you that this is something that should be done in the driver
and not in the lookup table. I think that it is still a good idea to have a
replacement for gpio_request_one with the new GPIO descriptor API. A large
share of the drivers want to call either gpio_direction_input() or
gpio_direction_output() right after requesting the GPIO. Combining both the
requesting and the configuration of the GPIO into one function call makes
the code a bit shorter and also simplifies the error handling. Even more so
if e.g. the GPIO is optional. This was one of the main reasons why
gpio_request_one was introduced, see the commit[1] that added it.
- Lars
[1]
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=3e45f1d1155894e6f4291f5536b224874d52d8e2
next prev parent reply other threads:[~2014-07-15 7:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1405086308-1461192-1-git-send-email-arnd@arndb.de>
[not found] ` <16507628.c6raaN50oI@wuerfel>
[not found] ` <20140714183624.GV6800@sirena.org.uk>
2014-07-15 7:19 ` [alsa-devel] [PATCH 2/4] ASoC: s3c64xx/smartq: use dynamic registration Arnd Bergmann
2014-07-15 7:36 ` Alexandre Courbot
2014-07-15 7:58 ` Lars-Peter Clausen [this message]
2014-07-15 9:14 ` Alexandre Courbot
2014-07-16 3:00 ` Alexandre Courbot
2014-07-16 7:12 ` Thierry Reding
2014-07-16 7:28 ` Alexandre Courbot
2014-07-16 7:51 ` Thierry Reding
2014-07-16 8:50 ` Rob Jones
2014-07-16 11:09 ` Thierry Reding
2014-07-23 15:20 ` Linus Walleij
2014-07-17 4:28 ` Alexandre Courbot
2014-07-17 7:44 ` Thierry Reding
2014-07-17 8:55 ` Alexandre Courbot
2014-07-17 10:17 ` Mark Brown
2014-07-17 10:41 ` Thierry Reding
2014-07-17 10:58 ` Lars-Peter Clausen
2014-07-17 11:05 ` Mark Brown
2014-07-21 3:36 ` Alexandre Courbot
2014-07-21 10:04 ` Mark Brown
2014-07-21 14:19 ` [alsa-devel] " Alexandre Courbot
2014-07-16 9:48 ` Mark Brown
2014-07-24 15:10 ` Alexandre Courbot
2014-07-15 10:39 ` Mark Brown
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=53C4DF0D.8010208@metafoo.de \
--to=lars@metafoo.de \
--cc=alsa-devel@alsa-project.org \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=gnurou@gmail.com \
--cc=kgene.kim@samsung.com \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=mcuelenaere@gmail.com \
--cc=t.figa@samsung.com \
/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).