From patchwork Fri May 23 12:52:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 30773 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1FB0B2066E for ; Fri, 23 May 2014 12:53:29 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id l6sf22986149oag.3 for ; Fri, 23 May 2014 05:53:29 -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=FcV1JsXm98GfG+Zl/HwhzcpDfgww++qwLNfjPM3btoM=; b=RD0KXLIF7+eozpUXSlG/ocg9An6/HQGEGW6danzneC7a2ARUm3LNBSyTMEnJ7zAt/5 t1vmzr3Jazpyw7Lv/NTgbkClaa7/UcyFqqyct/LQgiFCgszooo0p56KllkDzcW1BqbYH u0RJchSoW8eCKWqq76XiivDIcV8X0puoLu25sDaqhQgaS1ImfET7UplMw2e92a5f8pWC QLRBAK/6PriyGea5gPbrVklsS5DUV8JTW7bQY/hGuET3PtQnFySZoHTcEwqb2UG+2XYU ln/CN0sDHsTExOyzxvG4kVv01JXCvdqYgpl5+OmskaqB1V2fM2OCb39EBtVQk+DLEXvs Vsgg== X-Gm-Message-State: ALoCoQlxCIm9n8259Qt2pUBuII1RP8A2O87qzwwUTOzum+fQr84S/S1PINq3u8rh2J8rC1LaqLtg X-Received: by 10.182.104.74 with SMTP id gc10mr2059527obb.40.1400849609450; Fri, 23 May 2014 05:53:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.105.54 with SMTP id b51ls1765052qgf.48.gmail; Fri, 23 May 2014 05:53:29 -0700 (PDT) X-Received: by 10.52.166.18 with SMTP id zc18mr175527vdb.65.1400849609284; Fri, 23 May 2014 05:53:29 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id nd5si1537129vec.85.2014.05.23.05.53.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 May 2014 05:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so6123462veb.6 for ; Fri, 23 May 2014 05:53:29 -0700 (PDT) X-Received: by 10.58.245.2 with SMTP id xk2mr3872515vec.9.1400849609211; Fri, 23 May 2014 05:53:29 -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 ib8csp29078vcb; Fri, 23 May 2014 05:53:28 -0700 (PDT) X-Received: by 10.68.164.67 with SMTP id yo3mr5771530pbb.104.1400849608356; Fri, 23 May 2014 05:53:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oi6si3703641pbb.195.2014.05.23.05.53.27 for ; Fri, 23 May 2014 05:53:27 -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 S1753158AbaEWMxJ (ORCPT + 27 others); Fri, 23 May 2014 08:53:09 -0400 Received: from mail-wg0-f47.google.com ([74.125.82.47]:36894 "EHLO mail-wg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753111AbaEWMxD (ORCPT ); Fri, 23 May 2014 08:53:03 -0400 Received: by mail-wg0-f47.google.com with SMTP id x12so4704380wgg.6 for ; Fri, 23 May 2014 05:53:02 -0700 (PDT) X-Received: by 10.194.221.69 with SMTP id qc5mr1679620wjc.91.1400849582433; Fri, 23 May 2014 05:53:02 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-78-149-4-211.as13285.net. [78.149.4.211]) by mx.google.com with ESMTPSA id cv4sm3800963wjc.34.2014.05.23.05.53.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 May 2014 05:53:01 -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 v3 12/13] mmc: mmci: add explicit clk control Date: Fri, 23 May 2014 13:52:58 +0100 Message-Id: <1400849578-7585-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1400849362-7007-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1400849362-7007-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.128.175 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 On Controllers like Qcom SD card controller where cclk is mclk and mclk should be directly controlled by the driver. This patch adds support to control mclk directly in the driver, and also adds explicit_mclk_control and cclk_is_mclk flags in variant structure giving more flexibility to the driver. Signed-off-by: Srinivas Kandagatla Reviewed-by: Linus Walleij --- drivers/mmc/host/mmci.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 5cbf644..f6dfd24 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -73,6 +73,8 @@ static unsigned int fmax = 515633; * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply * @mclk_delayed_writes: enable delayed writes to ensure, subsequent updates * are not ignored. + * @explicit_mclk_control: enable explicit mclk control in driver. + * @cclk_is_mclk: enable iff card clock is multimedia card adapter clock. */ struct variant_data { unsigned int clkreg; @@ -94,6 +96,8 @@ struct variant_data { bool busy_detect; bool pwrreg_nopower; bool mclk_delayed_writes; + bool explicit_mclk_control; + bool cclk_is_mclk; }; static struct variant_data variant_arm = { @@ -202,6 +206,8 @@ static struct variant_data variant_qcom = { * for 3 clk cycles. */ .mclk_delayed_writes = true, + .explicit_mclk_control = true, + .cclk_is_mclk = true, }; static inline u32 mmci_readl(struct mmci_host *host, u32 off) @@ -317,7 +323,9 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) host->cclk = 0; if (desired) { - if (desired >= host->mclk) { + if (variant->cclk_is_mclk) { + host->cclk = host->mclk; + } else if (desired >= host->mclk) { clk = MCI_CLK_BYPASS; if (variant->st_clkdiv) clk |= MCI_ST_UX500_NEG_EDGE; @@ -1354,6 +1362,16 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (!ios->clock && variant->pwrreg_clkgate) pwr &= ~MCI_PWR_ON; + if (ios->clock != host->mclk && host->variant->explicit_mclk_control) { + int rc = clk_set_rate(host->clk, ios->clock); + if (rc < 0) { + dev_err(mmc_dev(host->mmc), + "Error setting clock rate (%d)\n", rc); + } else { + host->mclk = clk_get_rate(host->clk); + } + } + spin_lock_irqsave(&host->lock, flags); mmci_set_clkreg(host, ios->clock); @@ -1540,10 +1558,12 @@ static int mmci_probe(struct amba_device *dev, * is not specified. Either value must not exceed the clock rate into * the block, of course. */ - if (mmc->f_max) - mmc->f_max = min(host->mclk, mmc->f_max); - else - mmc->f_max = min(host->mclk, fmax); + if (!host->variant->explicit_mclk_control) { + if (mmc->f_max) + mmc->f_max = min(host->mclk, mmc->f_max); + else + mmc->f_max = min(host->mclk, fmax); + } dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); /* Get regulators and the supported OCR mask */