From: Ulf Hansson <ulf.hansson@linaro.org>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
Chris Ball <chris@printf.net>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Mark Brown <broonie@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
Alexandre Courbot <gnurou@gmail.com>,
Arend van Spriel <arend@broadcom.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Olof Johansson <olof@lixom.net>,
Hans de Goede <hdegoede@redhat.com>,
Doug Anderson <dianders@chromium.org>, NeilBrown <neilb@suse.de>
Subject: Re: [PATCH 0/4] mmc: core: Add support for MMC power sequences
Date: Tue, 13 Jan 2015 15:34:27 +0100 [thread overview]
Message-ID: <CAPDyKFr3bLxH5cUx_GF0VonmiM_Qy_xuaOc43=TMmZUnaoxE5A@mail.gmail.com> (raw)
In-Reply-To: <20150113142322.GQ12302@n2100.arm.linux.org.uk>
[...]
>>
>> Thanks a lot for elaborating! I understand your concern now.
>>
>> In this context, I believe it's important to state that I think these
>> host driver behaves badly! _All_ host drivers shall handle their
>> "power_up" things while they get MMC_POWER_UP through the ->set_ios()
>> callback. They shouldn't be taking short-cuts and ignore the
>> MMC_POWER_UP state, that also includes those host drivers which are
>> able to handle the power sequence by help from it's controller
>> hardware.
>
> You can't solve this in this way. Let's say that you decide to force
> the inteligent controllers to power up and enable clocks in the
> POWER_UP stage:
>
> pwrseq power sequence host action
>
> power_up no power applied
> POWER_UP host applies power to the card, waits,
> and applies the clock
>
> power_on power and clock is applied
> POWER_ON host does nothing
>
> So now, you have a variability for the power_on() callback, where with
> dumb hosts, the clock is not enabled, but for more inteligent hosts,
> the clock has already enabled, and likely we have already waited the
> 74 clocks necessary in the MMC protocol.
I understand, so I was not thinking of fixing the actual problem but
more to make the behaviour consistent.
>
>> I did quick research and found that the following host's ->set_ios()
>> callbacks need to be fixed in this regards.
>> au1xmmc_set_ios()
>> cb710_mmc_set_ios()
>> omap_hsmmc_set_ios()
>> sdricoh_set_ios()
>> __toshsd_set_ios()
>
> Rather than fixing them, how about introducing a new method for host
> controllers:
>
> power_up()
>
> which can be pointed to a library function which makes the ->set_ios
> calls as the current mmc_power_up() function does for those dumb
> controllers, but for the more inteligent controllers, just invokes
> their power up sequence and returns when that is complete.
Seems like a good idea!
>
>> > An alternative way to get consistency is to eliminate the pwrseq
>> > "power_on" callback altogether; the "power_up" callback will always
>> > be made before the host interface power sequence is started - and
>> > that is about the only thing we can guarantee given the variability
>> > in host interface designs.
>>
>> Eliminating is likely not an option, since it would mean we will have
>> a hard time to cope with requirements for the pwrseq sequences.
>>
>> An option would be to move the call to the pwrseq ->power_on()
>> callback to the end of mmc_power_up(). That would make it as
>> consistent as we can from mmc core point of view. Right?
>
> Yes, and you might as well call the pwrseq callbacks "->pre_power_on()"
> and "->post_power_on()" - maybe even "->post_pwrclk_on()" to make it
> clear that it happens after the power and clocks have been applied
> according to the MMC/SD protocol.
>
> What I'm envisioning mmc_power_up() becoming is something like this:
>
> void mmc_power_up(struct mmc_host *host, u32 ocr)
> {
> if (host->ios.power_mode == MMC_POWER_ON)
> return;
>
> mmc_host_clk_hold(host);
>
> if (pwrseq)
> pwrseq->pre_power_on(host);
>
> host->ios.vdd = fls(ocr) - 1;
> host->ios.clock = host->f_init;
> host->ios.power_mode = MMC_POWER_ON;
> /* and set remainder of initial state of host->ios */
>
> host->ops->power_up(host, &host->ios);
>
> if (pwrseq)
> pwrseq->post_power_on(host);
>
> mmc_host_clk_release(host);
> }
>
> The legacy power_up host method can save a copy host->ios, and manipulate
> the saved copy to call mmc_set_ios() as we currently do, with all the
> delays we have there.
>
Looks good!
I will rename the pwrseq callbacks to your proposal and send a v2.
Kind regards
Uffe
next prev parent reply other threads:[~2015-01-13 14:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-02 16:14 [PATCH 0/4] mmc: core: Add support for MMC power sequences Ulf Hansson
[not found] ` <1420215248-20650-1-git-send-email-ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-01-02 16:14 ` [PATCH 1/4] mmc: core: Initial " Ulf Hansson
2015-01-02 16:14 ` [PATCH 2/4] mmc: pwrseq: Document DT bindings for the simple MMC power sequence Ulf Hansson
2015-01-02 16:14 ` [PATCH 3/4] mmc: pwrseq: Initial support for the simple MMC power sequence provider Ulf Hansson
2015-01-02 16:14 ` [PATCH 4/4] mmc: pwrseq_simple: Add support for a reset GPIO pin Ulf Hansson
2015-01-02 18:14 ` [PATCH 0/4] mmc: core: Add support for MMC power sequences Russell King - ARM Linux
2015-01-04 19:20 ` Hans de Goede
2015-01-12 14:29 ` Ulf Hansson
[not found] ` <CAPDyKFpo=WpE3hDxqETVXOYX6pFsSmO7YybLJF=kJFyYFVcaoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-01-12 16:18 ` Russell King - ARM Linux
2015-01-13 14:08 ` Ulf Hansson
2015-01-13 14:23 ` Russell King - ARM Linux
2015-01-13 14:34 ` Ulf Hansson [this message]
2015-01-12 14:26 ` Tomeu Vizoso
2015-01-12 14:43 ` Ulf Hansson
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='CAPDyKFr3bLxH5cUx_GF0VonmiM_Qy_xuaOc43=TMmZUnaoxE5A@mail.gmail.com' \
--to=ulf.hansson@linaro.org \
--cc=arend@broadcom.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=chris@printf.net \
--cc=devicetree@vger.kernel.org \
--cc=dianders@chromium.org \
--cc=gnurou@gmail.com \
--cc=hdegoede@redhat.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=neilb@suse.de \
--cc=olof@lixom.net \
--cc=s.hauer@pengutronix.de \
/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).