diff mbox series

[RFC,13/15] sunxi: Implement spinand_ helpers

Message ID 20240411-spinand-v1-13-62d31bb188e8@jookia.org
State RFC
Delegated to: Andre Przywara
Headers show
Series Support SPI NAND booting on the T113 | expand

Commit Message

John Watts April 11, 2024, 4:25 a.m. UTC
These are used by NAND-aware loaders such as UBI.

Signed-off-by: John Watts <contact@jookia.org>
---
 arch/arm/mach-sunxi/spl_spi_sunxi.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
diff mbox series

Patch

diff --git a/arch/arm/mach-sunxi/spl_spi_sunxi.c b/arch/arm/mach-sunxi/spl_spi_sunxi.c
index 602ebfe8c5..d6b03678d0 100644
--- a/arch/arm/mach-sunxi/spl_spi_sunxi.c
+++ b/arch/arm/mach-sunxi/spl_spi_sunxi.c
@@ -450,6 +450,27 @@  static ulong spi_load_read_nand(struct spl_load_info *load, ulong sector,
 
 	return count;
 }
+
+void spinand_init(void)
+{
+	spi0_init();
+	spi0_nand_reset();
+}
+
+void spinand_deselect(void)
+{
+	spi0_deinit();
+}
+
+int spinand_spl_read_block(int block, int offset, int len, void *dst)
+{
+	ulong byte_offset = (block * CONFIG_SPL_SPINAND_BLOCK_SIZE) + offset;
+
+	spi_load_read_nand(NULL, byte_offset, len, dst);
+
+	return 0;
+}
+
 #endif
 
 /*****************************************************************************/