Skip to content

Commit 67a12ae

Browse files
mwallebroonie
authored andcommitted
spi: spi-nxp-fspi: don't depend on a specific node name erratum workaround
In commit 7e71b85 ("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: 82ce7d0 ("spi: spi-nxp-fspi: Implement errata workaround for LS1028A") Cc: Vladimir Oltean <[email protected]> Signed-off-by: Michael Walle <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3672bb8 commit 67a12ae

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

drivers/spi/spi-nxp-fspi.c

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <linux/acpi.h>
3535
#include <linux/bitops.h>
36+
#include <linux/bitfield.h>
3637
#include <linux/clk.h>
3738
#include <linux/completion.h>
3839
#include <linux/delay.h>
@@ -315,6 +316,7 @@
315316
#define NXP_FSPI_MIN_IOMAP SZ_4M
316317

317318
#define DCFG_RCWSR1 0x100
319+
#define SYS_PLL_RAT GENMASK(6, 2)
318320

319321
/* Access flash memory using IP bus only */
320322
#define FSPI_QUIRK_USE_IP_ONLY BIT(0)
@@ -926,9 +928,8 @@ static void erratum_err050568(struct nxp_fspi *f)
926928
{ .family = "QorIQ LS1028A" },
927929
{ /* sentinel */ }
928930
};
929-
struct device_node *np;
930931
struct regmap *map;
931-
u32 val = 0, sysclk = 0;
932+
u32 val, sys_pll_ratio;
932933
int ret;
933934

934935
/* Check for LS1028A family */
@@ -937,7 +938,6 @@ static void erratum_err050568(struct nxp_fspi *f)
937938
return;
938939
}
939940

940-
/* Compute system clock frequency multiplier ratio */
941941
map = syscon_regmap_lookup_by_compatible("fsl,ls1028a-dcfg");
942942
if (IS_ERR(map)) {
943943
dev_err(f->dev, "No syscon regmap\n");
@@ -948,23 +948,11 @@ static void erratum_err050568(struct nxp_fspi *f)
948948
if (ret < 0)
949949
goto err;
950950

951-
/* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */
952-
val = (val >> 2) & 0x1F;
953-
WARN(val == 0, "Strapping is zero: Cannot determine ratio");
951+
sys_pll_ratio = FIELD_GET(SYS_PLL_RAT, val);
952+
dev_dbg(f->dev, "val: 0x%08x, sys_pll_ratio: %d\n", val, sys_pll_ratio);
954953

955-
/* Compute system clock frequency */
956-
np = of_find_node_by_name(NULL, "clock-sysclk");
957-
if (!np)
958-
goto err;
959-
960-
if (of_property_read_u32(np, "clock-frequency", &sysclk))
961-
goto err;
962-
963-
sysclk = (sysclk * val) / 1000000; /* Convert sysclk to Mhz */
964-
dev_dbg(f->dev, "val: 0x%08x, sysclk: %dMhz\n", val, sysclk);
965-
966-
/* Use IP bus only if PLL is 300MHz */
967-
if (sysclk == 300)
954+
/* Use IP bus only if platform clock is 300MHz */
955+
if (sys_pll_ratio == 3)
968956
f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY;
969957

970958
return;

0 commit comments

Comments
 (0)