From patchwork Wed Aug 29 15:06:43 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: 1385311 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 786F03FDF5 for ; Wed, 29 Aug 2012 15:10:21 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T6jrI-00040k-Ur; Wed, 29 Aug 2012 15:07:09 +0000 Received: from mail-bk0-f49.google.com ([209.85.214.49]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T6jrF-0003zh-JF for linux-arm-kernel@lists.infradead.org; Wed, 29 Aug 2012 15:07:06 +0000 Received: by bkcji2 with SMTP id ji2so361957bkc.36 for ; Wed, 29 Aug 2012 08:07:03 -0700 (PDT) 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=LwB+PSdwl6cF/8tPZKCxvAiLFHEP9Sig+P+SuhrVAH4=; b=YSVdgyU1OTuiS9WbR5RMxgKDFqibzAGGsvQjciVE3angPaj5ai08QZKk2K2b8cCLCG zB/yVQRK53g6f3jyemTbaBw47x2Yk9NpjX1jYP0x60OyFUW9GNWk2vZoMeERtAsQD+HB pugGG+Ybw7FbWyWajhSf7YzN8GKbP2G/Af8C1in0OypafFYlc+TznIeVW8tfick/xD8O aR/RgckQwgIx/dlBSyxzOevXxhn+LH54RaFyR9MRpb60iAnKa59GFxFkFD+JhxRaz463 so+ckzCXXNRWRMqTyYUWyd35gfWHNK+21QZ3Zq/Qes1SR9TTbtjsRUy/h4X4W3DYReX1 zxtA== Received: by 10.204.157.143 with SMTP id b15mr1186856bkx.75.1346252823371; Wed, 29 Aug 2012 08:07:03 -0700 (PDT) Received: from localhost.localdomain (93-142-214-151.adsl.net.t-com.hr. [93.142.214.151]) by mx.google.com with ESMTPS id hg13sm15800519bkc.7.2012.08.29.08.07.01 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 29 Aug 2012 08:07:02 -0700 (PDT) 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, 29 Aug 2012 17:06:43 +0200 Message-Id: <1346252803-7817-1-git-send-email-dromede@gmail.com> X-Mailer: git-send-email 1.7.4.1 X-Spam-Note: CRM114 invocation failed 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.214.49 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: eric.y.miao@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;