From patchwork Thu May 15 09:37:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 30233 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 843DA20446 for ; Thu, 15 May 2014 09:37:24 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id uo5sf4246894pbc.4 for ; Thu, 15 May 2014 02:37:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=sJ9LsSEyLnM9xeN64s6w5d39uEfiy5HKbtbC9o8puxo=; b=ckgXolJsvmeOujdx0EBDF9/TuMirfRrJqfQX1+Cf+YPCFLA48EZ+Uf0V3dsqAMcP3U FaaYr5tFADBZpqIsUuGUOC+7MCYgS/1Jmxsd8wiJx3g4pmNkE3as27nTq4xr1zzGLpmJ f3bdgme/tSuykDDbZmpMmfgCVHEGxo/KJfhwSKvqbX9sygL7adSsifsqiBk1nlYg+60Y I+AXz0R0+E8DUOz0cdLhwsNuvApdNHL8/f/WuhDGUew2AkucicRgVZH9mQMT0bvvlNzB GmohS9I7bdpdNgTKMayl/sI+IXp2Lpa0ouwjxJMFqvuci0z7AV9y6lE/qZDZjq2jJmDN ENpA== X-Gm-Message-State: ALoCoQkkIEskshENwZM8fKfqBzzvNgE/mXNyKJf9ujS7UxfYmjOpZ+LEGzVjd2TsQq9D/d+MwJHB X-Received: by 10.66.65.109 with SMTP id w13mr1907315pas.21.1400146643877; Thu, 15 May 2014 02:37:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.107.97 with SMTP id g88ls176133qgf.40.gmail; Thu, 15 May 2014 02:37:23 -0700 (PDT) X-Received: by 10.58.111.163 with SMTP id ij3mr7653397veb.26.1400146643736; Thu, 15 May 2014 02:37:23 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id aw3si83749vdd.147.2014.05.15.02.37.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 May 2014 02:37:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id il7so3998712vcb.18 for ; Thu, 15 May 2014 02:37:23 -0700 (PDT) X-Received: by 10.52.137.174 with SMTP id qj14mr6464157vdb.32.1400146643664; Thu, 15 May 2014 02:37:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp307844vcb; Thu, 15 May 2014 02:37:23 -0700 (PDT) X-Received: by 10.66.136.103 with SMTP id pz7mr11131606pab.140.1400146641847; Thu, 15 May 2014 02:37:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wh4si2393260pbc.219.2014.05.15.02.37.21; Thu, 15 May 2014 02:37:21 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754383AbaEOJhK (ORCPT + 27 others); Thu, 15 May 2014 05:37:10 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:55879 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754254AbaEOJhG (ORCPT ); Thu, 15 May 2014 05:37:06 -0400 Received: by mail-wg0-f43.google.com with SMTP id l18so3116313wgh.2 for ; Thu, 15 May 2014 02:37:04 -0700 (PDT) X-Received: by 10.180.94.37 with SMTP id cz5mr30388097wib.19.1400146624760; Thu, 15 May 2014 02:37:04 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-78-145-240-98.as13285.net. [78.145.240.98]) by mx.google.com with ESMTPSA id fi2sm32644758wib.2.2014.05.15.02.37.03 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 May 2014 02:37:03 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Russell King , Ulf Hansson , linux-mmc@vger.kernel.org Cc: Chris Ball , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linus.walleij@linaro.org, Srinivas Kandagatla Subject: [PATCH v2 06/14] mmc: mmci: Qcomm: Add 3 clock cycle delay after register write Date: Thu, 15 May 2014 10:37:01 +0100 Message-Id: <1400146621-30056-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400146447-29803-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1400146447-29803-1-git-send-email-srinivas.kandagatla@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: srinivas.kandagatla@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Srinivas Kandagatla Most of the Qcomm SD card controller registers must be updated to the MCLK domain so subsequent writes to registers will be ignored until 3 clock cycles have passed. This patch adds a 3 clock cycle delay required after writing to controller registers on Qualcomm SOCs. Without this delay all the register writes are not successful, resulting in not detecting cards. The write clock delay is activated by setting up mclk_delayed_writes variable in variant data. Signed-off-by: Srinivas Kandagatla Reviewed-by: Linus Walleij --- drivers/mmc/host/mmci.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 881bb24..1385554 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -67,6 +67,8 @@ static unsigned int fmax = 515633; * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock * @busy_detect: true if busy detection on dat0 is supported * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply + * @mclk_delayed_writes: enable delayed writes to ensure, subsequent updates + * are not ignored. */ struct variant_data { unsigned int clkreg; @@ -83,6 +85,7 @@ struct variant_data { bool pwrreg_clkgate; bool busy_detect; bool pwrreg_nopower; + bool mclk_delayed_writes; }; static struct variant_data variant_arm = { @@ -171,6 +174,12 @@ static struct variant_data variant_qcom = { .datalength_bits = 24, .blksz_datactrl4 = true, .pwrreg_powerup = MCI_PWR_UP, + /* + * On QCom SD card controller, registers must be updated to the + * MCLK domain so subsequent writes to this register will be ignored + * for 3 clk cycles. + */ + .mclk_delayed_writes = true, }; static inline u32 mmci_readl(struct mmci_host *host, u32 off) @@ -181,6 +190,9 @@ static inline u32 mmci_readl(struct mmci_host *host, u32 off) static inline void mmci_writel(struct mmci_host *host, u32 data, u32 off) { writel(data, host->base + off); + + if (host->variant->mclk_delayed_writes) + udelay(DIV_ROUND_UP((3 * USEC_PER_SEC), host->mclk)); } static int mmci_card_busy(struct mmc_host *mmc)