Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

spi: spi-nxp-fspi: don't depend on a specific node name erratum workaround

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 <vladimir.oltean@nxp.com>
Signed-off-by: Michael Walle <michael@walle.cc>
Link: https://lore.kernel.org/r/20211001212726.159437-1-michael@walle.cc
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Michael Walle and committed by
Mark Brown
67a12ae5 3672bb82

+7 -19
+7 -19
drivers/spi/spi-nxp-fspi.c
··· 33 33 34 34 #include <linux/acpi.h> 35 35 #include <linux/bitops.h> 36 + #include <linux/bitfield.h> 36 37 #include <linux/clk.h> 37 38 #include <linux/completion.h> 38 39 #include <linux/delay.h> ··· 316 315 #define NXP_FSPI_MIN_IOMAP SZ_4M 317 316 318 317 #define DCFG_RCWSR1 0x100 318 + #define SYS_PLL_RAT GENMASK(6, 2) 319 319 320 320 /* Access flash memory using IP bus only */ 321 321 #define FSPI_QUIRK_USE_IP_ONLY BIT(0) ··· 928 926 { .family = "QorIQ LS1028A" }, 929 927 { /* sentinel */ } 930 928 }; 931 - struct device_node *np; 932 929 struct regmap *map; 933 - u32 val = 0, sysclk = 0; 930 + u32 val, sys_pll_ratio; 934 931 int ret; 935 932 936 933 /* Check for LS1028A family */ ··· 938 937 return; 939 938 } 940 939 941 - /* Compute system clock frequency multiplier ratio */ 942 940 map = syscon_regmap_lookup_by_compatible("fsl,ls1028a-dcfg"); 943 941 if (IS_ERR(map)) { 944 942 dev_err(f->dev, "No syscon regmap\n"); ··· 948 948 if (ret < 0) 949 949 goto err; 950 950 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); 954 953 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) 968 956 f->devtype_data->quirks |= FSPI_QUIRK_USE_IP_ONLY; 969 957 970 958 return;