Edward O'Callaghan (eocallaghan@alterapraxis.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6763
-gerrit
commit 636e1111de642e528ba2b3caebca1fdb153e9f9d Author: Edward O'Callaghan eocallaghan@alterapraxis.com Date: Tue Aug 26 04:36:26 2014 +1000
util/inteltool: Allow GPIO dumps to be in binary map format
Essentially we wish to have the machine parse the GPIO dump in other tools (sic intelgpio) and generate source based off the dumped map.
Change-Id: I06a2777e6ea3a90bf509c323496b5980d06071ad Signed-off-by: Edward O'Callaghan eocallaghan@alterapraxis.com --- util/inteltool/gpio.c | 54 +++++++++++++++++++++++++++++++++------------- util/inteltool/inteltool.c | 33 ++++++++++++++++++---------- util/inteltool/inteltool.h | 2 +- 3 files changed, 62 insertions(+), 27 deletions(-)
diff --git a/util/inteltool/gpio.c b/util/inteltool/gpio.c index 49c1325..abbccf0 100644 --- a/util/inteltool/gpio.c +++ b/util/inteltool/gpio.c @@ -333,24 +333,45 @@ static const gpio_default_t pp_pch_mobile_defaults[] = {
static uint16_t gpiobase;
-static void print_reg(const io_register_t *const reg) +static void dump_reg(const io_register_t *const reg) { switch (reg->size) { case 4: - printf("gpiobase+0x%04x: 0x%08x (%s)\n", - reg->addr, inl(gpiobase+reg->addr), reg->name); + printf("0x%04x: 0x%08x\n", + reg->addr, inl(gpiobase+reg->addr)); break; case 2: - printf("gpiobase+0x%04x: 0x%04x (%s)\n", - reg->addr, inw(gpiobase+reg->addr), reg->name); + printf("0x%04x: 0x%04x\n", + reg->addr, inw(gpiobase+reg->addr)); break; case 1: - printf("gpiobase+0x%04x: 0x%02x (%s)\n", - reg->addr, inb(gpiobase+reg->addr), reg->name); + printf("0x%04x: 0x%02x\n", + reg->addr, inb(gpiobase+reg->addr)); break; } }
+static void print_reg(const io_register_t *const reg, int dump) +{ + if (dump) + dump_reg(reg); + else + switch (reg->size) { + case 4: + printf("gpiobase+0x%04x: 0x%08x (%s)\n", + reg->addr, inl(gpiobase+reg->addr), reg->name); + break; + case 2: + printf("gpiobase+0x%04x: 0x%04x (%s)\n", + reg->addr, inw(gpiobase+reg->addr), reg->name); + break; + case 1: + printf("gpiobase+0x%04x: 0x%02x (%s)\n", + reg->addr, inb(gpiobase+reg->addr), reg->name); + break; + } +} + static uint32_t get_diff(const io_register_t *const reg, const uint32_t def) { uint32_t gpio_diff = 0; @@ -393,17 +414,19 @@ static void print_diff(const io_register_t *const reg, } }
-int print_gpios(struct pci_dev *sb, int show_all, int show_diffs) +int print_gpios(struct pci_dev *sb, int show_all, int show_diffs, int bin_dump) { int i, j, size, defaults_size = 0; const io_register_t *gpio_registers; const gpio_default_t *gpio_defaults = NULL; uint32_t gpio_diff;
- if (show_diffs && !show_all) - printf("\n========== GPIO DIFFS ===========\n\n"); - else - printf("\n============= GPIOS =============\n\n"); + if (!bin_dump) { + if (show_diffs && !show_all) + printf("\n========== GPIO DIFFS ===========\n\n"); + else + printf("\n============= GPIOS =============\n\n"); + }
switch (sb->device_id) { case PCI_DEVICE_ID_INTEL_Z68: @@ -556,12 +579,13 @@ int print_gpios(struct pci_dev *sb, int show_all, int show_diffs) return 1; }
- printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase); + if (!bin_dump) + printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
j = 0; for (i = 0; i < size; i++) { if (show_all) - print_reg(&gpio_registers[i]); + print_reg(&gpio_registers[i], bin_dump);
if (show_diffs && (j < defaults_size) && @@ -570,7 +594,7 @@ int print_gpios(struct pci_dev *sb, int show_all, int show_diffs) gpio_defaults[j].def); if (gpio_diff) { if (!show_all) - print_reg(&gpio_registers[i]); + print_reg(&gpio_registers[i], bin_dump); print_diff(&gpio_registers[i], gpio_defaults[j].def, gpio_diff); if (!show_all) diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c index c6e2a67..4745a68 100644 --- a/util/inteltool/inteltool.c +++ b/util/inteltool/inteltool.c @@ -203,6 +203,7 @@ void print_usage(const char *name) printf("\n" " -v | --version: print the version\n" " -h | --help: print this help\n\n" + " -b | --gpios-bin: dump soutbridge GPIO registers in binary format\n" " -g | --gpio: dump soutbridge GPIO registers\n" " -G | --gpio-diffs: show GPIO differences from defaults\n" " -r | --rcba: dump soutbridge RCBA registers\n" @@ -227,7 +228,7 @@ int main(int argc, char *argv[])
char *sbname = "unknown", *nbname = "unknown";
- int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0; + int dump_gpios = 0, dump_gpios_bin = 0, dump_mchbar = 0, dump_rcba = 0; int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0; int dump_pciexbar = 0, dump_coremsrs = 0, dump_ambs = 0; int show_gpio_diffs = 0; @@ -235,6 +236,7 @@ int main(int argc, char *argv[]) static struct option long_options[] = { {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, + {"gpios-bin", 0, 0, 'b'}, {"gpios", 0, 0, 'g'}, {"gpio-diffs", 0, 0, 'G'}, {"mchbar", 0, 0, 'm'}, @@ -249,13 +251,16 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} };
- while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaA", + while ((opt = getopt_long(argc, argv, "vh?bgGrpmedPMaA", long_options, &option_index)) != EOF) { switch (opt) { case 'v': print_version(); exit(0); break; + case 'b': + dump_gpios_bin = 1; + break; case 'g': dump_gpios = 1; break; @@ -377,9 +382,11 @@ int main(int argc, char *argv[]) * left-shifted "Extended Model" fields. * http://download.intel.com/design/processor/applnots/24161832.pdf */ - printf("CPU: ID 0x%x, Processor Type 0x%x, Family 0x%x, Model 0x%x, Stepping 0x%x\n", - id, (id >> 12) & 0x3, ((id >> 8) & 0xf) + ((id >> 20) & 0xff), - ((id >> 12) & 0xf0) + ((id >> 4) & 0xf), (id & 0xf)); + if (!dump_gpios_bin) { + printf("CPU: ID 0x%x, Processor Type 0x%x, Family 0x%x, Model 0x%x, Stepping 0x%x\n", + id, (id >> 12) & 0x3, ((id >> 8) & 0xf) + ((id >> 20) & 0xff), + ((id >> 12) & 0xf0) + ((id >> 4) & 0xf), (id & 0xf)); + }
/* Determine names */ for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++) @@ -389,19 +396,23 @@ int main(int argc, char *argv[]) if (sb->device_id == supported_chips_list[i].device_id) sbname = supported_chips_list[i].name;
- printf("Northbridge: %04x:%04x (%s)\n", - nb->vendor_id, nb->device_id, nbname); + if (!dump_gpios_bin) { + printf("Northbridge: %04x:%04x (%s)\n", + nb->vendor_id, nb->device_id, nbname);
- printf("Southbridge: %04x:%04x (%s)\n", - sb->vendor_id, sb->device_id, sbname); + printf("Southbridge: %04x:%04x (%s)\n", + sb->vendor_id, sb->device_id, sbname); + }
/* Now do the deed */
if (dump_gpios) { - print_gpios(sb, 1, show_gpio_diffs); + print_gpios(sb, 1, show_gpio_diffs, 0); printf("\n\n"); + } else if (dump_gpios_bin) { + print_gpios(sb, 1, show_gpio_diffs, 1); } else if (show_gpio_diffs) { - print_gpios(sb, 0, show_gpio_diffs); + print_gpios(sb, 0, show_gpio_diffs, 0); printf("\n\n"); }
diff --git a/util/inteltool/inteltool.h b/util/inteltool/inteltool.h index a06c70d..4edbff2 100644 --- a/util/inteltool/inteltool.h +++ b/util/inteltool/inteltool.h @@ -185,7 +185,7 @@ int print_intel_core_msrs(void); int print_mchbar(struct pci_dev *nb, struct pci_access *pacc); int print_pmbase(struct pci_dev *sb, struct pci_access *pacc); int print_rcba(struct pci_dev *sb); -int print_gpios(struct pci_dev *sb, int show_all, int show_diffs); +int print_gpios(struct pci_dev *sb, int show_all, int show_diffs, int bin_dump); int print_epbar(struct pci_dev *nb); int print_dmibar(struct pci_dev *nb); int print_pciexbar(struct pci_dev *nb);