From: Stefan Agner <stefan@agner.ch>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
linus.walleij@linaro.org, shawnguo@kernel.org,
aalonso@freescale.com, b38343@freescale.com,
ldewangan@nvidia.com, van.freenix@gmail.com,
p.zabel@pengutronix.de, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: freescale: avoid overwriting pin config when freeing GPIO
Date: Thu, 29 Sep 2016 09:33:53 -0700 [thread overview]
Message-ID: <1478f2c1989ab735b0f86d2fe579f94f@agner.ch> (raw)
In-Reply-To: <20160928041451.GC2551@vireshk-i7>
On 2016-09-27 21:14, Viresh Kumar wrote:
> On 27-09-16, 20:38, Stefan Agner wrote:
>> The i.MX I2C driver touches the pinctrl in its prepare/unprepare
>> callbacks.
>>
>> So, on a i.MX or Vybrid, the call chain looks like this:
>>
>> i2c_generic_gpio_recovery
>> -> i2c_get_gpios_for_recovery
>> -> gpio_request_one
>> -> i2c_generic_recovery
>> -> prepare_recovery (i2c_imx_prepare_recovery)
>> -> pinctrl_select_state [gpio]
>
> Why is this done here? And not in gpio_request_one?
>
You need to differentiate between Vybrid and i.MX:
Vybrid muxes a pin to GPIO on gpio_request_one (via .gpio_request_enable
callback)
i.MX does not mux a pin as GPIO on its own, but needs to be muxed
explicitly. That has been always the case...
I don't know what behavior is right, it is just "different"...
In Vybrid I did it that way because I knew that was the behavior of
another SoC I worked on (namely a Tegra)... And I had to touch the
pinctrl register anyway (using gpio_set_direction, to set the
direction).
I guess in the end it boils down to one question: Is the GPIO and
pinctrl API ment to be orthogonal? If so, then we probably should select
the GPIO via pinctrl in the i.MX I2C driver but mux the pin in
gpio_request_one similar as we do it on Vybrid... But that would be
rather invasive change...
@Shawn, Linus Walleij, others, what is your take on that?
>> -> unprepare_recovery (i2c_imx_unprepare_recovery)
>> -> pinctrl_select_state [default]
>> -> i2c_put_gpios_for_recovery
>> -> gpio_free
Currently free does not restore the last pinmux, so if the API's are
meant to be completely orthogonal we need to store the pinmux in
gpio_request_one so we can restore it in gpio_free.
--
Stefan
next prev parent reply other threads:[~2016-09-29 16:39 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-27 0:26 [PATCH] pinctrl: freescale: avoid overwriting pin config when freeing GPIO Stefan Agner
2016-09-27 12:12 ` Vladimir Zapolskiy
2016-09-27 16:37 ` Stefan Agner
2016-09-27 18:17 ` Vladimir Zapolskiy
2016-09-27 19:34 ` Stefan Agner
2016-09-27 20:28 ` Vladimir Zapolskiy
2016-09-28 2:00 ` Viresh Kumar
2016-09-28 3:38 ` Stefan Agner
2016-09-28 4:14 ` Viresh Kumar
2016-09-29 16:33 ` Stefan Agner [this message]
2016-09-30 2:12 ` Viresh Kumar
2016-10-10 8:32 ` Linus Walleij
2016-09-28 12:07 ` Vladimir Zapolskiy
2016-09-29 6:46 ` Viresh Kumar
2016-09-29 12:16 ` Vladimir Zapolskiy
2016-09-30 2:22 ` Viresh Kumar
2016-10-10 8:33 ` 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=1478f2c1989ab735b0f86d2fe579f94f@agner.ch \
--to=stefan@agner.ch \
--cc=aalonso@freescale.com \
--cc=b38343@freescale.com \
--cc=ldewangan@nvidia.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=van.freenix@gmail.com \
--cc=viresh.kumar@linaro.org \
--cc=vladimir_zapolskiy@mentor.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).