Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1600818pxb; Fri, 1 Oct 2021 14:33:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKSCQ3caYfDAJPmW1lFOhUlst9X6QQhvkg1Y3J/YxalBCaQ1qiR6NW62S+YdY3dG9R8Ntg X-Received: by 2002:a17:902:7b84:b0:13b:90a7:e270 with SMTP id w4-20020a1709027b8400b0013b90a7e270mr11699515pll.21.1633123996343; Fri, 01 Oct 2021 14:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633123996; cv=none; d=google.com; s=arc-20160816; b=KdgOk98Xs+RF4HM6cmDW5UeRpZzpAxpI13L6qxF5ok3ZciDAWoeLkaP13V1I36QYkB EBu5kMe0X6Zl0Rcyy76BGsbKEKxW3nNBMZBtPfphyV2TZShOth1uF4Cbo7eZToA+Jc+h awzzdRvd6RssEJtI3KVebmKNlbl+HG9jIaV3icj3Jfm4B4CecSLZKR7Wq61E1liZDTUp vSnoJDNfWp3XA3jxtteTt+XoFuOGdRIn9MQXmGvSXPVxyaSs8Jth8KKNVyzWaSX8up4E Wtq0o0wBzyhAmNSlSrZuwPXw+LM0PJPbHbKlU+2DqQ989dptW6gZRT5Hnb/Rw5s1a1bV biWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Hs1kuhtnkFaEUv7FOtmkbn3il4fEyf/TubyN0s51Qjs=; b=VvVaAzuCBVBDMS0pbe6t4p5vyjsEXXSTTyxnRCwy5hjrfe9OVO4Pj+ZC3Vo9oaTd0m 4buNgyxq+INXGNdOkeUiP5KAc4nTEMcsmBzaObeIOyZAJq+Y/t/OpuA6KndToYjB8zIh ha0QbSQJm6rhGBeRdVRscfHLTxs+Fc2uoW9ebu9tlGp2Rvb5y41YtMeitkzYqRZQN130 ZCXE3UKvVfbsC7uvQiqI/4QZfCJEK0JV6UZWCBMradSsXakN2UpW7u5qyn/GYPbD9+Xx iR/IW37UYhIpGxZK3LTT0DkfQtk7oeG4OSG3NO5vGa3kFVjQoXjNcfuSF1XyX4dE6cE2 RRkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=pY8czqpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q2si9203475pfl.259.2021.10.01.14.33.03; Fri, 01 Oct 2021 14:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=pY8czqpP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229935AbhJAV3V (ORCPT + 99 others); Fri, 1 Oct 2021 17:29:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbhJAV3U (ORCPT ); Fri, 1 Oct 2021 17:29:20 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B8A5C061775; Fri, 1 Oct 2021 14:27:36 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id EDCFD22234; Fri, 1 Oct 2021 23:27:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1633123653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Hs1kuhtnkFaEUv7FOtmkbn3il4fEyf/TubyN0s51Qjs=; b=pY8czqpPVJDZp88B7bjcqtt/r683duydVxmmZkByi2uSi32S31xjFE+UkddFCo3cXZhbnt 3z5xNjGI67Q9WWaKyr6AtW4bq2/u6j5qdGEPl6fwTTMYomICeMEfEFREXDcSM/gSDU+mT5 Xc0jrMvGo/Izvm+ySanQp1ahvTfboN4= From: Michael Walle To: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ashish Kumar , Yogesh Gaur , Mark Brown , Kuldeep Singh , Michael Walle , Vladimir Oltean Subject: [PATCH] spi: spi-nxp-fspi: don't depend on a specific node name erratum workaround Date: Fri, 1 Oct 2021 23:27:26 +0200 Message-Id: <20211001212726.159437-1-michael@walle.cc> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit 7e71b85473f8 ("arm64: dts: ls1028a: fix node name for the sysclk") the sysclk node name was renamed and broke the erratum workaround because it tries to fetch a device tree node by its name, which is very fragile in general. We don't even need the sysclk node because the only possible sysclk frequency input is 100MHz. In fact, the erratum says it applies if SYS_PLL_RAT is 3, not that the platform clock is 300 MHz. Make the workaround more reliable and just drop the unneeded sysclk lookup. For reference, the error during the bootup is the following: [ 4.898400] nxp-fspi 20c0000.spi: Errata cannot be executed. Read via IP bus may not work Fixes: 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errata workaround for LS1028A") Cc: Vladimir Oltean Signed-off-by: Michael Walle --- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c index a66fa97046ee..2b0301fc971c 100644 --- a/drivers/spi/spi-nxp-fspi.c +++ b/drivers/spi/spi-nxp-fspi.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -315,6 +316,7 @@ #define NXP_FSPI_MIN_IOMAP SZ_4M #define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2) /* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0) @@ -926,9 +928,8 @@ static void erratum_err050568(struct nxp_fspi *f) { .family = "QorIQ LS1028A" }, { /* sentinel */ } }; - struct device_node *np; struct regmap *map; - u32 val = 0, sysclk = 0; + u32 val, sys_pll_ratio; int ret; /* Check for LS1028A family */ @@ -937,7 +938,6 @@ static void erratum_err050568(struct nxp_fspi *f) return; } - /* Compute system clock frequency multiplier ratio */ map = syscon_regmap_lookup_by_compatible("fsl,ls1028a-dcfg"); if (IS_ERR(map)) { dev_err(f->dev, "No syscon regmap\n"); @@ -948,23 +948,11 @@ static void erratum_err050568(struct nxp_fspi *f) if (ret < 0) goto err; - /* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */ - val = (val >> 2) & 0x1F; - WARN(val == 0, "Strapping is zero: Cannot determine ratio"); + sys_pll_ratio = FIELD_GET(SYS_PLL_RAT, val); + dev_dbg(f->dev, "val: 0x%08x, sys_pll_ratio: %d\n", val, sys_pll_ratio); - /* Compute system clock frequency */ - np = of_find_node_by_name(NULL, "clock-sysclk"); - if (!np) - goto err; - - if (of_property_read_u32(np, "clock-frequency", &sysclk)) - goto err; - - sysclk = (sysclk * val) / 1000000; /* Convert sysclk to Mhz */ - dev_dbg(f->dev, "val: 0x%08x, sysclk: %dMhz\n", val, sysclk); - - /* Use IP bus only if PLL is 300MHz */ - if (sysclk == 300) + /* Use IP bus only if platform clock is 300MHz */ + if (sys_pll_ratio == 3) f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY; return; -- 2.30.2