From: Doug Anderson <dianders@chromium.org> To: Ulf Hansson <ulf.hansson@linaro.org>, Mark Brown <broonie@kernel.org>, Heiko Stuebner <heiko@sntech.de>, Jaehoon Chung <jh80.chung@samsung.com>, Seungwon Jeon <tgih.jun@samsung.com> Cc: Alexandru Stan <amstan@chromium.org>, Alim Akhtar <alim.akhtar@samsung.com>, Sonny Rao <sonnyrao@chromium.org>, Andrew Bresticker <abrestic@chromium.org>, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, Doug Anderson <dianders@chromium.org>, chris@printf.net, johan.rudholm@axis.com, tim.kryger@gmail.com, adrian.hunter@intel.com, andrew_gabbasov@mentor.com, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] mmc: core: Add mmc_regulator_set_vqmmc() Date: Wed, 10 Dec 2014 12:58:03 -0800 [thread overview] Message-ID: <1418245085-9754-2-git-send-email-dianders@chromium.org> (raw) In-Reply-To: <1418245085-9754-1-git-send-email-dianders@chromium.org> This adds logic to the MMC core to set VQMMC. This is expected to be called by MMC drivers like dw_mmc as part of (or instead of) their start_signal_voltage_switch() callback. A few notes: * When setting the signal voltage to 3.3V we do our best to make VQMMC and VMMC match. It's been reported that this makes some old cards happy since they were tested back in the day before UHS when VQMMC and VMMC were provided by the same regulator. A nice side effect of this is that we don't end up on the hairy edge of VQMMC (2.7V), which some EEs claim is a little too close to the minimum for comfort. * When setting the signal voltage to 1.8V or 1.2V we aim for that specific voltage instead of picking the lowest one in the range. * We very purposely don't print errors in mmc_regulator_set_vqmmc(). There are cases where the MMC core will try several different voltages and we don't want to pollute the logs. Signed-off-by: Doug Anderson <dianders@chromium.org> --- drivers/mmc/core/core.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 7 +++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 9584bff..d0da480 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1333,6 +1333,59 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, } EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); +static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator, + int min_uV, int ideal_uV, + int max_uV) +{ + /* + * Check if supported first to avoid errors since we may try several + * signal levels during power up and don't want to show errors. + */ + if (!regulator_is_supported_voltage(regulator, min_uV, max_uV)) + return -EINVAL; + + return regulator_set_closest_voltage(regulator, min_uV, ideal_uV, + max_uV); +} + +/** + * mmc_regulator_set_vqmmc - Set VQMMC as per the ios + * + * For 3.3V signaling, we try to match vqmmc to vmmc as closely as possible. + * That will match the behavior of old boards where vqmmc and vmmc were supplied + * by the same supply. + * + * For 1.2V and 1.8V signaling we'll try to get as close as possible to the + * requested voltage. This is definitely a good idea for UHS where there's a + * separate regulator on the card that's trying to make 1.8V and it's best if + * we match. + * + * This function is expected to be used by a controller's + * start_signal_voltage_switch() function. + */ +int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios) +{ + /* If no vqmmc supply then we can't change the voltage */ + if (IS_ERR(mmc->supply.vqmmc)) + return -EINVAL; + + switch (ios->signal_voltage) { + case MMC_SIGNAL_VOLTAGE_120: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 1100000, 1200000, 1300000); + case MMC_SIGNAL_VOLTAGE_180: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 1700000, 1800000, 1950000); + case MMC_SIGNAL_VOLTAGE_330: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 2700000, + regulator_get_voltage(mmc->supply.vmmc), 3600000); + default: + return -EINVAL; + } +} +EXPORT_SYMBOL_GPL(mmc_regulator_set_vqmmc); + #endif /* CONFIG_REGULATOR */ int mmc_regulator_get_supply(struct mmc_host *mmc) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 9f32270..524d6fc 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -416,6 +416,7 @@ int mmc_regulator_get_ocrmask(struct regulator *supply); int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsigned short vdd_bit); +int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios); #else static inline int mmc_regulator_get_ocrmask(struct regulator *supply) { @@ -428,6 +429,12 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, { return 0; } + +static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc, + struct mmc_ios *ios) +{ + return -EINVAL; +} #endif int mmc_regulator_get_supply(struct mmc_host *mmc); -- 2.2.0.rc0.207.ga3a616c
WARNING: multiple messages have this Message-ID (diff)
From: dianders@chromium.org (Doug Anderson) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] mmc: core: Add mmc_regulator_set_vqmmc() Date: Wed, 10 Dec 2014 12:58:03 -0800 [thread overview] Message-ID: <1418245085-9754-2-git-send-email-dianders@chromium.org> (raw) In-Reply-To: <1418245085-9754-1-git-send-email-dianders@chromium.org> This adds logic to the MMC core to set VQMMC. This is expected to be called by MMC drivers like dw_mmc as part of (or instead of) their start_signal_voltage_switch() callback. A few notes: * When setting the signal voltage to 3.3V we do our best to make VQMMC and VMMC match. It's been reported that this makes some old cards happy since they were tested back in the day before UHS when VQMMC and VMMC were provided by the same regulator. A nice side effect of this is that we don't end up on the hairy edge of VQMMC (2.7V), which some EEs claim is a little too close to the minimum for comfort. * When setting the signal voltage to 1.8V or 1.2V we aim for that specific voltage instead of picking the lowest one in the range. * We very purposely don't print errors in mmc_regulator_set_vqmmc(). There are cases where the MMC core will try several different voltages and we don't want to pollute the logs. Signed-off-by: Doug Anderson <dianders@chromium.org> --- drivers/mmc/core/core.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/host.h | 7 +++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 9584bff..d0da480 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1333,6 +1333,59 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, } EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); +static int mmc_regulator_set_voltage_if_supported(struct regulator *regulator, + int min_uV, int ideal_uV, + int max_uV) +{ + /* + * Check if supported first to avoid errors since we may try several + * signal levels during power up and don't want to show errors. + */ + if (!regulator_is_supported_voltage(regulator, min_uV, max_uV)) + return -EINVAL; + + return regulator_set_closest_voltage(regulator, min_uV, ideal_uV, + max_uV); +} + +/** + * mmc_regulator_set_vqmmc - Set VQMMC as per the ios + * + * For 3.3V signaling, we try to match vqmmc to vmmc as closely as possible. + * That will match the behavior of old boards where vqmmc and vmmc were supplied + * by the same supply. + * + * For 1.2V and 1.8V signaling we'll try to get as close as possible to the + * requested voltage. This is definitely a good idea for UHS where there's a + * separate regulator on the card that's trying to make 1.8V and it's best if + * we match. + * + * This function is expected to be used by a controller's + * start_signal_voltage_switch() function. + */ +int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios) +{ + /* If no vqmmc supply then we can't change the voltage */ + if (IS_ERR(mmc->supply.vqmmc)) + return -EINVAL; + + switch (ios->signal_voltage) { + case MMC_SIGNAL_VOLTAGE_120: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 1100000, 1200000, 1300000); + case MMC_SIGNAL_VOLTAGE_180: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 1700000, 1800000, 1950000); + case MMC_SIGNAL_VOLTAGE_330: + return mmc_regulator_set_voltage_if_supported( + mmc->supply.vqmmc, 2700000, + regulator_get_voltage(mmc->supply.vmmc), 3600000); + default: + return -EINVAL; + } +} +EXPORT_SYMBOL_GPL(mmc_regulator_set_vqmmc); + #endif /* CONFIG_REGULATOR */ int mmc_regulator_get_supply(struct mmc_host *mmc) diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 9f32270..524d6fc 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -416,6 +416,7 @@ int mmc_regulator_get_ocrmask(struct regulator *supply); int mmc_regulator_set_ocr(struct mmc_host *mmc, struct regulator *supply, unsigned short vdd_bit); +int mmc_regulator_set_vqmmc(struct mmc_host *mmc, struct mmc_ios *ios); #else static inline int mmc_regulator_get_ocrmask(struct regulator *supply) { @@ -428,6 +429,12 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, { return 0; } + +static inline int mmc_regulator_set_vqmmc(struct mmc_host *mmc, + struct mmc_ios *ios) +{ + return -EINVAL; +} #endif int mmc_regulator_get_supply(struct mmc_host *mmc); -- 2.2.0.rc0.207.ga3a616c
next prev parent reply other threads:[~2014-12-10 20:58 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-10 20:58 [PATCH 1/4] regulator: core: Support trying to get close to a certain voltage Doug Anderson 2014-12-10 20:58 ` Doug Anderson 2014-12-10 20:58 ` Doug Anderson [this message] 2014-12-10 20:58 ` [PATCH 2/4] mmc: core: Add mmc_regulator_set_vqmmc() Doug Anderson 2014-12-10 20:58 ` [PATCH 3/4] mmc: dw_mmc: Use mmc_regulator_set_vqmmc in start_signal_voltage_switch Doug Anderson 2014-12-10 20:58 ` Doug Anderson 2014-12-10 20:58 ` [PATCH 4/4] ARK: dts: Specify VMMC and VQMMC on rk3288-evb Doug Anderson 2014-12-10 20:58 ` Doug Anderson 2014-12-10 20:58 ` Doug Anderson 2014-12-10 23:53 ` [PATCH 1/4] regulator: core: Support trying to get close to a certain voltage Mark Brown 2014-12-10 23:53 ` Mark Brown 2014-12-11 1:08 ` Alexandru Stan 2014-12-11 1:08 ` Alexandru Stan 2014-12-11 12:31 ` Mark Brown 2014-12-11 12:31 ` Mark Brown 2014-12-11 16:09 ` Doug Anderson 2014-12-11 16:09 ` Doug Anderson 2014-12-11 17:09 ` Mark Brown 2014-12-11 17:09 ` Mark Brown 2014-12-11 19:55 ` Doug Anderson 2014-12-11 19:55 ` Doug Anderson 2014-12-12 0:24 ` Mark Brown 2014-12-12 0:24 ` Mark Brown 2014-12-12 3:31 ` Doug Anderson 2014-12-12 3:31 ` Doug Anderson 2014-12-12 12:59 ` Mark Brown 2014-12-12 12:59 ` Mark Brown 2014-12-15 22:11 ` Doug Anderson 2014-12-15 22:11 ` Doug Anderson 2014-12-16 13:13 ` Mark Brown 2014-12-16 13:13 ` Mark Brown
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=1418245085-9754-2-git-send-email-dianders@chromium.org \ --to=dianders@chromium.org \ --cc=abrestic@chromium.org \ --cc=adrian.hunter@intel.com \ --cc=alim.akhtar@samsung.com \ --cc=amstan@chromium.org \ --cc=andrew_gabbasov@mentor.com \ --cc=broonie@kernel.org \ --cc=chris@printf.net \ --cc=heiko@sntech.de \ --cc=jh80.chung@samsung.com \ --cc=johan.rudholm@axis.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mmc@vger.kernel.org \ --cc=linux-rockchip@lists.infradead.org \ --cc=sonnyrao@chromium.org \ --cc=tgih.jun@samsung.com \ --cc=tim.kryger@gmail.com \ --cc=ulf.hansson@linaro.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: 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.