mbox series

[v4,0/5] rockchip_sfc: add support for Rockchip SFC

Message ID 20210615191046.11812-1-macroalpha82@gmail.com
Headers show
Series rockchip_sfc: add support for Rockchip SFC | expand

Message

Chris Morgan June 15, 2021, 7:10 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

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

Comments

Kever Yang June 18, 2021, 2:22 a.m. UTC | #1
Hi Chris,

     For this patch set, I would like waiting for kernel sfc driver 
merge because there may have some update.


Thanks,

- Kever

On 2021/6/16 上午3:10, Chris Morgan wrote:
> From: Chris Morgan <macromorgan@hotmail.com>
>
> 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
>
Chris Morgan June 18, 2021, 4:30 p.m. UTC | #2
On Fri, Jun 18, 2021 at 10:22:33AM +0800, Kever Yang wrote:
> 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.

> 
> 
> Thanks,
> 
> - Kever
> 
> On 2021/6/16 上午3:10, Chris Morgan wrote:
> > From: Chris Morgan <macromorgan@hotmail.com>
> > 
> > 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
> > 
> 
>