提交 e137788d 编写于 作者: G Guennadi Liakhovetski 提交者: Chris Ball

mmc: add a function to get regulators, supplying card's power

Add a function to get regulators, supplying card's Vdd and Vccq on a
specific host. If a Vdd supplying regulator is found, the function checks,
whether a valid OCR mask can be obtained from it. The Vccq regulator is
optional. A failure to get it is not fatal.
Signed-off-by: NGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Reviwed-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: NUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: NChris Ball <cjb@laptop.org>
上级 6de707f2
...@@ -1022,6 +1022,29 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, ...@@ -1022,6 +1022,29 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc,
} }
EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr);
int mmc_regulator_get_supply(struct mmc_host *mmc)
{
struct device *dev = mmc_dev(mmc);
struct regulator *supply;
int ret;
supply = devm_regulator_get(dev, "vmmc");
mmc->supply.vmmc = supply;
mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
if (IS_ERR(supply))
return PTR_ERR(supply);
ret = mmc_regulator_get_ocrmask(supply);
if (ret > 0)
mmc->ocr_avail = ret;
else
dev_warn(mmc_dev(mmc), "Failed getting OCR mask: %d\n", ret);
return 0;
}
EXPORT_SYMBOL_GPL(mmc_regulator_get_supply);
#endif /* CONFIG_REGULATOR */ #endif /* CONFIG_REGULATOR */
/* /*
......
...@@ -155,6 +155,13 @@ struct mmc_hotplug { ...@@ -155,6 +155,13 @@ struct mmc_hotplug {
void *handler_priv; void *handler_priv;
}; };
struct regulator;
struct mmc_supply {
struct regulator *vmmc; /* Card power supply */
struct regulator *vqmmc; /* Optional Vccq supply */
};
struct mmc_host { struct mmc_host {
struct device *parent; struct device *parent;
struct device class_dev; struct device class_dev;
...@@ -309,6 +316,7 @@ struct mmc_host { ...@@ -309,6 +316,7 @@ struct mmc_host {
#ifdef CONFIG_REGULATOR #ifdef CONFIG_REGULATOR
bool regulator_enabled; /* regulator state */ bool regulator_enabled; /* regulator state */
#endif #endif
struct mmc_supply supply;
struct dentry *debugfs_root; struct dentry *debugfs_root;
...@@ -357,13 +365,12 @@ static inline void mmc_signal_sdio_irq(struct mmc_host *host) ...@@ -357,13 +365,12 @@ static inline void mmc_signal_sdio_irq(struct mmc_host *host)
wake_up_process(host->sdio_irq_thread); wake_up_process(host->sdio_irq_thread);
} }
struct regulator;
#ifdef CONFIG_REGULATOR #ifdef CONFIG_REGULATOR
int mmc_regulator_get_ocrmask(struct regulator *supply); int mmc_regulator_get_ocrmask(struct regulator *supply);
int mmc_regulator_set_ocr(struct mmc_host *mmc, int mmc_regulator_set_ocr(struct mmc_host *mmc,
struct regulator *supply, struct regulator *supply,
unsigned short vdd_bit); unsigned short vdd_bit);
int mmc_regulator_get_supply(struct mmc_host *mmc);
#else #else
static inline int mmc_regulator_get_ocrmask(struct regulator *supply) static inline int mmc_regulator_get_ocrmask(struct regulator *supply)
{ {
...@@ -376,6 +383,11 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, ...@@ -376,6 +383,11 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc,
{ {
return 0; return 0;
} }
static inline int mmc_regulator_get_supply(struct mmc_host *mmc)
{
return 0;
}
#endif #endif
int mmc_card_awake(struct mmc_host *host); int mmc_card_awake(struct mmc_host *host);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册