From patchwork Tue Jan 28 10:50:13 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Yang X-Patchwork-Id: 3546151 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 14D62C02DC for ; Tue, 28 Jan 2014 10:50:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3638F20127 for ; Tue, 28 Jan 2014 10:50:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21EA620125 for ; Tue, 28 Jan 2014 10:50:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751711AbaA1Kul (ORCPT ); Tue, 28 Jan 2014 05:50:41 -0500 Received: from mail-pd0-f194.google.com ([209.85.192.194]:49357 "EHLO mail-pd0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750816AbaA1Kuk (ORCPT ); Tue, 28 Jan 2014 05:50:40 -0500 Received: by mail-pd0-f194.google.com with SMTP id v10so101886pde.1 for ; Tue, 28 Jan 2014 02:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=hYdgxvK5Mu+rbdrttx6C/fK53CwO72XDsa1zxn2Y4Nw=; b=FpRe8CicwNdzh2McGS38vFBC1PRYskf0/9Z4PMakhBF5IGtro1fZ8L7MXf/c1ZJkmU EnSkdNTspqbO3Nis/y7fhIV/vhfqB/561fotXKJD6BvxgqHrjvM7Q+UcYc7BMyG2JKr6 j9mygjN4DizdJIsnzGYG95zUFXUvgVOcjpfqpZI/rKvCqBuC2H9TF0d+SWffP9ERtDhD lsN6wc8LJkixgeqtOY70dgEr3J6+QY+48kISRcsk+A6B9CKbVS6UVqs0PmH0Cs7/Gmo9 4qWgPgpM0f30zrJqxItpgFni/522alJvKlWOIYXlw52RvrX2QcBdjHWyuf3h28IL+OYb ugog== X-Received: by 10.66.142.233 with SMTP id rz9mr749855pab.71.1390906239663; Tue, 28 Jan 2014 02:50:39 -0800 (PST) Received: from localhost.localdomain ([124.219.7.128]) by mx.google.com with ESMTPSA id db3sm41258757pbb.10.2014.01.28.02.50.36 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Jan 2014 02:50:38 -0800 (PST) From: Vincent Yang To: cjb@laptop.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: andy.green@linaro.org, jaswinder.singh@linaro.org, fujitsu@lists.linaro.org, nonaka.h@jp.fujitsu.com, Vincent Yang Subject: [PATCH] mmc: core: Prevent unexpected SD Clock gating during Signal Voltage Switch Procedure Date: Tue, 28 Jan 2014 18:50:13 +0800 Message-Id: <1390906213-7612-1-git-send-email-Vincent.Yang@tw.fujitsu.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When switching the signal voltage from 3.3V to 1.8V, there should be only one SD Clock gating and un-gating operation. Between them the SD host controller should switch signal level to 1.8V. However, sometimes there is an additional gating and un-gating operation immediately after CMD11. This operation can cause some UHS-I cards report failure by holding DAT[3:0] low. It is because CONFIG_MMC_CLKGATE attempts to aggressively gate the clock for power saving. This patch is going to hold SD Clock before CMD11, therefore, the additional gating and un-gating operation can be prevented. It has been verified on some UHS-I SD memory cards and works correctly. Acked-by: Ulf Hansson --- drivers/mmc/core/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 098374b..86a35ef 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -1432,6 +1432,8 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) pr_warning("%s: cannot verify signal voltage switch\n", mmc_hostname(host)); + mmc_host_clk_hold(host); + cmd.opcode = SD_SWITCH_VOLTAGE; cmd.arg = 0; cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; @@ -1442,8 +1444,6 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage, u32 ocr) if (!mmc_host_is_spi(host) && (cmd.resp[0] & R1_ERROR)) return -EIO; - - mmc_host_clk_hold(host); /* * The card should drive cmd and dat[0:3] low immediately * after the response of cmd11, but wait 1 ms to be sure