Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1062888imm; Wed, 1 Aug 2018 09:35:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcrGwrIkZHwn2aHNKDK8aIq0EYgSC5vZOS0gTlX5OjOOatOZkCzfBO/isgF59bBsDSEY6wf X-Received: by 2002:a63:c44a:: with SMTP id m10-v6mr25418726pgg.416.1533141316685; Wed, 01 Aug 2018 09:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533141316; cv=none; d=google.com; s=arc-20160816; b=e3wDf5iQAUclyvR3dyc8fpW4Z0cvRT6zzxnLbItKd78oIFC2nTKLapiTcIzXTkmEgr sVvpRm3suRk3GF+ynWSjDd8BENJ9T0ICqO6la4gho0PvypjT7iHEFVSnuTsjtIOy0ZCH OeSj3zbTowbzFXpJDzVwI8gIho3M2K7qNDpzWBtvLr+RiciduWxNtTARyIrmeqvxn4P2 QEV7Bzkiaamneu9WygCPQAb6xjPRTzlua9iz9lgr4k2yQnTQ1P7clMG1fXbpswaG1Wpr llqcOWTKiXIYFyPYA4AofJVyhtKPBRgSNrrjG6kxEC5FUD3XseL73R9EIH3ZxjvC8rbA CGJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=lxiwTlaD5kV/hOVlGzoN+JRxh+ABPmNgQXdKu8QBsvA=; b=kYx3e6dzyqE8RMhmCMTa8TyJFkm/i/+2liBW/mhPNlo4ftL5/EYXqpIiIqd0k3zHa9 ZsL3z3IksbbvmcS1WJi4kLvL9zV5EPjKW+5wBCP/vN7IscMKU7APsuQZgP5+Ub724Lim veYGFVApZIebW89g89svkJUhXlxj330teMbiPCYqKUTZXsB/srUjcM7j0h+S0mwsvXpe JifQVC5U0tYsi5rD9NRdG7h8u2Xom9rRfJub5fAndiD2xRU1Rf3pX9j3wCMTJXo0U/QS GUTg8Bpd4eom5Pu8toS5IOj5Z9l5NK4gQyiEb9CBiN8qff0oiydVsc22FeUMoPwUrv3/ NrmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b11-v6si14051782pgt.44.2018.08.01.09.35.01; Wed, 01 Aug 2018 09:35:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390627AbeHASUW (ORCPT + 99 others); Wed, 1 Aug 2018 14:20:22 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:2920 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390113AbeHASUW (ORCPT ); Wed, 1 Aug 2018 14:20:22 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1, AES128-SHA) id ; Wed, 01 Aug 2018 09:33:44 -0700 Received: from HQMAIL108.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Wed, 01 Aug 2018 09:33:49 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Wed, 01 Aug 2018 09:33:49 -0700 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL108.nvidia.com (172.18.146.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 1 Aug 2018 16:33:48 +0000 Received: from hqnvemgw02.nvidia.com (172.16.227.111) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1347.2 via Frontend Transport; Wed, 1 Aug 2018 16:33:49 +0000 Received: from dhcp-10-21-25-168.Nvidia.com (Not Verified[10.21.25.201]) by hqnvemgw02.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Wed, 01 Aug 2018 09:33:49 -0700 From: Aapo Vienamo To: Rob Herring , Mark Rutland , Thierry Reding , Jonathan Hunter , Ulf Hansson , Adrian Hunter , Mikko Perttunen , Stefan Agner CC: , , , , Aapo Vienamo Subject: [PATCH 22/40] mmc: tegra: Configure default tap values Date: Wed, 1 Aug 2018 19:32:12 +0300 Message-ID: <1533141150-10511-23-git-send-email-avienamo@nvidia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533141150-10511-1-git-send-email-avienamo@nvidia.com> References: <1533141150-10511-1-git-send-email-avienamo@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set the default inbound timing adjustment tap value on reset and on non-tunable modes. The default tap value is not programmed on tunable modes because the tuning sequence is used instead to determine the tap value. Signed-off-by: Aapo Vienamo --- drivers/mmc/host/sdhci-tegra.c | 131 ++++++++++++++++++++++++----------------- 1 file changed, 76 insertions(+), 55 deletions(-) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index bd3305e..9550d35 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -213,6 +213,57 @@ static bool tegra_sdhci_is_pad_and_regulator_valid(struct sdhci_host *host) return true; } +static bool tegra_sdhci_configure_card_clk(struct sdhci_host *host, bool enable) +{ + bool orig_enabled; + u32 reg; + + reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL); + orig_enabled = !!(reg & SDHCI_CLOCK_CARD_EN); + + if (orig_enabled == enable) + return orig_enabled; + + if (enable) + reg |= SDHCI_CLOCK_CARD_EN; + else + reg &= ~SDHCI_CLOCK_CARD_EN; + + sdhci_writew(host, reg, SDHCI_CLOCK_CONTROL); + + return orig_enabled; +} + +static void tegra_sdhci_set_tap(struct sdhci_host *host, unsigned int tap) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); + const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; + bool card_clk_enabled = false; + u32 reg; + + /* + * Touching the tap values is a bit tricky on some SoC generations. + * The quirk enables a workaround for a glitch that sometimes occurs if + * the tap values are changed. + */ + + if (soc_data->nvquirks & NVQUIRK_DIS_CARD_CLK_CONFIG_TAP) + card_clk_enabled = tegra_sdhci_configure_card_clk(host, false); + + reg = sdhci_readl(host, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); + reg &= ~SDHCI_CLOCK_CTRL_TAP_MASK; + reg |= tap << SDHCI_CLOCK_CTRL_TAP_SHIFT; + sdhci_writel(host, reg, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); + + if (soc_data->nvquirks & NVQUIRK_DIS_CARD_CLK_CONFIG_TAP && + card_clk_enabled) { + udelay(1); + sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); + tegra_sdhci_configure_card_clk(host, card_clk_enabled); + } +} + static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -226,6 +277,8 @@ static void tegra_sdhci_reset(struct sdhci_host *host, u8 mask) if (!(mask & SDHCI_RESET_ALL)) return; + tegra_sdhci_set_tap(host, tegra_host->default_tap); + misc_ctrl = sdhci_readl(host, SDHCI_TEGRA_VENDOR_MISC_CTRL); clk_ctrl = sdhci_readl(host, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); @@ -286,27 +339,6 @@ static void tegra_sdhci_configure_cal_pad(struct sdhci_host *host, bool enable) } } -static bool tegra_sdhci_configure_card_clk(struct sdhci_host *host, bool enable) -{ - bool orig_enabled; - u32 reg; - - reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL); - orig_enabled = !!(reg & SDHCI_CLOCK_CARD_EN); - - if (orig_enabled == enable) - return orig_enabled; - - if (enable) - reg |= SDHCI_CLOCK_CARD_EN; - else - reg &= ~SDHCI_CLOCK_CARD_EN; - - sdhci_writew(host, reg, SDHCI_CLOCK_CONTROL); - - return orig_enabled; -} - static void tegra_sdhci_set_pad_autocal_offset(struct sdhci_host *host, u16 pdpu) { @@ -501,19 +533,6 @@ static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) } } -static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host, - unsigned timing) -{ - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); - - if (timing == MMC_TIMING_UHS_DDR50 || - timing == MMC_TIMING_MMC_DDR52) - tegra_host->ddr_signaling = true; - - sdhci_set_uhs_signaling(host, timing); -} - static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -521,34 +540,36 @@ static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host *host) return clk_round_rate(pltfm_host->clk, UINT_MAX); } -static void tegra_sdhci_set_tap(struct sdhci_host *host, unsigned int tap) +static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host, + unsigned timing) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); - const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; - bool card_clk_enabled = false; - u32 reg; + bool set_default_tap = false; - /* - * Touching the tap values is a bit tricky on some SoC generations. - * The quirk enables a workaround for a glitch that sometimes occurs if - * the tap values are changed. - */ + switch (timing) { + case MMC_TIMING_UHS_SDR50: + case MMC_TIMING_UHS_SDR104: + case MMC_TIMING_MMC_HS200: + case MMC_TIMING_MMC_HS400: + /* Don't set default tap on tunable modes. */ + break; + case MMC_TIMING_MMC_DDR52: + case MMC_TIMING_UHS_DDR50: + tegra_host->ddr_signaling = true; + set_default_tap = true; + break; + default: + set_default_tap = true; + break; + } - if (soc_data->nvquirks & NVQUIRK_DIS_CARD_CLK_CONFIG_TAP) - card_clk_enabled = tegra_sdhci_configure_card_clk(host, false); + sdhci_set_uhs_signaling(host, timing); - reg = sdhci_readl(host, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); - reg &= ~SDHCI_CLOCK_CTRL_TAP_MASK; - reg |= tap << SDHCI_CLOCK_CTRL_TAP_SHIFT; - sdhci_writel(host, reg, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); + tegra_sdhci_pad_autocalib(host); - if (soc_data->nvquirks & NVQUIRK_DIS_CARD_CLK_CONFIG_TAP && - card_clk_enabled) { - udelay(1); - sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA); - tegra_sdhci_configure_card_clk(host, card_clk_enabled); - } + if (set_default_tap) + tegra_sdhci_set_tap(host, tegra_host->default_tap); } static int tegra_sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) -- 2.7.4