diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-06-20 02:28:43 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-07-21 00:02:08 -0400 |
commit | e137788dd115dd9d21759a768dba5fff9685e587 (patch) | |
tree | 93c2bcea03d7e8799db1e575530cdfc4b534a932 | |
parent | 6de707f200f73af7a58b58b3a5b956cff7b6e228 (diff) |
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: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/core/core.c | 23 | ||||
-rw-r--r-- | include/linux/mmc/host.h | 16 |
2 files changed, 37 insertions, 2 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 28b1ffaf0bd1..8d00aef9523e 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1022,6 +1022,29 @@ int mmc_regulator_set_ocr(struct mmc_host *mmc, | |||
1022 | } | 1022 | } |
1023 | EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); | 1023 | EXPORT_SYMBOL_GPL(mmc_regulator_set_ocr); |
1024 | 1024 | ||
1025 | int mmc_regulator_get_supply(struct mmc_host *mmc) | ||
1026 | { | ||
1027 | struct device *dev = mmc_dev(mmc); | ||
1028 | struct regulator *supply; | ||
1029 | int ret; | ||
1030 | |||
1031 | supply = devm_regulator_get(dev, "vmmc"); | ||
1032 | mmc->supply.vmmc = supply; | ||
1033 | mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc"); | ||
1034 | |||
1035 | if (IS_ERR(supply)) | ||
1036 | return PTR_ERR(supply); | ||
1037 | |||
1038 | ret = mmc_regulator_get_ocrmask(supply); | ||
1039 | if (ret > 0) | ||
1040 | mmc->ocr_avail = ret; | ||
1041 | else | ||
1042 | dev_warn(mmc_dev(mmc), "Failed getting OCR mask: %d\n", ret); | ||
1043 | |||
1044 | return 0; | ||
1045 | } | ||
1046 | EXPORT_SYMBOL_GPL(mmc_regulator_get_supply); | ||
1047 | |||
1025 | #endif /* CONFIG_REGULATOR */ | 1048 | #endif /* CONFIG_REGULATOR */ |
1026 | 1049 | ||
1027 | /* | 1050 | /* |
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 0707d228d7f1..9deb725799e7 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h | |||
@@ -155,6 +155,13 @@ struct mmc_hotplug { | |||
155 | void *handler_priv; | 155 | void *handler_priv; |
156 | }; | 156 | }; |
157 | 157 | ||
158 | struct regulator; | ||
159 | |||
160 | struct mmc_supply { | ||
161 | struct regulator *vmmc; /* Card power supply */ | ||
162 | struct regulator *vqmmc; /* Optional Vccq supply */ | ||
163 | }; | ||
164 | |||
158 | struct mmc_host { | 165 | struct mmc_host { |
159 | struct device *parent; | 166 | struct device *parent; |
160 | struct device class_dev; | 167 | struct device class_dev; |
@@ -309,6 +316,7 @@ struct mmc_host { | |||
309 | #ifdef CONFIG_REGULATOR | 316 | #ifdef CONFIG_REGULATOR |
310 | bool regulator_enabled; /* regulator state */ | 317 | bool regulator_enabled; /* regulator state */ |
311 | #endif | 318 | #endif |
319 | struct mmc_supply supply; | ||
312 | 320 | ||
313 | struct dentry *debugfs_root; | 321 | struct dentry *debugfs_root; |
314 | 322 | ||
@@ -357,13 +365,12 @@ static inline void mmc_signal_sdio_irq(struct mmc_host *host) | |||
357 | wake_up_process(host->sdio_irq_thread); | 365 | wake_up_process(host->sdio_irq_thread); |
358 | } | 366 | } |
359 | 367 | ||
360 | struct regulator; | ||
361 | |||
362 | #ifdef CONFIG_REGULATOR | 368 | #ifdef CONFIG_REGULATOR |
363 | int mmc_regulator_get_ocrmask(struct regulator *supply); | 369 | int mmc_regulator_get_ocrmask(struct regulator *supply); |
364 | int mmc_regulator_set_ocr(struct mmc_host *mmc, | 370 | int mmc_regulator_set_ocr(struct mmc_host *mmc, |
365 | struct regulator *supply, | 371 | struct regulator *supply, |
366 | unsigned short vdd_bit); | 372 | unsigned short vdd_bit); |
373 | int mmc_regulator_get_supply(struct mmc_host *mmc); | ||
367 | #else | 374 | #else |
368 | static inline int mmc_regulator_get_ocrmask(struct regulator *supply) | 375 | static inline int mmc_regulator_get_ocrmask(struct regulator *supply) |
369 | { | 376 | { |
@@ -376,6 +383,11 @@ static inline int mmc_regulator_set_ocr(struct mmc_host *mmc, | |||
376 | { | 383 | { |
377 | return 0; | 384 | return 0; |
378 | } | 385 | } |
386 | |||
387 | static inline int mmc_regulator_get_supply(struct mmc_host *mmc) | ||
388 | { | ||
389 | return 0; | ||
390 | } | ||
379 | #endif | 391 | #endif |
380 | 392 | ||
381 | int mmc_card_awake(struct mmc_host *host); | 393 | int mmc_card_awake(struct mmc_host *host); |