From patchwork Tue Apr 29 08:20:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 29311 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BFCC1202FE for ; Tue, 29 Apr 2014 08:21:15 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id j17sf46345882oag.2 for ; Tue, 29 Apr 2014 01:21:15 -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=uhDVqgKNEEFVLIlQhWFREvy6JvDG3oz47PCBorxp8mI=; b=b7QhpADMQZYq5CPZOGaCWcnZT0ogKzqIb5XG3bGhsr1+hg/XWFII9R0rqwBZt81mxf Ya1KxZMqdiZpOXvj/xHOney1HxMTCISB2txwhuf8EmoyI/FoPAuT+HDtmKp8He5jZR4b X/v/XwoYKe7Q4vfL2fnXlD2fW5gMqLBvZRaHRTLIsoqTMG13UnHMYyxKkyHqI+pTAbCX mlmAQb2A00xnHJAWP9cKgKNVfpUYghmoAZOa/v9YimABqU5GI2meVei6Rr2KIFHf9bZu ig4Fg5nj9i0hzJayDgNycU3R1vtol7DLXEE4cQ9+KmUktd2UI9pDHomCLor8Q/UUFGIi NvjA== X-Gm-Message-State: ALoCoQldcjrovEnM7iSkeDZL7ZTRVYLGcl/3tCaNi+tSL+J1PEiMfHDLGA70iUsiHNI8UVAslLWU X-Received: by 10.42.185.1 with SMTP id cm1mr14230549icb.10.1398759675327; Tue, 29 Apr 2014 01:21:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.47.10 with SMTP id l10ls2772551qga.4.gmail; Tue, 29 Apr 2014 01:21:15 -0700 (PDT) X-Received: by 10.52.37.130 with SMTP id y2mr65603vdj.38.1398759675176; Tue, 29 Apr 2014 01:21:15 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id cb3si4333591vdc.41.2014.04.29.01.21.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Apr 2014 01:21:15 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hr9so9553364vcb.15 for ; Tue, 29 Apr 2014 01:21:15 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr28400434vcm.11.1398759675091; Tue, 29 Apr 2014 01:21:15 -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 ib8csp178191vcb; Tue, 29 Apr 2014 01:21:14 -0700 (PDT) X-Received: by 10.66.159.233 with SMTP id xf9mr9580926pab.139.1398759674170; Tue, 29 Apr 2014 01:21:14 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hb8si1088579pbc.454.2014.04.29.01.21.13 for ; Tue, 29 Apr 2014 01:21:13 -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 S932882AbaD2IVF (ORCPT + 28 others); Tue, 29 Apr 2014 04:21:05 -0400 Received: from mail-we0-f178.google.com ([74.125.82.178]:33375 "EHLO mail-we0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932640AbaD2IU7 (ORCPT ); Tue, 29 Apr 2014 04:20:59 -0400 Received: by mail-we0-f178.google.com with SMTP id q59so1964986wes.9 for ; Tue, 29 Apr 2014 01:20:58 -0700 (PDT) X-Received: by 10.180.228.42 with SMTP id sf10mr18993516wic.33.1398759658401; Tue, 29 Apr 2014 01:20:58 -0700 (PDT) Received: from srinivas-Inspiron-N5050.dlink.com (host-78-147-6-229.as13285.net. [78.147.6.229]) by mx.google.com with ESMTPSA id pm5sm29968679wjc.11.2014.04.29.01.20.57 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Apr 2014 01:20:57 -0700 (PDT) From: srinivas.kandagatla@linaro.org To: Russell King , linux-mmc@vger.kernel.org Cc: Chris Ball , Ulf Hansson , linux-kernel@vger.kernel.org, agross@quicinc.com, linux-arm-msm@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH v1 09/11] mmc: mmci: Add clock support for Qualcomm. Date: Tue, 29 Apr 2014 09:20:51 +0100 Message-Id: <1398759651-13341-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1398759492-12970-1-git-send-email-srinivas.kandagatla@linaro.org> References: <1398759492-12970-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=neutral (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) 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 MCICLK going to card bus is directly driven by the clock controller, so the driver has to set the required rates depending on the state of the card. This bit of support is very much similar to bypass mode but there is no such thing called bypass mode in MCICLK register of Qcom SD card controller. By default the clock is directly driven by the clk controller. This patch adds clock support for Qualcomm SDCC in the driver. This bit of code is conditioned on hw designer. Signed-off-by: Srinivas Kandagatla --- drivers/mmc/host/mmci.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 35aed38..da135c0 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -290,7 +290,10 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired) host->cclk = 0; if (desired) { - if (desired >= host->mclk) { + + if (host->hw_designer == AMBA_VENDOR_QCOM) { + host->cclk = host->mclk; + } else if (desired >= host->mclk) { clk = MCI_CLK_BYPASS; if (variant->st_clkdiv) clk |= MCI_ST_UX500_NEG_EDGE; @@ -1371,6 +1374,19 @@ 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->hw_designer == AMBA_VENDOR_QCOM) { + /* Qcom MCLKCLK register does not define bypass bits */ + 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); + host->cclk = host->mclk; + } + } + spin_lock_irqsave(&host->lock, flags); mmci_set_clkreg(host, ios->clock); @@ -1611,7 +1627,8 @@ static int mmci_probe(struct amba_device *dev, * of course. */ if (plat->f_max) - mmc->f_max = min(host->mclk, plat->f_max); + mmc->f_max = (host->hw_designer == AMBA_VENDOR_QCOM) ? + plat->f_max : min(host->mclk, plat->f_max); else mmc->f_max = min(host->mclk, fmax); dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max);