sunxi-tools icon indicating copy to clipboard operation
sunxi-tools copied to clipboard

SPI flash rework

Open apritzel opened this issue 4 months ago • 2 comments

The proposed patches to support SPI flash access on more SoCs (#218 and #208) have issues, and are mainly struggling with the slight differences between the SoCs when it comes to clock and pinmux setup. This PR reworks the SPI flash code, mainly by moving SoC specific information into the existing soc_info_table, so the SPI flash code can just read say the GPIO controller base address, without reverting to hard-to-maintain switch/case functions. Also this introduces a flags field, to include the three existing boolean fields, but also add some generation info (like H6_STYLE_CLOCKS), which can now be cleanly attributed to each SoC, again without fragile switch/case constructs.

I started with a separate SoC table in fel-spiflash.c, with just the info we need, but later felt this is just duplicating what we already have. Plus we can use the GPIO and clock base address later, for upcoming features, like MMC support or GPIO access.

Let me know what you think and whether this is a good idea or not.

@iscle @dron0gus please have a look, I think this should simplify the code changes you need to support your SoCs.

apritzel avatar Aug 17 '25 12:08 apritzel