mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-19 03:15:00 +00:00
mmc: use an enumerated type to represent PARTITION_CONFIG fields
Modern eMMC v4+ devices have multiple hardware partitions per the JEDEC specification described as: Boot Area Partition 1 Boot Area Partition 2 RPMB Partition General Purpose Partition 1 General Purpose Partition 2 General Purpose Partition 3 General Purpose Partition 4 User Data Area These are referenced by fields in the PARTITION_CONFIG register (Extended CSD Register 179) which is defined as: bit 7: reserved bit 6: BOOT_ACK 0x0: No boot acknowledge sent (default 0x1: Boot acknowledge sent during boot operation Bit bit 5:3: BOOT_PARTITION_ENABLE 0x0: Device not boot enabled (default) 0x1: Boot Area partition 1 enabled for boot 0x2: Boot Area partition 2 enabled for boot 0x3-0x6: Reserved 0x7: User area enabled for boot bit 2:0 PARTITION_ACCESS 0x0: No access to boot partition (default) 0x1: Boot Area partition 1 0x2: Boot Area partition 2 0x3: Replay Protected Memory Block (RPMB) 0x4: Access to General Purpose partition 1 0x5: Access to General Purpose partition 2 0x6: Access to General Purpose partition 3 0x7: Access to General Purpose partition 4 Note that setting PARTITION_ACCESS to 0x0 results in selecting the User Data Area partition. You can see above that the two fields BOOT_PARTITION_ENABLE and PARTITION_ACCESS do not use the same enumerated values. U-Boot uses a set of macros to access fields of the PARTITION_CONFIG register: There are various places in U-Boot where the BOOT_PARTITION_ENABLE field is accessed via EXT_CSD_EXTRACT_PARTITION_ACCESS and converted to a hardware partition consistent with the definition of the PARTITION_ACCESS field which is also the value used to specify the hardware partition of the various mmc_switch incarnations. To add some sanity to the distinction between BOOT_PARTITION_ENABLE (used to specify the active device on power-cycle) and PARTITION_ACCESS (used to switch between hardware partitions) create two enumerated types and use them wherever struct mmc * part_config is used or the above macros are used. This represents no code changes. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
This commit is contained in:
parent
d4781422d1
commit
8746aa0f5d
9 changed files with 47 additions and 27 deletions
|
@ -205,7 +205,7 @@ static unsigned long get_boot_device_offset(void *dev, int dev_type)
|
||||||
} else {
|
} else {
|
||||||
u8 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
u8 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
|
|
||||||
if (part == 1 || part == 2) {
|
if (part == EMMC_BOOT_PART_BOOT1 || part == EMMC_BOOT_PART_BOOT2) {
|
||||||
if (is_imx8qxp() && is_soc_rev(CHIP_REV_B))
|
if (is_imx8qxp() && is_soc_rev(CHIP_REV_B))
|
||||||
offset = CONTAINER_HDR_MMCSD_OFFSET;
|
offset = CONTAINER_HDR_MMCSD_OFFSET;
|
||||||
else
|
else
|
||||||
|
@ -294,15 +294,15 @@ int spl_mmc_emmc_boot_partition(struct mmc *mmc)
|
||||||
int part;
|
int part;
|
||||||
|
|
||||||
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
if (part == 1 || part == 2) {
|
if (part == EMMC_BOOT_PART_BOOT1 || part == EMMC_BOOT_PART_BOOT2) {
|
||||||
unsigned long sec_set_off = 0;
|
unsigned long sec_set_off = 0;
|
||||||
bool sec_boot = false;
|
bool sec_boot = false;
|
||||||
|
|
||||||
sec_boot = check_secondary_cnt_set(&sec_set_off);
|
sec_boot = check_secondary_cnt_set(&sec_set_off);
|
||||||
if (sec_boot)
|
if (sec_boot)
|
||||||
part = (part == 1) ? 2 : 1;
|
part = (part == EMMC_BOOT_PART_BOOT1) ? EMMC_HWPART_BOOT2 : EMMC_HWPART_BOOT1;
|
||||||
} else if (part == 7) {
|
} else if (part == EMMC_BOOT_PART_USER) {
|
||||||
part = 0;
|
part = EMMC_HWPART_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
|
|
|
@ -396,7 +396,7 @@ static bool sunxi_valid_emmc_boot(struct mmc *mmc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Partition 0 is the user data partition, bootpart must be 1 or 2. */
|
/* Partition 0 is the user data partition, bootpart must be 1 or 2. */
|
||||||
if (bootpart != 1 && bootpart != 2)
|
if (bootpart != EMMC_BOOT_PART_BOOT1 && bootpart != EMMC_BOOT_PART_BOOT2)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Failure to switch to the boot partition is fatal. */
|
/* Failure to switch to the boot partition is fatal. */
|
||||||
|
|
|
@ -350,8 +350,8 @@ unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc, unsigned long
|
||||||
{
|
{
|
||||||
if (!IS_SD(mmc)) {
|
if (!IS_SD(mmc)) {
|
||||||
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
||||||
case 1:
|
case EMMC_BOOT_PART_BOOT1:
|
||||||
case 2:
|
case EMMC_BOOT_PART_BOOT2:
|
||||||
if (IS_ENABLED(CONFIG_IMX8MN) || IS_ENABLED(CONFIG_IMX8MP))
|
if (IS_ENABLED(CONFIG_IMX8MN) || IS_ENABLED(CONFIG_IMX8MP))
|
||||||
raw_sect -= 32 * 2;
|
raw_sect -= 32 * 2;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -173,20 +173,20 @@ int board_late_init(void)
|
||||||
int bootpart;
|
int bootpart;
|
||||||
|
|
||||||
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
||||||
case 1: /* boot0 */
|
case EMMC_BOOT_PART_BOOT1:
|
||||||
bootpart = 1;
|
bootpart = EMMC_HWPART_BOOT1;
|
||||||
break;
|
break;
|
||||||
case 2: /* boot1 */
|
case EMMC_BOOT_PART_BOOT2:
|
||||||
bootpart = 2;
|
bootpart = EMMC_HWPART_BOOT2;
|
||||||
break;
|
break;
|
||||||
case 7: /* user */
|
case EMMC_BOOT_PART_USER:
|
||||||
default:
|
default:
|
||||||
bootpart = 0;
|
bootpart = EMMC_HWPART_DEFAULT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* IMX8MP/IMX8MN BOOTROM v2 uses offset=0 for boot parts */
|
/* IMX8MP/IMX8MN BOOTROM v2 uses offset=0 for boot parts */
|
||||||
if ((IS_ENABLED(CONFIG_IMX8MN) || IS_ENABLED(CONFIG_IMX8MP)) &&
|
if ((IS_ENABLED(CONFIG_IMX8MN) || IS_ENABLED(CONFIG_IMX8MP)) &&
|
||||||
(bootpart == 1 || bootpart == 2))
|
(bootpart == EMMC_BOOT_PART_BOOT1 || bootpart == EMMC_BOOT_PART_BOOT2))
|
||||||
bootblk = 0;
|
bootblk = 0;
|
||||||
env_set_hex("bootpart", bootpart);
|
env_set_hex("bootpart", bootpart);
|
||||||
env_set_hex("bootblk", bootblk);
|
env_set_hex("bootblk", bootblk);
|
||||||
|
@ -217,10 +217,10 @@ uint mmc_get_env_part(struct mmc *mmc)
|
||||||
{
|
{
|
||||||
if (!IS_SD(mmc)) {
|
if (!IS_SD(mmc)) {
|
||||||
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
switch (EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config)) {
|
||||||
case 1:
|
case EMMC_BOOT_PART_BOOT1:
|
||||||
return 1;
|
return EMMC_HWPART_BOOT1;
|
||||||
case 2:
|
case EMMC_BOOT_PART_BOOT2:
|
||||||
return 2;
|
return EMMC_HWPART_BOOT2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,8 @@ uint board_mmc_get_env_part(struct mmc *mmc)
|
||||||
{
|
{
|
||||||
uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
|
|
||||||
if (part == 7)
|
if (part == EMMC_BOOT_PART_USER)
|
||||||
part = 0;
|
part = EMMC_HWPART_DEFAULT;
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -106,8 +106,8 @@ uint mmc_get_env_part(struct mmc *mmc)
|
||||||
{
|
{
|
||||||
uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
uint part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
|
|
||||||
if (part == 7)
|
if (part == EMMC_BOOT_PART_USER)
|
||||||
part = 0;
|
part = EMMC_HWPART_DEFAULT;
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,8 +224,8 @@ static int mmc_burn_image(size_t image_size)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
if (part == 7)
|
if (part == EMMC_BOOT_PART_USER)
|
||||||
part = 0;
|
part = EMMC_HWPART_DEFAULT;
|
||||||
|
|
||||||
#ifdef CONFIG_BLK
|
#ifdef CONFIG_BLK
|
||||||
err = blk_dselect_hwpart(blk_desc, part);
|
err = blk_dselect_hwpart(blk_desc, part);
|
||||||
|
|
|
@ -320,8 +320,8 @@ int default_spl_mmc_emmc_boot_partition(struct mmc *mmc)
|
||||||
* which is the first physical partition (0).
|
* which is the first physical partition (0).
|
||||||
*/
|
*/
|
||||||
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config);
|
||||||
if (part == 7)
|
if (part == EMMC_BOOT_PART_USER)
|
||||||
part = 0;
|
part = EMMC_HWPART_DEFAULT;
|
||||||
#endif
|
#endif
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
|
@ -381,6 +381,26 @@ enum mmc_voltage {
|
||||||
#define MMC_TIMING_MMC_HS200 9
|
#define MMC_TIMING_MMC_HS200 9
|
||||||
#define MMC_TIMING_MMC_HS400 10
|
#define MMC_TIMING_MMC_HS400 10
|
||||||
|
|
||||||
|
/* emmc PARTITION_CONFIG BOOT_PARTITION_ENABLE values */
|
||||||
|
enum emmc_boot_part {
|
||||||
|
EMMC_BOOT_PART_DEFAULT = 0,
|
||||||
|
EMMC_BOOT_PART_BOOT1 = 1,
|
||||||
|
EMMC_BOOT_PART_BOOT2 = 2,
|
||||||
|
EMMC_BOOT_PART_USER = 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* emmc PARTITION_CONFIG ACCESS_ENABLE values */
|
||||||
|
enum emmc_hwpart {
|
||||||
|
EMMC_HWPART_DEFAULT = 0, /* user */
|
||||||
|
EMMC_HWPART_BOOT1 = 1,
|
||||||
|
EMMC_HWPART_BOOT2 = 2,
|
||||||
|
EMMC_HWPART_RPMB = 3,
|
||||||
|
EMMC_HWPART_GP1 = 4,
|
||||||
|
EMMC_HWPART_GP2 = 5,
|
||||||
|
EMMC_HWPART_GP3 = 6,
|
||||||
|
EMMC_HWPART_GP4 = 7,
|
||||||
|
};
|
||||||
|
|
||||||
/* Driver model support */
|
/* Driver model support */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue