From patchwork Thu Dec 26 11:33:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Moon X-Patchwork-Id: 1215470 X-Patchwork-Delegate: narmstrong@baylibre.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tjY3X6IZ"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47k7CP3WzHz9sPJ for ; Thu, 26 Dec 2019 22:34:25 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4C402814F4; Thu, 26 Dec 2019 12:34:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="tjY3X6IZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4985B801BA; Thu, 26 Dec 2019 12:34:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, SPF_HELO_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 54DD7801BA for ; Thu, 26 Dec 2019 12:34:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=linux.amoon@gmail.com Received: by mail-pg1-x541.google.com with SMTP id k197so12737293pga.10 for ; Thu, 26 Dec 2019 03:34:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=z7tSe9CKsGznFo3xd/MYyv+yoMfbCv8W9qI3L0337uo=; b=tjY3X6IZ/Uwf+eltoEkHdI1KO1a6y8A+2Blr0hsFso/zxPBWeiIq0en7dV07ZeWqq7 Zy/rNJFDnVuogh2WAoyLeJ+WStp8C++EyPHyTO9/b+VpGR7NBvybZvpa3qCFkXCQCljQ bP9UwC/lpajZTBgXDuYOIoHOlOWewTGEojfFR87xT03dOXJVpBHdXmnOu3emR1Hyslyx E0jgzbCXUDKRY0H9TZOkLpdOdVJ68jIxkILkjHTGTlZ3Zz7h03I/DVTCEAnRrhBP229v 2O4l5pQQxPrABFF5dj6OjHFsaxlxF5fPsZeGtdw74ZRsLlyTXCaXLcEr4UC7kNq4qWhf /aoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=z7tSe9CKsGznFo3xd/MYyv+yoMfbCv8W9qI3L0337uo=; b=ClRRn/a0Q3lTX7w+hcHkewTP+1vq8dPTyJhiZ5GT7xiNvnUOJFKizh8WgC6uPzuRPg mBwalPrqIV2QJKADbOMWteqG99JAEIyWAUpXsrwYYaNAjzHRKxzAxv97iMCcGSr15qh9 BBlcNIdd7xW5hZDxpCO0wc5x642ajSCL2tftRrcuY4Q2vrXzXGWqJkFzBNl/qxAOhcjd 88JZ7mK5Dd4G7Lv1DvX0AyBfiyi+hXH5pBZs9wfC7FWqUoXIWZQvQJAPUDEzBRHlBF1p XudmTjCMQ8ip3ioBBN0lHPQSIwSgvgQOlA0b7kvEMsJWQ2nh+tEcBZMbS4gEPqVgtCFm h2Vg== X-Gm-Message-State: APjAAAXb5poV47DS9KaGxs9jC9l+p3eNF6oxNMcYAJwdklOMfCQSyRdG BNQpn14SucXbQNLEadgzUQg= X-Google-Smtp-Source: APXvYqyvizV0Tau7rCt0oT8xNOG443aPqv2KYHwlAPCNk50d+iAozCWcJ/OHiE/FzduZIRUiITU9/Q== X-Received: by 2002:a63:d108:: with SMTP id k8mr47357030pgg.434.1577360041865; Thu, 26 Dec 2019 03:34:01 -0800 (PST) Received: from localhost.localdomain ([45.112.0.38]) by smtp.gmail.com with ESMTPSA id e188sm37000247pfe.113.2019.12.26.03.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Dec 2019 03:34:01 -0800 (PST) From: Anand Moon To: Neil Armstrong , Peng Fan , Jerome Brunet , u-boot-amlogic@groups.io, u-boot@lists.denx.de Subject: [PATCHv3 1/3] mmc: meson-gx: Fix clk phase tuning for MMC Date: Thu, 26 Dec 2019 11:33:51 +0000 Message-Id: <20191226113353.1757-2-linux.amoon@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191226113353.1757-1-linux.amoon@gmail.com> References: <20191226113353.1757-1-linux.amoon@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean As per mainline line kernel fix the clk tunnig phase for mmc, set Core=180, Tx=0, Rx=0 clk phase for mmc initialization. Signed-off-by: Anand Moon --- Changes from previous v2: Fix the clk phase macro to support PHASE_180 drop the wrong CLK_CORE_PHASE_MASK macro. v1: use the mainline kernel tuning for clk tuning. Fixed the commmit messages. Patch v1: https://patchwork.ozlabs.org/patch/1201208/ Before these changes. clock is enabled (380953Hz) clock is enabled (25000000Hz) After these changes clock is enabled (380953Hz) clock is enabled (25000000Hz) clock is enabled (52000000Hz) Test on Odroid N2 and Odroid C2 with eMMC and microSD cards --- arch/arm/include/asm/arch-meson/sd_emmc.h | 14 ++++++-------- drivers/mmc/meson_gx_mmc.c | 9 +++++---- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/arch/arm/include/asm/arch-meson/sd_emmc.h b/arch/arm/include/asm/arch-meson/sd_emmc.h index e3a72c8b66..ee20c009e2 100644 --- a/arch/arm/include/asm/arch-meson/sd_emmc.h +++ b/arch/arm/include/asm/arch-meson/sd_emmc.h @@ -7,6 +7,7 @@ #define __SD_EMMC_H__ #include +#include #define SDIO_PORT_A 0 #define SDIO_PORT_B 1 @@ -19,14 +20,11 @@ #define CLK_MAX_DIV 63 #define CLK_SRC_24M (0 << 6) #define CLK_SRC_DIV2 (1 << 6) -#define CLK_CO_PHASE_000 (0 << 8) -#define CLK_CO_PHASE_090 (1 << 8) -#define CLK_CO_PHASE_180 (2 << 8) -#define CLK_CO_PHASE_270 (3 << 8) -#define CLK_TX_PHASE_000 (0 << 10) -#define CLK_TX_PHASE_090 (1 << 10) -#define CLK_TX_PHASE_180 (2 << 10) -#define CLK_TX_PHASE_270 (3 << 10) + +#define CLK_PHASE_180 2 +#define CLK_TX_PHASE_MASK GENMASK(11, 10) +#define CLK_RX_PHASE_MASK GENMASK(13, 12) + #define CLK_ALWAYS_ON BIT(24) #define MESON_SD_EMMC_CFG 0x44 diff --git a/drivers/mmc/meson_gx_mmc.c b/drivers/mmc/meson_gx_mmc.c index 86c1a7164a..ad697d3a5e 100644 --- a/drivers/mmc/meson_gx_mmc.c +++ b/drivers/mmc/meson_gx_mmc.c @@ -52,10 +52,11 @@ static void meson_mmc_config_clock(struct mmc *mmc) clk_div = DIV_ROUND_UP(clk, mmc->clock); /* 180 phase core clock */ - meson_mmc_clk |= CLK_CO_PHASE_180; - - /* 180 phase tx clock */ - meson_mmc_clk |= CLK_TX_PHASE_000; + meson_mmc_clk |= CLK_PHASE_180; + /* 000 phase rx clock */ + meson_mmc_clk |= CLK_RX_PHASE_MASK; + /* 000 phase tx clock */ + meson_mmc_clk |= CLK_TX_PHASE_MASK; /* clock settings */ meson_mmc_clk |= clk_src;