From patchwork Mon Aug 28 14:29:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 111159 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4918240qge; Mon, 28 Aug 2017 07:29:30 -0700 (PDT) X-Received: by 10.84.129.103 with SMTP id 94mr1010190plb.113.1503930570079; Mon, 28 Aug 2017 07:29:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503930570; cv=none; d=google.com; s=arc-20160816; b=VzllipEpJkXxMy8aH7sLck+jLXd6Ojl321WNo6xwXx962AaBSSGbOiAlab5aDkncBW hek8LvcVLe1j+H0WixCDNLkgMKW7Tpv79TPVfxk7BcOh6Owg/k/fmEKy+rlQxgTvsiK2 zpxVJkE2yV5kSjVX6V7565+sSE51pGiCe0MuHXP/S0/ij4ONKWkkN2dBBkWuwL9zOhba hGiny9TAZwEcBBbOo6f0R8d2nmA4IikDRMIX4/vRySUHl0pDprzTnY0L1xvzephoq0Y4 C2z3VKFIlokbnYbgO1HR3k7AyZnWX2vnKNYZe+uRVSSwW12kt1C5zIbCmKp+Cq1d8r4N oO8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=afyHp2o2S6masuQIEbzSGY2kewHHHRdXqO9NNXzKKWA=; b=cQi4cDBUOGtoKQ1kCWdSwJno/iVFGNN1bhBbFrfldRxF3U3VZHI4w7UTrqO9589/VQ 08SG2VWpmTiaMNbaEmJlW3LVZuMe3rE5sxdTxF71pcRzKOk/pP8W8gnL1mTUh4SCUUSH XkY6c15UyzHPfZrJV7vkgbso0eXSU28V0Q6+Z3CF0AV9xOH1z/NOMEC6oH+8/K1u9OFY sBBstGO4nP1nKfUL0dc9wgyFhnB7E1U5bsBRk2k1tIpM1iwpubm1AgpVrI43zRTs7jBD ks4EviyVS9hmaa6FMIUh4RnILvhjqlYPU8sPiAvB/vYCDW4je5h8XUg1bGarR5C05vZk HuIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xJo3zfgu; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s36si400338pld.335.2017.08.28.07.29.29; Mon, 28 Aug 2017 07:29:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=xJo3zfgu; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751394AbdH1O31 (ORCPT + 6 others); Mon, 28 Aug 2017 10:29:27 -0400 Received: from mail-wm0-f50.google.com ([74.125.82.50]:36900 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbdH1O3Z (ORCPT ); Mon, 28 Aug 2017 10:29:25 -0400 Received: by mail-wm0-f50.google.com with SMTP id u26so4787736wma.0 for ; Mon, 28 Aug 2017 07:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q6ZzmRUbf+Bq71L5VxJpb47uoLFu6DnJxkYZN7wmFi8=; b=xJo3zfguHQElNtohBL40VMjIy0cEMoLTLionFo1gi5/lKHmAuquzQMGtf51ktO7kp/ hYNi5y+DiJGUz/7cfUP29VichaacJbFLWZrc8tXsYJ4vVvXs/+AOB7cFrw+F+v6pNyAZ tSh4x45Iw+UxXYwWdc/4JoHNm62cWgTskSmSOLjTVe/sY4Q9Mxn/yEOYVgrFUmeJm96r xEUq50IFM0hjgVV/6jp9yviujzXFAIPkDLGIxM30VGvJYWeuQVAm/EwbPuKx/7I7j2bw mxHStEVjaWe4saE/VdUAXIw1MjQclwmc5qsTXSXJPkhemVlV6l01PE3YQ7872sP8U3nF /zDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q6ZzmRUbf+Bq71L5VxJpb47uoLFu6DnJxkYZN7wmFi8=; b=CdQRv8l+sWsDqqYQbp6PEqPLh0mivzyOhG2LLR2P8qq+kW2HsI4Bh3dpmNadHvJJsI WQJtotxiHGWw/+JiXP38SJ/5M4xRYKSAnHt7jN8uUA5xc3uZwd42T3E64JEv6iKGH2DM 02BLHmZOM9LwPNhDeBRxZLy14idq7Wsg3ejYXC2QZm98UUsBQQnrGUgwU8M3K7VHZOMr yL6u0mwoESLCH1MbG+gYwGjyHWAn3aS3S+d85CyManGbOJqOjSLYujd0jOo5pXFv5r/p zvB8Q9DfKrjYBUYa3cGnjezgnjOzIQK8brHmxgSEFZaUT4J0eItI96rCxlB1nh6axd/v R/Xg== X-Gm-Message-State: AHYfb5jDDei0K8wg7Q1XRxnsSaATLCnwg/TVrosar8CyisIbTRg3n/r/ W15DSzUtaoc26Z1T X-Received: by 10.28.220.212 with SMTP id t203mr559335wmg.174.1503930563398; Mon, 28 Aug 2017 07:29:23 -0700 (PDT) Received: from localhost.localdomain (uluru.liltaz.com. [163.172.81.188]) by smtp.googlemail.com with ESMTPSA id z39sm604792wrz.61.2017.08.28.07.29.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 07:29:22 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/13] mmc: meson-gx: rework clk_set function Date: Mon, 28 Aug 2017 16:29:06 +0200 Message-Id: <20170828142915.27020-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170828142915.27020-1-jbrunet@baylibre.com> References: <20170828142915.27020-1-jbrunet@baylibre.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Clean-up clk_set function to prepare the next changes (DDR and clk-stop) Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) -- 2.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 0d29f1f347eb..cd5964aa4f58 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -139,7 +139,7 @@ struct meson_host { struct clk *core_clk; struct clk_mux mux; struct clk *mux_clk; - unsigned long current_clock; + unsigned long req_rate; struct clk_divider cfg_div; struct clk *cfg_div_clk; @@ -275,29 +275,18 @@ static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) int ret; u32 cfg; - if (clk_rate) { - if (WARN_ON(clk_rate > mmc->f_max)) - clk_rate = mmc->f_max; - else if (WARN_ON(clk_rate < mmc->f_min)) - clk_rate = mmc->f_min; - } - - if (clk_rate == host->current_clock) + /* Same request - bail-out */ + if (host->req_rate == clk_rate) return 0; /* stop clock */ cfg = readl(host->regs + SD_EMMC_CFG); - if (!(cfg & CFG_STOP_CLOCK)) { - cfg |= CFG_STOP_CLOCK; - writel(cfg, host->regs + SD_EMMC_CFG); - } - - dev_dbg(host->dev, "change clock rate %u -> %lu\n", - mmc->actual_clock, clk_rate); + cfg |= CFG_STOP_CLOCK; + writel(cfg, host->regs + SD_EMMC_CFG); + host->req_rate = 0; if (!clk_rate) { mmc->actual_clock = 0; - host->current_clock = 0; /* return with clock being stopped */ return 0; } @@ -309,13 +298,12 @@ static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) return ret; } + host->req_rate = clk_rate; mmc->actual_clock = clk_get_rate(host->cfg_div_clk); - host->current_clock = clk_rate; + dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); if (clk_rate != mmc->actual_clock) - dev_dbg(host->dev, - "divider requested rate %lu != actual rate %u\n", - clk_rate, mmc->actual_clock); + dev_dbg(host->dev, "requested rate was %lu\n", clk_rate); /* (re)start clock */ cfg = readl(host->regs + SD_EMMC_CFG);