spi: spi-nxp-fspi: don't depend on a specific node name erratum workaround
Subsystems (4)
PATCH 1/1 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
--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)
drivers/spi/spi-nxp-fspi.c +7 -19
@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h>
@@ -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 ;
Signature · 1 line
2.30.2
Mark Brown
maintainerQuoted 10 lines · Michael Walle
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 ifSYS_PLL_RATis 3, not that the platform clock is 300 MHz. Make the workaround more reliable and just drop the unneeded sysclk lookup.[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-nxp-fspi: don't depend on a specific node name erratum workaround
commit: 67a12ae52599c9f2f24ef14adb43fc3b164792b5
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 4 lines · Michael Walle
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.
It seems to me that the honest approach for the patch that got broken would have been to add a separate "nxp,ls1028a-fspi" compatible string instead of keeping banging "nxp,lx2160a-fspi", and for this special compatible string, require the platform PLL as a clock provider, and use clk_get() and clk_get_rate().
Quoted 2 lines
We don't even need the sysclk node because the only possible sysclk frequency input is 100MHz.
True. In the RCW, every SYSCLK_FREQ value except 0b1001011000 - 100 MHz is reserved.
That goes to show how shallow my patch which broke this ERR workaround was. The sysclk frequency in the device tree was 100 MHz before _and_ after the U-Boot "fixup", but the warning message was just annoying me.
Quoted 2 lines
In fact, the erratum says it applies if
SYS_PLL_RATis 3, not that the platform clock is 300 MHz.
Correct, although one implies the other.
And probably the platform clock does not matter either, just the clock that the block gets, which just "happens" to be platform clock / 2. Anyway.
Quoted 5 lines
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
Well, in Kuldeep's defence, at least this part is sane, right? I mean we cannot prove an issue => we don't disable reads via the AHB. So it's just the error message (which I didn't notice TBH, sorry).
On the other hand, is anyone using LS1028A with a platform clock of 300 MHz? :)
Quoted 20 lines
Fixes 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errata workaround for LS1028A")Cc Vladimir Oltean <[email protected]>Signed-off-by Michael Walle <[email protected]>--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)drivers/spi/spi-nxp-fspi.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h>
drivers/spi/spi-nxp-fspi.c line 319
Quoted 4 lines
drivers/spi/spi-nxp-fspi.c +1
-0@@ -315,6 +316,7 @@#define NXP_FSPI_MIN_IOMAP SZ_4M#define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2)
Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Quoted 23 lines
drivers/spi/spi-nxp-fspi.c +1
-3/* 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" );
drivers/spi/spi-nxp-fspi.c static void erratum_err050568(struct nxp_fspi *f) · line 952
Quoted 8 lines
drivers/spi/spi-nxp-fspi.c +2
-3@@ -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);
Do we really feel that this dev_dbg is valuable?
Quoted 22 lines
drivers/spi/spi-nxp-fspi.c +2
-13-/* 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 ;Signature · 1 line
2.30.2
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +5 -3
@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { }; fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi"; #address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };
drivers/spi/spi-nxp-fspi.c +8 -49
81 lines not on this page · raw message
Am 2021-10-02 03:37, schrieb Vladimir Oltean:
Quoted 11 lines · Michael Walle
Quoted 6 lines
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 workWell, in Kuldeep's defence, at least this part is sane, right? I mean we cannot prove an issue => we don't disable reads via the AHB. So it's just the error message (which I didn't notice TBH, sorry).
Its just an error message in case the platform clock is 400Mhz. But if you have a 300MHz platform clock the workaround wouldn't be applied.
The reference is just there if someone stumbles over this error and searches for it on google.
Quoted 24 lines
On the other hand, is anyone using LS1028A with a platform clock of 300 MHz? :)
Quoted 22 lines
Fixes 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errata workaround for LS1028A")Cc Vladimir Oltean <[email protected]>Signed-off-by Michael Walle <[email protected]>--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)drivers/spi/spi-nxp-fspi.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h> @@ -315,6 +316,7 @@#define NXP_FSPI_MIN_IOMAP SZ_4M
Quoted 5 lines
drivers/spi/spi-nxp-fspi.c line 319
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c +1
-0#define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2)Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings) will qualify as a fixes commit. Esp. when you change the compatible string.
Quoted 27 lines
Quoted 27 lines
drivers/spi/spi-nxp-fspi.c +1
-3/* 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;
Quoted 9 lines
drivers/spi/spi-nxp-fspi.c static void erratum_err050568(struct nxp_fspi · line 955
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +2
-3-/* 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);Do we really feel that this
dev_dbgis valuable?
No, I just briefly looked at it to see it prints 4 ;)
Quoted 30 lines
Quoted 17 lines
drivers/spi/spi-nxp-fspi.c +2
-13-/* 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 ;Quoted 4 lines
return;
--
2.30.2How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 5 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { }; fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";
Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi";
to keep at least some compatibility.
Quoted 29 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct · line 929
Quoted 8 lines
drivers/spi/spi-nxp-fspi.c +0
-4@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) static void erratum_err050568(struct nxp_fspi *f) { - const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };
Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
Quoted 73 lines
drivers/spi/spi-nxp-fspi.c +5
-35-struct device_node *np; -struct regmap *map; -u32 val =0 , sysclk =0 ; -int ret; +struct clk *clk_base; -/* Check for LS1028A family */ -if (!soc_device_match (ls1028a_soc_attr)) { -dev_dbg (f->dev,"Errata applicable only for LS1028A\n" ); +clk_base = clk_get(f->dev, "base"); +if (IS_ERR(clk_base)) { +dev_err(f->dev, "Errata cannot be executed. Read via IP bus may not work\n"); 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" ); - goto err; - } - - ret =regmap_read (map,DCFG_RCWSR1 , &val); -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" ); - -/* 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 PLL is configured for 300 MHz, hence we get 150 MHz */
drivers/spi/spi-nxp-fspi.c +1
-5+if (clk_get_rate (clk_base) ==150000000 ) f->devtype_data->quirks |=FSPI_QUIRK_USE_IP_ONLY ; - -return ; - -err: - dev_err(f->dev, "Errata cannot be executed. Read via IP bus may notwork\n");
drivers/spi/spi-nxp-fspi.c +1
-1+clk_put (clk_base); }static int nxp_fspi_default_setup (struct nxp_fspi *f)@@ -994,10 +955,8 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)/* * ERR050568: Flash access by FlexSPI AHB command may not work with * platform frequency equal to 300 MHz on LS1028A. -* LS1028A reuses LX2160A compatible entry. Make errata applicable for
drivers/spi/spi-nxp-fspi.c +1
-2-* Layerscape LS1028A platform. */ -if (of_device_is_compatible (f->dev->of_node,"nxp,lx2160a-fspi" )) +if (of_device_is_compatible (f->dev->of_node,"nxp,ls1028a-fspi" ))erratum_err050568 (f);/* Reset the module */
Signature · 1 line
-michael
Quoted 10 lines · Michael Walle
Am 2021-10-02 03:37, schrieb Vladimir Oltean:
Quoted 9 lines · Michael Walle
Quoted 7 lines
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. Readvia IP bus may not work
Quoted 6 lines
Quoted 3 lines
Well, in Kuldeep's defence, at least this part is sane, right? I mean we cannot prove an issue => we don't disable reads via the AHB. So it's just the error message (which I didn't notice TBH, sorry).
Its just an error message in case the platform clock is 400Mhz. But if you have a 300MHz platform clock the workaround wouldn't be applied.
Understood, that's why I asked...
Quoted 5 lines
The reference is just there if someone stumbles over this error and searches for it on google.
Quoted 2 lines
On the other hand, is anyone using LS1028A with a platform clock of 300 MHz? :)
...this.
Quoted 29 lines
Quoted 23 lines
Quoted 23 lines
Fixes 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errata workaroundfor LS1028A")
Cc Vladimir Oltean <[email protected]>Signed-off-by Michael Walle <[email protected]>--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)drivers/spi/spi-nxp-fspi.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h> @@ -315,6 +316,7 @@#define NXP_FSPI_MIN_IOMAP SZ_4MQuoted 5 lines
drivers/spi/spi-nxp-fspi.c line 319
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c +1
-0#define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2)Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Quoted 6 lines
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings) will qualify as a fixes commit. Esp. when you change the compatible string.
I think it could be justified as a fixes commit to Shawn Guo - the LS1028A is not "compatible" with LX2160A in the sense that it has software-visible errata which LX2160A doesn't have.
Quoted 70 lines
Quoted 26 lines
Quoted 26 lines
drivers/spi/spi-nxp-fspi.c +1
-3/* 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;Quoted 9 lines
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +0
-1-/* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */
drivers/spi/spi-nxp-fspi.c +2
-2- 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);Do we really feel that this
dev_dbgis valuable?No, I just briefly looked at it to see it prints 4 ;)
Quoted 32 lines
Quoted 19 lines
drivers/spi/spi-nxp-fspi.c +2
-14-/* 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 ; --Quoted 2 lines
2.30.2
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { };
Quoted 7 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi";
to keep at least some compatibility.
Of course that would be even better. I just wanted to rush to get here before Mark, and it looks like I still didn't make it in time.
Worst case, new (cleaned up to not calculate the platform clock on its own) driver will still probe with old device tree, but not apply the ERR workaround for 300 MHz systems.
I may be ignorant here, but I just don't know how many systems use 300 MHz platform in practice. Anyway, it's always difficult to fix up something that came to depend on DT bindings in a certain way.
Quoted 31 lines
Quoted 31 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
Quoted 13 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) · line 928
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +0
-4static void erratum_err050568 (struct nxp_fspi *f) { -const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
So you want a compatible string a la "fsl,ls1021a-v1.0-dspi", right? I don't know, no strong opinion, as you said, we both know that no LS1028A rev 2 seems to be planned.
Quoted 74 lines
Quoted 71 lines
drivers/spi/spi-nxp-fspi.c +5
-35-struct device_node *np; -struct regmap *map; -u32 val =0 , sysclk =0 ; -int ret; +struct clk *clk_base; -/* Check for LS1028A family */ -if (!soc_device_match (ls1028a_soc_attr)) { -dev_dbg (f->dev,"Errata applicable only for LS1028A\n" ); + clk_base =clk_get (f->dev,"base" ); +if (IS_ERR (clk_base)) { +dev_err (f->dev,"Errata cannot be executed. Read via IP bus may not work\n");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" ); - goto err; - } - - ret =regmap_read (map,DCFG_RCWSR1 , &val); -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" ); - -/* 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 PLL is configured for 300 MHz, hence we get 150 MHz */
drivers/spi/spi-nxp-fspi.c +1
-5+if (clk_get_rate (clk_base) ==150000000 ) f->devtype_data->quirks |=FSPI_QUIRK_USE_IP_ONLY ; - -return ; - -err: - dev_err(f->dev, "Errata cannot be executed. Read via IP bus may notwork\n");
drivers/spi/spi-nxp-fspi.c +2
-3+clk_put (clk_base); }static int nxp_fspi_default_setup (struct nxp_fspi *f)@@ -994,10 +955,8 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)/* * ERR050568: Flash access by FlexSPI AHB command may not work with * platform frequency equal to 300 MHz on LS1028A. -* LS1028A reuses LX2160A compatible entry. Make errata applicable for -* Layerscape LS1028A platform. */ -if (of_device_is_compatible (f->dev->of_node,"nxp,lx2160a-fspi" )) +if (of_device_is_compatible (f->dev->of_node,"nxp,ls1028a-fspi" ))erratum_err050568 (f);/* Reset the module */
Signature · 1 line
-michael
Am 2021-10-02 11:23, schrieb Vladimir Oltean:
Quoted 20 lines · Michael Walle
Quoted 10 lines
Am 2021-10-02 03:37, schrieb Vladimir Oltean:
Quoted 9 lines · Michael Walle
Quoted 7 lines
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. Readvia IP bus may not work
Quoted 6 lines
Quoted 3 lines
Well, in Kuldeep's defence, at least this part is sane, right? I mean we cannot prove an issue => we don't disable reads via the AHB. So it's just the error message (which I didn't notice TBH, sorry).
Its just an error message in case the platform clock is 400Mhz. But if you have a 300MHz platform clock the workaround wouldn't be applied.
Understood, that's why I asked...
Quoted 7 lines
Quoted 5 lines
The reference is just there if someone stumbles over this error and searches for it on google.
Quoted 2 lines
On the other hand, is anyone using LS1028A with a platform clock of 300 MHz? :)
...this.
Which I can't answer ;)
Quoted 37 lines
Quoted 30 lines
Quoted 24 lines
Quoted 24 lines
Fixes 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errata workaroundfor LS1028A")
Cc Vladimir Oltean <[email protected]>Signed-off-by Michael Walle <[email protected]>--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)drivers/spi/spi-nxp-fspi.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h> @@ -315,6 +316,7 @@#define NXP_FSPI_MIN_IOMAP SZ_4MQuoted 5 lines
drivers/spi/spi-nxp-fspi.c line 319
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c +1
-0#define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2)Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Quoted 6 lines
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings) will qualify as a fixes commit. Esp. when you change the compatible string.
Quoted 3 lines
I think it could be justified as a fixes commit to Shawn Guo - the LS1028A is not "compatible" with LX2160A in the sense that it has software-visible errata which LX2160A doesn't have.
And you'd need to get Rob into the boat for the dt bindings "fixes", no? For the new clock.
Quoted 78 lines
Quoted 70 lines
Quoted 26 lines
Quoted 26 lines
drivers/spi/spi-nxp-fspi.c +1
-3/* 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;Quoted 9 lines
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +0
-1-/* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */
drivers/spi/spi-nxp-fspi.c +2
-2- 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);Do we really feel that this
dev_dbgis valuable?No, I just briefly looked at it to see it prints 4 ;)
Quoted 32 lines
Quoted 19 lines
drivers/spi/spi-nxp-fspi.c +2
-14-/* 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 ; --Quoted 2 lines
2.30.2
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { };Quoted 7 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi";
to keep at least some compatibility.
Quoted 6 lines
Of course that would be even better. I just wanted to rush to get here before Mark, and it looks like I still didn't make it in time.
Worst case, new (cleaned up to not calculate the platform clock on its own) driver will still probe with old device tree, but not apply the ERR workaround for 300 MHz systems.
No worst case is, the flexspi driver doesn't probe at all (new devicetree, old kernel ;).
Quoted 49 lines
I may be ignorant here, but I just don't know how many systems use 300 MHz platform in practice. Anyway, it's always difficult to fix up something that came to depend on DT bindings in a certain way.
Quoted 31 lines
Quoted 31 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)Quoted 13 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) · line 928
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +0
-4static void erratum_err050568 (struct nxp_fspi *f) { -const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
Quoted 3 lines
So you want a compatible string a la "fsl,ls1021a-v1.0-dspi", right? I don't know, no strong opinion, as you said, we both know that no LS1028A rev 2 seems to be planned.
Nooo. No revisions in the compatible string.
const struct soc_device_attribute ls1028a_soc_attr[] = {
{ .family = "QorIQ LS1028A", .revision = "1.0" },
{ }
};Thus you'd still need that check above.
-michael
Quoted 8 lines · Michael Walle
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings)
I don't think I'm the one who forgot to update the bindings, btw. In Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt (still not using JSON schema), the "clocks" are not documented as to what they want and why do both "fspi" and "fspi_en" even exist. The only mention you see of the "fspi" and "fspi_en" clocks in that file is an _example_. And that example remains correct, because it is for the LX2160A.
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
will qualify as a fixes
commit. Esp. when you change the compatible string.I think it could be justified as a fixes commit to Shawn Guo - the LS1028A is not "compatible" with LX2160A in the sense that it has software-visible errata which LX2160A doesn't have.
And you'd need to get Rob into the boat for the dt bindings "fixes", no? For the new clock.
Yup.
Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 10 lines
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { };Quoted 7 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi";
to keep at least some compatibility.Of course that would be even better. I just wanted to rush to get here before Mark, and it looks like I still didn't make it in time.
Quoted 7 lines
Quoted 4 lines
Worst case, new (cleaned up to not calculate the platform clock on its own)
driver will still probe with old device tree, but not apply the ERR workaround for 300 MHz systems.No worst case is, the flexspi driver doesn't probe at all (new devicetree, old kernel ;).
Well, if you're going to take my patch as is, sure. But the device tree can still be modified in such a way that old kernels keep seeing what they saw before - the fallback compatibility string, and ignore the third clock provider.
With even more care and consideration for new kernels operating with old DT blobs, the ERR workaround could check for the clock provider in the device tree first, then fall back to open-coding its own deductions of the platform clock if that fails. After a grace period of one or two years or so, maybe the open-coding could then be removed.
Quoted 53 lines
Quoted 49 lines
I may be ignorant here, but I just don't know how many systems use 300 MHz platform in practice. Anyway, it's always difficult to fix up something that came to depend on DT bindings in a certain way.
Quoted 31 lines
Quoted 31 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)Quoted 13 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) · line 928
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +0
-4static void erratum_err050568 (struct nxp_fspi *f) { -const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
Quoted 3 lines
So you want a compatible string a la "fsl,ls1021a-v1.0-dspi", right? I don't know, no strong opinion, as you said, we both know that no LS1028A rev 2 seems to be planned.
Quoted 8 lines
Nooo. No revisions in the compatible string.
const struct soc_device_attribute ls1028a_soc_attr[] = { { .family = "QorIQ LS1028A", .revision = "1.0" }, { } };Thus you'd still need that check above.
Ok, the idea of changing the compatible string was to make the driver search for the third "base" clock. But the bindings document can simply say that the "base" clock is optional for all SoCs - with the caveat that the LS1028A ERR workarounds will not be applied if not provided. And in that case, not even a SoC specific compatible string is needed.
Am 2021-10-02 11:55, schrieb Vladimir Oltean:
Quoted 10 lines · Michael Walle
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings)
Quoted 6 lines
I don't think I'm the one who forgot to update the bindings, btw. In
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt(still not using JSON schema), the "clocks" are not documented as to what they want and why do both "fspi" and "fspi_en" even exist. The only mention you see of the "fspi" and "fspi_en" clocks in that file is an _example_. And that example remains correct, because it is for the LX2160A.
That doesn't mean you shouldn't document it in the bindings.
I just wanted to point out that for a fixes commit, you'd have to consider that change, too.
Quoted 38 lines
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines
will qualify as a fixes
commit. Esp. when you change the compatible string.I think it could be justified as a fixes commit to Shawn Guo - the LS1028A is not "compatible" with LX2160A in the sense that it has software-visible errata which LX2160A doesn't have.
And you'd need to get Rob into the boat for the dt bindings "fixes", no? For the new clock.
Yup.
Quoted 26 lines
Quoted 25 lines
Quoted 10 lines
Quoted 10 lines
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { };Quoted 7 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi";
to keep at least some compatibility.Of course that would be even better. I just wanted to rush to get here before Mark, and it looks like I still didn't make it in time.
Worst case, new (cleaned up to not calculate the platform clock on its own)
driver will still probe with old device tree, but not apply the ERR workaround for 300 MHz systems.
Quoted 7 lines
Quoted 2 lines
No worst case is, the flexspi driver doesn't probe at all (new devicetree, old kernel ;).
Well, if you're going to take my patch as is, sure. But the device tree can still be modified in such a way that old kernels keep seeing what they saw before - the fallback compatibility string, and ignore the third clock provider.
Ack.
Quoted 5 lines
With even more care and consideration for new kernels operating with old DT blobs, the ERR workaround could check for the clock provider in the device tree first, then fall back to open-coding its own deductions of the platform clock if that fails. After a grace period of one or two years or so, maybe the open-coding could then be removed.
Mh, do you really want to go that extra mile for something you don't even know is used? It's up to you, I wouldn't do it ;)
Quoted 60 lines
Quoted 60 lines
Quoted 49 lines
I may be ignorant here, but I just don't know how many systems use 300 MHz platform in practice. Anyway, it's always difficult to fix up something that came to depend on DT bindings in a certain way.
Quoted 31 lines
Quoted 31 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)Quoted 13 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) · line 928
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +0
-4static void erratum_err050568 (struct nxp_fspi *f) { -const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
Quoted 3 lines
So you want a compatible string a la "fsl,ls1021a-v1.0-dspi", right? I don't know, no strong opinion, as you said, we both know that no LS1028A rev 2 seems to be planned.
Nooo. No revisions in the compatible string.
const struct soc_device_attribute ls1028a_soc_attr[] = { { .family = "QorIQ LS1028A", .revision = "1.0" }, { } };
Quoted 7 lines
Quoted 1 line
Thus you'd still need that check above.
Ok, the idea of changing the compatible string was to make the driver search for the third "base" clock. But the bindings document can simply say that the "base" clock is optional for all SoCs - with the caveat that the LS1028A ERR workarounds will not be applied if not provided. And in that case, not even a SoC specific compatible string is needed.
Ack.
-michael
Hi Vladimir and Michael,
Quoted 30 lines
-----Original Message-----
From: Vladimir Oltean <[email protected]>
Sent: Saturday, October 2, 2021 2:53 PM
To: Michael Walle <[email protected]>
Cc: [email protected]; [email protected]; Ashish Kumar <[email protected]>; Yogesh Gaur <[email protected]>; Mark Brown <[email protected]>; Kuldeep Singh <[email protected]>
Subject: Re: [PATCH] spi: spi-nxp-fspi: don't depend on a specific node name erratum workaroundQuoted 10 lines · Michael Walle
Am 2021-10-02 03:37, schrieb Vladimir Oltean:
Quoted 9 lines · Michael Walle
Quoted 7 lines
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. Readvia IP bus may not work
Quoted 6 lines
Quoted 3 lines
Well, in Kuldeep's defence, at least this part is sane, right? I mean we cannot prove an issue => we don't disable reads via the AHB. So it's just the error message (which I didn't notice TBH, sorry).
Its just an error message in case the platform clock is 400Mhz. But if you have a 300MHz platform clock the workaround wouldn't be applied.
Understood, that's why I asked...
Quoted 7 lines
Quoted 5 lines
The reference is just there if someone stumbles over this error and searches for it on google.
Quoted 2 lines
On the other hand, is anyone using LS1028A with a platform clock of 300 MHz? :)
...this.
I didn't receive emails in proper order not sure why. Anyway, I will try to pitch in details which I have.
There was one customer(cannot recall name) using LS1028A with 300Mhz.
They reported AHB failure issue and later on it turns out to be an errata. I didn't hear anything from them whether they pursued with 300Mhz or fallback to 400Mhz.
Quoted 31 lines
Quoted 31 lines
Quoted 30 lines
Quoted 23 lines
Fixes 82ce7d0e74b6 ("spi: spi-nxp-fspi: Implement errataworkaround for LS1028A")
Cc Vladimir Oltean <[email protected]>Signed-off-by Michael Walle <[email protected]>--- drivers/spi/spi-nxp-fspi.c | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-)(quoted diff) +0
-0
b/drivers/spi/spi-nxp-fspi.cindexa66fa97046ee..2b0301fc971c100644drivers/spi/spi-nxp-fspi.c +1
-0@@ -33,6 +33,7 @@#include <linux/acpi.h> #include <linux/bitops.h> +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h> drivers/spi/spi-nxp-fspi.c line 319
Quoted 4 lines
drivers/spi/spi-nxp-fspi.c +1
-0@@ -315,6 +316,7 @@#define NXP_FSPI_MIN_IOMAP SZ_4M#define DCFG_RCWSR1 0x100 +#define SYS_PLL_RAT GENMASK(6, 2)Ugh. So your solution still makes a raw read of the platform PLL value from the DCFG, now it just adds a nice definition for it. Not nice.
Quoted 6 lines
Quoted 6 lines
Keep in mind that this is intended to be a fixes commit. I agree with you that having a new clock in the device tree and checking that would have been better. Feel free to change the workaround after this fix is applied (without a fixes tag), but I don't think introducing a new clock (and you forgot to update the bindings) will qualify as a fixes commit. Esp. when you change the compatible string.
dt-bindings are updated to json schema and already posted upstream awaiting Mark's feedback.
Moreover, using third optional clock seems a viable solution.
Since this is the first time we have stumbled such issue and isn't a frequent one,
We can keep current changes as is and if face similar issue later, can switch to new proposed solution.
Similar changes are also done for u-boot[1] in an absurd manner as I couldn't find simpler way to do it. I'll be glad to receive feedback on those patches.
Regards
Kuldeep
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=256398
Quoted 224 lines
I think it could be justified as a fixes commit to Shawn Guo - the LS1028A is not "compatible" with LX2160A in the sense that it has software-visible errata which LX2160A doesn't have.
Quoted 3 lines
Quoted 3 lines
drivers/spi/spi-nxp-fspi.c static void erratum_err050568(struct nxp_fspi
Quoted 3 lines
drivers/spi/spi-nxp-fspi.c +0
-0/* 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)
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi-nxp-fspi.c static void erratum_err050568(struct nxp_fspi
Quoted 11 lines
drivers/spi/spi-nxp-fspi.c +1
-2{ .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)
Quoted 7 lines
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +0
-1return ; } -/* 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@@
Quoted 49 lines
Quoted 5 lines
Quoted 5 lines
static void erratum_err050568(struct
nxp_fspi
*f)drivers/spi/spi-nxp-fspi.c +0
-0if (ret <0 ) goto err;Quoted 9 lines
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +0
-1-/* Strap bits 6:2 define SYS_PLL_RAT i.e frequency multiplier ratio */
drivers/spi/spi-nxp-fspi.c +2
-2- 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);Do we really feel that this
dev_dbgis valuable?No, I just briefly looked at it to see it prints 4 ;)
Quoted 32 lines
Quoted 19 lines
drivers/spi/spi-nxp-fspi.c +2
-14-/* 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 ; --Quoted 2 lines
2.30.2
How about:
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +0
-0@@ -326,15 +326,17 @@ i2c7: i2c@2070000 { };Quoted 7 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi i2c7: i2c@2070000 { · line 329
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +1
-1fspi: spi@20c0000 { - compatible = "nxp,lx2160a-fspi"; + compatible = "nxp,ls1028a-fspi";Why not
compatible = "nxp,ls1028a-fspi", "nxp,lx2160a-fspi"; to keep at
least some compatibility.Of course that would be even better. I just wanted to rush to get here before Mark, and it looks like I still didn't make it in time.
Worst case, new (cleaned up to not calculate the platform clock on its own) driver will still probe with old device tree, but not apply the ERR workaround for 300 MHz systems.
I may be ignorant here, but I just don't know how many systems use 300 MHz platform in practice. Anyway, it's always difficult to fix up something that came to depend on DT bindings in a certain way.
Quoted 31 lines
Quoted 31 lines
arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi +4
-2#address-cells = <1>; #size-cells = <0>; reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>; reg-names = "fspi_base", "fspi_mmap"; interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>; - clocks = <&fspi_clk>, <&fspi_clk>; - clock-names = "fspi_en", "fspi"; + clocks = <&fspi_clk>, <&fspi_clk>, + <&clockgen QORIQ_CLK_PLATFORM_PLL + QORIQ_CLK_PLL_DIV(2)>; + clock-names = "fspi_en", "fspi", "base"; status = "disabled"; };drivers/spi/spi-nxp-fspi.c +0
-2@@ -314,8 +314,6 @@#define NXP_FSPI_MAX_CHIPSELECT 4#define NXP_FSPI_MIN_IOMAP SZ_4M -#define DCFG_RCWSR1 0x100 -/* Access flash memory using IP bus only */ #define FSPI_QUIRK_USE_IP_ONLY BIT(0)@@ -922,55 +920,18 @@ static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)Quoted 12 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op) · line 928
Quoted 5 lines
drivers/spi/spi-nxp-fspi.c +0
-4static void erratum_err050568 (struct nxp_fspi *f) { -const struct soc_device_attribute ls1028a_soc_attr[] = { - { .family ="QorIQ LS1028A" }, - {/* sentinel */ } - };Mh, I see how you came to the conclusion to rename the compatible string. But normally, this also contains a revision check, which is missing here IMHO. It might as well be fixed in the next revision (though we both know, this is highly unlikely; its still wrong). So while you could rename the compatible (oh no!) you'd still have to do the rev 1.0 check here.
So you want a compatible string a la "fsl,ls1021a-v1.0-dspi", right? I don't know, no strong opinion, as you said, we both know that no LS1028A rev 2 seems to be planned.
Quoted 6 lines
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +1
-4-struct device_node *np; -struct regmap *map; -u32 val =0 , sysclk =0 ; -int ret; +struct clk *clk_base;Quoted 6 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
Quoted 6 lines
drivers/spi/spi-nxp-fspi.c +3
-3-/* Check for LS1028A family */ -if (!soc_device_match (ls1028a_soc_attr)) { -dev_dbg (f->dev,"Errata applicable only for LS1028A\n" ); + clk_base =clk_get (f->dev,"base" ); +if (IS_ERR (clk_base)) { + dev_err(f->dev, "Errata cannot be executed. Read via IP busmay
Quoted 47 lines
Quoted 47 lines
drivers/spi/spi-nxp-fspi.c +3
-28+not work\n");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" ); - goto err; - } - - ret =regmap_read (map,DCFG_RCWSR1 , &val); -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" ); - -/* 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 PLL is configured for 300 MHz, +hence we get 150 MHz */
drivers/spi/spi-nxp-fspi.c +1
-5+if (clk_get_rate (clk_base) ==150000000 ) f->devtype_data->quirks |=FSPI_QUIRK_USE_IP_ONLY ; - -return ; - -err: - dev_err(f->dev, "Errata cannot be executed. Read via IP bus may notwork\n");
drivers/spi/spi-nxp-fspi.c +1
-0+clk_put (clk_base); }Quoted 5 lines
drivers/spi/spi-nxp-fspi.c
Quoted 5 lines
static int
nxp_fspi_default_setup(struct nxp_fspi *f)@@ -994,10
+955,8 @@ static intnxp_fspi_default_setup(struct nxp_fspi *f)drivers/spi/spi-nxp-fspi.c +0
-0/* * ERR050568: Flash access by FlexSPI AHB command may not work with
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c +0
-1* platform frequency equal to 300 MHz on LS1028A. -* LS1028A reuses LX2160A compatible entry. Make errata applicable for
Quoted 10 lines
drivers/spi/spi-nxp-fspi.c static int nxp_fspi_default_setup(struct nxp_fspi *f) · line 962
Quoted 7 lines
drivers/spi/spi-nxp-fspi.c +1
-2-* Layerscape LS1028A platform. */ -if (of_device_is_compatible (f->dev->of_node,"nxp,lx2160a-fspi" )) +if (of_device_is_compatible (f->dev->of_node,"nxp,ls1028a-fspi" ))erratum_err050568 (f);/* Reset the module */ --
-michael