[PATCH v3 1/5] board: starfive: function to read eMMC size
Heinrich Schuchardt
heinrich.schuchardt at canonical.com
Thu May 9 12:11:49 CEST 2024
The EEPROM provides information about the size of the eMMC.
Provide a new function get_mmc_size_from_eeprom() to read it.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
Reviewed-by: E. Shattow <lucent at gmail.com>
---
v3:
no change
v2:
fix typos in get_mmc_size_from_eeprom() description
---
arch/riscv/include/asm/arch-jh7110/eeprom.h | 7 +++++++
board/starfive/visionfive2/Kconfig | 9 +++++++++
.../visionfive2/visionfive2-i2c-eeprom.c | 18 ++++++++++++++++++
3 files changed, 34 insertions(+)
diff --git a/arch/riscv/include/asm/arch-jh7110/eeprom.h b/arch/riscv/include/asm/arch-jh7110/eeprom.h
index 62d184aeb57..45ad2a5f7bc 100644
--- a/arch/riscv/include/asm/arch-jh7110/eeprom.h
+++ b/arch/riscv/include/asm/arch-jh7110/eeprom.h
@@ -12,6 +12,13 @@
u8 get_pcb_revision_from_eeprom(void);
u32 get_ddr_size_from_eeprom(void);
+/**
+ * get_mmc_size_from_eeprom() - read eMMC size from EEPROM
+ *
+ * @return: size in GiB or 0 on error.
+ */
+u32 get_mmc_size_from_eeprom(void);
+
/**
* get_product_id_from_eeprom - get product ID string
*
diff --git a/board/starfive/visionfive2/Kconfig b/board/starfive/visionfive2/Kconfig
index 2186a939646..d7e8a7a7d78 100644
--- a/board/starfive/visionfive2/Kconfig
+++ b/board/starfive/visionfive2/Kconfig
@@ -50,4 +50,13 @@ config BOARD_SPECIFIC_OPTIONS # dummy
imply PHY_LIB
imply PHY_MSCC
+config STARFIVE_NO_EMMC
+ bool "Report eMMC size as zero"
+ help
+ The serial number string in the EEPROM is meant to report the
+ size of onboard eMMC. Unfortunately some Milk-V Mars CM Lite
+ modules without eMMC show a non-zero size here.
+
+ Set to 'Y' if you have a Mars CM Lite module.
+
endif
diff --git a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
index 5095a0e9fdb..9648a270494 100644
--- a/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
+++ b/board/starfive/visionfive2/visionfive2-i2c-eeprom.c
@@ -548,6 +548,24 @@ u32 get_ddr_size_from_eeprom(void)
return hextoul(&pbuf.eeprom.atom1.data.pstr[14], NULL);
}
+u32 get_mmc_size_from_eeprom(void)
+{
+ u32 size;
+
+ if (IS_ENABLED(CONFIG_STARFIVE_NO_EMMC))
+ return 0;
+
+ if (read_eeprom())
+ return 0;
+
+ size = dectoul(&pbuf.eeprom.atom1.data.pstr[19], NULL);
+
+ if (pbuf.eeprom.atom1.data.pstr[21] == 'T')
+ size <<= 10;
+
+ return size;
+}
+
U_BOOT_LONGHELP(mac,
"\n"
" - display EEPROM content\n"
--
2.43.0
More information about the U-Boot
mailing list