summaryrefslogtreecommitdiff
path: root/util/ifdtool
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2019-10-17 19:37:45 +0200
committerNico Huber <nico.h@gmx.de>2019-10-19 17:04:42 +0000
commit4cb888e946bf3372373a689af54201b2a0a6871e (patch)
treeef3e29974e585a28f608f573fe5d1c118bcd789a /util/ifdtool
parent42cad6c1b6fcf00fb675849a731911c876c9028b (diff)
downloadcoreboot-4cb888e946bf3372373a689af54201b2a0a6871e.tar.xz
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>
Diffstat (limited to 'util/ifdtool')
-rw-r--r--util/ifdtool/ifdtool.c66
1 files changed, 34 insertions, 32 deletions
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 24e20e19ab..0e8f76d76b 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -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);
}
@@ -1403,30 +1405,30 @@ static void print_usage(const char *name)
{
printf("usage: %s [-vhdix?] <filename>\n", name);
printf("\n"
- " -d | --dump: dump intel firmware descriptor\n"
- " -f | --layout <filename> dump regions into a flashrom layout file\n"
- " -t | --validate Validate that the firmware descriptor layout matches the fmap layout\n"
- " -x | --extract: extract intel fd modules\n"
- " -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"
- " -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"
- " -e | --em100 set SPI frequency to 20MHz and disable\n"
- " Dual Output Fast Read Support\n"
- " -l | --lock Lock firmware descriptor and ME region\n"
- " -u | --unlock Unlock firmware descriptor and ME region\n"
- " -M | --altmedisable <0|1> Set the AltMeDisable (or HAP for skylake or newer platform)\n"
- " bit to disable ME\n"
- " -p | --platform Add platform-specific quirks\n"
- " aplk - Apollo Lake\n"
- " cnl - Cannon Lake\n"
- " glk - Gemini Lake\n"
- " sklkbl - Skylake/Kaby Lake\n"
- " -v | --version: print the version\n"
- " -h | --help: print this help\n\n"
+ " -d | --dump: dump intel firmware descriptor\n"
+ " -f | --layout <filename> dump regions into a flashrom layout file\n"
+ " -t | --validate Validate that the firmware descriptor layout matches the fmap layout\n"
+ " -x | --extract: extract intel fd modules\n"
+ " -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|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"
+ " -e | --em100 set SPI frequency to 20MHz and disable\n"
+ " Dual Output Fast Read Support\n"
+ " -l | --lock Lock firmware descriptor and ME region\n"
+ " -u | --unlock Unlock firmware descriptor and ME region\n"
+ " -M | --altmedisable <0|1> Set the AltMeDisable (or HAP for skylake or newer platform)\n"
+ " bit to disable ME\n"
+ " -p | --platform Add platform-specific quirks\n"
+ " aplk - Apollo Lake\n"
+ " cnl - Cannon Lake\n"
+ " glk - Gemini Lake\n"
+ " sklkbl - Skylake/Kaby Lake\n"
+ " -v | --version: print the version\n"
+ " -h | --help: print this help\n\n"
"<region> is one of Descriptor, BIOS, ME, GbE, Platform\n"
"\n");
}