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 A8772C43217 for ; Sun, 16 Jan 2022 20:19:14 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 04CCF835EA; Sun, 16 Jan 2022 21:18:56 +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="TlnDdnYe"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D64B81982; Sun, 16 Jan 2022 21:18:49 +0100 (CET) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 9F6E0835CB for ; Sun, 16 Jan 2022 21:18:45 +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-x536.google.com with SMTP id z22so56933846edd.12 for ; Sun, 16 Jan 2022 12:18:45 -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=TzASpsDhcAJy3DzV3mLZW8A/StILYbd31Wt4qZD/V0U=; b=TlnDdnYe7zRWWM0427pGMHa2zhQg5KSHy7VkrzBlixDWHldbO2BfroUeTU9lFF5ncU apgRl8Wjn9l7FMZ70raoqT9/FFjWX2ilvXPT+FfSTv3EmMIwK8FJYemNV1jEqbaULrzg sXim83kmpLRN+bIkFNaJt5DxT7oJW5M6L20fGkf74gB7cH307+oubN7sLVq44m/SiLZO S2e5OiKMIzRK+Ee9m6HNJkcz6DW7z+VnEoibMY9c7aSAuHHp0Y6zDOR2sfISEfleswk2 u+LGvBh7Q26kz42DV0m6bkI1mHO5r7TSEvB7KrEMxgNeLB/tgHtYSE+vUy2Ccw3X89Dx fM+w== 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=TzASpsDhcAJy3DzV3mLZW8A/StILYbd31Wt4qZD/V0U=; b=A1+tlAxHYXcYx8HS2Av38s3CQgXS4ID5bCQoXJIIvSR5QMkJwufZ6kL/DDqg/opLSu MbZERATdQ4qz0YJ0by8XDaXu/73uCJTej3Yqr9pOFXpx+JTj8X6dNCzh/wBkdtOXHQXH RaxKdqKMVMvPdS8+XkcJcVIAwtDTVpKfII9C+LO/ZEMoSovaLggKuSAqCiFROkA21MyT PvdjA/zZtm0VJfD+3vP4JsueqiYJ3MFJKY5uJagQP7uuPPfLkV/yq1lq6vcUtwvF4E26 FvYUcywGw0txId6JqlSETglpzciFK8g0Cr5S1P+CUvlN+qQ3ELFjlAxBCVy4cX7jIBQY RYGQ== X-Gm-Message-State: AOAM532CbQq0KAUNrgw1667qCgblsQY1XZL+psHwUB8C3ccyQothrzRK vIlvOafJMtqwT+vgjG7BdwDNRY+Hrvs= X-Google-Smtp-Source: ABdhPJxtMQjrwuKFphsrXSA0P41IC3DuQvZ6mrS4e6pKcwKvqI8CD4SKp0JqOoqAoakhSZQ8hMKX5g== X-Received: by 2002:a17:906:b24d:: with SMTP id ce13mr14386681ejb.44.1642364325298; Sun, 16 Jan 2022 12:18:45 -0800 (PST) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id b10sm4872469edu.42.2022.01.16.12.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Jan 2022 12:18:44 -0800 (PST) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Aswath Govindraju , Kever Yang , Philipp Tomsich , Samuel Dionne-Riel , Stephen Carlson , Peter Robinson , Faiz Abbas , Jack Mitchell , Simon Glass , Jaehoon Chung , Ashok Reddy Soma , Michal Simek , Peng Fan , Yifeng Zhao , Jagan Teki , Alper Nebi Yasak Subject: [PATCH v3 4/4] rockchip: sdhci: Add HS400 Enhanced Strobe support for RK3568 Date: Sun, 16 Jan 2022 23:18:13 +0300 Message-Id: <20220116201814.11672-5-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220116201814.11672-1-alpernebiyasak@gmail.com> References: <20220116201814.11672-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. Additionally, a bit signifying that the connected hardware is an eMMC chip must be set to enable Data Strobe for HS400 and HS400ES modes. Also make the driver set this bit as appropriate. This is partly 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 --- Only build-tested as I don't have a RK3568 board. Changes in v3: - Set DWCMSHC_CARD_IS_EMMC bit in rk3568_emmc_phy_init() 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 | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index f920c5141142..4c7cc7535e2e 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -45,6 +45,14 @@ #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_CARD_IS_EMMC BIT(0) +#define DWCMSHC_ENHANCED_STROBE BIT(8) + /* Rockchip specific Registers */ #define DWCMSHC_EMMC_DLL_CTRL 0x800 #define DWCMSHC_EMMC_DLL_CTRL_RESET BIT(1) @@ -244,11 +252,25 @@ static int rk3568_emmc_phy_init(struct udevice *dev) { struct rockchip_sdhc *prv = dev_get_priv(dev); struct sdhci_host *host = &prv->host; + struct mmc *mmc = host->mmc; u32 extra; + u32 vendor; + int reg; extra = DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL; sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK); + /* set CARD_IS_EMMC bit to enable Data Strobe for HS400 and HS400ES */ + reg = (sdhci_readl(host, DWCMSHC_P_VENDOR_AREA1) & DWCMSHC_AREA1_MASK) + + DWCMSHC_EMMC_CONTROL; + + vendor = sdhci_readw(host, reg); + if (IS_MMC(mmc)) + vendor |= DWCMSHC_CARD_IS_EMMC; + else + vendor &= ~DWCMSHC_CARD_IS_EMMC; + sdhci_writew(host, vendor, reg); + return 0; } @@ -311,6 +333,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 +560,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