From patchwork Tue Sep 25 07:03:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Rudholm X-Patchwork-Id: 11701 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 AD3A523E54 for ; Tue, 25 Sep 2012 07:04:19 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4373AA1878B for ; Tue, 25 Sep 2012 07:04:19 +0000 (UTC) Received: by ieje10 with SMTP id e10so12094160iej.11 for ; Tue, 25 Sep 2012 00:04:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=fnYjIcRwvrN72W+oTJXy1M7Qd3BtBes+kmO2gBn21dc=; b=P67XsDE5FyIk1xnYSviPLAM59iRY1cqUVX/KS0Bd1bv9f16qVMnnopc7PsLmJIGgFx 2uetoIrjPQMsDsJ50Ql5HEWJK8gAF0uEVbgfGiwPaFie43tqasJE0DMebP43SAvby/9A gotD5MovCLbaOknWmtelTkv0iolONo6xdEW2R9bdn500hv4nYzX7N8lI0PDuC6f46hw6 cMr0RccWnsxkdZMxiTn+DtUcQt356TeC5j/R9GxaZj64wnrCtS4AOY94sAirulvsc5HR Jcx9X8CJXQY2IDQwFdp3qhEHirh/tSsnXeBADsHGPdimNaYRXdpsywzhCCWjT33fNvO2 wZ9w== Received: by 10.50.0.193 with SMTP id 1mr7437283igg.0.1348556658581; Tue, 25 Sep 2012 00:04:18 -0700 (PDT) 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.50.184.232 with SMTP id ex8csp279536igc; Tue, 25 Sep 2012 00:04:17 -0700 (PDT) Received: by 10.14.201.73 with SMTP id a49mr16830015eeo.39.1348556657259; Tue, 25 Sep 2012 00:04:17 -0700 (PDT) Received: from eu1sys200aog106.obsmtp.com (eu1sys200aog106.obsmtp.com [207.126.144.121]) by mx.google.com with SMTP id c41si12699602eem.134.2012.09.25.00.04.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 25 Sep 2012 00:04:17 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.121 is neither permitted nor denied by best guess record for domain of johan.rudholm@stericsson.com) client-ip=207.126.144.121; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.121 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 eu1sys200aob106.postini.com ([207.126.147.11]) with SMTP ID DSNKUGFXay6vTQ39ySISKAjtTfgFP30BXtrP@postini.com; Tue, 25 Sep 2012 07:04:16 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 D5B2CCA; Tue, 25 Sep 2012 06:55:51 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 4A873900; Tue, 25 Sep 2012 07:04:06 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 5C9DE24C07C; Tue, 25 Sep 2012 09:04:01 +0200 (CEST) Received: from steludxu1610.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 25 Sep 2012 09:04:05 +0200 From: Johan Rudholm To: , Chris Ball Cc: Per Forlin , Ulf Hansson , Fredrik Soderstedt , Johan Rudholm Subject: [PATCH v2 1/2] mmc: core: Proper signal voltage switch Date: Tue, 25 Sep 2012 09:03:42 +0200 Message-ID: <1348556622-2068-1-git-send-email-johan.rudholm@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkGzoz8ULGvwMsVPTgHUSg0+ktMlp0FPc4UsQPtfKcA0AcfYYlSdvaKOaN8cGrvZRZzwtTI When switching SD and SDIO cards from 3.3V to 1.8V signal levels, the clock should be gated for 5 ms during the step. Failure by the card to switch is indicated by dat0 being pulled low. The host should check for this condition and power-cycle the card if failure is indicated. Signed-off-by: Johan Rudholm --- Changelog v2: - Keep calls to mmc_host_clk_hold / mmc_host_clk_release --- drivers/mmc/core/core.c | 22 ++++++++++++++++++++++ include/linux/mmc/host.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6612163..dae6744 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1220,6 +1220,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 { struct mmc_command cmd = {0}; int err = 0; + unsigned char old_voltage = host->ios.signal_voltage; BUG_ON(!host); @@ -1243,8 +1244,29 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, bool cmd11 host->ios.signal_voltage = signal_voltage; if (host->ops->start_signal_voltage_switch) { + u32 clock = host->ios.clock; + mmc_host_clk_hold(host); + host->ios.clock = 0; + mmc_set_ios(host); err = host->ops->start_signal_voltage_switch(host, &host->ios); + + /* Hold clock for at least 5 ms according to spec */ + mmc_delay(5); + host->ios.clock = clock; + mmc_set_ios(host); + + /* Wait for at least 1 ms until we check if card is ready */ + mmc_delay(1); + + /* Check busy */ + if (cmd11 && host->ops->card_busy && + host->ops->card_busy(host)) { + host->ios.signal_voltage = old_voltage; + host->ops->start_signal_voltage_switch(host, + &host->ios); + err = -EAGAIN; + } mmc_host_clk_release(host); } diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index d5d9bd4..b58641a 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -131,6 +131,9 @@ struct mmc_host_ops { int (*start_signal_voltage_switch)(struct mmc_host *host, struct mmc_ios *ios); + /* Check if the card is pulling dat0 low */ + int (*card_busy)(struct mmc_host *host); + /* The tuning command opcode value is different for SD and eMMC cards */ int (*execute_tuning)(struct mmc_host *host, u32 opcode); void (*enable_preset_value)(struct mmc_host *host, bool enable);