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 B5778C678D5 for ; Thu, 9 Mar 2023 01:29:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 00C4185DA4; Thu, 9 Mar 2023 02:29:42 +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="gslM/EoX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5928385DAD; Thu, 9 Mar 2023 02:29:40 +0100 (CET) Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) (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 79A0185D81 for ; Thu, 9 Mar 2023 02:29:37 +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=anarsoul@gmail.com Received: by mail-pj1-x1036.google.com with SMTP id qa18-20020a17090b4fd200b0023750b675f5so4427129pjb.3 for ; Wed, 08 Mar 2023 17:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678325375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qFU4p6dosFBi+kTG92vP/0lnk5i8ZRadV7HY57WEOfI=; b=gslM/EoXqkuf3DWEq1V8Wbi7dxy3Kf7ps45HFDhg5EQN4HQCLMx01YVoDtD31E/RDo Uz7bFCC0rKuLhAoHngXeazncHFnK76SsZqbLr5NKpw6USc5IXaP4+HubilT6f812M48Z Pwozo463Gly/d652Ztk5MnE9McmMmWaFLH6o45Bp1DEjvAoUzmiNV92CeM+qRqkF5ECL UgelOa9dSFzQBHyh0AO65+0L48AcLXiBrx+58JFEEnIpoACfkF5ymPZHMZVeRijGwk6v Bb2lkRQPS8xbowACC7ZsSXXLkMEXNshaOAWUVDB9gyi5PdwLovBmuSiPj1viSBAxJo55 dBiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678325375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qFU4p6dosFBi+kTG92vP/0lnk5i8ZRadV7HY57WEOfI=; b=Ssq1y0hWqJxsrzZYoSV1x0OdaRlco69oD3JnOiKDShBsUUE77/KcnqgEIRu+/Vk5K3 f1r3oBEQUElKdeiCIFuDUsoQCamwHAabPk9YXHXB6E8f15/XqmG/8we7irXAEmUcSsvD E9fz6SH5pLaYb6aYH2dd0aVTqxNe5OUoaoqqWBcoJ2hDJNdW8LRpwl00D7b5Rotgd02p qff2umMz/ZGJ/4qLcKSCnOwGufwaOOKTV5qrdC17HMFkPkTD6CWbvwQIkk9Ek51dQtVZ XdPRO4QBWJrK/H+xmG0Gr4tlDGLkKZWKIKvvPjM5gm7QdgHd7TQqt0mD0rClsReyg20E i7FQ== X-Gm-Message-State: AO0yUKUOuNs5Q/Pk/UC8diWOU0uPyd9gWUpP/6HdUxashS7p0Oh7g9zq XPD6ad0tMXh40ZL8CJpDuok= X-Google-Smtp-Source: AK7set89aH2aFzpvKPp0gsjnhGpLWLIr2+sV8sJPT6+kXU5cPO2F9NR4oHvKb5OfVnrCC4bhiE7BMQ== X-Received: by 2002:a17:90a:8d13:b0:234:b170:1f27 with SMTP id c19-20020a17090a8d1300b00234b1701f27mr14530019pjo.0.1678325375618; Wed, 08 Mar 2023 17:29:35 -0800 (PST) Received: from anarsoul-xps15.lan ([2604:3d08:7780:e52::398]) by smtp.gmail.com with ESMTPSA id e4-20020a17090a6f8400b002340b2c62e7sm322797pjk.55.2023.03.08.17.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Mar 2023 17:29:34 -0800 (PST) From: Vasily Khoruzhick To: Peng Fan , Jaehoon Chung , Simon Glass , Philipp Tomsich , Kever Yang , u-boot@lists.denx.de Cc: Vasily Khoruzhick Subject: [PATCH] rockchip: sdhci: rk3568: bypass DLL when clk <= 52 MHz Date: Wed, 8 Mar 2023 17:28:30 -0800 Message-Id: <20230309012830.235782-1-anarsoul@gmail.com> X-Mailer: git-send-email 2.39.2 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.8 at phobos.denx.de X-Virus-Status: Clean For Rockchip platform, DLL bypass bit and start bit need to be set if DLL is not locked. With this change applied eMMC in my NanoPi R5S can run at 52 MHz. Based on linux commit b75a52b0dda3 ("mmc: sdhci-of-dwcmshc: Update DLL and pre-change delay for rockchip platform") Signed-off-by: Vasily Khoruzhick --- drivers/mmc/rockchip_sdhci.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c index 1ac95f32b3..fef23f593e 100644 --- a/drivers/mmc/rockchip_sdhci.c +++ b/drivers/mmc/rockchip_sdhci.c @@ -61,6 +61,7 @@ #define DWCMSHC_EMMC_DLL_RXCLK 0x804 #define DWCMSHC_EMMC_DLL_TXCLK 0x808 #define DWCMSHC_EMMC_DLL_STRBIN 0x80c +#define DECMSHC_EMMC_DLL_CMDOUT 0x810 #define DWCMSHC_EMMC_DLL_STATUS0 0x840 #define DWCMSHC_EMMC_DLL_STATUS1 0x844 #define DWCMSHC_EMMC_DLL_START BIT(0) @@ -69,6 +70,7 @@ #define DWCMSHC_EMMC_DLL_START_DEFAULT 5 #define DWCMSHC_EMMC_DLL_INC_VALUE 2 #define DWCMSHC_EMMC_DLL_INC 8 +#define DWCMSHC_EMMC_DLL_BYPASS BIT(24) #define DWCMSHC_EMMC_DLL_DLYENA BIT(27) #define DLL_TXCLK_TAPNUM_DEFAULT 0xA @@ -83,6 +85,7 @@ #define DWCMSHC_EMMC_DLL_TIMEOUT BIT(9) #define DLL_RXCLK_NO_INVERTER 1 #define DLL_RXCLK_INVERTER 0 +#define DLL_RXCLK_ORI_GATE BIT(31) #define DWCMSHC_ENHANCED_STROBE BIT(8) #define DLL_LOCK_WO_TMOUT(x) \ ((((x) & DWCMSHC_EMMC_DLL_LOCKED) == DWCMSHC_EMMC_DLL_LOCKED) && \ @@ -348,10 +351,14 @@ static int rk3568_sdhci_emmc_set_clock(struct sdhci_host *host, unsigned int clo DLL_STRBIN_TAPNUM_FROM_SW; sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN); } else { - /* reset the clock phase when the frequency is lower than 100MHz */ - sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_CTRL); - extra = DLL_RXCLK_NO_INVERTER << DWCMSHC_EMMC_DLL_RXCLK_SRCSEL; - sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_RXCLK); + /* + * Disable DLL and reset both of sample and drive clock. + * The bypass bit and start bit need to be set if DLL is not locked. + */ + sdhci_writel(host, DWCMSHC_EMMC_DLL_BYPASS | DWCMSHC_EMMC_DLL_START, + DWCMSHC_EMMC_DLL_CTRL); + sdhci_writel(host, DLL_RXCLK_ORI_GATE, DWCMSHC_EMMC_DLL_RXCLK); + sdhci_writel(host, 0, DECMSHC_EMMC_DLL_CMDOUT); sdhci_writel(host, 0, DWCMSHC_EMMC_DLL_TXCLK); /* * Before switching to hs400es mode, the driver will enable -- 2.39.2