From: Ulf Hansson <ulf.hansson@linaro.org>
To: Lars Persson <lars.persson@axis.com>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"Guennadi Liakhovetski" <g.liakhovetski@gmx.de>,
"Rob Herring" <robh+dt@kernel.org>,
"Paweł Moll" <pawel.moll@arm.com>,
"Mark Rutland" <mark.rutland@arm.com>,
"Ian Campbell" <ijc+devicetree@hellion.org.uk>,
"Kumar Gala" <galak@codeaurora.org>,
"Lars Persson" <larper@axis.com>
Subject: Re: [PATCH v2 3/3] mmc: usdhi6rol0: add pinctrl to set pin drive strength
Date: Tue, 19 Apr 2016 11:45:44 +0200 [thread overview]
Message-ID: <CAPDyKFo60PBkOtLRyuDBHVh+LB_d0vcATSuTMu4TWeLsWgQVSw@mail.gmail.com> (raw)
In-Reply-To: <181127e4ec8bbfbf0f80018ff157b59d63597c44.1460986983.git.larper@axis.com>
On 18 April 2016 at 15:44, Lars Persson <lars.persson@axis.com> wrote:
> Some boards need different pin drive strength for the UHS mode. Add an
> optional pinctrl setting with two pin states covering UHS speeds and
> other speeds.
>
> Signed-off-by: Lars Persson <larper@axis.com>
> ---
> drivers/mmc/host/usdhi6rol0.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c
> index 2585ea4..e8a5c8f 100644
> --- a/drivers/mmc/host/usdhi6rol0.c
> +++ b/drivers/mmc/host/usdhi6rol0.c
> @@ -22,6 +22,7 @@
> #include <linux/mmc/sdio.h>
> #include <linux/module.h>
> #include <linux/pagemap.h>
> +#include <linux/pinctrl/consumer.h>
> #include <linux/platform_device.h>
> #include <linux/scatterlist.h>
> #include <linux/string.h>
> @@ -198,6 +199,11 @@ struct usdhi6_host {
> struct dma_chan *chan_rx;
> struct dma_chan *chan_tx;
> bool dma_active;
> +
> + /* Pin control */
> + struct pinctrl *pinctrl;
> + struct pinctrl_state *pins_default;
> + struct pinctrl_state *pins_uhs;
> };
>
> /* I/O primitives */
> @@ -1147,14 +1153,39 @@ static void usdhi6_enable_sdio_irq(struct mmc_host *mmc, int enable)
> }
> }
>
> +static int usdhi6_set_pinstates(struct usdhi6_host *host, int voltage)
> +{
> + if (IS_ERR(host->pinctrl) || IS_ERR(host->pins_default) ||
> + IS_ERR(host->pins_uhs))
So this means, if you have UHS support you need both default and uhs
pins. That makes sense but it's not according to the DT documentation
in patch 1/3.
> + return 0;
> +
> + switch (voltage) {
> + case MMC_SIGNAL_VOLTAGE_180:
> + case MMC_SIGNAL_VOLTAGE_120:
> + return pinctrl_select_state(host->pinctrl,
> + host->pins_uhs);
> +
> + default:
> + return pinctrl_select_state(host->pinctrl,
> + host->pins_default);
> + }
> +}
> +
> static int usdhi6_sig_volt_switch(struct mmc_host *mmc, struct mmc_ios *ios)
> {
> int ret;
>
> ret = mmc_regulator_set_vqmmc(mmc, ios);
What if you don't have pins for default and uhs state? Should you
verify that's the case before deciding to switch voltage?
>
> - if (ret < 0)
> + if (ret < 0) {
> dev_warn(mmc_dev(mmc), "Voltage switch failed: %d\n", ret);
> + return ret;
> + }
> +
> + ret = usdhi6_set_pinstates(mmc_priv(mmc), ios->signal_voltage);
> + if (ret)
> + dev_warn_once(mmc_dev(mmc),
> + "Failed to set pinstate err=%d\n", ret);
>
> return ret;
> }
> @@ -1817,6 +1848,13 @@ static int usdhi6_probe(struct platform_device *pdev)
> mmc->f_max = host->imclk;
> mmc->f_min = host->imclk / 512;
>
> + host->pinctrl = devm_pinctrl_get(&pdev->dev);
> + if (!IS_ERR(host->pinctrl)) {
> + host->pins_default = pinctrl_lookup_state(host->pinctrl,
> + PINCTRL_STATE_DEFAULT);
According to the DT documentation in patch 1/3, the default pins
should be required and not optional. I assume you want them to be
optional, but required when supporting UHS, right?
> + host->pins_uhs = pinctrl_lookup_state(host->pinctrl,
> + "pins_uhs");
> + }
> platform_set_drvdata(pdev, host);
>
> ret = mmc_add_host(mmc);
> --
> 2.1.4
>
Kind regards
Uffe
next prev parent reply other threads:[~2016-04-19 9:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 13:44 [PATCH v2 0/3] mmc: usdhi6rol0: UHS support Lars Persson
[not found] ` <cover.1460986983.git.larper-VrBV9hrLPhE@public.gmane.org>
2016-04-18 13:44 ` [PATCH v2 1/3] mmc: dt: usdhi6rol0: add optional pinctrl binding Lars Persson
2016-04-19 9:43 ` Ulf Hansson
2016-04-18 13:44 ` [PATCH v2 2/3] mmc: usdhi6rol0: add support for UHS modes Lars Persson
2016-04-18 13:44 ` [PATCH v2 3/3] mmc: usdhi6rol0: add pinctrl to set pin drive strength Lars Persson
2016-04-19 9:45 ` Ulf Hansson [this message]
2016-04-19 10:10 ` Lars Persson
2016-04-20 12:15 ` Ulf Hansson
[not found] ` <CAPDyKFoV7h73K+7HhkdS7BC1RUAo3dcum_+cRikY=_F2YBeNSA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-04-20 13:41 ` Lars Persson
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=CAPDyKFo60PBkOtLRyuDBHVh+LB_d0vcATSuTMu4TWeLsWgQVSw@mail.gmail.com \
--to=ulf.hansson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=g.liakhovetski@gmx.de \
--cc=galak@codeaurora.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=larper@axis.com \
--cc=lars.persson@axis.com \
--cc=linux-mmc@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
/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).