From patchwork Thu Sep 20 18:40:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Rudholm X-Patchwork-Id: 11585 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 38A8A23E54 for ; Thu, 20 Sep 2012 18:45:36 +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 51DB4A181DD for ; Thu, 20 Sep 2012 18:45:35 +0000 (UTC) Received: by ieje10 with SMTP id e10so3415603iej.11 for ; Thu, 20 Sep 2012 11:45:34 -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=7lebqkrnuBd6b5n1xBqMtBi6mQGm2Qf8q/cm1jLTRyM=; b=dAlX7LcpXRIpn+7+vD6GcEZEPPdLJInf71nv87ZJLyLbkRojymlMW5+lMeNe8w5Ef5 iJOc8tvheD5sx4oserk5RVrWF0gVKFcVA1NeXZPSy7Qx243JDa8ZTrEPoBVp/GMc3Kvh ZGvcD3/1m29tuV8Rbbdb+Asj8Qz3QQuT8AG6ZtwvrIL8UDDUt9N4HlACrI39ZtVV8Fxq s+JiYFh+It6NUAN/oWemG9Y2tC/Umhc/2GqF4QhrI/V30L/nAGEgFabtRLgDSljKmBuv JpTLJHDNaicREgwckT/F9x6adhCWMvzJh1T+JFtaNFMgwAOHnOSGY/ubm+Yb3dTlJvk6 M+1w== Received: by 10.50.217.229 with SMTP id pb5mr2576148igc.28.1348166734641; Thu, 20 Sep 2012 11:45:34 -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 ex8csp92088igc; Thu, 20 Sep 2012 11:45:33 -0700 (PDT) Received: by 10.14.215.193 with SMTP id e41mr3334323eep.44.1348166733108; Thu, 20 Sep 2012 11:45:33 -0700 (PDT) Received: from eu1sys200aog109.obsmtp.com (eu1sys200aog109.obsmtp.com [207.126.144.127]) by mx.google.com with SMTP id h44si801581eeo.97.2012.09.20.11.45.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 20 Sep 2012 11:45:32 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.127 is neither permitted nor denied by best guess record for domain of johan.rudholm@stericsson.com) client-ip=207.126.144.127; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.127 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 eu1sys200aob109.postini.com ([207.126.147.11]) with SMTP ID DSNKUFtjdvO7NB9YVTUGNvIXma9k7d0/886x@postini.com; Thu, 20 Sep 2012 18:45:32 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 52599B1; Thu, 20 Sep 2012 18:33:38 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id F1DC5B72; Thu, 20 Sep 2012 18:41:52 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 8F69424C07C; Thu, 20 Sep 2012 20:41:42 +0200 (CEST) Received: from steludxu1610.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Thu, 20 Sep 2012 20:41:52 +0200 From: Johan Rudholm To: , Chris Ball Cc: Per Forlin , Ulf Hansson , Johan Rudholm Subject: [PATCH 1/2] mmc: core: Proper signal voltage switch Date: Thu, 20 Sep 2012 20:40:54 +0200 Message-ID: <1348166454-3210-1-git-send-email-johan.rudholm@stericsson.com> X-Mailer: git-send-email 1.7.10 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQntyaMFLOfeLmuROJE9VkboJjxPbOR1G1rHrUYXKSwtP2w5PUirxzhZWt3+IisVnT1FPOor 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 --- drivers/mmc/core/core.c | 24 ++++++++++++++++++++++-- include/linux/mmc/host.h | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 6612163..3779431 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,9 +1244,28 @@ 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) { - mmc_host_clk_hold(host); + u32 clock = host->ios.clock; + + host->ios.clock = 0; + mmc_set_ios(host); err = host->ops->start_signal_voltage_switch(host, &host->ios); - mmc_host_clk_release(host); + + /* 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; + } } return err; 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);