From patchwork Sat Feb 18 13:22:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9581089 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 7C7C5604A4 for ; Sat, 18 Feb 2017 13:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DCC82846A for ; Sat, 18 Feb 2017 13:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62BB9283F3; Sat, 18 Feb 2017 13:27:21 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham 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 0B5C728480 for ; Sat, 18 Feb 2017 13:27:21 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7zOu6TwTrwkY9l/Fz6apqxkYpT1EImxRi+0Ab1qXEmM=; b=TiMtymYGT9t1Tz 2PMq20Xgq9zk06K5tPnD3pYduQeb31y0pdTVMWH3u9lIeWsvz5KxiP8y444RbJIKdUs8+jFtqiLo8 tXvjg2Pacaw3YYeTeU8u66WsxrJJcvllTwPU23zJOHjIt+d4/KvBsl5gmViD9o97NAAd41OZhMylW hKrv67RlKpKwV2xVftvDzaRysvb3BIGog2VD1UIaazX4kiADmFyXwMIJfBsiJtbSpY79xdg5Oc7Tu 53cqCZDWHyc2+OPuAoiJtZBgJO9Y8HT1Jwa/wJztFTt6PkaIhTNVpSSF37jots0UHdVHhqr0o+rty M6UIU2ESbn4Ns9OtedfA==; 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 1cf52i-0001Ft-PU; Sat, 18 Feb 2017 13:27:16 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cf52V-0000tz-PL for linux-amlogic@lists.infradead.org; Sat, 18 Feb 2017 13:27:09 +0000 Received: by mail-wm0-x243.google.com with SMTP id r18so6864287wmd.3 for ; Sat, 18 Feb 2017 05:26:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=2uaKGq9bXNCaN1M44ny0rcfu0zIj7KK6DAkjMgA+KMY=; b=TZjYtx0SK6+KlYc+8ObmqGqTwVr1QgLiw20fKyGlfh/lOEDOIFM82YhiW2iLS8CUmm tdIuAZYz+0XcYO6jasVWSDTVLVnFGorObnTMTHjEofgNEYUS0zs0fEQiItMlCxM8y/FD NTjimjbvqx4HkhpEgELg6PctIJv6Gal2lLzy3PzwGBFGmZRsm1Filu7Gtcnwb8UHSep9 Cg//inGnv8kamEgL6/s2mzo07CLwNLi8Pgn/73/2HRbsYaa/kL+FXn9KmtaLPJwhZPd4 Mf/QzP2bZ5LW/w9IdMpFQjsDnl1V748ZuBGgsKzcNrrNgh6yYpeqWQP9z3EmR0k3V1lL BNmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=2uaKGq9bXNCaN1M44ny0rcfu0zIj7KK6DAkjMgA+KMY=; b=VLNdPUjlvc1LFJOgE7QJF/VLjGUM51N2rq5Sl+hveDd8wCNhKfmc3qBmUdzW8dmmld XUPs+YpnretKuqu/VrJYTWcG5kt6ZQBe6bQQYWRyD7je4H0qa8yqt5Zv3geWl3yEeaSE UC0LAy1L31fABZ8rfWN+WgQBdoCYFZI13FZa6hs+cqMFpjT5sVkPQBnwRLe7xD4U6VA5 RA4aK//KtYD5aaI86EOPi3YGoyRaVUB+9wyF4xIFEqJNHeNqj0LEfTqMQfqRQmy+ed3f QRz++eg79B9iNHKUt5b42nkhfJsgC3Pqewqn6BtaGH5rqY9XG4oL7YdEa3qr5kMSpQRv TiRw== X-Gm-Message-State: AMke39khxxnJh19vVXGL2oU9EBHQGFHLOwNM3/pF9/GyuiRf+c+1wt06Nmql7YddrF/mtg== X-Received: by 10.28.180.132 with SMTP id d126mr9285046wmf.123.1487424401985; Sat, 18 Feb 2017 05:26:41 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:7c19:f774:dabe:f95d? (p200300C6EBDC40007C19F774DABEF95D.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:7c19:f774:dabe:f95d]) by smtp.googlemail.com with ESMTPSA id u189sm5671355wmu.1.2017.02.18.05.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 05:26:41 -0800 (PST) Subject: [PATCH v3 8/10] mmc: meson-gx: improve initial configuration To: Ulf Hansson , Kevin Hilman References: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> From: Heiner Kallweit Message-ID: <28e5119c-3779-4393-8bfb-38254c0761e0@gmail.com> Date: Sat, 18 Feb 2017 14:22:27 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <583f6496-68a9-b8e1-6b25-1f073f819a3c@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170218_052704_392373_4055C873 X-CRM114-Status: GOOD ( 10.46 ) X-BeenThere: linux-amlogic@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" Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Config values which are not changed during runtime we can set in the probe function already. The block size setting is overwritten later in meson_mmc_start_cmd anyway if needed, so it doesn't harm if we remove this setting in meson_mmc_set_ios. In addition: - write config register only if configuration changed - Initialize clocks after other config registers have been initialized Signed-off-by: Heiner Kallweit Acked-by: Kevin Hilman --- v2: - added acked-by v3: - rebased --- drivers/mmc/host/meson-gx-mmc.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 684cc088..e904b0a5 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -394,15 +394,6 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) val &= ~(CFG_BUS_WIDTH_MASK << CFG_BUS_WIDTH_SHIFT); val |= bus_width << CFG_BUS_WIDTH_SHIFT; - val &= ~(CFG_BLK_LEN_MASK << CFG_BLK_LEN_SHIFT); - val |= ilog2(SD_EMMC_CFG_BLK_SIZE) << CFG_BLK_LEN_SHIFT; - - val &= ~(CFG_RESP_TIMEOUT_MASK << CFG_RESP_TIMEOUT_SHIFT); - val |= ilog2(SD_EMMC_CFG_RESP_TIMEOUT) << CFG_RESP_TIMEOUT_SHIFT; - - val &= ~(CFG_RC_CC_MASK << CFG_RC_CC_SHIFT); - val |= ilog2(SD_EMMC_CFG_CMD_GAP) << CFG_RC_CC_SHIFT; - val &= ~CFG_DDR; if (ios->timing == MMC_TIMING_UHS_DDR50 || ios->timing == MMC_TIMING_MMC_DDR52 || @@ -413,11 +404,11 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) if (ios->timing == MMC_TIMING_MMC_HS400) val |= CFG_CHK_DS; - writel(val, host->regs + SD_EMMC_CFG); - - if (val != orig) + if (val != orig) { + writel(val, host->regs + SD_EMMC_CFG); dev_dbg(host->dev, "%s: SD_EMMC_CFG: 0x%08x -> 0x%08x\n", __func__, orig, val); + } } static void meson_mmc_request_done(struct mmc_host *mmc, @@ -695,6 +686,17 @@ static int meson_mmc_get_cd(struct mmc_host *mmc) return status; } +static void meson_mmc_cfg_init(struct meson_host *host) +{ + u32 cfg = 0; + + cfg |= ilog2(SD_EMMC_CFG_RESP_TIMEOUT) << CFG_RESP_TIMEOUT_SHIFT; + cfg |= ilog2(SD_EMMC_CFG_CMD_GAP) << CFG_RC_CC_SHIFT; + cfg |= ilog2(SD_EMMC_CFG_BLK_SIZE) << CFG_BLK_LEN_SHIFT; + + writel(cfg, host->regs + SD_EMMC_CFG); +} + static const struct mmc_host_ops meson_mmc_ops = { .request = meson_mmc_request, .set_ios = meson_mmc_set_ios, @@ -755,10 +757,6 @@ static int meson_mmc_probe(struct platform_device *pdev) if (ret) goto free_host; - ret = meson_mmc_clk_init(host); - if (ret) - goto free_host; - /* Stop execution */ writel(0, host->regs + SD_EMMC_START); @@ -767,6 +765,13 @@ static int meson_mmc_probe(struct platform_device *pdev) writel(IRQ_EN_MASK, host->regs + SD_EMMC_STATUS); writel(IRQ_EN_MASK, host->regs + SD_EMMC_IRQ_EN); + /* set config to sane default */ + meson_mmc_cfg_init(host); + + ret = meson_mmc_clk_init(host); + if (ret) + goto free_host; + ret = devm_request_threaded_irq(&pdev->dev, irq, meson_mmc_irq, meson_mmc_irq_thread, IRQF_SHARED, DRIVER_NAME, host);