From: Ben Hutchings <ben.hutchings@codethink.co.uk> To: Ian Molton <ian@mnementh.co.uk>, Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: linux-mmc@vger.kernel.org, linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>, Simon Horman <horms@verge.net.au>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Subject: [PATCH v4 6/8] mmc: sh_mobile_sdhi: Add UHS-I mode support Date: Tue, 30 Jun 2015 16:57:07 +0000 [thread overview] Message-ID: <1435683427.23818.68.camel@codethink.co.uk> (raw) In-Reply-To: <1435683177.23818.60.camel@codethink.co.uk> Implement voltage switch, supporting modes up to SDR-50. Based on work by Shinobu Uehara, Rob Taylor, William Towle and Ian Molton. Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> --- drivers/mmc/host/sh_mobile_sdhi.c | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 6ed36b984e6e..76899b90946e 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -30,6 +30,9 @@ #include <linux/mfd/tmio.h> #include <linux/sh_dma.h> #include <linux/delay.h> +#include <linux/pinctrl/consumer.h> +#include <linux/pinctrl/pinctrl-state.h> +#include <linux/regulator/consumer.h> #include "tmio_mmc.h" @@ -86,6 +89,8 @@ struct sh_mobile_sdhi { struct clk *clk; struct tmio_mmc_data mmc_data; struct tmio_mmc_dma dma_priv; + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_3v3, *pinctrl_1v8; }; static void sh_mobile_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width) @@ -185,6 +190,49 @@ static void sh_mobile_sdhi_clk_disable(struct tmio_mmc_host *host) clk_disable_unprepare(priv->clk); } +static int sh_mobile_sdhi_start_signal_voltage_switch( + struct tmio_mmc_host *host, unsigned char signal_voltage) +{ + struct sh_mobile_sdhi *priv = host_to_priv(host); + struct pinctrl_state *state; + int min_uV, max_uV; + int ret; + + switch (signal_voltage) { + case MMC_SIGNAL_VOLTAGE_330: + min_uV = 2700000; + max_uV = 3600000; + state = priv->pinctrl_3v3; + break; + case MMC_SIGNAL_VOLTAGE_180: + min_uV = 1700000; + max_uV = 1950000; + state = priv->pinctrl_1v8; + break; + default: + return -EINVAL; + } + + /* + * If anything is missing, assume signal voltage is fixed at + * 3.3V and succeed/fail accordingly. + */ + if (IS_ERR(host->mmc->supply.vqmmc) || + IS_ERR(priv->pinctrl) || IS_ERR(state)) + return signal_voltage = MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL; + + ret = regulator_set_voltage(host->mmc->supply.vqmmc, min_uV, max_uV); + if (ret) + return ret; + + ret = pinctrl_select_state(priv->pinctrl, state); + if (ret) + return ret; + + usleep_range(5000, 5500); + return 0; +} + static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) { int timeout = 1000; @@ -277,6 +325,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) goto eprobe; } + priv->pinctrl = devm_pinctrl_get(&pdev->dev); + if (!IS_ERR(priv->pinctrl)) { + priv->pinctrl_3v3 = pinctrl_lookup_state(priv->pinctrl, + PINCTRL_STATE_DEFAULT); + priv->pinctrl_1v8 = pinctrl_lookup_state(priv->pinctrl, + "1v8"); + } + host = tmio_mmc_host_alloc(pdev); if (!host) { ret = -ENOMEM; @@ -289,6 +345,10 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) host->clk_update = sh_mobile_sdhi_clk_update; host->clk_disable = sh_mobile_sdhi_clk_disable; host->multi_io_quirk = sh_mobile_sdhi_multi_io_quirk; + + host->start_signal_voltage_switch + = sh_mobile_sdhi_start_signal_voltage_switch; + /* SD control register space size is 0x100, 0x200 for bus_shift=1 */ if (resource_size(res) > 0x100) host->bus_shift = 1; -- 2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: Ben Hutchings <ben.hutchings@codethink.co.uk> To: Ian Molton <ian@mnementh.co.uk>, Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: linux-mmc@vger.kernel.org, linux-sh@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@lists.codethink.co.uk, Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>, Simon Horman <horms@verge.net.au>, Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Subject: [PATCH v4 6/8] mmc: sh_mobile_sdhi: Add UHS-I mode support Date: Tue, 30 Jun 2015 17:57:07 +0100 [thread overview] Message-ID: <1435683427.23818.68.camel@codethink.co.uk> (raw) In-Reply-To: <1435683177.23818.60.camel@codethink.co.uk> Implement voltage switch, supporting modes up to SDR-50. Based on work by Shinobu Uehara, Rob Taylor, William Towle and Ian Molton. Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk> --- drivers/mmc/host/sh_mobile_sdhi.c | 60 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 6ed36b984e6e..76899b90946e 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c @@ -30,6 +30,9 @@ #include <linux/mfd/tmio.h> #include <linux/sh_dma.h> #include <linux/delay.h> +#include <linux/pinctrl/consumer.h> +#include <linux/pinctrl/pinctrl-state.h> +#include <linux/regulator/consumer.h> #include "tmio_mmc.h" @@ -86,6 +89,8 @@ struct sh_mobile_sdhi { struct clk *clk; struct tmio_mmc_data mmc_data; struct tmio_mmc_dma dma_priv; + struct pinctrl *pinctrl; + struct pinctrl_state *pinctrl_3v3, *pinctrl_1v8; }; static void sh_mobile_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width) @@ -185,6 +190,49 @@ static void sh_mobile_sdhi_clk_disable(struct tmio_mmc_host *host) clk_disable_unprepare(priv->clk); } +static int sh_mobile_sdhi_start_signal_voltage_switch( + struct tmio_mmc_host *host, unsigned char signal_voltage) +{ + struct sh_mobile_sdhi *priv = host_to_priv(host); + struct pinctrl_state *state; + int min_uV, max_uV; + int ret; + + switch (signal_voltage) { + case MMC_SIGNAL_VOLTAGE_330: + min_uV = 2700000; + max_uV = 3600000; + state = priv->pinctrl_3v3; + break; + case MMC_SIGNAL_VOLTAGE_180: + min_uV = 1700000; + max_uV = 1950000; + state = priv->pinctrl_1v8; + break; + default: + return -EINVAL; + } + + /* + * If anything is missing, assume signal voltage is fixed at + * 3.3V and succeed/fail accordingly. + */ + if (IS_ERR(host->mmc->supply.vqmmc) || + IS_ERR(priv->pinctrl) || IS_ERR(state)) + return signal_voltage == MMC_SIGNAL_VOLTAGE_330 ? 0 : -EINVAL; + + ret = regulator_set_voltage(host->mmc->supply.vqmmc, min_uV, max_uV); + if (ret) + return ret; + + ret = pinctrl_select_state(priv->pinctrl, state); + if (ret) + return ret; + + usleep_range(5000, 5500); + return 0; +} + static int sh_mobile_sdhi_wait_idle(struct tmio_mmc_host *host) { int timeout = 1000; @@ -277,6 +325,14 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) goto eprobe; } + priv->pinctrl = devm_pinctrl_get(&pdev->dev); + if (!IS_ERR(priv->pinctrl)) { + priv->pinctrl_3v3 = pinctrl_lookup_state(priv->pinctrl, + PINCTRL_STATE_DEFAULT); + priv->pinctrl_1v8 = pinctrl_lookup_state(priv->pinctrl, + "1v8"); + } + host = tmio_mmc_host_alloc(pdev); if (!host) { ret = -ENOMEM; @@ -289,6 +345,10 @@ static int sh_mobile_sdhi_probe(struct platform_device *pdev) host->clk_update = sh_mobile_sdhi_clk_update; host->clk_disable = sh_mobile_sdhi_clk_disable; host->multi_io_quirk = sh_mobile_sdhi_multi_io_quirk; + + host->start_signal_voltage_switch + = sh_mobile_sdhi_start_signal_voltage_switch; + /* SD control register space size is 0x100, 0x200 for bus_shift=1 */ if (resource_size(res) > 0x100) host->bus_shift = 1; -- 2.1.4
next prev parent reply other threads:[~2015-06-30 16:57 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-06-30 16:52 [PATCH v4 0/8] UHS-I support for sh_mobile_sdhi Ben Hutchings 2015-06-30 16:52 ` Ben Hutchings 2015-06-30 16:53 ` [PATCH v4 1/8] pinctrl: sh-pfc: Implement pinconf power-source param for voltage switching Ben Hutchings 2015-06-30 16:53 ` Ben Hutchings 2015-07-01 7:24 ` Laurent Pinchart 2015-07-01 7:24 ` Laurent Pinchart 2015-08-24 8:45 ` Linus Walleij 2015-08-24 8:45 ` Linus Walleij 2015-06-30 16:54 ` [PATCH v4 2/8] pinctrl: sh-pfc: r8a7790: Implement voltage switching for SDHI Ben Hutchings 2015-06-30 16:54 ` Ben Hutchings 2015-07-01 7:37 ` Laurent Pinchart 2015-07-01 7:37 ` Laurent Pinchart 2015-07-02 23:21 ` Ben Hutchings 2015-07-02 23:21 ` Ben Hutchings 2015-07-09 12:34 ` Ben Hutchings 2015-07-09 12:34 ` Ben Hutchings 2015-11-13 8:38 ` Kuninori Morimoto 2015-11-13 8:38 ` Kuninori Morimoto 2016-02-03 9:59 ` Laurent Pinchart 2016-02-03 9:59 ` Laurent Pinchart 2016-02-11 13:53 ` Wolfram Sang 2016-02-11 13:53 ` Wolfram Sang 2015-06-30 16:54 ` [PATCH v4 3/8] mmc: tmio, sh_mobile_sdhi: Pass tmio_mmc_host ptr to clk_{enable,disable} ops Ben Hutchings 2015-06-30 16:54 ` Ben Hutchings 2015-06-30 16:56 ` [PATCH v4 4/8] mmc: tmio, sh_mobile_sdhi: Add support for variable input clock frequency Ben Hutchings 2015-06-30 16:56 ` Ben Hutchings 2015-06-30 16:56 ` [PATCH v4 5/8] mmc: tmio: Add UHS-I mode support Ben Hutchings 2015-06-30 16:56 ` Ben Hutchings 2015-06-30 16:57 ` Ben Hutchings [this message] 2015-06-30 16:57 ` [PATCH v4 6/8] mmc: sh_mobile_sdhi: " Ben Hutchings 2015-06-30 16:57 ` [PATCH v4 7/8] ARM: shmobile: r8a7790: Set maximum frequencies for SDHI clocks Ben Hutchings 2015-06-30 16:57 ` Ben Hutchings 2015-07-07 0:39 ` Simon Horman 2015-07-07 0:39 ` Simon Horman 2015-07-07 1:19 ` Kuninori Morimoto 2015-07-07 1:19 ` Kuninori Morimoto 2015-07-08 1:25 ` Simon Horman 2015-07-08 1:25 ` Simon Horman 2015-07-07 1:19 ` Kuninori Morimoto 2015-07-07 1:19 ` Kuninori Morimoto 2015-06-30 16:57 ` [PATCH v4 8/8] ARM: shmobile: lager: Enable UHS-I SDR-50 Ben Hutchings 2015-06-30 16:57 ` Ben Hutchings 2015-07-01 0:28 ` [PATCH v4 0/8] UHS-I support for sh_mobile_sdhi Kuninori Morimoto 2015-07-01 0:28 ` Kuninori Morimoto
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=1435683427.23818.68.camel@codethink.co.uk \ --to=ben.hutchings@codethink.co.uk \ --cc=horms@verge.net.au \ --cc=ian@mnementh.co.uk \ --cc=kuninori.morimoto.gx@renesas.com \ --cc=laurent.pinchart@ideasonboard.com \ --cc=linux-gpio@vger.kernel.org \ --cc=linux-kernel@lists.codethink.co.uk \ --cc=linux-mmc@vger.kernel.org \ --cc=linux-sh@vger.kernel.org \ --cc=sergei.shtylyov@cogentembedded.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.