From patchwork Tue Jan 8 14:06:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Rudholm X-Patchwork-Id: 13920 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 3041B23E21 for ; Tue, 8 Jan 2013 14:06:47 +0000 (UTC) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by fiordland.canonical.com (Postfix) with ESMTP id BD3FCA18E8E for ; Tue, 8 Jan 2013 14:06:46 +0000 (UTC) Received: by mail-vc0-f170.google.com with SMTP id fl11so404542vcb.1 for ; Tue, 08 Jan 2013 06:06:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:mime-version:content-type:x-gm-message-state; bh=59hRKIC/AgPB1kUwkCotGlxexKoAy4QPBhO3/tJBy/E=; b=V0vsjK0CN9DDWfK7OXJHaP8d66ey8ROm8oPSoqCU4228C7lUoJZ8l5nPYKtWI4NnAd +417pnBy8HQbUpYuq1VxMb50qXJ3uQdlbQ5ZvnpGSLxZrHAHtbqwrTg5MZ0SUSztaF2d w53a9TlXR+7RO5kq/jlzNVenLqDKUs8PFLvWePRreqQaHqqJooibgPdXyxvPq0Nw0Va3 6DEFqkLD8AGdGYrGWppMLmLf9ArqioHwZB1iROCxO4H0NPDypRj5OySpHA2gsPXIMk9P 6IELBAecrRGfJRZDa73XTbwyBbVsrrV+uV3wkZGv/7RKZPNBaiuTAJ9/YN6EjOGKmjZj Ikaw== X-Received: by 10.220.8.18 with SMTP id f18mr84380714vcf.14.1357654006266; Tue, 08 Jan 2013 06:06:46 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp111769veb; Tue, 8 Jan 2013 06:06:45 -0800 (PST) X-Received: by 10.14.218.69 with SMTP id j45mr174430039eep.35.1357654003879; Tue, 08 Jan 2013 06:06:43 -0800 (PST) Received: from eu1sys200aog101.obsmtp.com (eu1sys200aog101.obsmtp.com [207.126.144.111]) by mx.google.com with SMTP id l8si165829052eem.101.2013.01.08.06.06.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 Jan 2013 06:06:43 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.111 is neither permitted nor denied by best guess record for domain of johan.rudholm@stericsson.com) client-ip=207.126.144.111; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.111 is neither permitted nor denied by best guess record for domain of johan.rudholm@stericsson.com) smtp.mail=johan.rudholm@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob101.postini.com ([207.126.147.11]) with SMTP ID DSNKUOwn5bqHH1jM1qGrkHE11/0D/BWXubWd@postini.com; Tue, 08 Jan 2013 14:06:43 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id B5E2ED3; Tue, 8 Jan 2013 13:58:14 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8C4BEEA1; Tue, 8 Jan 2013 14:06:23 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 72212A8065; Tue, 8 Jan 2013 15:06:17 +0100 (CET) Received: from steludxu1610.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 8 Jan 2013 15:06:22 +0100 From: Johan Rudholm To: , Chris Ball Cc: Per Forlin , Ulf Hansson , Fredrik Soderstedt , Kevin Liu , Philip Rakity , Daniel Drake , Aaron , Subhash Jadavani , Johan Rudholm Subject: [PATCH v5 3/4] mmc: core: Break out start_signal_voltage_switch Date: Tue, 8 Jan 2013 15:06:01 +0100 Message-ID: <1357653962-10887-4-git-send-email-johan.rudholm@stericsson.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1357653962-10887-1-git-send-email-johan.rudholm@stericsson.com> References: <1357653962-10887-1-git-send-email-johan.rudholm@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQniY+t0Jw9ve+xWiBuI5d0N+a7hIyIOgPmFdzNJ4gTJlDiEdaJLSXdy/T9VB7w9uswXY35s Allow callers to access the start_signal_voltage_switch host_ops member without going through any cmd11 logic. This is mostly a preparation for the following signal voltage switch patch. Also, reset ios.signal_voltage to its original value if start_signal_voltage_switch fails. Signed-off-by: Johan Rudholm --- drivers/mmc/core/core.c | 35 +++++++++++++++++++++++------------ drivers/mmc/core/core.h | 4 ++-- drivers/mmc/core/mmc.c | 8 ++++---- drivers/mmc/core/sd.c | 2 +- drivers/mmc/core/sdio.c | 3 +-- 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 285f064..03db641 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1219,7 +1219,26 @@ u32 mmc_select_voltage(struct mmc_host *host, u32 ocr) return ocr; } -int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11) +int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) +{ + int err = 0; + int old_signal_voltage = host->ios.signal_voltage; + + host->ios.signal_voltage = signal_voltage; + if (host->ops->start_signal_voltage_switch) { + mmc_host_clk_hold(host); + err = host->ops->start_signal_voltage_switch(host, &host->ios); + mmc_host_clk_release(host); + } + + if (err) + host->ios.signal_voltage = old_signal_voltage; + + return err; + +} + +int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) { struct mmc_command cmd = {0}; int err = 0; @@ -1230,7 +1249,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 * Send CMD11 only if the request is to switch the card to * 1.8V signalling. */ - if ((signal_voltage != MMC_SIGNAL_VOLTAGE_330) && cmd11) { + if (signal_voltage != MMC_SIGNAL_VOLTAGE_330) { cmd.opcode = SD_SWITCH_VOLTAGE; cmd.arg = 0; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; @@ -1243,15 +1262,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 return -EIO; } - host->ios.signal_voltage = signal_voltage; - - if (host->ops->start_signal_voltage_switch) { - mmc_host_clk_hold(host); - err = host->ops->start_signal_voltage_switch(host, &host->ios); - mmc_host_clk_release(host); - } - - return err; + return __mmc_set_signal_voltage(host, signal_voltage); } /* @@ -1314,7 +1325,7 @@ static void mmc_power_up(struct mmc_host *host) mmc_set_ios(host); /* Set signal voltage to 3.3V */ - mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330, false); + __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330); /* * This delay should be sufficient to allow the power supply diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index 4a90067..f2439d5 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -40,8 +40,8 @@ void mmc_set_ungated(struct mmc_host *host); void mmc_set_bus_mode(struct mmc_host *host, unsigned int mode); void mmc_set_bus_width(struct mmc_host *host, unsigned int width); u32 mmc_select_voltage(struct mmc_host *host, u32 ocr); -int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, - bool cmd11); +int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); +int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); void mmc_power_off(struct mmc_host *host); diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index e6e3911..bd86771 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -769,11 +769,11 @@ static int mmc_select_hs200(struct mmc_card *card) if (card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_2V && host->caps2 & MMC_CAP2_HS200_1_2V_SDR) - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120, 0); + err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); if (err && card->ext_csd.card_type & EXT_CSD_CARD_TYPE_SDR_1_8V && host->caps2 & MMC_CAP2_HS200_1_8V_SDR) - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, 0); + err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); /* If fails try again during next card power cycle */ if (err) @@ -1221,8 +1221,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, * WARNING: eMMC rules are NOT the same as SD DDR */ if (ddr == MMC_1_2V_DDR_MODE) { - err = mmc_set_signal_voltage(host, - MMC_SIGNAL_VOLTAGE_120, 0); + err = __mmc_set_signal_voltage(host, + MMC_SIGNAL_VOLTAGE_120); if (err) goto err; } diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 74972c2..0cc1b26 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c @@ -759,7 +759,7 @@ try_again: */ if (!mmc_host_is_spi(host) && rocr && ((*rocr & 0x41000000) == 0x41000000)) { - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, true); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); if (err) { ocr &= ~SD_OCR_S18R; goto try_again; diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 2273ce6..0c84e0f 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -650,8 +650,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50))) { - err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, - true); + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); if (err) { ocr &= ~R4_18V_PRESENT; host->ocr &= ~R4_18V_PRESENT;