[coreboot-gerrit] New patch to review for coreboot: ifdtool: add option to change chip density.
Jan Tatje
gerrit at coreboot.org
Fri Mar 11 00:53:39 CET 2016
Jan Tatje just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/14032
-gerrit
commit 7e8dac9a1fd80f81ff0ba5f30f24c0634bead115
Author: Jan Tatje <jan at jnt.io>
Date: Fri Mar 11 00:52:07 2016 +0100
ifdtool: add option to change chip density.
Change-Id: Iba7affbf6cbefa3147b7b0e019298d905e694716
---
util/ifdtool/ifdtool.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 83 insertions(+), 3 deletions(-)
diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c
index 8a12725..6e2e46a 100644
--- a/util/ifdtool/ifdtool.c
+++ b/util/ifdtool/ifdtool.c
@@ -748,6 +748,71 @@ 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("IFD version 2 not supported for density change\n");
+ exit(EXIT_FAILURE);
+ default:
+ 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;
+ case 32:
+ density = COMPONENT_DENSITY_32MB;
+ printf("32MB\n");
+ break;
+ case 64:
+ density = COMPONENT_DENSITY_64MB;
+ printf("64MB\n");
+ break;
+ default:
+ printf("unknown density: error\n");
+ exit(EXIT_FAILURE);
+ }
+
+ /* clear lower 6 bit which are chip density */
+ fcba->flcomp &= ~(63);
+ /* 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 +1140,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\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 +1156,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 +1169,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 +1178,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 +1237,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 +1316,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 +1377,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