From patchwork Fri Aug 4 17:43:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 9881941 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 673CA60360 for ; Fri, 4 Aug 2017 18:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55142288DF for ; Fri, 4 Aug 2017 18:49:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 483B6289DE; Fri, 4 Aug 2017 18:49: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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE 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 1F814288DF for ; Fri, 4 Aug 2017 18:49:33 +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=nn4Cic5r0a10GKmSF4W0ll8Df071Qa/QEozQcHINag0=; b=jCMRJ9SYBuOy5H7YbztoGTiE7B ucuJKSf7GpHbo/N43FrqSfFldlUey9j832ZOdB7ktSMycghHtYcckwBgpXdEr9IgKr6UKVOzHd1jN p1pLetCSEpZlqnEaZQvUTHqb6QlIyPu/8yKlVsKDAu5A8dV8cdzY4e4tTWTTlMXICvnvV8CtJR/1O on76Tffpy067fV29aFrf7cI9MCFZy1eoBwnLA7AamE9xqs7to+fbGvQ8pW028kEgM0O1PBou+01cR G9tJYMigGc4DILHM1bzrfDP5RbT2KLsi6kKI53az9vpHwjg3rrjyXBUjnJC9m9SfqUtZwQ2rFupCf ag1IuNFA==; 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 1ddhf8-0006pZ-2g; Fri, 04 Aug 2017 18:49:30 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddhf5-0006p8-CQ for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Aug 2017 18:49:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PtNyZothBHk4rSMpMPjQGgngGnIBEhWGyWASzoTeU9g=; b=ix3evQXMoKMCXV6z3jomeCb0+ URqG4DJDmegxxyLsbzDGsaUJzfIzo8ObpkP7B5KyLMyo+p5WWLY0DW873FMNz33Ltn+qUmcsub0Vf +F/m68GWWzIu21+S9SOhSx/xSD8Defkbc7yqtxcJ5ZeUOGl4mAV4YcLGtBnUX6e15yO6w0b5HbRx1 iqYUqybrKALqrQJ8Q6DckloQVcqa2MFkNnwYbFmH2xd/HCUuq73gWE73nxtaStZWhp4oPB+fCGs6n KjpJgTJ9a+ZobYIoRNogfTyNNHOaXkxW+TdF3flvJ0nbbiEu4753hdpFrb9/v5LDPJI/mGbN667m9 G9HyiqZGQ==; Received: from mail-wm0-x22b.google.com ([2a00:1450:400c:c09::22b]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ddgeJ-0001yV-8S for linux-arm-kernel@lists.infradead.org; Fri, 04 Aug 2017 17:44:38 +0000 Received: by mail-wm0-x22b.google.com with SMTP id m85so25329587wma.0 for ; Fri, 04 Aug 2017 10:44:11 -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=PtNyZothBHk4rSMpMPjQGgngGnIBEhWGyWASzoTeU9g=; b=KRHV822i/E+RJTwaJKBPBmpPdbfsH/te1Chg4NGEE/nFtxBxfwLi+EBtxB32O9GjCV 3C8tLz2cIVl+loTzcn2LbucWxT1YzWmlJz6Rn0SmAYvi45l0N0+BO2h4ZAfr/WKhY3ty MCXaoSmwerbK2PLYee4K/pFTwvExU1yyKe0VVskLN1Q/8BbG3POqH1qtUH3rWuSeM27k 0qRI71zmUWJOMFo+cpTFAPTI7QmqeDx2fvuvEkZ/4K6Fx/trKSjC0zLvFDp8iFz5eJZs C2zSDdDUYvkuG7wUSAO6OVLraWaEWpppt3xVOWVouIsXqSw0K+4UZd0dxEzn6YNLFBzC QXVA== 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=PtNyZothBHk4rSMpMPjQGgngGnIBEhWGyWASzoTeU9g=; b=k+qg9D3lUn3VjjtdYTCS5ixMDbVuHZ9/sRZiRnIr5hBSa/lUP3E7m+vzai0Ki4KBSk BqSkoyoIWs1S9OHHnFU7Nyhj/3TEtXpabcQtUi/SelQ0TRySR0P6gPNUYW8/HD0c9Tn7 NGPQyXz7IF2SCCj62vazEpvmfDIA+drhv+x3mjbRjHr6KaoK9qnuZAIAZmOzN8GKoTik zwJ/61Hmko2pSy0YgnpwztYUgSbIWtV+v3dtWOKT6fsl/BhgstVg7HmzPFNitIBx77ZA nSICn5gasDIn8ILXLA74hCggDTElaK/4jQa774qDSkfkS/35QeRwUrBdAZ+XVo6TIgg2 Svtw== X-Gm-Message-State: AHYfb5gVHmjW196lBBwsgGhIU2xxnkcYqa7RMKkK/bK/3+yh/qG62s64 hLdRXgheqG8Ko3Xn X-Received: by 10.28.236.8 with SMTP id k8mr1723760wmh.139.1501868649993; Fri, 04 Aug 2017 10:44:09 -0700 (PDT) Received: from localhost.localdomain (cag06-3-82-243-161-21.fbx.proxad.net. [82.243.161.21]) by smtp.googlemail.com with ESMTPSA id p17sm996082wma.45.2017.08.04.10.44.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 04 Aug 2017 10:44:09 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Subject: [PATCH 07/14] mmc: meson-gx: rework clk_set function Date: Fri, 4 Aug 2017 19:43:46 +0200 Message-Id: <20170804174353.16486-8-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170804174353.16486-1-jbrunet@baylibre.com> References: <20170804174353.16486-1-jbrunet@baylibre.com> 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) 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);