From patchwork Wed Sep 26 11:38:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Liu X-Patchwork-Id: 1509281 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 1A4453FC71 for ; Wed, 26 Sep 2012 11:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755950Ab2IZLom (ORCPT ); Wed, 26 Sep 2012 07:44:42 -0400 Received: from na3sys009aog114.obsmtp.com ([74.125.149.211]:35752 "EHLO na3sys009aog114.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755064Ab2IZLol (ORCPT ); Wed, 26 Sep 2012 07:44:41 -0400 Received: from MSI-MTA.marvell.com ([65.219.4.132]) (using TLSv1) by na3sys009aob114.postini.com ([74.125.148.12]) with SMTP ID DSNKUGLqpHllk9Da2dhdC5lDlY26pPna/Tbi@postini.com; Wed, 26 Sep 2012 04:44:41 PDT Received: from maili.marvell.com ([10.68.76.210]) by MSI-MTA.marvell.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 26 Sep 2012 04:44:08 -0700 Received: from localhost.localdomain (unknown [10.38.36.240]) by maili.marvell.com (Postfix) with ESMTP id ADC404E510; Wed, 26 Sep 2012 04:44:07 -0700 (PDT) From: Kevin Liu To: linux-mmc@vger.kernel.org, cjb@laptop.org, pierre@ossman.eu, ulf.hansson@linaro.org, zgao6@marvell.com Cc: hzhuang1@marvell.com, cxie4@marvell.com, prakity@marvell.com, kliu5@marvell.com Subject: [PATCH v4 13/15] mmc: sdhci: add mmc 1.8v signal voltage switch function Date: Wed, 26 Sep 2012 19:38:45 +0800 Message-Id: <1348659527-4200-14-git-send-email-keyuan.liu@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1348659527-4200-1-git-send-email-keyuan.liu@gmail.com> References: <1348659527-4200-1-git-send-email-keyuan.liu@gmail.com> X-OriginalArrivalTime: 26 Sep 2012 11:44:09.0032 (UTC) FILETIME=[3D7CEC80:01CD9BDC] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org From: Kevin Liu Add the function since MMC 1.8v signal voltage switch don't need the same switch sequence requirements as SD/SDIO. Signed-off-by: Kevin Liu --- drivers/mmc/host/sdhci.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 45 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 14ec904..50e7a54 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -1794,6 +1794,46 @@ static int sdhci_do_1_8v_signal_voltage_switch(struct sdhci_host *host, return -EAGAIN; } +static int sdhci_mmc_do_1_8v_signal_voltage_switch(struct sdhci_host *host, + u16 ctrl) +{ + int ret; + + if (host->vqmmc) { + ret = regulator_set_voltage(host->vqmmc, 1700000, 1950000); + if (ret) { + pr_warning("%s: Switching to 1.8V signalling voltage " + " failed\n", mmc_hostname(host->mmc)); + return -EIO; + } + } + + /* + * May need to apply soc/platfrom settings for the + * voltage switch + */ + if (host->ops->signal_voltage_switch) + host->ops->signal_voltage_switch(host, + host->mmc->ios.signal_voltage); + + /* Enable 1.8V Signal Enable in the Host Control2 register */ + ctrl |= SDHCI_CTRL_VDD_180; + sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); + + /* Wait for 5ms */ + usleep_range(5000, 5500); + + /* 1.8V regulator output should be stable within 5 ms */ + ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); + if (ctrl & SDHCI_CTRL_VDD_180) + return 0; + + pr_warning("%s: 1.8V regulator output did not became stable\n", + mmc_hostname(host->mmc)); + + return -EIO; +} + static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host, struct mmc_ios *ios) { @@ -1814,8 +1854,12 @@ static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host, if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_330) return sdhci_do_3_3v_signal_voltage_switch(host, ctrl); else if (!(ctrl & SDHCI_CTRL_VDD_180) && - (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)) + (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180)) return sdhci_do_1_8v_signal_voltage_switch(host, ctrl); + else if (!(ctrl & SDHCI_CTRL_VDD_180) && + (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_MMC_180)) + return sdhci_mmc_do_1_8v_signal_voltage_switch(host, + ctrl); else /* No signal voltage switch required */ return 0;