All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Agner <stefan@agner.ch>
To: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>,
	viresh.kumar@linaro.org
Cc: 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: Tue, 27 Sep 2016 12:34:39 -0700	[thread overview]
Message-ID: <671a23a9ccdbdd6594ad89bf496c1490@agner.ch> (raw)
In-Reply-To: <e72b95e2-353a-d058-4321-dfbdaac2ba1b@mentor.com>

On 2016-09-27 11:17, Vladimir Zapolskiy wrote:
> Hi Stefan,
> 
> On 09/27/2016 07:37 PM, Stefan Agner wrote:
>> On 2016-09-27 05:12, Vladimir Zapolskiy wrote:
>>> Hi Stefan,
>>>
>>> On 09/27/2016 03:26 AM, Stefan Agner wrote:
>>>> If a GPIO gets freed after selecting a new pinctrl configuration
>>>> the driver should not change pinctrl anymore. Otherwise this will
>>>> likely lead to a unusable pin configuration for > the newly selected
>>>> pinctrl.
>>>>
>>>> Signed-off-by: Stefan Agner <stefan@agner.ch>
>>>> ---
>>>> This turned out to be problematic when using the I2C GPIO bus recovery
>>>> functionality. After muxing back to I2C, the GPIO is being freed, which
>>>> cased I2C to stop working completely.
>>>
>>> IMHO this recent "i.MX I2C GPIO bus recovery" feature is kind of a hack,
>>> for example I believe it breaks I2C bus driver initialization on i.MX31
>>> boards, where today there is no pinctrl driver at all.
>>
>> This has been addressed by Li Yang's patch, already in the next branch:
>> https://lkml.org/lkml/2016/9/12/1161
> 
> Nice to know about it, thank you for the link.
> 
>>>
>>> IMHO something like I've partially described in the recent "Requesting as
>>> a GPIO a pin already used through pinctrl" topic should be done here.
>>> Could you consider to add another pinctrl-1 group with alternative GPIO
>>> line mux/config settings to an i2c controller device node and apply it,
>>> when you need a bus recovery? You may find references how this kind of
>>> dynamic pinctrl management is done within mmc/sd subsystem.
>>
>> I don't quite understand, that is already the case. This is what device
>> tree looks like to get the I2C recovery functionality:
>>
>> &i2c1 {
>> 	pinctrl-names = "default", "gpio";
>> 	pinctrl-0 = <&pinctrl_i2c1>;
>> 	pinctrl-1 = <&pinctrl_i2c1_gpio>;
>> 	scl-gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
>> 	sda-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>;
>> 	status = "okay";
>> };
> 
> Great, then why do you experience a problem you've described?
> 
>>>> After muxing back to I2C, the GPIO is being freed, which cased I2C
>>>> to stop working completely.
> 
> Release GPIO firstly, then mux back to I2C, that's the correct sequence
> and I believe it obsoletes this change.
> 

Added Viresh Kumar to the discussion, he implemented the I2C recovery
functions.

Yes, reordering the pinctrl/gpio_free calls would fix the problem too.

However, I guess there is no explicit rule to that ("request/free GPIOs
only when they are muxed as GPIO"), so I think of it that the issue is
actually in the pinctrl driver.

On top of that it is not entirely trivial to reorder the calls the way
i2c_generic_gpio_recovery and i2c_generic_recovery are set up right now.


>>>
>>> By the way did I miss a patch, which falls back to mux settings on
>>> .gpio_disable_free call for non-Vybrid platforms?
>>
>> Currently only Vybrid makes use of the .gpio_request_enable... and so
>> should .gpio_disable_free then.
>>
> 
> So, I guess this is a change with a runtime difference for Vybrid only.

That is correct.

> 
> I find that it was initially done wrong that a number of Vybrid specific
> hooks were added to the shared pinctrl-imx.c, in my opinion it is better
> to make needed abstractions and move all code around SHARE_MUX_CONF_REG
> to pinctrl-vf610.c:
> 
> ./pinctrl-imx.c:216:		if (info->flags & SHARE_MUX_CONF_REG) {
> ./pinctrl-imx.c:317:	if (!(info->flags & SHARE_MUX_CONF_REG))
> ./pinctrl-imx.c:357:	if (!(info->flags & SHARE_MUX_CONF_REG))
> ./pinctrl-imx.c:382:	if (!(info->flags & SHARE_MUX_CONF_REG))
> ./pinctrl-imx.c:425:	if (info->flags & SHARE_MUX_CONF_REG)
> ./pinctrl-imx.c:450:		if (info->flags & SHARE_MUX_CONF_REG) {
> ./pinctrl-imx.c:534:	if (info->flags & SHARE_MUX_CONF_REG)
> ./pinctrl-imx.c:575:		if (info->flags & SHARE_MUX_CONF_REG) {
> 
> Nevertheless this is not directly related to the change.

Yeah I was really on the fence there. Despite the same name, the IOMUXC
on Vybrid is quite a bit different than on i.MX. The problem is it is
not easily possible to factor out the SoC specific stuff into
pinctrl-vf610.c I would have basically had to add tons of callbacks or
re-implement lots of functions in pinctrl-vf610.c. Maybe it would have
probably been better to basically implement Vybrids IOMUXC as its own
pinctrl driver.

--
Stefan

  reply	other threads:[~2016-09-27 19:40 UTC|newest]

Thread overview: 22+ 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 12:12   ` Vladimir Zapolskiy
2016-09-27 16:37   ` Stefan Agner
2016-09-27 18:17     ` Vladimir Zapolskiy
2016-09-27 18:17       ` Vladimir Zapolskiy
2016-09-27 19:34       ` Stefan Agner [this message]
2016-09-27 20:28         ` Vladimir Zapolskiy
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
2016-09-30  2:12                 ` Viresh Kumar
2016-10-10  8:32                 ` Linus Walleij
2016-09-28 12:07             ` Vladimir Zapolskiy
2016-09-28 12:07               ` Vladimir Zapolskiy
2016-09-29  6:46               ` Viresh Kumar
2016-09-29 12:16                 ` Vladimir Zapolskiy
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=671a23a9ccdbdd6594ad89bf496c1490@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.