Skip to content

Commit

Permalink
board: starfive: function to read eMMC size
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: E. Shattow <[email protected]>
  • Loading branch information
xypron authored and Leo Yu-Chi Liang committed May 14, 2024
1 parent 9578e74 commit 156c99f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions arch/riscv/include/asm/arch-jh7110/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
9 changes: 9 additions & 0 deletions board/starfive/visionfive2/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 18 additions & 0 deletions board/starfive/visionfive2/visionfive2-i2c-eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 156c99f

Please sign in to comment.