From patchwork Fri Jun 16 12:45:29 2017 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: 9791435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23F546038E for ; Fri, 16 Jun 2017 12:48:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121242862B for ; Fri, 16 Jun 2017 12:48:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 069992863B; Fri, 16 Jun 2017 12:48:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E6692862B for ; Fri, 16 Jun 2017 12:48:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753848AbdFPMrs (ORCPT ); Fri, 16 Jun 2017 08:47:48 -0400 Received: from fllnx209.ext.ti.com ([198.47.19.16]:38600 "EHLO fllnx209.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846AbdFPMrn (ORCPT ); Fri, 16 Jun 2017 08:47:43 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id v5GCk1bj022300; Fri, 16 Jun 2017 07:46:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1497617161; bh=N6jJC4vdjBypZT+ArPLF1dUp176jJjNX8J48fkN+gKQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fsquBcXWJN7z+YWr5U4feL0sMVf9zWVrVid3gZ7C30lFoBh1rh9Bdn1VoQPLl/g/u OUjo47xR0VDSRjI2jmRvU6RLSuYKquZQzRUUcv6fq7Y6Mj3yqSSh9P5e0db80r1wlf 0zzTZ/QZvyfR9T+h/R0OjD75uabRisKlEp96VQcY= Received: from DLEE70.ent.ti.com (dlee70.ent.ti.com [157.170.170.113]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v5GCjuwY012043; Fri, 16 Jun 2017 07:45:56 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE70.ent.ti.com (157.170.170.113) with Microsoft SMTP Server id 14.3.294.0; Fri, 16 Jun 2017 07:45:55 -0500 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v5GCjjBd000652; Fri, 16 Jun 2017 07:45:52 -0500 From: Kishon Vijay Abraham I To: Ulf Hansson , Rob Herring , Tony Lindgren , CC: Russell King , Ravikumar Kattekola , , , , , , Subject: [PATCH 01/16] mmc: host: omap_hsmmc: Support pbias and vmmc_aux to switch to 1.8v Date: Fri, 16 Jun 2017 18:15:29 +0530 Message-ID: <20170616124544.15046-2-kishon@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170616124544.15046-1-kishon@ti.com> References: <20170616124544.15046-1-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-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 Signed-off-by: Sekhar Nori --- drivers/mmc/host/omap_hsmmc.c | 50 ++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 7c12f3715676..48bb06788d9f 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -244,11 +244,12 @@ 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 omap_hsmmc_host *host = mmc_priv(mmc); struct mmc_ios *ios = &mmc->ios; + int uvoltage; if (!IS_ERR(mmc->supply.vmmc)) { ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); @@ -257,7 +258,25 @@ static int omap_hsmmc_enable_supply(struct mmc_host *mmc) } /* Enable interface voltage rail, if needed */ - if (!IS_ERR(mmc->supply.vqmmc) && !host->vqmmc_enabled) { + if (!IS_ERR(mmc->supply.vqmmc)) { + if (host->vqmmc_enabled) { + ret = regulator_disable(mmc->supply.vqmmc); + if (ret) { + dev_err(mmc_dev(mmc), + "vmmc_aux reg disable failed\n"); + goto err_vqmmc; + } + host->vqmmc_enabled = 0; + } + + 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"); @@ -309,22 +328,19 @@ static int omap_hsmmc_disable_supply(struct mmc_host *mmc) } static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, - int vdd) + int iov) { int ret; + int uvoltage; if (IS_ERR(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; } @@ -351,13 +367,13 @@ static int omap_hsmmc_set_pbias(struct omap_hsmmc_host *host, bool power_on, } static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, - int vdd) + int iov) { struct mmc_host *mmc = host->mmc; int ret = 0; if (mmc_pdata(host)->set_power) - return mmc_pdata(host)->set_power(host->dev, power_on, vdd); + return mmc_pdata(host)->set_power(host->dev, power_on, iov); /* * If we don't see a Vcc regulator, assume it's a fixed @@ -367,7 +383,7 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, return 0; if (mmc_pdata(host)->before_set_reg) - mmc_pdata(host)->before_set_reg(host->dev, power_on, vdd); + mmc_pdata(host)->before_set_reg(host->dev, power_on, iov); ret = omap_hsmmc_set_pbias(host, false, 0); if (ret) @@ -387,11 +403,11 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, * 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 { @@ -401,7 +417,7 @@ static int omap_hsmmc_set_power(struct omap_hsmmc_host *host, int power_on, } if (mmc_pdata(host)->after_set_reg) - mmc_pdata(host)->after_set_reg(host->dev, power_on, vdd); + mmc_pdata(host)->after_set_reg(host->dev, power_on, iov); return 0;