From patchwork Tue Apr 30 14:03:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balaji T K X-Patchwork-Id: 2504711 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 239823FD85 for ; Tue, 30 Apr 2013 14:04:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760734Ab3D3OEI (ORCPT ); Tue, 30 Apr 2013 10:04:08 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:54080 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760712Ab3D3OEG (ORCPT ); Tue, 30 Apr 2013 10:04:06 -0400 Received: from dbdlxv05.itg.ti.com ([172.24.171.60]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id r3UE42mv032003; Tue, 30 Apr 2013 09:04:03 -0500 Received: from DBDE72.ent.ti.com (dbde72.ent.ti.com [172.24.171.97]) by dbdlxv05.itg.ti.com (8.14.3/8.13.8) with ESMTP id r3UE3vab005935; Tue, 30 Apr 2013 09:04:01 -0500 Received: from dbdp32.itg.ti.com (172.24.170.251) by DBDE72.ent.ti.com (172.24.171.97) with Microsoft SMTP Server id 14.2.342.3; Tue, 30 Apr 2013 22:03:57 +0800 Received: from ulaa0393241.apr.dhcp.ti.com (smtpvbd.itg.ti.com [172.24.170.250]) by dbdp32.itg.ti.com (8.13.8/8.13.8) with ESMTP id r3UE3smc003935; Tue, 30 Apr 2013 19:33:57 +0530 From: Balaji T K To: , , , , CC: Balaji T K Subject: [PATCH 03/13] mmc: omap_hsmmc: use needs_vmmc Date: Tue, 30 Apr 2013 19:33:43 +0530 Message-ID: <1367330633-5941-4-git-send-email-balajitk@ti.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1367330633-5941-1-git-send-email-balajitk@ti.com> References: <1367330633-5941-1-git-send-email-balajitk@ti.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Use needs_vmmc/needs_vmmc_aux to check whether regulator is mandatory and handle regulator errors like EPROBE_DEFER properly Signed-off-by: Balaji T K --- drivers/mmc/host/omap_hsmmc.c | 65 ++++++++++++++++++++++------------------ 1 files changed, 36 insertions(+), 29 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 7e122a9..4f7ca7a 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -183,6 +183,8 @@ struct omap_hsmmc_host { struct omap_hsmmc_next next_data; struct omap_mmc_platform_data *pdata; + int needs_vmmc:1; + int needs_vmmc_aux:1; }; static int omap_hsmmc_card_detect(struct device *dev, int slot) @@ -311,11 +313,13 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) int ocr_value = 0; reg = regulator_get(host->dev, "vmmc"); - if (IS_ERR(reg)) { - dev_err(host->dev, "vmmc regulator missing\n"); + if (IS_ERR(reg) && host->needs_vmmc) { + dev_err(host->dev, "unable to get vmmc regulator %ld\n", + PTR_ERR(reg)); return PTR_ERR(reg); - } else { - mmc_slot(host).set_power = omap_hsmmc_set_power; + } + mmc_slot(host).set_power = omap_hsmmc_set_power; + if (!IS_ERR(reg)) { host->vcc = reg; ocr_value = mmc_regulator_get_ocrmask(reg); if (!mmc_slot(host).ocr_mask) { @@ -328,31 +332,33 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) return -EINVAL; } } + } - /* Allow an aux regulator */ - reg = regulator_get(host->dev, "vmmc_aux"); - host->vcc_aux = IS_ERR(reg) ? NULL : reg; - - /* For eMMC do not power off when not in sleep state */ - if (mmc_slot(host).no_regulator_off_init) - return 0; - /* - * UGLY HACK: workaround regulator framework bugs. - * When the bootloader leaves a supply active, it's - * initialized with zero usecount ... and we can't - * disable it without first enabling it. Until the - * framework is fixed, we need a workaround like this - * (which is safe for MMC, but not in general). - */ - if (regulator_is_enabled(host->vcc) > 0 || - (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) { - int vdd = ffs(mmc_slot(host).ocr_mask) - 1; + /* Allow an aux regulator */ + reg = regulator_get(host->dev, "vmmc_aux"); + host->vcc_aux = IS_ERR(reg) ? NULL : reg; + if (IS_ERR(reg) && host->needs_vmmc_aux) { + dev_err(host->dev, "unable to get vmmc_aux regulator %ld\n", + PTR_ERR(reg)); + return PTR_ERR(reg); + } - mmc_slot(host).set_power(host->dev, host->slot_id, - 1, vdd); - mmc_slot(host).set_power(host->dev, host->slot_id, - 0, 0); - } + /* For eMMC do not power off when not in sleep state */ + if (mmc_slot(host).no_regulator_off_init || + (!host->needs_vmmc && !host->needs_vmmc_aux)) + return 0; + /* + * To disable boot_on regulator, enable regulator + * to increase usecount and then disable it. + */ + if (regulator_is_enabled(host->vcc) > 0 || + (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) { + int vdd = ffs(mmc_slot(host).ocr_mask) - 1; + + mmc_slot(host).set_power(host->dev, host->slot_id, + 1, vdd); + mmc_slot(host).set_power(host->dev, host->slot_id, + 0, 0); } return 0; @@ -1822,6 +1828,8 @@ static int omap_hsmmc_probe(struct platform_device *pdev) host->base = ioremap(host->mapbase, SZ_4K); host->power_mode = MMC_POWER_OFF; host->next_data.cookie = 1; + host->needs_vmmc = pdata->needs_vmmc; + host->needs_vmmc_aux = pdata->needs_vmmc_aux; platform_set_drvdata(pdev, host); @@ -1949,7 +1957,7 @@ static int omap_hsmmc_probe(struct platform_device *pdev) if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) { ret = omap_hsmmc_reg_get(host); if (ret) - goto err_reg; + goto err_irq_cd; host->use_reg = 1; } @@ -2006,7 +2014,6 @@ err_slot_name: err_irq_cd: if (host->use_reg) omap_hsmmc_reg_put(host); -err_reg: if (host->pdata->cleanup) host->pdata->cleanup(&pdev->dev); err_irq_cd_init: