rockchip_sfc: add support for Rockchip SFC
Subsystems (5)
v4 cover rockchip_sfc: add support for Rockchip SFC
From: Chris Morgan <[email protected]>
Changes from v3:
- Added "rockchip_sfc_adjust_op_work()" function from proposed Linux driver to fix potential issue on hardware. Note I never noticed this issue while testing, so I cannot test if it fixed any specific issue for me.
- Updated of-compatible string back to "rockchip,sfc" to match what is currently proposed for upstream driver. The hardware itself has multiple versions but a register is present in the hardware that is read by the driver to set version specific functionality.
- Updated px30.dtsi and rk3266-odroid-go2.dts device-trees so that sfc nodes match what is in upstream.
Changes from v2:
- Resending due to glitch with patch file truncating final two lines on patch 1/5 and incorrect patch version number on patch 5/5.
Changes from v1:
- Reworked code to utilize spi-mem framework, and based it closely off of work in progress code for mainline Linux.
- Removed DMA, as it didn't offer much performance benefit for booting (in my test cases), added complexity to the code, and interfered with A-TF.
- Updated the names of the bindings to match the work in progress Linux code.
- Moved alias to u-boot specific device-tree for Odroid Go Advance. Alias is updated with the spi0 node pointing to the SFC to help the sf command as well as facilitate booting from the SFC.
- Note 2 below no longer applies, as rebasing this off of upstream code should allow the device to work for NAND, and by utilizing the spi-mem framework it no longer has to extract the parameters from the dm_spi_ops.xfer.
Known Issues Remaining with this Patch Series:
1) I don't know the best way to upstream the XTX25F128B flash chip. This chip should use a continuation code for the manufacturer ID, however I cannot seem to find any way to actually read the continuation code as one may not be present. There is a risk of this driver, used as-is, to collide with another chip which has the same manufacturer ID with a different continuation code.
Additionally, it might be worth mentioning but I noticed the Rockchip BROM will only boot the TPL/SPL off of the SFC if I write it to address 0x10000. This is not documented and different than the address looked at for SD card booting (512 * 64 = 0x8000 for SD Card booting). Also, like the SD card driver I can confirm that if DMA is enabled at the SPL stage A-TF seems to fail silently, then when Linux loads it hangs. FIFO mode was removed from the driver to simplify it and for this reason.
Tested: Read (works)
Write (works)
Erase (works)
SPL Read (works if you edit the u-boot,spl-boot-order)
Chris Morgan (5):
spi: rockchip_sfc: add support for Rockchip SFC
rockchip: px30: Add support for using SFC
rockchip: px30: add the serial flash controller
mtd: spi-nor-ids: Add XTX XT25F128B
rockchip: px30: add support for SFC for Odroid Go Advance
arch/arm/dts/px30.dtsi | 38 ++ arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 18 + arch/arm/dts/rk3326-odroid-go2.dts | 16 + arch/arm/mach-rockchip/px30/px30.c | 64 +++ drivers/mtd/spi/Kconfig | 6 + drivers/mtd/spi/spi-nor-ids.c | 4 + drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/rockchip_sfc.c | 513 +++++++++++++++++++++ 9 files changed, 668 insertions(+) create mode 100644 drivers/spi/rockchip_sfc.c
Signature · 1 line
2.25.1
PATCH v4 1/5 spi: rockchip_sfc: add support for Rockchip SFC
From: Chris Morgan <[email protected]>
This patch adds support for the Rockchip serial flash controller found on the PX30 SoC. It should work for versions 3-5 of the SFC IP, however I am only able to test it on v3.
This is adapted from the WIP SPI-MEM driver for the SFC on mainline Linux. Note that the main difference between this and earlier versions of the driver is that this one does not support DMA. In testing the performance difference (performing a dual mode read on a 128Mb chip) is negligible. DMA, if used, must also be disabled in SPL mode when using A-TF anyway.
--- drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/rockchip_sfc.c | 513 +++++++++++++++++++++++++++++++++++++ 3 files changed, 522 insertions(+) create mode 100644 drivers/spi/rockchip_sfc.c
drivers/spi/Kconfig +8 -0
@@ -312,6 +312,14 @@ config RENESAS_RPC_SPI on Renesas RCar Gen3 SoCs. This uses driver model and requires a device tree binding to operate. +config ROCKCHIP_SFC + bool "Rockchip SFC Driver" + help + Enable the Rockchip SFC Driver for SPI NOR flash. This device is + a limited purpose SPI controller for driving NOR flash on certain + Rockchip SoCs. This uses driver model and requires a device tree + binding to operate. + config ROCKCHIP_SPI bool "Rockchip SPI driver" help
drivers/spi/Makefile +1 -0
@@ -52,6 +52,7 @@ obj-$(CONFIG_PIC32_SPI) += pic32_spi.o obj-$(CONFIG_PL022_SPI) += pl022_spi.o obj-$(CONFIG_SPI_QUP) += spi-qup.o obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o +obj-$(CONFIG_ROCKCHIP_SFC) += rockchip_sfc.o obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o obj-$(CONFIG_SPI_SIFIVE) += spi-sifive.o
drivers/spi/rockchip_sfc.c new file +513 -0
513 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v4 2/5 rockchip: px30: Add support for using SFC
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
This patch adds support for setting the correct pin configuration for the Rockchip Serial Flash Controller found on the PX30.
--- arch/arm/mach-rockchip/px30/px30.c | 64 ++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
arch/arm/mach-rockchip/px30/px30.c +64 -0
@@ -51,6 +51,57 @@ struct mm_region *mem_map = px30_mem_map;#define QOS_PRIORITY_LEVEL (h, l) ((((h) & 3) << 8) | ((l) & 3)) +/* GRF_GPIO1AL_IOMUX */ +enum { +GPIO1A3_SHIFT =12 , +GPIO1A3_MASK =0xf <<GPIO1A3_SHIFT , +GPIO1A3_GPIO =0 , +GPIO1A3_FLASH_D3 , +GPIO1A3_EMMC_D3 , +GPIO1A3_SFC_SIO3 , + +GPIO1A2_SHIFT =8 , +GPIO1A2_MASK =0xf <<GPIO1A2_SHIFT , +GPIO1A2_GPIO =0 , +GPIO1A2_FLASH_D2 , +GPIO1A2_EMMC_D2 , +GPIO1A2_SFC_SIO2 , + +GPIO1A1_SHIFT =4 , +GPIO1A1_MASK =0xf <<GPIO1A1_SHIFT , +GPIO1A1_GPIO =0 , +GPIO1A1_FLASH_D1 , +GPIO1A1_EMMC_D1 , +GPIO1A1_SFC_SIO1 , + +GPIO1A0_SHIFT =0 , +GPIO1A0_MASK =0xf <<GPIO1A0_SHIFT , +GPIO1A0_GPIO =0 , +GPIO1A0_FLASH_D0 , +GPIO1A0_EMMC_D0 , +GPIO1A0_SFC_SIO0 , +}; + +/* GRF_GPIO1AH_IOMUX */ +enum { +GPIO1A4_SHIFT =0 , +GPIO1A4_MASK =0xf <<GPIO1A4_SHIFT , +GPIO1A4_GPIO =0 , +GPIO1A4_FLASH_D4 , +GPIO1A4_EMMC_D4 , +GPIO1A4_SFC_CSN0 , +}; + +/* GRF_GPIO1BL_IOMUX */ +enum { +GPIO1B1_SHIFT =4 , +GPIO1B1_MASK =0xf <<GPIO1B1_SHIFT , +GPIO1B1_GPIO =0 , +GPIO1B1_FLASH_RDY , +GPIO1B1_EMMC_CLKOUT , +GPIO1B1_SFC_CLK , +}; +/* GRF_GPIO1BH_IOMUX */ enum {GPIO1B7_SHIFT =12 ,
@@ -193,6 +244,19 @@ int arch_cpu_init(void) GPIO1D4_SDMMC_D2 << GPIO1D4_SHIFT);#endif +#ifdef CONFIG_ROCKCHIP_SFC +rk_clrsetreg (&grf->gpio1al_iomux, +GPIO1A3_MASK |GPIO1A2_MASK |GPIO1A1_MASK |GPIO1A0_MASK , +GPIO1A3_SFC_SIO3 <<GPIO1A3_SHIFT | +GPIO1A2_SFC_SIO2 <<GPIO1A2_SHIFT | +GPIO1A1_SFC_SIO1 <<GPIO1A1_SHIFT | +GPIO1A0_SFC_SIO0 <<GPIO1A0_SHIFT ); +rk_clrsetreg (&grf->gpio1ah_iomux,GPIO1A4_MASK , +GPIO1A4_SFC_CSN0 <<GPIO1A4_SHIFT ); +rk_clrsetreg (&grf->gpio1bl_iomux,GPIO1B1_MASK , +GPIO1B1_SFC_CLK <<GPIO1B1_SHIFT ); +#endif +#endif /* Enable PD_VO (default disable at reset) */
Signature · 1 line
2.25.1
PATCH v4 3/5 rockchip: px30: add the serial flash controller
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
Add the serial flash controller to the devicetree for the PX30.
--- arch/arm/dts/px30.dtsi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
arch/arm/dts/px30.dtsi +38 -0
@@ -960,6 +960,18 @@ status = "disabled"; }; + sfc: spi@ff3a0000 { + compatible = "rockchip,sfc"; + reg = <0x0 0xff3a0000 0x0 0x4000>; + interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&cru SCLK_SFC>, <&cru HCLK_SFC>; + clock-names = "clk_sfc", "hclk_sfc"; + pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus4>; + pinctrl-names = "default"; + power-domains = <&power PX30_PD_MMC_NAND>; + status = "disabled"; + }; + gpu: gpu@ff400000 { compatible = "rockchip,px30-mali", "arm,mali-bifrost"; reg = <0x0 0xff400000 0x0 0x4000>;
@@ -1926,6 +1938,32 @@ }; }; + sfc { + sfc_bus4: sfc-bus4 { + rockchip,pins = + <1 RK_PA0 3 &pcfg_pull_none>, + <1 RK_PA1 3 &pcfg_pull_none>, + <1 RK_PA2 3 &pcfg_pull_none>, + <1 RK_PA3 3 &pcfg_pull_none>; + }; + + sfc_bus2: sfc-bus2 { + rockchip,pins = + <1 RK_PA0 3 &pcfg_pull_none>, + <1 RK_PA1 3 &pcfg_pull_none>; + }; + + sfc_cs0: sfc-cs0 { + rockchip,pins = + <1 RK_PA4 3 &pcfg_pull_none>; + }; + + sfc_clk: sfc-clk { + rockchip,pins = + <1 RK_PB1 3 &pcfg_pull_none>; + }; + }; + lcdc { lcdc_rgb_dclk_pin: lcdc-rgb-dclk-pin { rockchip,pins =
Signature · 1 line
2.25.1
PATCH v4 4/5 mtd: spi-nor-ids: Add XTX XT25F128B
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
Adds support for XT25F128B used on Odroid Go Advance. Unfortunately this chip uses a continuation code which I cannot seem to parse, so there are possibly going to be collisions with chips that use the same manufacturer/ID.
--- drivers/mtd/spi/Kconfig | 6 ++++++ drivers/mtd/spi/spi-nor-ids.c | 4 ++++ 2 files changed, 10 insertions(+)
drivers/mtd/spi/Kconfig +6 -0
@@ -162,6 +162,12 @@ config SPI_FLASH_XMC Add support for various XMC (Wuhan Xinxin Semiconductor Manufacturing Corp.) SPI flash chips (XM25xxx) +config SPI_FLASH_XTX + bool "XTX SPI flash support" + help + Add support for various XTX (XTX Technology Limited) + SPI flash chips (XT25xxx). + endif config SPI_FLASH_USE_4K_SECTORS
drivers/mtd/spi/spi-nor-ids.c +4 -0
@@ -336,6 +336,10 @@ const struct flash_info spi_nor_ids[] = { /* XMC (Wuhan Xinxin Semiconductor Manufacturing Corp.) */ { INFO("XM25QH64A", 0x207017, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("XM25QH128A", 0x207018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, +#endif +#ifdef CONFIG_SPI_FLASH_XTX + /* XTX Technology (Shenzhen) Limited */ + { INFO("XT25F128B", 0x0b4018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, #endif { }, };
Signature · 1 line
2.25.1
PATCH v4 5/5 rockchip: px30: add support for SFC for Odroid Go Advance
In reply to Chris MorganFrom: Chris Morgan <[email protected]>
The Odroid Go Advance uses a Rockchip Serial Flash Controller with an XT25F128B SPI NOR flash chip. This adds support for both. Note that while both the controller and chip support quad mode, only two lines are connected to the chip. Additionally, a possible errata was found while testing the Linux driver, in that setting the tx mode to 2 would cause erases and writes to sometimes fail. Setting the rx mode to 2 and the tx mode to 1 for this reason, and to match the upcoming changes to Linux.
--- arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 18 ++++++++++++++++++ arch/arm/dts/rk3326-odroid-go2.dts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+)
arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi +18 -0
@@ -7,6 +7,16 @@ chosen { u-boot,spl-boot-order = &sdmmc; }; + + aliases { + i2c0 = &i2c0; + i2c1 = &i2c1; + mmc0 = &sdmmc; + serial1 = &uart1; + serial2 = &uart2; + spi0 = &sfc; + spi_flash = "/spi@ff3a0000/flash@0"; + }; }; &cru {
@@ -57,6 +67,14 @@ u-boot,spl-fifo-mode; }; +&sfc { + u-boot,dm-pre-reloc; + + flash@0 { + u-boot,dm-pre-reloc; + }; +}; + &uart1 { clock-frequency = <24000000>; u-boot,dm-pre-reloc;
arch/arm/dts/rk3326-odroid-go2.dts +16 -0
@@ -617,6 +617,22 @@ status = "okay"; }; +&sfc { + pinctrl-0 = <&sfc_clk &sfc_cs0 &sfc_bus2>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + flash@0 { + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <108000000>; + spi-rx-bus-width = <2>; + spi-tx-bus-width = <1>; + }; +}; + &tsadc { status = "okay"; };
Signature · 1 line
2.25.1
Hi Chris,
For this patch set, I would like waiting for kernel sfc driver merge because there may have some update.
Thanks,
- Kever
Quoted 75 lines · Chris Morgan
From: Chris Morgan <[email protected]>
Changes from v3:
- Added "rockchip_sfc_adjust_op_work()" function from proposed Linux driver to fix potential issue on hardware. Note I never noticed this issue while testing, so I cannot test if it fixed any specific issue for me.
- Updated of-compatible string back to "rockchip,sfc" to match what is currently proposed for upstream driver. The hardware itself has multiple versions but a register is present in the hardware that is read by the driver to set version specific functionality.
- Updatedpx30.dtsiandrk3266-odroid-go2.dtsdevice-trees so that sfc nodes match what is in upstream.Changes from v2:
- Resending due to glitch with patch file truncating final two lines on patch 1/5 and incorrect patch version number on patch 5/5.Changes from v1:
- Reworked code to utilize spi-mem framework, and based it closely off of work in progress code for mainline Linux.
- Removed DMA, as it didn't offer much performance benefit for booting (in my test cases), added complexity to the code, and interfered with A-TF.
- Updated the names of the bindings to match the work in progress Linux code.
- Moved alias to u-boot specific device-tree for Odroid Go Advance. Alias is updated with the spi0 node pointing to the SFC to help the sf command as well as facilitate booting from the SFC.
- Note 2 below no longer applies, as rebasing this off of upstream code should allow the device to work for NAND, and by utilizing the spi-mem framework it no longer has to extract the parameters from the dm_spi_ops.xfer.Known Issues Remaining with this Patch Series:
1) I don't know the best way to upstream the XTX25F128B flash chip. This chip should use a continuation code for the manufacturer ID, however I cannot seem to find any way to actually read the continuation code as one may not be present. There is a risk of this driver, used as-is, to collide with another chip which has the same manufacturer ID with a different continuation code.
Additionally, it might be worth mentioning but I noticed the Rockchip BROM will only boot the TPL/SPL off of the SFC if I write it to address
0x10000. This is not documented and different than the address looked at for SD card booting (512 * 64 =0x8000for SD Card booting). Also, like the SD card driver I can confirm that if DMA is enabled at the SPL stage A-TF seems to fail silently, then when Linux loads it hangs. FIFO mode was removed from the driver to simplify it and for this reason.Tested: Read (works)
Write (works)
Erase (works)
SPL Read (works if you edit the u-boot,spl-boot-order)Chris Morgan (5):
spi:rockchip_sfc: add support for Rockchip SFC
rockchip: px30: Add support for using SFC
rockchip: px30: add the serial flash controller
mtd: spi-nor-ids: Add XTX XT25F128B
rockchip: px30: add support for SFC for Odroid Go Advancearch/arm/dts/px30.dtsi | 38 ++ arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 18 + arch/arm/dts/rk3326-odroid-go2.dts | 16 + arch/arm/mach-rockchip/px30/px30.c | 64 +++ drivers/mtd/spi/Kconfig | 6 + drivers/mtd/spi/spi-nor-ids.c | 4 + drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/rockchip_sfc.c | 513 +++++++++++++++++++++ 9 files changed, 668 insertions(+)create mode 100644
drivers/spi/rockchip_sfc.c
Quoted 4 lines · Kever Yang
Hi Chris,
For this patch set, I would like waiting for kernel sfc driver merge because there may have some update.
Agreed. I just want to get this out there though in case anyone wants to test it. I'm okay with "pausing" the review for this one until the Linux driver is accepted upstream.
On a related note, can you provide some additional docs regarding the BROM and how it interacts with the SFC? I found out through trial and error that it reads off of sector 0x10000 (instead of 0x08000 like the SD Card), and that like the SD card the Arm Trusted Firmware hates DMA reads in TPL/SPL modes. Is there anything else we should know if we want to boot an upstream SPL from it (note that I can already do this with this driver, just wanted to know if there were more "gotchas").
Thank you.
Quoted 84 lines
Thanks,
- Kever
Quoted 75 lines · Chris Morgan
From: Chris Morgan <[email protected]>
Changes from v3:
- Added "rockchip_sfc_adjust_op_work()" function from proposed Linux driver to fix potential issue on hardware. Note I never noticed this issue while testing, so I cannot test if it fixed any specific issue for me.
- Updated of-compatible string back to "rockchip,sfc" to match what is currently proposed for upstream driver. The hardware itself has multiple versions but a register is present in the hardware that is read by the driver to set version specific functionality.
- Updatedpx30.dtsiandrk3266-odroid-go2.dtsdevice-trees so that sfc nodes match what is in upstream.Changes from v2:
- Resending due to glitch with patch file truncating final two lines on patch 1/5 and incorrect patch version number on patch 5/5.Changes from v1:
- Reworked code to utilize spi-mem framework, and based it closely off of work in progress code for mainline Linux.
- Removed DMA, as it didn't offer much performance benefit for booting (in my test cases), added complexity to the code, and interfered with A-TF.
- Updated the names of the bindings to match the work in progress Linux code.
- Moved alias to u-boot specific device-tree for Odroid Go Advance. Alias is updated with the spi0 node pointing to the SFC to help the sf command as well as facilitate booting from the SFC.
- Note 2 below no longer applies, as rebasing this off of upstream code should allow the device to work for NAND, and by utilizing the spi-mem framework it no longer has to extract the parameters from the dm_spi_ops.xfer.Known Issues Remaining with this Patch Series:
1) I don't know the best way to upstream the XTX25F128B flash chip. This chip should use a continuation code for the manufacturer ID, however I cannot seem to find any way to actually read the continuation code as one may not be present. There is a risk of this driver, used as-is, to collide with another chip which has the same manufacturer ID with a different continuation code.
Additionally, it might be worth mentioning but I noticed the Rockchip BROM will only boot the TPL/SPL off of the SFC if I write it to address
0x10000. This is not documented and different than the address looked at for SD card booting (512 * 64 =0x8000for SD Card booting). Also, like the SD card driver I can confirm that if DMA is enabled at the SPL stage A-TF seems to fail silently, then when Linux loads it hangs. FIFO mode was removed from the driver to simplify it and for this reason.Tested: Read (works)
Write (works)
Erase (works)
SPL Read (works if you edit the u-boot,spl-boot-order)Chris Morgan (5):
spi:rockchip_sfc: add support for Rockchip SFC
rockchip: px30: Add support for using SFC
rockchip: px30: add the serial flash controller
mtd: spi-nor-ids: Add XTX XT25F128B
rockchip: px30: add support for SFC for Odroid Go Advancearch/arm/dts/px30.dtsi | 38 ++ arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi | 18 + arch/arm/dts/rk3326-odroid-go2.dts | 16 + arch/arm/mach-rockchip/px30/px30.c | 64 +++ drivers/mtd/spi/Kconfig | 6 + drivers/mtd/spi/spi-nor-ids.c | 4 + drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/rockchip_sfc.c | 513 +++++++++++++++++++++ 9 files changed, 668 insertions(+)create mode 100644
drivers/spi/rockchip_sfc.c