From: dromede@gmail.com (dromede at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC][PATCH] pxamci: defining CONFIG_REGULATOR_DUMMY may break PXA MMC controller driver.
Date: Wed, 29 Aug 2012 17:06:43 +0200 [thread overview]
Message-ID: <1346252803-7817-1-git-send-email-dromede@gmail.com> (raw)
From: Marko Katic <dromede.gmail.com>
Here's an interesting scenario. The spitz machine has an
Intersil 6271A voltage regulator and an ADS7846 touchscreen
controller. The ADS7846 driver requires the use of the voltage regulator
or if not present, CONFIG_REGULATOR_DUMMY should be used for proper operation.
So to support both devices, CONFIG_REGULATOR and CONFIG REGULATOR_DUMMY have
to be defined.
However, enabling CONFIG_REGULATOR_DUMMY breaks pxamci in pxamci_init_ocr().
and pxamci_set_power() in the case when no vmmc regulator is present.
These functions don't handle the presence of a dummy regulator very well
since they expect a proper regulator when CONFIG_REGULATOR is defined or
no regulator at all. I've modified both to do more checking and to always
fall back to platform data if such data is present.
I should probably add some dev_warns somewhere, i would like some input
on that.
Signed-off-by: Marko Katic <dromede.gmail.com>
---
drivers/mmc/host/pxamci.c | 36 ++++++++++++++++++++++--------------
1 files changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index cb2dc0e..ffbf177 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -80,18 +80,24 @@ struct pxamci_host {
static inline void pxamci_init_ocr(struct pxamci_host *host)
{
#ifdef CONFIG_REGULATOR
+ int ocr_mask;
host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
if (IS_ERR(host->vcc))
host->vcc = NULL;
else {
- host->mmc->ocr_avail = mmc_regulator_get_ocrmask(host->vcc);
- if (host->pdata && host->pdata->ocr_mask)
+ ocr_mask = mmc_regulator_get_ocrmask(host->vcc);
+ if (ocr_mask <= 0)
+ host->mmc->ocr_avail = 0;
+ else
+ host->mmc->ocr_avail = ocr_mask;
+
+ if (host->pdata && host->pdata->ocr_mask && host->mmc->ocr_avail)
dev_warn(mmc_dev(host->mmc),
"ocr_mask/setpower will not be used\n");
}
#endif
- if (host->vcc == NULL) {
+ if (host->vcc == NULL || host->mmc->ocr_avail == 0) {
/* fall-back to platform data */
host->mmc->ocr_avail = host->pdata ?
host->pdata->ocr_mask :
@@ -104,27 +110,29 @@ static inline int pxamci_set_power(struct pxamci_host *host,
unsigned int vdd)
{
int on;
-
+
+#ifdef CONFIG_REGULATOR
if (host->vcc) {
- int ret;
+ int ret = 0;
- if (power_mode == MMC_POWER_UP) {
+ if (power_mode == MMC_POWER_UP)
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
- if (ret)
- return ret;
- } else if (power_mode == MMC_POWER_OFF) {
+
+ if (power_mode == MMC_POWER_OFF)
ret = mmc_regulator_set_ocr(host->mmc, host->vcc, 0);
- if (ret)
- return ret;
- }
+
+ if (ret == 0)
+ return ret;
}
- if (!host->vcc && host->pdata &&
+#endif
+
+ if (host->pdata &&
gpio_is_valid(host->pdata->gpio_power)) {
on = ((1 << vdd) & host->pdata->ocr_mask);
gpio_set_value(host->pdata->gpio_power,
!!on ^ host->pdata->gpio_power_invert);
}
- if (!host->vcc && host->pdata && host->pdata->setpower)
+ if (host->pdata && host->pdata->setpower)
host->pdata->setpower(mmc_dev(host->mmc), vdd);
return 0;
--
1.7.4.1
next reply other threads:[~2012-08-29 15:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-29 15:06 dromede at gmail.com [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-11-28 22:08 [RFC][PATCH] pxamci: defining CONFIG_REGULATOR_DUMMY may break PXA MMC controller driver dromede at gmail.com
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=1346252803-7817-1-git-send-email-dromede@gmail.com \
--to=dromede@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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).