From patchwork Thu Jul 30 07:46:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 6899431 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 965929F380 for ; Thu, 30 Jul 2015 07:47:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3097204EA for ; Thu, 30 Jul 2015 07:47:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87C44204E7 for ; Thu, 30 Jul 2015 07:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750884AbbG3HrH (ORCPT ); Thu, 30 Jul 2015 03:47:07 -0400 Received: from comal.ext.ti.com ([198.47.26.152]:52434 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750770AbbG3HrG (ORCPT ); Thu, 30 Jul 2015 03:47:06 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id t6U7kg8V027199; Thu, 30 Jul 2015 02:46:42 -0500 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id t6U7kgLX009266; Thu, 30 Jul 2015 02:46:42 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.224.2; Thu, 30 Jul 2015 02:46:42 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id t6U7kZVV006418; Thu, 30 Jul 2015 02:46:39 -0500 From: Kishon Vijay Abraham I To: , , , , , , CC: , , Subject: [PATCH 01/11] mmc: host: omap_hsmmc: Support vmmc_aux to switch to 1.8v Date: Thu, 30 Jul 2015 13:16:24 +0530 Message-ID: <1438242394-25599-2-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1438242394-25599-1-git-send-email-kishon@ti.com> References: <1438242394-25599-1-git-send-email-kishon@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 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for vmmc_aux to switch to 1.8v. Also use "iov" instead of "vdd" to indicate io voltage. This is in preparation for adding support for io signal voltage switch. Signed-off-by: Kishon Vijay Abraham I --- drivers/mmc/host/omap_hsmmc.c | 47 +++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 6d52873..09e949f 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -243,10 +243,11 @@ static int omap_hsmmc_get_cover_state(struct device *dev) return mmc_gpio_get_cd(host->mmc); } -static int omap_hsmmc_enable_supply(struct mmc_host *mmc) +static int omap_hsmmc_enable_supply(struct mmc_host *mmc, int iov) { int ret; struct mmc_ios *ios = &mmc->ios; + int uvoltage; if (mmc->supply.vmmc) { ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); @@ -255,7 +256,24 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc) } /* Enable interface voltage rail, if needed */ - if (mmc->supply.vqmmc && !regulator_is_enabled(mmc->supply.vqmmc)) { + if (mmc->supply.vqmmc) { + if (regulator_is_enabled(mmc->supply.vqmmc)) { + ret = regulator_disable(mmc->supply.vqmmc); + if (ret) { + dev_err(mmc_dev(mmc), + "vmmc_aux reg disable failed\n"); + goto err_vqmmc; + } + } + + uvoltage = (iov == VDD_165_195) ? VDD_1V8 : VDD_3V0; + ret = regulator_set_voltage(mmc->supply.vqmmc, uvoltage, + uvoltage); + if (ret) { + dev_err(mmc_dev(mmc), "vmmc_aux set voltage failed\n"); + goto err_vqmmc; + } + ret = regulator_enable(mmc->supply.vqmmc); if (ret) { dev_err(mmc_dev(mmc), "vmmc_aux reg enable failed\n"); @@ -304,22 +322,19 @@ err_set_ocr: } static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, - int vdd) + int iov) { int ret; + int uvoltage; if (!host->pbias) return 0; if (power_on) { - if (vdd <= VDD_165_195) - ret = regulator_set_voltage(host->pbias, VDD_1V8, - VDD_1V8); - else - ret = regulator_set_voltage(host->pbias, VDD_3V0, - VDD_3V0); - if (ret < 0) { - dev_err(host->dev, "pbias set voltage fail\n"); + uvoltage = (iov <= VDD_165_195) ? VDD_1V8 : VDD_3V0; + ret = regulator_set_voltage(host->pbias, uvoltage, uvoltage); + if (ret) { + dev_err(host->dev, "pbias set voltage failed\n"); return ret; } @@ -343,7 +358,7 @@ static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, return 0; } -static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) +static int omap_hsmmc_set_power(struct device *dev, int power_on, int iov) { struct omap_hsmmc_host *host = platform_get_drvdata(to_platform_device(dev)); @@ -358,7 +373,7 @@ static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) return 0; if (mmc_pdata(host)->before_set_reg) - mmc_pdata(host)->before_set_reg(dev, power_on, vdd); + mmc_pdata(host)->before_set_reg(dev, power_on, iov); ret = omap_hsmmc_set_pbias(host, false, 0); if (ret) @@ -378,11 +393,11 @@ static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) * chips/cards need an interface voltage rail too. */ if (power_on) { - ret = omap_hsmmc_enable_supply(mmc); + ret = omap_hsmmc_enable_supply(mmc, iov); if (ret) return ret; - ret = omap_hsmmc_set_pbias(host, true, vdd); + ret = omap_hsmmc_set_pbias(host, true, iov); if (ret) goto err_set_voltage; } else { @@ -392,7 +407,7 @@ static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd) } if (mmc_pdata(host)->after_set_reg) - mmc_pdata(host)->after_set_reg(dev, power_on, vdd); + mmc_pdata(host)->after_set_reg(dev, power_on, iov); return 0;