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 e4351accc183bc36dbba47b7e6535d4175bbcd26 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
NOTFORMERGE: needs a little more work..
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 | 59 ++++++++++++++++++++++++++++++++++------------ util/inteltool/inteltool.c | 16 +++++++++---- util/inteltool/inteltool.h | 2 +- 3 files changed, 57 insertions(+), 20 deletions(-)
diff --git a/util/inteltool/gpio.c b/util/inteltool/gpio.c index 49c1325..c96f1d0 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,15 @@ 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("\n<--------- GPIOBASE = 0x%04x --------->\n\n", gpiobase); + else + 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 +596,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) @@ -580,5 +606,8 @@ int print_gpios(struct pci_dev *sb, int show_all, int show_diffs) } }
+ if (bin_dump) + printf("\n<------------------------------------->\n"); + return 0; } diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c index c6e2a67..ad7ed7f 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; @@ -398,10 +403,13 @@ int main(int argc, char *argv[]) /* 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); printf("\n\n"); } 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);