feat(mmc): get boot partition size

The boot partition size of an eMMC is given in ext_csd register, at
offset 226 (BOOT_SIZE_MULT), which has to be multiplied by 128kB.
Add a helper function mmc_boot_part_size() to get this eMMC boot
partition size.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I0e8e0fc9632f147fa1b1b3374accb78439025403
This commit is contained in:
Yann Gautier 2022-09-01 19:23:39 +02:00
parent 810bb3d0f4
commit f462c1249a
2 changed files with 7 additions and 0 deletions

View file

@ -805,6 +805,11 @@ int mmc_part_switch_user(void)
return ret; return ret;
} }
size_t mmc_boot_part_size(void)
{
return mmc_ext_csd[CMD_EXTCSD_BOOT_SIZE_MULT] * SZ_128K;
}
size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size) size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size)
{ {
size_t size_read; size_t size_read;

View file

@ -62,6 +62,7 @@
#define CMD_EXTCSD_HS_TIMING 185 #define CMD_EXTCSD_HS_TIMING 185
#define CMD_EXTCSD_PART_SWITCH_TIME 199 #define CMD_EXTCSD_PART_SWITCH_TIME 199
#define CMD_EXTCSD_SEC_CNT 212 #define CMD_EXTCSD_SEC_CNT 212
#define CMD_EXTCSD_BOOT_SIZE_MULT 226
#define EXT_CSD_PART_CONFIG_ACC_MASK GENMASK(2, 0) #define EXT_CSD_PART_CONFIG_ACC_MASK GENMASK(2, 0)
#define PART_CFG_BOOT_PARTITION1_ENABLE (U(1) << 3) #define PART_CFG_BOOT_PARTITION1_ENABLE (U(1) << 3)
@ -262,6 +263,7 @@ size_t mmc_write_blocks(int lba, const uintptr_t buf, size_t size);
size_t mmc_erase_blocks(int lba, size_t size); size_t mmc_erase_blocks(int lba, size_t size);
int mmc_part_switch_current_boot(void); int mmc_part_switch_current_boot(void);
int mmc_part_switch_user(void); int mmc_part_switch_user(void);
size_t mmc_boot_part_size(void);
size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size); size_t mmc_boot_part_read_blocks(int lba, uintptr_t buf, size_t size);
int mmc_init(const struct mmc_ops *ops_ptr, unsigned int clk, int mmc_init(const struct mmc_ops *ops_ptr, unsigned int clk,
unsigned int width, unsigned int flags, unsigned int width, unsigned int flags,