From eda887e2ccb155a6daf7d2bc4693fa7e52f6a835 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Thu, 1 Aug 2019 14:02:18 -0700 Subject: g: refactor pinmux state printing function This refactoring improves optional parameter alignment, includes virtual pads in the output and shaves 44 bytes from the image size. BRANCH=cr50, cr50-mp BUG=none TEST=saved pinmux command output in files pm.before and pm.after, then verified that the following command produced no output $ diff -w <(sort pm.before) <(sort pm.after) Change-Id: I81c2fad8c9e87e05dd39c588340a82f83e3ab488 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731138 Reviewed-by: Mary Ruthven (cherry picked from commit 77be418d68b6569133d45b040792e6aa34e20c82) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3229787 Reviewed-by: Andrey Pronin Tested-by: Mary Ruthven Commit-Queue: Mary Ruthven (cherry picked from commit 1772606c7bc44521b2ecee8c673187fb8d3a369e) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3260167 --- chip/g/gpio.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/chip/g/gpio.c b/chip/g/gpio.c index 4b3c4ce553..3b8a402726 100644 --- a/chip/g/gpio.c +++ b/chip/g/gpio.c @@ -478,7 +478,7 @@ static void print_periph(int sel) ccprintf("UNDEF"); } -static void show_pinmux(const char *name, int i, int ofs) +static void show_pinmux(const char name, int i, int ofs) { uint32_t sel = DIO_SEL_REG(i * 8 + ofs); uint32_t ctl = DIO_CTL_REG(i * 8 + ofs); @@ -489,7 +489,7 @@ static void show_pinmux(const char *name, int i, int ofs) if (!sel && !(ctl & (0xf << 2)) && !(GREG32(PINMUX, EXITEN0) & bitmask)) return; - ccprintf("%08x: %s%-2d %2d %s%s%s%s ", + ccprintf("%08x: DIO%c%-2d %2d %3s%3s%3s%4s ", GC_PINMUX_BASE_ADDR + i * 8 + ofs, name, i, sel, (ctl & (1<<2)) ? " IN" : "", @@ -542,15 +542,25 @@ static void show_pinmux_periph(int i) static int command_pinmux(int argc, char **argv) { - int i; + size_t i; + + const struct { + char name; + uint8_t count; + uint8_t base_offset; + } pads[] = { + {'M', 5, 0}, + {'A', 15, 0x28}, + {'B', 8, 0xa0}, + {'V', 2, 0xe8}, + }; - /* Pad sources */ - for (i = 0; i <= 4; i++) - show_pinmux("DIOM", i, 0x00); - for (i = 0; i <= 14; i++) - show_pinmux("DIOA", i, 0x28); - for (i = 0; i <= 7; i++) - show_pinmux("DIOB", i, 0xa0); + for (i = 0; i < ARRAY_SIZE(pads); i++) { + uint8_t j; + + for (j = 0; j < pads[i].count; j++) + show_pinmux(pads[i].name, j, pads[i].base_offset); + } ccprintf("\n"); -- cgit v1.2.1