util/ifdtool: Add support for setting flash density on IFD V2

Change-Id: Ibc3e4c197f99f99007cb208cf6cc4ae6f56be70c
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36101
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Arthur Heymans 2019-10-17 19:37:45 +02:00 committed by Nico Huber
parent 42cad6c1b6
commit 4cb888e946
1 changed files with 34 additions and 32 deletions

View File

@ -921,6 +921,7 @@ static void set_chipdensity(const char *filename, char *image, int size,
unsigned int density)
{
fcba_t *fcba = find_fcba(image, size);
uint8_t mask, chip2_offset;
if (!fcba)
exit(EXIT_FAILURE);
@ -937,12 +938,13 @@ static void set_chipdensity(const char *filename, char *image, int size,
printf("error: Selected density not supported in IFD version 1.\n");
exit(EXIT_FAILURE);
}
mask = 0x7;
chip2_offset = 3;
break;
case IFD_VERSION_2:
/* I do not have a version 2 IFD nor do i have the docs. */
printf("error: Changing the chip density for IFD version 2 has not been"
" implemented yet.\n");
exit(EXIT_FAILURE);
mask = 0xf;
chip2_offset = 4;
break;
default:
printf("error: Unknown IFD version\n");
exit(EXIT_FAILURE);
@ -952,13 +954,13 @@ static void set_chipdensity(const char *filename, char *image, int size,
/* clear chip density for corresponding chip */
switch (selected_chip) {
case 1:
fcba->flcomp &= ~(0x7);
fcba->flcomp &= ~mask;
break;
case 2:
fcba->flcomp &= ~(0x7 << 3);
fcba->flcomp &= ~(mask << chip2_offset);
break;
default: /*both chips*/
fcba->flcomp &= ~(0x3F);
fcba->flcomp &= ~(mask | (mask << chip2_offset));
break;
}
@ -966,7 +968,7 @@ static void set_chipdensity(const char *filename, char *image, int size,
if (selected_chip == 1 || selected_chip == 0)
fcba->flcomp |= (density); /* first chip */
if (selected_chip == 2 || selected_chip == 0)
fcba->flcomp |= (density << 3); /* second chip */
fcba->flcomp |= (density << chip2_offset); /* second chip */
write_image(filename, image, size);
}
@ -1410,7 +1412,7 @@ static void print_usage(const char *name)
" -i | --inject <region>:<module> inject file <module> into region <region>\n"
" -n | --newlayout <filename> update regions using a flashrom layout file\n"
" -s | --spifreq <17|20|30|33|48|50> set the SPI frequency\n"
" -D | --density <512|1|2|4|8|16> set chip density (512 in KByte, others in MByte)\n"
" -D | --density <512|1|2|4|8|16|32|64> set chip density (512 in KByte, others in MByte)\n"
" -C | --chip <0|1|2> select spi chip on which to operate\n"
" can only be used once per run:\n"
" 0 - both chips (default), 1 - first chip, 2 - second chip\n"