devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/4] mmc: core: Add support for MMC power sequences
@ 2015-01-14 13:02 Ulf Hansson
  2015-01-14 13:02 ` [PATCH V2 1/4] mmc: core: Initial " Ulf Hansson
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Ulf Hansson @ 2015-01-14 13:02 UTC (permalink / raw)
  To: linux-mmc, Chris Ball
  Cc: linux-arm-kernel, devicetree, Linus Walleij, Mark Brown,
	Arnd Bergmann, Alexandre Courbot, Arend van Spriel, Sascha Hauer,
	Olof Johansson, Russell King, Hans de Goede, Doug Anderson,
	NeilBrown, Tomeu Vizoso, Ulf Hansson

Changes in v2:
	Fixed comments from Russell King:
	- Renamed pwrseq callbacks and corresponding interface functions.
	- Move the call to the previous namned ->power_on() callback, to the
	  end of mmc_power_up() to get consistent behavior.


This is yet another try to solve the issues of dealing with power sequences for
the MMC subsystem. The latest attempt, see link below, took a generic approach
by adding a new top level driver layer. That's was rejected by several reasons.
http://lwn.net/Articles/602855/

This time the approach is focused to fix the issues for MMC only.

To give a short background, SOCs may specify a specific MMC power sequence. To
successfully detect an (e)MMC/SD/SDIO card, that power sequence must be followed
while initializing the card.

To be able to handle these SOC specific power sequences, we add a MMC power
sequence interface, which helps the mmc core to deal with such.

A MMC power sequence provider then implements a set of callbacks from the above
mentioned interface. The provider has a corresponding DT compatibility string
and relies on CONFIG_OF to be set to find it's various resourses, like for
example a GPIO reset.

The mmc core will from mmc_of_parse() try find a "mmc-pwrseq" DT node and then
call the corresponding MMC power sequence provider's initialization function.


Ulf Hansson (4):
  mmc: core: Initial support for MMC power sequences
  mmc: pwrseq: Document DT bindings for the simple MMC power sequence
  mmc: pwrseq: Initial support for the simple MMC power sequence
    provider
  mmc: pwrseq_simple: Add support for a reset GPIO pin

 .../devicetree/bindings/mmc/mmc,pwrseq-simple.txt  |  23 +++++
 Documentation/devicetree/bindings/mmc/mmc.txt      |   5 +
 drivers/mmc/core/Makefile                          |   2 +-
 drivers/mmc/core/core.c                            |   7 ++
 drivers/mmc/core/host.c                            |   4 +-
 drivers/mmc/core/pwrseq.c                          | 109 +++++++++++++++++++++
 drivers/mmc/core/pwrseq.h                          |  42 ++++++++
 drivers/mmc/core/pwrseq_simple.c                   |  86 ++++++++++++++++
 include/linux/mmc/host.h                           |   2 +
 9 files changed, 278 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mmc/mmc,pwrseq-simple.txt
 create mode 100644 drivers/mmc/core/pwrseq.c
 create mode 100644 drivers/mmc/core/pwrseq.h
 create mode 100644 drivers/mmc/core/pwrseq_simple.c

-- 
1.9.1


^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [PATCH V2 2/4] mmc: pwrseq: Document DT bindings for the simple MMC power sequence
@ 2015-01-19 20:17 NeilBrown
  0 siblings, 0 replies; 13+ messages in thread
From: NeilBrown @ 2015-01-19 20:17 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Mark Rutland, Ulf Hansson, linux-mmc, Chris Ball,
	linux-arm-kernel, devicetree, Linus Walleij, Mark Brown,
	Arnd Bergmann, Alexandre Courbot, Arend van Spriel, Sascha Hauer,
	Olof Johansson, Hans de Goede, Doug Anderson, Tomeu Vizoso



On Fri, 16 Jan 2015 11:36:46 +0000 Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:

> On Fri, Jan 16, 2015 at 07:53:08AM +1300, NeilBrown wrote:
> > Also, it isn't clear to me whether the need for power/reset is a function of
> > the mmc-host, or a function of the device attached to the host.  I suspect
> > some are needed by one, some by the other.  Any by both?
> 
> Neil,
> 
> There's a horrid issue there.  The standard model of MMC/SD is that the
> device will be powered up by the host, and will then be probed to find
> out what the device is.  This normally works fine as the host is
> responsible for controlling the power to the socket which the card is
> plugged into.
> 
> Where things fall down is when you have a MMC/SD device embedded onto
> a board, and they decide that it'll be given separate controls for
> power and reset which are not under the control of the host.
> 
> If the MMC/SD device is not powered up before we probe the bus, then
> the device is not discoverable, and this breaks the standard model:
> - If we run the standard MMC/SD device discovery code with the device
>   powered down, it will find no device attached, so no device will be
>   created.
> 
> - If we create a device, then the device driver will be probed
>   immediately.  While the device driver can then bind, discover the
>   power and reset controls, and activate them, it can't then talk to
>   its device because the MMC layer hasn't gone through the required
>   standard device discovery and probe sequence.  If we could do that,
>   we would then need some way to stop that mechanism creating another
>   device.

Hi Russell,
 thanks for the overview - quite helpful.
 I would like to particularly focus on that last sentence mentioning
 "some way to stop [standard device discovery] creating another device".

 That way already exists, or something very similar to it, in the mmc/sdio
 core. In particular, the 'oldcard' argument to mmc_sdio_init_card().

 This is called both when initialising a card and when restoring power to it.
 If 'oldcard' is set and the card found matches 'oldcard', then 'oldcard' is
 left unchanged.  i.e. a new device is not created.

 Suppose that devicetree listed a child node for an mmc host with
 "non-removable" set, then we could do a preliminary probe which sets
 up host->card so that subsequent "standard" probes find the properly
 matching card and leave 'oldcard' unchanged.  This card could somehow
 register its own power-up sequence.

 In the case of 'non-removable' it might be nice to be much more cautious
 about clearing host->card when a probe fails.  One of the (many) problems I
 have on my device is that occasionally the probe of the mmc/sdio/wifi card
 fails (EBUSY I think, but I'm not sure and I have no idea why).  Once that
 happens, the wifi becomes inaccessible until a reboot. 

 As mmc_rescan ensures that a non-removable card is only scanned once, it
 would be really good if we were extra careful never to remove a
 non-removable card, even in the face of error...


> 
> If we instead take the view that the host is responsible for powering
> up the device, then we are merely keeping with the standard MMC/SD
> model, and we don't have to hack around his.
> 
> Keeping to the standard model of a host responsible for power control
> of its child devices is just a whole lot nicer.
> 

I'm not really against the proposed patch.  It should remove at least one of
my problems, and I don't think it makes any other problems more difficult.
So if the above ideas don't appeal to anyone else, I'll raise no further
objections.

Thanks,
NeilBrown



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-01-19 20:17 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 13:02 [PATCH V2 0/4] mmc: core: Add support for MMC power sequences Ulf Hansson
2015-01-14 13:02 ` [PATCH V2 1/4] mmc: core: Initial " Ulf Hansson
2015-01-14 13:02 ` [PATCH V2 2/4] mmc: pwrseq: Document DT bindings for the simple MMC power sequence Ulf Hansson
2015-01-15 16:58   ` Mark Rutland
2015-01-15 18:53     ` NeilBrown
     [not found]       ` <20150116075308.3f4e250a-wvvUuzkyo1EYVZTmpyfIwg@public.gmane.org>
2015-01-16  9:13         ` Ulf Hansson
2015-01-16 11:36         ` Russell King - ARM Linux
2015-01-16  8:47     ` Ulf Hansson
2015-01-14 13:02 ` [PATCH V2 3/4] mmc: pwrseq: Initial support for the simple MMC power sequence provider Ulf Hansson
2015-01-14 13:02 ` [PATCH V2 4/4] mmc: pwrseq_simple: Add support for a reset GPIO pin Ulf Hansson
2015-01-15 17:04   ` Mark Rutland
2015-01-16  8:44     ` Ulf Hansson
  -- strict thread matches above, loose matches on Subject: below --
2015-01-19 20:17 [PATCH V2 2/4] mmc: pwrseq: Document DT bindings for the simple MMC power sequence NeilBrown

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).