From patchwork Mon Aug 21 16:02:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9913169 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 1EC99602A0 for ; Mon, 21 Aug 2017 16:05:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 158E32877E for ; Mon, 21 Aug 2017 16:05:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A262287B3; Mon, 21 Aug 2017 16:05:35 +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 928FB287B9 for ; Mon, 21 Aug 2017 16:05:34 +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=Z20hTA1NeApqjWPIGwODL4/M4y+PldB2ptMjBEsfGVg=; b=LrUPfFk3wCTt5Qhv1KmmYbnUtc J+L2aogLfrtlamJDnIuVPdpjPiubZPetCNjdKu3POlps+hG/DTavY7+B2Cgr3zFONd5NQvuKduotz /Ly1/LRAPdg3GjRZKyIXPR+BtaDJDJvDWeN59ohBmy9OH0jUnL8yD7SwhQa+P38dWC8NWUn4q3b3L SEj+uaCwOS1GTM2sDR8wiSd3gmrHQNeAYUqu+2VS2Szj+hGt/wyaxgjs9/dLQ033XN9Yhn861hH7k LWtsvycLTLGZrRTusgdjSkOBIzC0XgodecBFEZGDWs/MVKI3/pFDJ1A415bXw+tcMuBT7B7eT4fE4 JQ/V90Xg==; 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 1djpCl-0003h3-It; Mon, 21 Aug 2017 16:05:31 +0000 Received: from mail-wr0-x231.google.com ([2a00:1450:400c:c0c::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1djpAo-0001FK-Ec for linux-arm-kernel@lists.infradead.org; Mon, 21 Aug 2017 16:03:37 +0000 Received: by mail-wr0-x231.google.com with SMTP id f8so66999436wrf.3 for ; Mon, 21 Aug 2017 09:03:14 -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=hr+C/T8uNZUC2Q3WmJzHqYHhdk4t7v/kNGCjMEB0QHI=; b=HmcpJvfZVk0kqQEzHqxtw+5SjsiYldI2svTrQr9BNsDLFvgU2N5hkJ0uVwL7xoBM1H ZiEakHIDhXdXeNNXSNDxOmaLDMsruj+u8LvPEpRKr12UEkvk8tAoVTlTlZFElZmJVKzx +REPoArnMC5ZS6UV2gzVpOkzq8zcIjZQAVH1F+m4wIKGeLf41SKyxfjdXcPEAHosoBTj jgly74dPyJxPCrVLBOUtKRI0/poBiJkgRXsqnlzK1+W7RpEHWLilCdtTTBiz4OkINBa5 k0qDQ1sjkCCVmRz+YdETN0IbX92oRd6Fil6wUBbRjJLP/1JhUwjV/riFRdM499U2Be4C pz4g== 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=hr+C/T8uNZUC2Q3WmJzHqYHhdk4t7v/kNGCjMEB0QHI=; b=DZLWvTpb3EUtBUYocVG8Exlz2yOcuUxgu1iCtI1Q6CSvszzoyQdNmLMfAx3znweHrw 5MnXlq1WqVQA0PjFLfM7tE3ozkTJDPmTHiHGdmZiqNvd+uG1DIcvK9WDZaNKpG5MioLD uRBE76f0ATeJJaQqjxtqfYuyCekUyoxL5RYwSXAPmHd8hBdzzXUS+H3QsRQ77CDlwWU1 O3XgA6nTSjojWpLK14+aXSk4VVQ6qj11LgmSH+rwzKTkiZ08jVPngGjy3oDjJzQm0W+t 7tDG02H92ZFsuYFaaQW2+iELq1w6dIiM/NJTXO0UfkxX/6oTXlblcC7FEJO2bncVktKV 9LKA== X-Gm-Message-State: AHYfb5gunTTi+lRp/092No8BU6744DxF1Kfba3CzRTjml6sF7CcG0K4z CCmTsfAPDdeaMfGV X-Received: by 10.223.195.210 with SMTP id d18mr6416689wrg.30.1503331393115; Mon, 21 Aug 2017 09:03:13 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 63sm8120063wra.30.2017.08.21.09.03.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 09:03:12 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Subject: [PATCH v2 07/16] mmc: meson-gx: rework clk_set function Date: Mon, 21 Aug 2017 18:02:52 +0200 Message-Id: <20170821160301.21899-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170821160301.21899-1-jbrunet@baylibre.com> References: <20170821160301.21899-1-jbrunet@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170821_090330_767757_B0B0ED26 X-CRM114-Status: GOOD ( 14.23 ) 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 18fff28025d8..8f9ba5190c18 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);