From patchwork Fri Mar 3 19:58:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9603431 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 0B6F760414 for ; Fri, 3 Mar 2017 20:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F027128631 for ; Fri, 3 Mar 2017 20:00:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E515D28633; Fri, 3 Mar 2017 20:00:51 +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 88BD228631 for ; Fri, 3 Mar 2017 20:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752089AbdCCUAv (ORCPT ); Fri, 3 Mar 2017 15:00:51 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35251 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbdCCUAu (ORCPT ); Fri, 3 Mar 2017 15:00:50 -0500 Received: by mail-wm0-f66.google.com with SMTP id z63so2507111wmg.2 for ; Fri, 03 Mar 2017 12:00:49 -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=+G2IWycg3BDxkzvi76aQtsmyxVSjUqdPZnKlnNPYswQ=; b=P8NRpyBUmNpc/e/IEVt6x7LW+ubuAnDixqOTq5axgyR5DK2wtz9ZVIIJamOa+x+kzA RJ+d55x9nPjFqdkPzFu5c7dqxZVKJtFlRVTy4hLt2e+2M2JrBZfGXGuXKHOg86HPJiQy IXo049qkDN2+IOXb2YDpq8ZhazSCNEGR/fY0M073iQlLGPgEowNbHAmQqbl+FzXRaZnF vU1ZVyeP5YLblYHlvXdqZO8CX4K8XwlImP6cq4c52LFDtPRKHqOXkeYQEJHsiFaUzF9n 3aTpCH95EfxJ5WdWBTJkxxXxM+lBlunUVTVDSwqxCJWd6OkNmwpPC5uI6Ii9XEUtO71V nPzw== 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=+G2IWycg3BDxkzvi76aQtsmyxVSjUqdPZnKlnNPYswQ=; b=Lf53b0XWfMcWk4xqVzpZ7/cW6t7+/40kUdJ32HYngE1DNA0iSXGPRz1w/jJVDiO3hF aFUrVVnynUMbyZ0pnhivPSiibHTGpvzbudzKuLAgjk8cTTXDKSdLwXvuTEJFV72Wm2Wn hsYTyZzv597oIRff+7fcDvHt3ZKDhoea2paKYGT03lqkzkR5RlyMLorwt/91qwYYNTOX TyleHRmfeqeB9KW09N1RL38FLOxYIiqWgRq4bGZ7eT3yYGabyepUH/XtRUzM0HW4epvH +ZOmSxwjPpWKHQv9plHKz5uoIhxLyR+WRQa9DF7cuBS2tCGCXJ5gPFJa7wR7+Mdh/RzU v9OA== X-Gm-Message-State: AMke39mCr1/vurRLmWxKa8oJzPLDnI826gr0PBdHsna0XJt4c40cB20jwZxXlfK7ielUng== X-Received: by 10.28.5.72 with SMTP id 69mr4071189wmf.6.1488571248552; Fri, 03 Mar 2017 12:00:48 -0800 (PST) Received: from ?IPv6:2003:c6:ebdc:4000:f903:fe11:afad:80a0? (p200300C6EBDC4000F903FE11AFAD80A0.dip0.t-ipconnect.de. [2003:c6:ebdc:4000:f903:fe11:afad:80a0]) by smtp.googlemail.com with ESMTPSA id k70sm4283128wmc.3.2017.03.03.12.00.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Mar 2017 12:00:48 -0800 (PST) Subject: [PATCH v4 8/10] mmc: meson-gx: improve initial configuration To: Ulf Hansson , Kevin Hilman References: <62912f3d-2307-cfff-3c69-c8b8ffaeb474@gmail.com> Cc: "linux-mmc@vger.kernel.org" , linux-amlogic@lists.infradead.org From: Heiner Kallweit Message-ID: <58eac416-40da-8a20-e54a-0e6be3b7ba33@gmail.com> Date: Fri, 3 Mar 2017 20:58:18 +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: <62912f3d-2307-cfff-3c69-c8b8ffaeb474@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 v3: - rebased v4: - no changes --- 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);