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: 9925683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4696860329 for ; Mon, 28 Aug 2017 14:35:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39B6220453 for ; Mon, 28 Aug 2017 14:35:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EA9E286E0; Mon, 28 Aug 2017 14:35:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E01D720453 for ; Mon, 28 Aug 2017 14:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ESR6U+D/ojPh32603IzSMvzyQeV18AEfvWer2E4u3M8=; b=BeogJGPdGFytZRRvtcPLhs5o/7 Wp1MpYtNqTDpIBWAWsZThS1Hn+Y4DMjllJNb/wfHxQD+cZIwx4eFQSyBnDVPfe6n+f1GVOCP2D25y 8BTaPHeCIH211po8uZspBJn8DRNcKixaSVmJe8gDJYFbPA/yDAxhQKi280F7EWTYn1TGr2iaxVWVp y/W+TF/BSYAKaPLMj0puA0YBIZnpe9cW1FgiwtwN4Zc6PAkADqcDKwXwbcBdzsqzQi17Dq7MJy29W XcDD6PdvIKdSZvGctffzQb+F7bNgtgIvRm9Rodm5n8/30qQerWN8OsUD/njg0O/k1WYQHqTWNEHu5 z8g83fSA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmL8o-0002C9-6i; Mon, 28 Aug 2017 14:35:50 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmL2v-0004Wt-7B for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 14:29:54 +0000 Received: by mail-wm0-x234.google.com with SMTP id u26so4787739wma.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=YPfyl7kj7mx0m0yJPxUeyuiS+1QKhibkE7sVj3ymK3GrBBjAb7/mQgBasWKEu6kcT+ 4oZKGH5BuLase9hzT0huDRTL4XdQQ/R9MgfG7xNY5nUtGyKw6aq9XmNoDawjXdhnks0I OAjTGr5kSolKVW0hXfag7+o34O0z7NaSqZC3SSqjKXnI/rfTxoKBFgb1ab0ijmCBcOzX XaeU+uLAB/c+vh87gHYJBQ/zE9xzALQckmYZFeBdjoqzpateBcjI9sv4gm64IqexPs09 8rthNRKYA+HUO3C9JaJTQw2jqDbQ10922lxUcw+AF7M2zCkcgsipINiNxGvRWEAsDo6+ 93uA== X-Gm-Message-State: AHYfb5hIXg9fEH0prceMv6IKcC4/FWfPzkZmgCPMi6vXGhKXSS/KCpYK YtKUuBldu7WZ2IKl 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170828_072945_508912_297E6C46 X-CRM114-Status: GOOD ( 13.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jerome Brunet MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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);