]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: starfive: function to read eMMC size
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 12 May 2024 04:25:22 +0000 (06:25 +0200)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Tue, 14 May 2024 10:40:09 +0000 (18:40 +0800)
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@canonical.com>
Reviewed-by: E. Shattow <lucent@gmail.com>
arch/riscv/include/asm/arch-jh7110/eeprom.h
board/starfive/visionfive2/Kconfig
board/starfive/visionfive2/visionfive2-i2c-eeprom.c

index 62d184aeb5719e91b1a6e39f223b3fffa56575a3..45ad2a5f7bc64be91c3784a6570f5848c5c843f4 100644 (file)
 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
  *
index 2186a939646d0c380015ed6cb3fbf0602ede7b58..d7e8a7a7d78649a4876dcd496bed66bee317e1e0 100644 (file)
@@ -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
index 5095a0e9fdb0fa770779f517eed2c45da8b6741d..9648a2704942d54c41ba4379dc5ddebd59a254f3 100644 (file)
@@ -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"