[PATCH] spi: rockchip-sfc: Only use x2 clock rate on version 10 and later
Jonas Karlman
jonas at kwiboo.se
Sun Nov 22 09:43:57 PST 2026
The detected NAND ID is read back incorrectly on RK3506 using SCLK_FSPI
rate above ~50 MHz.
spi-nand spi0.0: unknown raw ID f7d511000000
spi-nand spi0.0: probe with driver spi-nand failed with error -95
The FSPI_VER value, clock names and vendor kernel sclk-x2-bypass
handling seem to indicate that x2 clock rate should only be used on
FSPI version 10 and later, not 8 and later.
Summary of FSPI_VER reg, clock names and vendor kernel workarounds:
SoC Reg address Value
rk3568 FSPI_VER fe30002c: 00000005
rk3588 FSPI_VER fe2b002c: 00000005
rv1106 FSPI_VER ffac002c: 00000006
rk3528 FSPI_VER ffc0002c: 00000008 (vendor sclk-x2-bypass)
rk3562 FSPI_VER ff86002c: 00000008 (vendor sclk-x2-bypass)
rk3506 FSPI_VER ff48802c: 00000009 (sfc->version set to 6)
rk3576 FSPI0_VER 2a34002c: 00070010 (SCLK_FSPI_X2)
rk3576 FSPI1_VER 2a30002c: 00070010 (SCLK_FSPI1_X2)
rv1103b FSPI0_VER 20d4002c: 00070011 (SCLK_SFC_2X, sclk-x2-bypass)
rv1103b FSPI1_VER 205c002c: 00070011 (SCLK_SFC_2X_PMU1, sclk-x2-bypass)
rv1126b FSPI0_VER 2146002c: 00070011 (SCLK_2X_FSPI0)
rv1126b FSPI1_VER 208c002c: 00170011 (SCLK_1X_FSPI1, sclk-x2-bypass)
rk3538 FSPI_VER fde2002c: 00670013 (SCLK_2X_FSPI)
rk3572 FSPI0_VER 2a02002c: 00470013 (SCLK_FSPI0_X2)
rk3572 FSPI1_VER 2a08002c: 00470013 (SCLK_FSPI1_X2)
Vendor kernel use x1 clock rates for RK3528, RK3562 and RK3506 thanks to
use of vendor sclk-x2-bypass prop or version downgrade, effectively only
use x2 clock rates on version 10 and later.
FSPI1 on RV1126B should likely also use x1 clock rates, and DDR_UNSPPT
(bit 20) of FSPI_VER being set could possible be used as a runtime
indicator.
Runtime testing also seem to indicate that SCLK_X2_BYPASS (bit 24) of
FSPI_EXT_CTRL only stays set after being written on RV1103B, not on any
other version 8 and later controllers.
Change to only use double clock rate for version 10 and later to fix
use of SPI NAND on RK3506.
spi-nand spi0.0: Winbond SPI NAND was found.
spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 128
Fixes: af103eb7d7d8 ("spi: rockchip-sfc: Support sclk_x2 version")
Signed-off-by: Jonas Karlman <jonas at kwiboo.se>
---
drivers/spi/spi-rockchip-sfc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-rockchip-sfc.c b/drivers/spi/spi-rockchip-sfc.c
index a85a260ba95f..8cc300d533e4 100644
--- a/drivers/spi/spi-rockchip-sfc.c
+++ b/drivers/spi/spi-rockchip-sfc.c
@@ -113,6 +113,7 @@
#define SFC_VER_4 0x4
#define SFC_VER_5 0x5
#define SFC_VER_8 0x8
+#define SFC_VER_10 0x10
/* Delay line controller register */
#define SFC_DLL_CTRL0 0x3C
@@ -220,7 +221,7 @@ static u32 rockchip_sfc_get_max_iosize(struct rockchip_sfc *sfc)
static int rockchip_sfc_clk_set_rate(struct rockchip_sfc *sfc, unsigned long speed)
{
- if (sfc->version >= SFC_VER_8)
+ if (sfc->version >= SFC_VER_10)
return clk_set_rate(sfc->clk, speed * 2);
else
return clk_set_rate(sfc->clk, speed);
@@ -228,7 +229,7 @@ static int rockchip_sfc_clk_set_rate(struct rockchip_sfc *sfc, unsigned long sp
static unsigned long rockchip_sfc_clk_get_rate(struct rockchip_sfc *sfc)
{
- if (sfc->version >= SFC_VER_8)
+ if (sfc->version >= SFC_VER_10)
return clk_get_rate(sfc->clk) / 2;
else
return clk_get_rate(sfc->clk);
--
2.56.1
More information about the Linux-rockchip
mailing list