[coreboot-gerrit] Patch set updated for coreboot: util/ifdtool: add option to change chip density
Jan Tatje
gerrit at coreboot.org
Fri Mar 11 16:45:31 CET 2016
Jan Tatje just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14032
-gerrit
commit 683bd27adb57d6e409b1f883756ab64eab6a75bb
Author: Jan Tatje <jan at jnt.io>
Date: Fri Mar 11 00:52:07 2016 +0100
util/ifdtool: add option to change chip density
Adds -D / --density option to change the chip density. This is only
implemented for IFD version 1 as I do not have an IFD version 2 to
test this. Density of both chips is changed, but second value is
ignored, if there is no second chip present.
Change-Id: Iba7affbf6cbefa3147b7b0e019298d905e694716
Signed-off-by: Jan Tatje <jan at jnt.io>
---
util/ifdtool/ifdtool.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 78 insertions(+), 3 deletions(-)
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 8a12725..7fabe61 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -748,6 +748,66 @@ static void set_em100_mode(char *filename, char *image, int size)
set_spi_frequency(filename, image, size, freq);
}
+static void set_chipdensity(char *filename, char *image, int size, int new_density)
+{
+ fdbar_t *fdb = find_fd(image, size);
+ fcba_t *fcba = (fcba_t *) (image + (((fdb->flmap0) & 0xff) << 4));
+ uint32_t density = 0;
+
+ switch (ifd_version) {
+ case IFD_VERSION_1:
+ 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);
+ default:
+ printf("error: Unknown IFD version\n");
+ exit(EXIT_FAILURE);
+ break;
+ }
+
+ printf("setting chip density to ");
+ switch (new_density) {
+ case 512:
+ density = COMPONENT_DENSITY_512KB;
+ printf("512KB\n");
+ break;
+ case 1:
+ density = COMPONENT_DENSITY_1MB;
+ printf("1MB\n");
+ break;
+ case 2:
+ density = COMPONENT_DENSITY_2MB;
+ printf("2MB\n");
+ break;
+ case 4:
+ density = COMPONENT_DENSITY_4MB;
+ printf("4MB\n");
+ break;
+ case 8:
+ density = COMPONENT_DENSITY_8MB;
+ printf("8MB\n");
+ break;
+ case 16:
+ density = COMPONENT_DENSITY_16MB;
+ printf("16MB\n");
+ break;
+ default:
+ printf("unknown density: error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* clear lower 6 bit which are chip density */
+ fcba->flcomp &= ~(0x3F);
+ /* set the new density */
+ fcba->flcomp |= (density); /* first chip */
+ fcba->flcomp |= (density << 3); /* second chip */
+
+ write_image(filename, image, size);
+}
+
static void lock_descriptor(char *filename, char *image, int size)
{
int wr_shift, rd_shift;
@@ -1075,6 +1135,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"
" -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"
@@ -1090,9 +1151,10 @@ int main(int argc, char *argv[])
int opt, option_index = 0;
int mode_dump = 0, mode_extract = 0, mode_inject = 0, mode_spifreq = 0;
int mode_em100 = 0, mode_locked = 0, mode_unlocked = 0;
- int mode_layout = 0, mode_newlayout = 0;
+ int mode_layout = 0, mode_newlayout = 0, mode_density = 0;
char *region_type_string = NULL, *region_fname = NULL, *layout_fname = NULL;
int region_type = -1, inputfreq = 0;
+ int new_density= 0;
enum spi_frequency spifreq = SPI_FREQUENCY_20MHZ;
static struct option long_options[] = {
@@ -1102,6 +1164,7 @@ int main(int argc, char *argv[])
{"inject", 1, NULL, 'i'},
{"newlayout", 1, NULL, 'n'},
{"spifreq", 1, NULL, 's'},
+ {"density", 1, NULL, 'D'},
{"em100", 0, NULL, 'e'},
{"lock", 0, NULL, 'l'},
{"unlock", 0, NULL, 'u'},
@@ -1110,7 +1173,7 @@ int main(int argc, char *argv[])
{0, 0, 0, 0}
};
- while ((opt = getopt_long(argc, argv, "df:xi:n:s:eluvh?",
+ while ((opt = getopt_long(argc, argv, "df:D:xi:n:s:eluvh?",
long_options, &option_index)) != EOF) {
switch (opt) {
case 'd':
@@ -1169,6 +1232,15 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
break;
+ case 'D':
+ mode_density = 1;
+ new_density = strtol(optarg, NULL, 0);
+ if (!new_density) {
+ fprintf(stderr, "No chip density specified\n");
+ print_usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+ break;
case 's':
// Parse the requested SPI frequency
inputfreq = strtol(optarg, NULL, 0);
@@ -1239,7 +1311,7 @@ int main(int argc, char *argv[])
if ((mode_dump + mode_layout + mode_extract + mode_inject +
mode_newlayout + mode_spifreq + mode_em100 + mode_locked +
- mode_unlocked) == 0) {
+ mode_unlocked + mode_density) == 0) {
fprintf(stderr, "You need to specify a mode.\n\n");
print_usage(argv[0]);
exit(EXIT_FAILURE);
@@ -1300,6 +1372,9 @@ int main(int argc, char *argv[])
if (mode_spifreq)
set_spi_frequency(filename, image, size, spifreq);
+ if (mode_density)
+ set_chipdensity(filename, image, size, new_density);
+
if (mode_em100)
set_em100_mode(filename, image, size);
More information about the coreboot-gerrit
mailing list