linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: Kishon Vijay Abraham I <kishon@ti.com>,
	linus.walleij@linaro.org, gnurou@gmail.com,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	nsekhar@ti.com
Cc: linux-omap@vger.kernel.org, linux-mmc@vger.kernel.org,
	Benoit Parrot <bparrot@ti.com>
Subject: Re: [PATCH] gpio: pcf857x: restore the initial line state of all pcf lines
Date: Thu, 18 Dec 2014 08:11:43 -0600	[thread overview]
Message-ID: <5492E09F.1000003@ti.com> (raw)
In-Reply-To: <549271A9.5040701@ti.com>

On 12/18/2014 12:18 AM, Kishon Vijay Abraham I wrote:
> 
> 
> On Tuesday 16 December 2014 02:20 AM, Nishanth Menon wrote:
>> On 12/12/2014 02:06 AM, Kishon Vijay Abraham I wrote:
>>> The reset values for all the PCF lines are high and hence on shutdown
>>> we should drive all the lines high in order to bring it to the reset state.
>>>
>>> This is actually required since pcf doesn't have a reset line and even after
>>> warm reset (by invoking "reboot" in prompt) the pcf lines maintains it's
>>> previous programmed state. This becomes a problem if the boards are designed
>>> to work with the default initial state.
>>>
>>> DRA7XX_evm uses PCF8575 and one of the PCF output lines feeds to MMC/SD and
>>> this line should be driven high in order for the MMC/SD to be detected.
>>> This line is modelled as regulator and the hsmmc driver takes care of enabling
>>> and disabling it. In the case of 'reboot', during shutdown path as part of it's
>>> cleanup process the hsmmc driver disables this regulator. This makes MMC boot
>>> not functional.
>>>
>>> Fixed it by driving high all the pcf lines.
>>>
>>> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
>>> ---
>>>  drivers/gpio/gpio-pcf857x.c |    9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c
>>> index 236708a..00b15b2 100644
>>> --- a/drivers/gpio/gpio-pcf857x.c
>>> +++ b/drivers/gpio/gpio-pcf857x.c
>>> @@ -448,6 +448,14 @@ static int pcf857x_remove(struct i2c_client *client)
>>>  	return status;
>>>  }
>>>  
>>> +static void pcf857x_shutdown(struct i2c_client *client)
>>> +{
>>> +	struct pcf857x *gpio = i2c_get_clientdata(client);
>>> +
>>> +	/* Drive all the I/O lines high */
>>> +	gpio->write(gpio->client, BIT(gpio->chip.ngpio) - 1);
>>
>> you might force a contention here - depending on System configuration.
>> example:
>> +-------+
>> |       |
>> |  U1   |         +------+      +-----------+
>> |       +--------->      |      |           |
>> +-------+         |      |      |           |
>>                   | Switch<-----+    SoC    |
>> +-------+         |      |      |           |
>> |       |         |      |      |           |
>> | U2    <---------+--^---+      +-----------+
>> |       |            |
>> |       |            |
>> +-------+            |
>>                   +--+--+
>>                   |     |
>>                   | PCF |
>>                   |     |
>>                   +-----+
>>
>> At low, SoC pin is connected to U2 as drive. when reset to high, you
>> now have U1 driving to the same pin that SoC has, potentially
>> resulting in contention.
>>
>>
>> Unfortunately, at this level, you do not know what the state of the
>> system is, blindly forcing a pin level will potentially cause
>> contention risk depending on pin configuration.
> 
> Assume we are doing a reset when the system is powered on, irrespective of the
> state of the system, we'll be forcing the pin level to the default state.

Yes, I dont deny that system will be fine *after* reset sequence is
started or completed. However there is a duration between the pcf
shutdown handler is called and the final reset handler is invoked -
that is the duration when  the contention might cause device behavior.
Essentially ignoring the state various drivers have asked PCF to setup
the pins and doing a hands down configuration may have side effects we
cant properly expect.

> 
> The same thing happens here so I don't think this would be a problem.
> 
> Thanks
> Kishon
> 


-- 
Regards,
Nishanth Menon

  reply	other threads:[~2014-12-18 14:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-12  8:06 [PATCH] gpio: pcf857x: restore the initial line state of all pcf lines Kishon Vijay Abraham I
2014-12-15 20:50 ` Nishanth Menon
2014-12-18  6:18   ` Kishon Vijay Abraham I
2014-12-18 14:11     ` Nishanth Menon [this message]
2015-01-05  6:26       ` Kishon Vijay Abraham I
2015-01-14 11:58         ` Linus Walleij
2015-03-16  8:46           ` Kishon Vijay Abraham I
2015-03-18 12:21             ` Linus Walleij
2015-03-18 13:21               ` Kishon Vijay Abraham I
2015-03-25 15:28                 ` 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=5492E09F.1000003@ti.com \
    --to=nm@ti.com \
    --cc=bparrot@ti.com \
    --cc=gnurou@gmail.com \
    --cc=kishon@ti.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=nsekhar@ti.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).