From patchwork Fri Mar 25 12:11:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Simek X-Patchwork-Id: 1609414 X-Patchwork-Delegate: monstr@monstr.eu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=LwveB23a; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KQ1Cb1kvtz9s0r for ; Fri, 25 Mar 2022 23:11:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 094B48416C; Fri, 25 Mar 2022 13:11:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=monstr-eu.20210112.gappssmtp.com header.i=@monstr-eu.20210112.gappssmtp.com header.b="LwveB23a"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C70C28417E; Fri, 25 Mar 2022 13:11:16 +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=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (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 39AB18415F for ; Fri, 25 Mar 2022 13:11:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=xilinx.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=monstr@monstr.eu Received: by mail-ej1-x631.google.com with SMTP id qa43so14916088ejc.12 for ; Fri, 25 Mar 2022 05:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monstr-eu.20210112.gappssmtp.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+M2Yj/qRpFLHn2/di3hz+b8annHaNbFjULLxfQWFuX8=; b=LwveB23a8HKfiSPUXi59L3hSwr3yq/Jxs4VsSYyo7s/hGl7Kua5OSI8RQjjEUAt1lU ZqfKdSOCQfbsP4PUjeOO++HVVvB5BRODVtAgRpr+xtjbwhNAV6M3rxwvspssWw8lTZHR L9+sjw6hwRFoqEuX4vO/FhkHCRNbJ1WOBORKAQEv5clJJAzPaEiEjn1kRbbOERnZSQ4k /SVS0KV6PJYGLMn7fvxkJAOiLWikFVJnbn4PfLBzozT0yVcHRYTVNIvQ5+GaZ2t7tO70 UXTQYdSwLvh1/H5QpporfsaFX8UpwfTurkt7Re3MLaatBRLzQzeBeZ4Wkpy0f2LptSmE zhUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=+M2Yj/qRpFLHn2/di3hz+b8annHaNbFjULLxfQWFuX8=; b=RtcY/wJ6wY2AnGhfRtvFhCjakQ9dJDf2IYMlv8lnuOvR8XknPGwT66txjSyzevaDFY LmBJVnhSKSeFzwNSQ4SeJX1miz5WrlsMRmqXhuCDrV/vNkWQ3iH2QQsrknfzBlwhGgkF TH5CnkcAFidgDtdaQTiX75OsHaUgJz+0tzc2D7I5MXVopx+0B541eyDWKex5BAUUOfe2 i3dO4FVGR80t0e/MANKUOv/2pLEfhMQtWxZH1YtglLaXDN1Aj5KsHSGCTB0U5nEC3rKb koWjGw3t2d/mY4RS+ZtxF6LQEcWVqH8idxrsYYA0m6xqaYKdA8Jr9xM+7aredTL1wwVV fdkg== X-Gm-Message-State: AOAM532mb3k5rTIL6Oss8wK0Fi6r77kQGtutM1grD3sB9s5+l+rXPtHF FSP758UNl91gL+oLOMeHYAxRdaO+oe0P9w== X-Google-Smtp-Source: ABdhPJz15PiAkHrunVCPFkc6AntqrjMf4l2IXOwmXRK89H9QboRkzyfSNPCQMRtwzqJhba0h8uCeqg== X-Received: by 2002:a17:907:b590:b0:6c1:c061:d945 with SMTP id qx16-20020a170907b59000b006c1c061d945mr11295883ejc.768.1648210271657; Fri, 25 Mar 2022 05:11:11 -0700 (PDT) Received: from localhost ([2a02:768:2307:40d6::f9e]) by smtp.gmail.com with ESMTPSA id n25-20020aa7db59000000b00415965e9727sm2732424edt.18.2022.03.25.05.11.11 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 Mar 2022 05:11:11 -0700 (PDT) From: Michal Simek To: u-boot@lists.denx.de, git@xilinx.com Cc: Ashok Reddy Soma , Jaehoon Chung , Peng Fan Subject: [PATCH] mmc: zynq_sdhci: Fix SDx_BASECLK configuration Date: Fri, 25 Mar 2022 13:11:10 +0100 Message-Id: <6c1e5eeeedd2864a0c85e6b409d182031d8c6c1a.1648210268.git.michal.simek@xilinx.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 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.5 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma The DLL mode supported SD reference clocks are 50 MHz, 100 MHz and 200 MHz. When user select SD frequency as 200MHz in the design, the actual frequency is going to come around ~187MHz (<= 200MHz considering the parent clock and divisor selection). We need to set SDx_BASECLK as 200 in this case, setting 187 will result in tuning failures in mmc. Set SDx_BASECLK to exact value of 200, 100 or 50 based on the frequency range. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek Reviewed-by: Jaehoon Chung --- drivers/mmc/zynq_sdhci.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index d96f5d543f54..a59d96c6bdad 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -765,6 +765,15 @@ static int sdhci_zynqmp_set_dynamic_config(struct arasan_sdhci_priv *priv, mhz = DIV64_U64_ROUND_UP(clock, 1000000); + if (mhz > 100 && mhz <= 200) + mhz = 200; + else if (mhz > 50 && mhz <= 100) + mhz = 100; + else if (mhz > 25 && mhz <= 50) + mhz = 50; + else + mhz = 25; + ret = zynqmp_pm_set_sd_config(node_id, SD_CONFIG_BASECLK, mhz); if (ret) { dev_err(dev, "SD_CONFIG_BASECLK failed\n");