Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4839FC433EF for ; Tue, 11 Jan 2022 13:40:35 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04F5F83082; Tue, 11 Jan 2022 14:40:18 +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="XSzcSUCE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DFEC783102; Tue, 11 Jan 2022 14:40:14 +0100 (CET) Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) (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 923BC803CE for ; Tue, 11 Jan 2022 14:40:06 +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=alpernebiyasak@gmail.com Received: by mail-ed1-x533.google.com with SMTP id t24so19478727edi.8 for ; Tue, 11 Jan 2022 05:40:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LjMmoYvGDtz8EzHrJyAlk25GCXLXlEDxegW0ytD67kU=; b=XSzcSUCEYUx6xw/xW8THQcXJLZdqxBJSTmSEJK9iCFm3JHP1cXDJOwoT8/f3RF80Bk JgYFfTJeQKKsVamnO5F6lE5ZgXoYJo3W25KCq+mGFpzHUctD/iMO1fDqhHOlr+1SntGl HefIq40EC+zisPHDq0xAwGMTpBMjMS4sxk1ULz/0f6108mt9sMKa6RRtiWhH5AuFs3R1 LQA8jKctCpE+1onJVUyhHT/u8/Tu3NIJHBuZSFn/wgyO+l4GNlmyPa9Zc0iSBwd9qc4g 77jXeOAoPRY78xJB7FzEcb+RZbRKK2DWj3J+Azw0bryz9CcYPbe+KS/XPghR/Dw6yRHi Ht/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LjMmoYvGDtz8EzHrJyAlk25GCXLXlEDxegW0ytD67kU=; b=y8zEbhMc1GwS9FwmyZsw/450wJQKUTcCymQIQvnOrW3sPR5QdpTxE7MVvW520IzHlo d8X+f4S3bQORZoVv2jGvNeSqIYecl1Rmwb4dawL0GDedgFnMqkFhEOzN1jr3LpMIer8U PPp0DYO3oOA2aN0BOjQ76SbzTwz+jXQZlZwRSWrGpLr2aR9Zesdeatbi2f9q6udOP2kL 4jps4cWFxKN403MPMc1qB+E2TylgCFYmxtQDKYeJ2CT0ZBOHH6OeU+aIHet/BfVXuQLH Up92GQxvUzkGIBUG5RLoYzoRUWMBY7bfHflNi343kLrgEAG1PaNTGWgGCTYnoxf5H/qP 6fOA== X-Gm-Message-State: AOAM531+W8HldDwYnwLllLFvzuPgs55eypc5S65lNUM/Xo+liyM84Cf6 jhyS1QTfJbub2mJrAsWajUqn2oELiPwJ+g== X-Google-Smtp-Source: ABdhPJwecsWU5bqeJ1MWRcl6zOejVqsCSTI6O+z01yiNyWLkdE5IKqYg3EBRMUSJXeiPz7pyNnMF2g== X-Received: by 2002:aa7:c1c1:: with SMTP id d1mr4353976edp.416.1641908406142; Tue, 11 Jan 2022 05:40:06 -0800 (PST) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id ck3sm1180324edb.36.2022.01.11.05.40.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 05:40:05 -0800 (PST) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Yifeng Zhao , Peng Fan , Ashok Reddy Soma , Samuel Dionne-Riel , Aswath Govindraju , Philipp Tomsich , Jagan Teki , Stephen Carlson , Akash Gajjar , Michal Simek , Kever Yang , Faiz Abbas , Simon Glass , Peter Robinson , Jaehoon Chung , Jack Mitchell , Alper Nebi Yasak Subject: [PATCH v2 4/4] rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3568 Date: Tue, 11 Jan 2022 16:39:31 +0300 Message-Id: <20220111133931.7866-5-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220111133931.7866-1-alpernebiyasak@gmail.com> References: <20220111133931.7866-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.2 at phobos.denx.de X-Virus-Status: Clean On RK3568, a register bit must be set to enable Enhanced Strobe. However, it appears that the address of this register may differ from vendor to vendor and should be read from the underlying MMC IP. Let the Rockchip SDHCI driver read this address and set the relevant bit when Enhanced Strobe configuration is requested. This is mostly ported from Linux's Synopsys DWC MSHC driver which happens to be the underlying IP. (drivers/mmc/host/sdhci-of-dwcmshc.c in Linux tree). Signed-off-by: Alper Nebi Yasak --- Didn't add Reviewed-by tag due to changes. Only build-tested as I don't have a RK3568 board. Changes in v2: - Rename rk3568_set_enhanced_strobe -> rk3568_sdhci_set_enhanced_strobe - Let set_enhanced_strobe() unset the ES bit if mode is not HS400_ES drivers/mmc/rockchip_sdhci.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index f920c5141142..3030d746f890 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -45,6 +45,13 @@ #define ARASAN_VENDOR_REGISTER 0x78 #define ARASAN_VENDOR_ENHANCED_STROBE BIT(0) +/* DWC IP vendor area 1 pointer */ +#define DWCMSHC_P_VENDOR_AREA1 0xe8 +#define DWCMSHC_AREA1_MASK GENMASK(11, 0) +/* Offset inside the vendor area 1 */ +#define DWCMSHC_EMMC_CONTROL 0x2c +#define DWCMSHC_ENHANCED_STROBE BIT(8) + /* Rockchip specific Registers */ #define DWCMSHC_EMMC_DLL_CTRL 0x800 #define DWCMSHC_EMMC_DLL_CTRL_RESET BIT(1) @@ -311,6 +318,25 @@ static int rk3568_emmc_get_phy(struct udevice *dev) return 0; } +static int rk3568_sdhci_set_enhanced_strobe(struct sdhci_host *host) +{ + struct mmc *mmc = host->mmc; + u32 vendor; + int reg; + + reg = (sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK) + + DWCMSHC_EMMC_CONTROL; + + vendor = sdhci_readl(host, reg); + if (mmc->selected_mode == MMC_HS_400_ES) + vendor |= DWCMSHC_ENHANCED_STROBE; + else + vendor &= ~DWCMSHC_ENHANCED_STROBE; + sdhci_writel(host, vendor, reg); + + return 0; +} + static int rk3568_sdhci_set_ios_post(struct sdhci_host *host) { struct mmc *mmc = host->mmc; @@ -519,6 +545,7 @@ static const struct sdhci_data rk3568_data = { .get_phy = rk3568_emmc_get_phy, .emmc_phy_init = rk3568_emmc_phy_init, .set_ios_post = rk3568_sdhci_set_ios_post, + .set_enhanced_strobe = rk3568_sdhci_set_enhanced_strobe, }; static const struct udevice_id sdhci_ids[] = { -- 2.34.1