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: 4232461 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 632929F32B for ; Fri, 23 May 2014 12:54:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92CE1202C8 for ; Fri, 23 May 2014 12:54:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A1E8120108 for ; Fri, 23 May 2014 12:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbaEWMxH (ORCPT ); Fri, 23 May 2014 08:53:07 -0400 Received: from mail-wg0-f51.google.com ([74.125.82.51]:43855 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753112AbaEWMxD (ORCPT ); Fri, 23 May 2014 08:53:03 -0400 Received: by mail-wg0-f51.google.com with SMTP id x13so4675955wgg.34 for ; Fri, 23 May 2014 05:53:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2zDq3FKA8jEK94BNzbhVi3jiS04V22Io85hUf/+Qxss=; b=JUJVXv4RU6hKUFJVBtx+Vy7R2dZy7tMyJ0j5tMtj3Zg0Qzo1/RbgSeMMy6VAP/3SXq OGk3xgNCJcm3FFq82vaN92nc654+Me2c2c9QV6LxPKN+r1d900yWSoSeJr1rIuQCQ9wC cppJPP4uM6nDLJN5pk8UF3fXj74YFi4h/iSAY8A71zeEXuILRVWZN/8yuwsvs5xKvtgr wxXMSE4ExhQAcn8W7tPcPkrOnUE7MEBj3kjRu/sv7PbgTR5Sx1oSSNqPmH2ZuTpk0W+1 lsRfhiOCl/wFMDvJlHjd0lkmljt6ypLjX2aLAp0/f74M3ZfY23CuiqNdvxyu+kwFR3MT +W8w== X-Gm-Message-State: ALoCoQnUAIwAWA6qmSculcKoBuwnnfoEdbhzXyHuHLVGVC8POR+l6lOxD3MvIjoNrhAQ09nGHKxX 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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 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 */