From patchwork Wed Nov 28 22:08:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dromede@gmail.com X-Patchwork-Id: 1819321 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 02916DF2F9 for ; Wed, 28 Nov 2012 22:13:13 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Tdppt-0004ZH-1J; Wed, 28 Nov 2012 22:10:29 +0000 Received: from mail-ea0-f177.google.com ([209.85.215.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Tdppj-0004V8-5J for linux-arm-kernel@lists.infradead.org; Wed, 28 Nov 2012 22:10:20 +0000 Received: by mail-ea0-f177.google.com with SMTP id c10so3661773eaa.36 for ; Wed, 28 Nov 2012 14:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=ilaNOmkMh+JxNgooISss+ta/2WqdN6AhKVs/x8ClA+k=; b=ikkoU/xznzCRAAEFnqK2k+UHL2OXfRjTf2GRHgsm6POrGVCOXHpWw4SPvrIS89jesj 9nm6h95r4jQaTI2i3pdm46EFUSMN+3Mf6a7spOc6BaUt94Nj38rYFZdt2l1tV0nGwgm+ HIoOQCBgBgSSmSPBK+A6j6br4sSt7DXJOcnwlOpbqE/POgIS5C9boe0vCv09mMgC+ymG clk+6Bie9UEWXm57/1ZKRGIg6Jat15pGWwzUjeTmaVl1+/PoK+LhiWbXimO7z5RskekK dGVG9OoWtOhOa0SPES+DL66iRaACf+CcvqNtSsmUrnmPmZWQdrXORsL+UfNbJv9gWzDl TufQ== Received: by 10.14.199.134 with SMTP id x6mr74465862een.31.1354140617463; Wed, 28 Nov 2012 14:10:17 -0800 (PST) Received: from localhost.localdomain (93-142-246-232.adsl.net.t-com.hr. [93.142.246.232]) by mx.google.com with ESMTPS id a44sm49798541eeo.7.2012.11.28.14.10.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 28 Nov 2012 14:10:16 -0800 (PST) From: dromede@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, 28 Nov 2012 23:08:38 +0100 Message-Id: <1354140518-13433-1-git-send-email-dromede@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121128_171019_615597_B68A34D7 X-CRM114-Status: GOOD ( 16.52 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dromede[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Marko Katic , broonie@opensource.wolfsonmicro.com, linux-mmc@vger.kernel.org, drwyrm@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Marko Katic 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 --- 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;