diff options
Diffstat (limited to 'util/inteltool')
-rw-r--r-- | util/inteltool/gpio.c | 112 | ||||
-rw-r--r-- | util/inteltool/inteltool.c | 16 | ||||
-rw-r--r-- | util/inteltool/inteltool.h | 2 |
3 files changed, 103 insertions, 27 deletions
diff --git a/util/inteltool/gpio.c b/util/inteltool/gpio.c index 8b85593942..e42b9da445 100644 --- a/util/inteltool/gpio.c +++ b/util/inteltool/gpio.c @@ -20,6 +20,8 @@ #include <stdio.h> #include "inteltool.h" +typedef struct { uint16_t addr; uint32_t def; } gpio_default_t; + static const io_register_t ich0_gpio_registers[] = { { 0x00, 4, "GPIO_USE_SEL" }, { 0x04, 4, "GP_IO_SEL" }, @@ -256,14 +258,79 @@ static const io_register_t pch_gpio_registers[] = { { 0x78, 4, "RESERVED" }, { 0x7c, 4, "RESERVED" }, }; +static uint16_t gpiobase; + +static void print_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); + 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; + } +} -int print_gpios(struct pci_dev *sb) +static uint32_t get_diff(const io_register_t *const reg, const uint32_t def) { - int i, size; - uint16_t gpiobase; + uint32_t gpio_diff = 0; + switch (reg->size) { + case 4: + gpio_diff = def ^ inl(gpiobase+reg->addr); + break; + case 2: + gpio_diff = (uint16_t)def ^ inw(gpiobase+reg->addr); + break; + case 1: + gpio_diff = (uint8_t)def ^ inb(gpiobase+reg->addr); + break; + } + return gpio_diff; +} + +static void print_diff(const io_register_t *const reg, + const uint32_t def, const uint32_t diff) +{ + switch (reg->size) { + case 4: + printf("gpiobase+0x%04x: 0x%08x (%s) DEFAULT\n", + reg->addr, def, reg->name); + printf("gpiobase+0x%04x: 0x%08x (%s) DIFF\n", + reg->addr, diff, reg->name); + break; + case 2: + printf("gpiobase+0x%04x: 0x%04x (%s) DEFAULT\n", + reg->addr, def, reg->name); + printf("gpiobase+0x%04x: 0x%04x (%s) DIFF\n", + reg->addr, diff, reg->name); + break; + case 1: + printf("gpiobase+0x%04x: 0x%02x (%s) DEFAULT\n", + reg->addr, def, reg->name); + printf("gpiobase+0x%04x: 0x%02x (%s) DIFF\n", + reg->addr, diff, reg->name); + break; + } +} + +int print_gpios(struct pci_dev *sb, int show_all, int show_diffs) +{ + int i, j, size, defaults_size = 0; const io_register_t *gpio_registers; + const gpio_default_t *gpio_defaults; + uint32_t gpio_diff; - printf("\n============= GPIOS =============\n\n"); + 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: @@ -376,26 +443,25 @@ int print_gpios(struct pci_dev *sb) printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase); + j = 0; for (i = 0; i < size; i++) { - switch (gpio_registers[i].size) { - case 4: - printf("gpiobase+0x%04x: 0x%08x (%s)\n", - gpio_registers[i].addr, - inl(gpiobase+gpio_registers[i].addr), - gpio_registers[i].name); - break; - case 2: - printf("gpiobase+0x%04x: 0x%04x (%s)\n", - gpio_registers[i].addr, - inw(gpiobase+gpio_registers[i].addr), - gpio_registers[i].name); - break; - case 1: - printf("gpiobase+0x%04x: 0x%02x (%s)\n", - gpio_registers[i].addr, - inb(gpiobase+gpio_registers[i].addr), - gpio_registers[i].name); - break; + if (show_all) + print_reg(&gpio_registers[i]); + + if (show_diffs && + (j < defaults_size) && + (gpio_defaults[j].addr == gpio_registers[i].addr)) { + gpio_diff = get_diff(&gpio_registers[i], + gpio_defaults[j].def); + if (gpio_diff) { + if (!show_all) + print_reg(&gpio_registers[i]); + print_diff(&gpio_registers[i], + gpio_defaults[j].def, gpio_diff); + if (!show_all) + printf("\n"); + } + j++; } } diff --git a/util/inteltool/inteltool.c b/util/inteltool/inteltool.c index d56d0580fa..2396eb04a2 100644 --- a/util/inteltool/inteltool.c +++ b/util/inteltool/inteltool.c @@ -197,11 +197,12 @@ void print_version(void) void print_usage(const char *name) { - printf("usage: %s [-vh?grpmedPMa]\n", name); + printf("usage: %s [-vh?gGrpmedPMa]\n", name); printf("\n" " -v | --version: print the version\n" " -h | --help: print this help\n\n" " -g | --gpio: dump soutbridge GPIO registers\n" + " -G | --gpio-diffs: show GPIO differences from defaults\n" " -r | --rcba: dump soutbridge RCBA registers\n" " -p | --pmbase: dump soutbridge Power Management registers\n\n" " -m | --mchbar: dump northbridge Memory Controller registers\n" @@ -227,11 +228,13 @@ int main(int argc, char *argv[]) int dump_gpios = 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; static struct option long_options[] = { {"version", 0, 0, 'v'}, {"help", 0, 0, 'h'}, {"gpios", 0, 0, 'g'}, + {"gpio-diffs", 0, 0, 'G'}, {"mchbar", 0, 0, 'm'}, {"rcba", 0, 0, 'r'}, {"pmbase", 0, 0, 'p'}, @@ -244,7 +247,7 @@ int main(int argc, char *argv[]) {0, 0, 0, 0} }; - while ((opt = getopt_long(argc, argv, "vh?grpmedPMaA", + while ((opt = getopt_long(argc, argv, "vh?gGrpmedPMaA", long_options, &option_index)) != EOF) { switch (opt) { case 'v': @@ -254,6 +257,9 @@ int main(int argc, char *argv[]) case 'g': dump_gpios = 1; break; + case 'G': + show_gpio_diffs = 1; + break; case 'm': dump_mchbar = 1; break; @@ -277,6 +283,7 @@ int main(int argc, char *argv[]) break; case 'a': dump_gpios = 1; + show_gpio_diffs = 1; dump_mchbar = 1; dump_rcba = 1; dump_pmbase = 1; @@ -393,7 +400,10 @@ int main(int argc, char *argv[]) /* Now do the deed */ if (dump_gpios) { - print_gpios(sb); + print_gpios(sb, 1, show_gpio_diffs); + printf("\n\n"); + } else if (show_gpio_diffs) { + print_gpios(sb, 0, show_gpio_diffs); printf("\n\n"); } diff --git a/util/inteltool/inteltool.h b/util/inteltool/inteltool.h index ac23fe143a..5a6dcc8f0d 100644 --- a/util/inteltool/inteltool.h +++ b/util/inteltool/inteltool.h @@ -164,7 +164,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 print_gpios(struct pci_dev *sb, int show_all, int show_diffs); int print_epbar(struct pci_dev *nb); int print_dmibar(struct pci_dev *nb); int print_pciexbar(struct pci_dev *nb); |