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:
parent
42cad6c1b6
commit
4cb888e946
|
@ -921,6 +921,7 @@ static void set_chipdensity(const char *filename, char *image, int size,
|
||||||
unsigned int density)
|
unsigned int density)
|
||||||
{
|
{
|
||||||
fcba_t *fcba = find_fcba(image, size);
|
fcba_t *fcba = find_fcba(image, size);
|
||||||
|
uint8_t mask, chip2_offset;
|
||||||
if (!fcba)
|
if (!fcba)
|
||||||
exit(EXIT_FAILURE);
|
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");
|
printf("error: Selected density not supported in IFD version 1.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
mask = 0x7;
|
||||||
|
chip2_offset = 3;
|
||||||
break;
|
break;
|
||||||
case IFD_VERSION_2:
|
case IFD_VERSION_2:
|
||||||
/* I do not have a version 2 IFD nor do i have the docs. */
|
mask = 0xf;
|
||||||
printf("error: Changing the chip density for IFD version 2 has not been"
|
chip2_offset = 4;
|
||||||
" implemented yet.\n");
|
break;
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
default:
|
default:
|
||||||
printf("error: Unknown IFD version\n");
|
printf("error: Unknown IFD version\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -952,13 +954,13 @@ static void set_chipdensity(const char *filename, char *image, int size,
|
||||||
/* clear chip density for corresponding chip */
|
/* clear chip density for corresponding chip */
|
||||||
switch (selected_chip) {
|
switch (selected_chip) {
|
||||||
case 1:
|
case 1:
|
||||||
fcba->flcomp &= ~(0x7);
|
fcba->flcomp &= ~mask;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fcba->flcomp &= ~(0x7 << 3);
|
fcba->flcomp &= ~(mask << chip2_offset);
|
||||||
break;
|
break;
|
||||||
default: /*both chips*/
|
default: /*both chips*/
|
||||||
fcba->flcomp &= ~(0x3F);
|
fcba->flcomp &= ~(mask | (mask << chip2_offset));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +968,7 @@ static void set_chipdensity(const char *filename, char *image, int size,
|
||||||
if (selected_chip == 1 || selected_chip == 0)
|
if (selected_chip == 1 || selected_chip == 0)
|
||||||
fcba->flcomp |= (density); /* first chip */
|
fcba->flcomp |= (density); /* first chip */
|
||||||
if (selected_chip == 2 || selected_chip == 0)
|
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);
|
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"
|
" -i | --inject <region>:<module> inject file <module> into region <region>\n"
|
||||||
" -n | --newlayout <filename> update regions using a flashrom layout file\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"
|
" -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"
|
" -C | --chip <0|1|2> select spi chip on which to operate\n"
|
||||||
" can only be used once per run:\n"
|
" can only be used once per run:\n"
|
||||||
" 0 - both chips (default), 1 - first chip, 2 - second chip\n"
|
" 0 - both chips (default), 1 - first chip, 2 - second chip\n"
|
||||||
|
|
Loading…
Reference in New Issue