From patchwork Thu Feb 16 19:42:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9578245 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 3702260209 for ; Thu, 16 Feb 2017 19:43:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AE2D2866A for ; Thu, 16 Feb 2017 19:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2008C2866D; Thu, 16 Feb 2017 19:43:20 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC2E32866A for ; Thu, 16 Feb 2017 19:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933236AbdBPTnN (ORCPT ); Thu, 16 Feb 2017 14:43:13 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:33662 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933224AbdBPTnN (ORCPT ); Thu, 16 Feb 2017 14:43:13 -0500 Received: by mail-wm0-f66.google.com with SMTP id v77so4690383wmv.0 for ; Thu, 16 Feb 2017 11:43:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=UVYc5FKUBt6om8ZbanA0UF7nS/7q7/17WE5esuW0GU4=; b=C9vkA6pai2X2zzazPENMlv1xjGaNY7BRfQ1lRdyzLj6H245qv/7J+b32AsNNM9zvmo UP8HJcBmmCCxUgNV2WrdZAUc8EHBmcTTm1Y9jm/3D1KQChXDIlz0CJW3n5TKQmlUGsKM PDsJac8NFnhGSrs93MvXyPRtGcpSTZZRYIEzDxQvHniGXrxTuK07NvV1yXMLPdU/2m2q 9yqqP2efgLzkcEvwichbEzIIzyhnkRoy6iOe1+IPbMVpSxy4uGsvhHNLBx467ye3l572 U9FTa1yq2rsJERp0I/8hC0i+uuv/N64arg6/KzrkULb+Fy3DZt+rW3Qq6y/fkKUF/8cb SoGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=UVYc5FKUBt6om8ZbanA0UF7nS/7q7/17WE5esuW0GU4=; b=bEgZHLQZF+zgcekoqgvcTG+xzhIZo8NsYhGk+XAy6pPdXvg68s3+Ygiqzw5OBGpBmn L7l4Qlo0jM5r5bt3C+utz1oGHrjfu2mzpB74h+wPL73VFcrYXl+CSnHrNtlen1eQ01FM skl+mAtVpltDOKmfr0/sWRUje2rFW1ADybRiqu1/ONODTbkxHu6J76+mOvkPJX3xPXI7 snpI9bXWfJAdM3IFw3YwYwx/+chsTX1W32kk0YdygGYF9HEEXCrN06UwMlfFfahSVyEF O4nsJ6oD6/TC+sUnCiOf64vVBi6vgRJhlCQFmuCc/CmD4qLlmXQ9GyC0BHVWYBGJvjqE aAZg== X-Gm-Message-State: AMke39nlSFgkaH7eK2QjSFs7PBtLMPBwOkwxpP1OJEAsx9E/88yr5FJagbgck+P/IOn/3Q== X-Received: by 10.28.101.214 with SMTP id z205mr14911151wmb.15.1487274191680; Thu, 16 Feb 2017 11:43:11 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:f02a:ffb3:d41d:abac? (p200300C6EBDC4000F02AFFB3D41DABAC.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:f02a:ffb3:d41d:abac]) by smtp.googlemail.com with ESMTPSA id q5sm10125684wrd.32.2017.02.16.11.43.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 11:43:11 -0800 (PST) From: Heiner Kallweit Subject: [PATCH v2 8/9] mmc: meson-gx: improve initial configuration To: Ulf Hansson , Kevin Hilman References: <7d5263e2-9325-dedb-a5f6-954c4a09e977@gmail.com> Cc: "linux-mmc@vger.kernel.org" , linux-amlogic@lists.infradead.org Message-ID: Date: Thu, 16 Feb 2017 20:42:31 +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: <7d5263e2-9325-dedb-a5f6-954c4a09e977@gmail.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.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 --- 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 a8f43cc6..e7c3ac1c 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -390,15 +390,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 || @@ -409,11 +400,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, @@ -691,6 +682,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, @@ -751,10 +753,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); @@ -763,6 +761,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);