linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Balaji T K <balajitk@ti.com>
Cc: linux-omap <linux-omap@vger.kernel.org>,
	Benoit Cousson <bcousson@baylibre.com>,
	devicetree@vger.kernel.org, linux-mmc <linux-mmc@vger.kernel.org>,
	Chris Ball <cjb@laptop.org>, Mark Brown <broonie@kernel.org>,
	Tony Lindgren <tony@atomide.com>
Subject: Re: [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently
Date: Wed, 11 Dec 2013 12:21:11 +0100	[thread overview]
Message-ID: <CAPDyKFpERuDx_9qdbuC5z7NGbt-BEydR=qxiPrS2Qdvapd-0pw@mail.gmail.com> (raw)
In-Reply-To: <52A6FF84.40901@ti.com>

On 10 December 2013 12:48, Balaji T K <balajitk@ti.com> wrote:
> On Tuesday 10 December 2013 04:39 PM, Ulf Hansson wrote:
>>
>> On 21 November 2013 15:20, Balaji T K <balajitk@ti.com> wrote:
>>>
>>> handle vcc and vcc_aux independently to reduce indent.
>>>
>>> Signed-off-by: Balaji T K <balajitk@ti.com>
>>> ---
>>>   drivers/mmc/host/omap_hsmmc.c |   54
>>> +++++++++++++++++++----------------------
>>>   1 files changed, 25 insertions(+), 29 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/omap_hsmmc.c
>>> b/drivers/mmc/host/omap_hsmmc.c
>>> index 1eb4350..342be25 100644
>>> --- a/drivers/mmc/host/omap_hsmmc.c
>>> +++ b/drivers/mmc/host/omap_hsmmc.c
>>> @@ -286,11 +286,12 @@ static int omap_hsmmc_set_power(struct device *dev,
>>> int slot, int power_on,
>>>           * chips/cards need an interface voltage rail too.
>>>           */
>>>          if (power_on) {
>>> -               ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
>>> +               if (host->vcc)
>>> +                       ret = mmc_regulator_set_ocr(host->mmc, host->vcc,
>>> vdd);
>>>                  /* Enable interface voltage rail, if needed */
>>>                  if (ret == 0 && host->vcc_aux) {
>>>                          ret = regulator_enable(host->vcc_aux);
>>> -                       if (ret < 0)
>>> +                       if (ret < 0 && host->vcc)
>>>                                  ret = mmc_regulator_set_ocr(host->mmc,
>>>                                                          host->vcc, 0);
>>>                  }
>>> @@ -298,7 +299,7 @@ static int omap_hsmmc_set_power(struct device *dev,
>>> int slot, int power_on,
>>>                  /* Shut down the rail */
>>>                  if (host->vcc_aux)
>>>                          ret = regulator_disable(host->vcc_aux);
>>> -               if (!ret) {
>>> +               if (host->vcc) {
>>>                          /* Then proceed to shut down the local regulator
>>> */
>>>                          ret = mmc_regulator_set_ocr(host->mmc,
>>>                                                  host->vcc, 0);
>>> @@ -318,10 +319,10 @@ static int omap_hsmmc_reg_get(struct
>>> omap_hsmmc_host *host)
>>>
>>>          reg = devm_regulator_get(host->dev, "vmmc");
>>>          if (IS_ERR(reg)) {
>>> -               dev_err(host->dev, "vmmc regulator missing\n");
>>> +               dev_err(host->dev, "unable to get vmmc regulator %ld\n",
>>> +                       PTR_ERR(reg));
>>>                  return PTR_ERR(reg);
>>>          } else {
>>> -               mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>                  host->vcc = reg;
>>>                  ocr_value = mmc_regulator_get_ocrmask(reg);
>>>                  if (!mmc_slot(host).ocr_mask) {
>>> @@ -334,31 +335,26 @@ static int omap_hsmmc_reg_get(struct
>>> omap_hsmmc_host *host)
>>>                                  return -EINVAL;
>>>                          }
>>>                  }
>>> +       }
>>> +       mmc_slot(host).set_power = omap_hsmmc_set_power;
>>>
>>> -               /* Allow an aux regulator */
>>> -               reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>> -               host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>> +       /* Allow an aux regulator */
>>> +       reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
>>> +       host->vcc_aux = IS_ERR(reg) ? NULL : reg;
>>>
>>> -               /* For eMMC do not power off when not in sleep state */
>>> -               if (mmc_slot(host).no_regulator_off_init)
>>> -                       return 0;
>>> -               /*
>>> -               * UGLY HACK:  workaround regulator framework bugs.
>>> -               * When the bootloader leaves a supply active, it's
>>> -               * initialized with zero usecount ... and we can't
>>> -               * disable it without first enabling it.  Until the
>>> -               * framework is fixed, we need a workaround like this
>>> -               * (which is safe for MMC, but not in general).
>>> -               */
>>
>>
>> The above problem is handled by the mmc core layer. I certainly think
>> you shall adopt your code to it.
>
> Hi Ulf,
>
> how about optional vqmmc, omap_hsmmc does call mmc_regulator_set_ocr for
> vmmc
> Am I missing something?

Hi Balaji,

Sorry for being to vague, let me elaborate.

1. Before omap_hsmmc_probe returns, it invokes mmc_add_host().

2. mmc_add_host() -> mmc_start_host() -> > mmc_power_up().

3. mmc_power_up() invokes the host driver's .set_ios() callback, to
makes sure boot-on regulators are kept enabled. Otherwise the
late_initcall, regulator_init_complete() will potentially cut power
for unused regulators.

This is important because there are SoCs that are only capable of
power cycling the VCC regulator but not VCCQ. According to the eMMC
spec, we must not cut VCC without sending the SLEEP cmd first.
Obviously, since we prevent VCC from being cut, we need to prevent
VCCQ from being cut as well.

Normally a .set_ios() function's invokes mmc_regulator_set_ocr() for
the VCC regulator. VCCQ ("vmmc_aux") is handled by directly using the
regulator API (I guess we could invent an API similar to
mmc_regulator_set_ocr() but for VCCQ, but that is a future task).

So, from a host driver perspective you could add a local variable to
cache the "enabled" state of the VCCQ regulator. By leaving the
default state to "disabled", you will trigger it to be enabled once
mmc_power_up() invokes your .set_ios() callback. Vice verse will then
happen when mmc_power_off gets invoked.

Finally, don't forget to enable MMC_CAP2_FULL_PWR_CYCLE, if your SoC
can cut both VCC and VCCQ for your eMMC slots. For SD cards only VCC
should be needed to enable MMC_CAP2_FULL_PWR_CYCLE.

Kind regards
Ulf Hansson


>
>
>>
>> Kind regards
>> Ulf Hansson
>>
>>> -               if (regulator_is_enabled(host->vcc) > 0 ||
>>> -                   (host->vcc_aux &&
>>> regulator_is_enabled(host->vcc_aux))) {
>>> -                       int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>> +       /* For eMMC do not power off when not in sleep state */
>>> +       if (mmc_slot(host).no_regulator_off_init)
>>> +               return 0;
>>> +       /*
>>> +        * To disable boot_on regulator, enable regulator
>>> +        * to increase usecount and then disable it.
>>> +        */
>>> +       if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
>>> +           (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
>>> +               int vdd = ffs(mmc_slot(host).ocr_mask) - 1;
>>>
>>> -                       mmc_slot(host).set_power(host->dev,
>>> host->slot_id,
>>> -                                                1, vdd);
>>> -                       mmc_slot(host).set_power(host->dev,
>>> host->slot_id,
>>> -                                                0, 0);
>>> -               }
>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 1,
>>> vdd);
>>> +               mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
>>>          }
>>>
>>>          return 0;
>>> --
>>> 1.7.5.4
>>>
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>

  reply	other threads:[~2013-12-11 11:21 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-30 14:03 [PATCH 00/13] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
2013-04-30 14:03 ` [PATCH 01/13] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
2013-04-30 14:03 ` [PATCH 02/13] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
2013-04-30 14:03 ` [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc Balaji T K
2013-04-30 14:03 ` [PATCH 04/13] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
2013-04-30 14:03 ` [PATCH 05/13] mmc: omap_hsmmc: remove use_reg Balaji T K
2013-04-30 14:03 ` [PATCH 06/13] mmc: omap_hsmmc: add dt pbias and control mmc support Balaji T K
2013-05-16 16:16   ` Tony Lindgren
2013-05-23 16:07     ` Balaji T K
2013-05-23 18:40       ` Tony Lindgren
2013-06-06 19:14         ` [PATCH v2 00/10] mmc: omap_hsmmc: dt pbias and regulator voltage switch Balaji T K
2013-06-06 19:14           ` [PATCH v2 01/10] ARM: OMAP2+: add needs_vmmc to hsmmc_info Balaji T K
2013-06-12 14:24             ` Tony Lindgren
     [not found]               ` <20130612142409.GW8164-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2013-06-12 17:00                 ` Balaji T K
2013-06-06 19:14           ` [PATCH v2 02/10] mmc: omap_hsmmc: make vcc and vcc_aux independent Balaji T K
2013-06-12 14:25             ` Tony Lindgren
2013-06-12 14:33               ` Balaji T K
2013-06-12 14:38                 ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 03/10] mmc: omap_hsmmc: use needs_vmmc Balaji T K
2013-06-06 19:14           ` [PATCH v2 04/10] mmc: omap_hsmmc: update needs_vmmc for dt Balaji T K
2013-06-06 19:14           ` [PATCH v2 05/10] mmc: omap_hsmmc: remove use_reg Balaji T K
2013-06-06 19:14           ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Balaji T K
2013-06-12 14:37             ` Tony Lindgren
2013-06-12 17:46               ` Balaji T K
2013-06-13  9:38               ` Linus Walleij
2013-06-13  9:37             ` Linus Walleij
2013-06-13  9:53               ` Tony Lindgren
2013-06-13 10:02                 ` Laurent Pinchart
2013-06-13 14:52                   ` Balaji T K
2013-06-13 14:53                     ` Laurent Pinchart
2013-06-13 12:39                 ` Linus Walleij
2013-06-13 14:41                 ` Balaji T K
2013-06-13 15:29                   ` Linus Walleij
     [not found]                     ` <CACRpkdY6cZ+bT-C9Go3sZVw6ErQqTm0m9__uKQrkg4eUU1thHA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-06-13 16:29                       ` Tony Lindgren
2013-06-13 17:45                         ` Mark Brown
2013-11-21 14:20                           ` [RFC PATCH v3 0/8] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 1/8] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-11-21 15:08                               ` Ulf Hansson
2013-12-05 15:29                                 ` Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 2/8] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-10 11:09                               ` Ulf Hansson
2013-12-10 11:48                                 ` Balaji T K
2013-12-11 11:21                                   ` Ulf Hansson [this message]
2013-12-18 14:52                                     ` Balaji T K
     [not found]                             ` <1385043627-30439-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-11-21 14:20                               ` [RFC PATCH v3 3/8] regulator: add pbias regulator support Balaji T K
2013-11-21 14:46                                 ` Mark Brown
2013-12-03 15:54                                   ` Balaji T K
2013-12-03 16:06                                     ` Mark Brown
2013-11-21 14:20                             ` [RFC PATCH v3 4/8] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 5/8] ARM: dts: add pbias dt node Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 6/8] ARM: dts: add pbias-supply Balaji T K
2013-11-21 17:03                               ` Tony Lindgren
2013-12-05 14:55                                 ` Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 7/8] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-11-21 14:20                             ` [RFC PATCH v3 8/8] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-12-10 10:16                             ` [PATCH v4 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-12-10 10:16                               ` [PATCH v4 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-12-10 10:16                               ` [PATCH v4 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-10 10:16                               ` [PATCH v4 3/7] regulator: add pbias regulator support Balaji T K
2013-12-10 10:40                                 ` Mark Brown
2013-12-10 12:22                                   ` Balaji T K
2013-12-10 14:34                                   ` [PATCH v5 " Balaji T K
2013-12-10 18:33                                     ` Tony Lindgren
2013-12-10 22:39                                       ` Tony Lindgren
2013-12-12 15:12                                       ` Balaji T K
2013-12-11 22:46                                     ` Mark Brown
2013-12-10 10:16                               ` [PATCH v4 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-12-10 10:16                               ` [PATCH v4 5/7] ARM: dts: add pbias dt node Balaji T K
2013-12-10 22:42                                 ` Tony Lindgren
2013-12-12 14:58                                   ` Balaji T K
2013-12-10 10:16                               ` [PATCH v4 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-12-10 10:16                               ` [PATCH v4 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-12-19 12:38                               ` [PATCH v6 0/7] mmc: omap_hsmmc: pbias dt and cleanup Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 1/7] mmc: omap_hsmmc: use devm_regulator API Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 2/7] mmc: omap_hsmmc: handle vcc and vcc_aux independently Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 3/7] regulator: add pbias regulator support Balaji T K
     [not found]                                   ` <1387456720-7202-4-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-12-19 12:51                                     ` Mark Brown
2013-12-19 16:33                                   ` Tony Lindgren
2013-12-20  9:47                                     ` Balaji T K
2013-12-20 15:57                                       ` Tony Lindgren
2013-12-20 16:09                                         ` Mark Brown
2013-12-20 16:13                                           ` Tony Lindgren
2013-12-20 16:44                                             ` Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 4/7] mmc: omap_hsmmc: adapt hsmmc to use pbias regulator Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 5/7] ARM: dts: add pbias dt node Balaji T K
2013-12-19 16:33                                   ` Tony Lindgren
2013-12-20 11:40                                     ` Balaji T K
2013-12-20 15:58                                       ` Tony Lindgren
2013-12-20 16:08                                         ` Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 6/7] ARM: OMAP: enable SYSCON and REGULATOR_PBIAS in omap2plus_defconfig Balaji T K
2013-12-19 12:38                                 ` [PATCH v6 7/7] mmc: omap_hsmmc: remove pbias workaround Balaji T K
2013-06-13 10:47               ` [PATCH v2 06/10] mmc: omap_hsmmc: add support for pbias configuration in dt Lee Jones
2013-06-13 15:01                 ` Balaji T K
2013-06-13 16:17                   ` Lee Jones
2013-06-06 19:14           ` [PATCH v2 07/10] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
     [not found]           ` <1370546059-24181-1-git-send-email-balajitk-l0cyMroinI0@public.gmane.org>
2013-06-06 19:14             ` [PATCH v2 08/10] ARM: dts: omap3: split omap3_pmx_core Balaji T K
2013-06-12 14:35               ` Tony Lindgren
2013-06-12 17:08                 ` Balaji T K
2013-06-12 17:54                   ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 09/10] ARM: dts: omap3: add pbias and mmc_init pinctrl states Balaji T K
2013-06-12 14:35             ` Tony Lindgren
2013-06-12 17:43               ` Balaji T K
2013-06-12 17:50                 ` Tony Lindgren
2013-06-06 19:14           ` [PATCH v2 10/10] ARM: dts: omap4: " Balaji T K
2013-06-12 14:36             ` Tony Lindgren
2013-04-30 14:03 ` [PATCH 07/13] mmc: omap_hsmmc: remove dt pbias workaround Balaji T K
2013-04-30 14:03 ` [PATCH 08/13] Documentation: dt: mmc: omap hsmmc Balaji T K
2013-04-30 14:03 ` [PATCH 09/13] ARM: dts: omap3: Add omap control mmc data Balaji T K
2013-04-30 14:03 ` [PATCH 10/13] ARM: dts: omap36xx: " Balaji T K
2013-04-30 14:03 ` [PATCH 11/13] ARM: dts: omap4: " Balaji T K
2013-04-30 14:03 ` [PATCH 12/13] ARM: dts: omap5: " Balaji T K
2013-04-30 14:03 ` [PATCH 13/13] ARM: dts: am3517: add omap_control_mmc Balaji T K

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='CAPDyKFpERuDx_9qdbuC5z7NGbt-BEydR=qxiPrS2Qdvapd-0pw@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=balajitk@ti.com \
    --cc=bcousson@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=cjb@laptop.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=tony@atomide.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).