From patchwork Fri Apr 1 15:44:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 8725811 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A669F9F38C for ; Fri, 1 Apr 2016 15:45:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28E3D203C4 for ; Fri, 1 Apr 2016 15:45:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F1DA2028D for ; Fri, 1 Apr 2016 15:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754852AbcDAPpQ (ORCPT ); Fri, 1 Apr 2016 11:45:16 -0400 Received: from sauhun.de ([89.238.76.85]:60304 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753665AbcDAPpH (ORCPT ); Fri, 1 Apr 2016 11:45:07 -0400 Received: from p4fe25416.dip0.t-ipconnect.de ([79.226.84.22]:54658 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1am1Fw-0005qr-LA; Fri, 01 Apr 2016 17:45:04 +0200 From: Wolfram Sang To: linux-mmc@vger.kernel.org Cc: Wolfram Sang , linux-renesas-soc@vger.kernel.org, Ben Hutchings Subject: [PATCH v2 4/9] mmc: tmio: always start clock after frequency calculation Date: Fri, 1 Apr 2016 17:44:34 +0200 Message-Id: <1459525479-20842-5-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1459525479-20842-1-git-send-email-wsa@the-dreams.de> References: <1459525479-20842-1-git-send-email-wsa@the-dreams.de> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wolfram Sang Starting the clock is always done after frequency change anyhow, so we can do it directly after the clock calculation and remove the specific calls. This is the first part of doing proper clock de-/activation at calculation time. Signed-off-by: Wolfram Sang --- drivers/mmc/host/tmio_mmc_pio.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index 53e5ba5a21914c..a05938da049bd6 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c @@ -154,6 +154,18 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) } } +static void tmio_mmc_clk_start(struct tmio_mmc_host *host) +{ + sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN | + sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); + msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 1 : 10); + + if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) { + sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100); + msleep(10); + } +} + static void tmio_mmc_set_clock(struct tmio_mmc_host *host, unsigned int new_clock) { @@ -182,6 +194,8 @@ static void tmio_mmc_set_clock(struct tmio_mmc_host *host, sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & CLK_CTL_DIV_MASK); if (!(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG)) msleep(10); + + tmio_mmc_clk_start(host); } static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) @@ -196,18 +210,6 @@ static void tmio_mmc_clk_stop(struct tmio_mmc_host *host) msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 5 : 10); } -static void tmio_mmc_clk_start(struct tmio_mmc_host *host) -{ - sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, CLK_CTL_SCLKEN | - sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL)); - msleep(host->pdata->flags & TMIO_MMC_FAST_CLK_CHG ? 1 : 10); - - if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) { - sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100); - msleep(10); - } -} - static void tmio_mmc_reset(struct tmio_mmc_host *host) { /* FIXME - should we set stop clock reg here */ @@ -955,14 +957,12 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) tmio_mmc_clk_stop(host); break; case MMC_POWER_UP: - tmio_mmc_set_clock(host, ios->clock); tmio_mmc_power_on(host, ios->vdd); - tmio_mmc_clk_start(host); + tmio_mmc_set_clock(host, ios->clock); tmio_mmc_set_bus_width(host, ios->bus_width); break; case MMC_POWER_ON: tmio_mmc_set_clock(host, ios->clock); - tmio_mmc_clk_start(host); tmio_mmc_set_bus_width(host, ios->bus_width); break; } @@ -1271,10 +1271,8 @@ int tmio_mmc_host_runtime_resume(struct device *dev) tmio_mmc_reset(host); tmio_mmc_clk_enable(host); - if (host->clk_cache) { + if (host->clk_cache) tmio_mmc_set_clock(host, host->clk_cache); - tmio_mmc_clk_start(host); - } tmio_mmc_enable_dma(host, true);