mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-03 21:49:32 +00:00
g: expand pinmux to print info on spi and i2c
pinmux only prints uart and gpio information. This change makes pinmux print i2c and spi connections too. This does not handle the direct pin to peripheral mappings, so the spi0 and sps0 peripheral pins still won't show up. BUG=none BRANCH=cr50 TEST=run pinmux on reef Change-Id: Iaa6204e2af7f018569b92280bd1367aef201cc28 Signed-off-by: Mary Ruthven <mruthven@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/501172 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
This commit is contained in:
@@ -357,12 +357,43 @@ void _gpio1_interrupt(void)
|
||||
DECLARE_IRQ(GC_IRQNUM_GPIO0_GPIOCOMBINT, _gpio0_interrupt, 1);
|
||||
DECLARE_IRQ(GC_IRQNUM_GPIO1_GPIOCOMBINT, _gpio1_interrupt, 1);
|
||||
|
||||
/*
|
||||
* The uart, i2c, and spi suffix arrays must match the order of the pinmux
|
||||
* select registers in chip/g/hw_regdefs.h. If the order is incorrect, the
|
||||
* pinmux command output will be wrong.
|
||||
*/
|
||||
static const char * const uart_str[] = {
|
||||
"0_CTS", "0_RTS", "0_RX", "0_TX",
|
||||
"1_CTS", "1_RTS", "1_RX", "1_TX",
|
||||
"2_CTS", "2_RTS", "2_RX", "2_TX",
|
||||
};
|
||||
|
||||
static const char * const i2c_str[] = {
|
||||
"0_SCL", "0_SDA",
|
||||
"1_SCL", "1_SDA",
|
||||
"S0_SCL", "S0_SDA",
|
||||
};
|
||||
|
||||
static const char * const spi_str[] = {
|
||||
"SPICLK", "SPICSB", "SPIMISO", "SPIMOSI",
|
||||
};
|
||||
|
||||
static void print_periph(int sel)
|
||||
{
|
||||
if (sel >= 1 && sel <= 16)
|
||||
ccprintf("GPIO0_GPIO%d", sel - 1);
|
||||
else if (sel >= 17 && sel <= 32)
|
||||
ccprintf("GPIO1_GPIO%d", sel - 17);
|
||||
else if (sel >= 33 && sel <= 38)
|
||||
ccprintf("I2C%s", i2c_str[sel - 33]);
|
||||
else if (sel >= 49 && sel <= 52)
|
||||
ccprintf("SPI1_%s", spi_str[sel - 49]);
|
||||
else if (sel >= 67 && sel <= 78)
|
||||
ccprintf("UART%s", uart_str[sel - 67]);
|
||||
else if (sel)
|
||||
ccprintf("UNDEF");
|
||||
}
|
||||
|
||||
static void show_pinmux(const char *name, int i, int ofs)
|
||||
{
|
||||
uint32_t sel = DIO_SEL_REG(i * 8 + ofs);
|
||||
@@ -374,7 +405,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: %s%-2d %2d %s%s%s%s ",
|
||||
GC_PINMUX_BASE_ADDR + i * 8 + ofs,
|
||||
name, i, sel,
|
||||
(ctl & (1<<2)) ? " IN" : "",
|
||||
@@ -382,12 +413,7 @@ static void show_pinmux(const char *name, int i, int ofs)
|
||||
(ctl & (1<<4)) ? " PU" : "",
|
||||
(ctl & (1<<5)) ? " INV" : "");
|
||||
|
||||
if (sel >= 1 && sel <= 16)
|
||||
ccprintf(" GPIO0_GPIO%d", sel - 1);
|
||||
else if (sel >= 17 && sel <= 32)
|
||||
ccprintf(" GPIO1_GPIO%d", sel - 17);
|
||||
else if (sel >= 67 && sel <= 78)
|
||||
ccprintf(" UART%s", uart_str[sel - 67]);
|
||||
print_periph(sel);
|
||||
|
||||
if (GREG32(PINMUX, EXITEN0) & bitmask) {
|
||||
ccprintf(" WAKE_");
|
||||
@@ -415,32 +441,18 @@ static void print_dio_str(uint32_t sel)
|
||||
cflush();
|
||||
}
|
||||
|
||||
static void show_pinmux_gpio(const char *name, int i, int ofs)
|
||||
static void show_pinmux_periph(int i)
|
||||
{
|
||||
uint32_t sel = DIO_SEL_REG(i * 4 + ofs);
|
||||
|
||||
if (sel == 0)
|
||||
return;
|
||||
|
||||
ccprintf("%08x: %s%-2d %2d",
|
||||
GC_PINMUX_BASE_ADDR + i * 4 + ofs,
|
||||
name, i, sel);
|
||||
print_dio_str(sel);
|
||||
}
|
||||
|
||||
static void show_pinmux_uart(int i)
|
||||
{
|
||||
|
||||
uint32_t ofs = GC_PINMUX_UART0_CTS_SEL_OFFSET + i * 4;
|
||||
uint32_t ofs = GC_PINMUX_GPIO0_GPIO0_SEL_OFFSET + i * 4;
|
||||
uint32_t sel = DIO_SEL_REG(ofs);
|
||||
|
||||
if (sel == 0)
|
||||
return;
|
||||
|
||||
ccprintf("%08x: UART%s %2d",
|
||||
GC_PINMUX_BASE_ADDR + ofs,
|
||||
uart_str[i], sel);
|
||||
ccprintf("%08x: ", GC_PINMUX_BASE_ADDR + ofs);
|
||||
print_periph(i + 1);
|
||||
|
||||
ccprintf("\t%2d", sel);
|
||||
print_dio_str(sel);
|
||||
}
|
||||
|
||||
@@ -459,13 +471,8 @@ static int command_pinmux(int argc, char **argv)
|
||||
ccprintf("\n");
|
||||
|
||||
/* GPIO & Peripheral sources */
|
||||
for (i = 0; i <= 15; i++)
|
||||
show_pinmux_gpio("GPIO0_GPIO", i, 0xf8);
|
||||
for (i = 0; i <= 15; i++)
|
||||
show_pinmux_gpio("GPIO1_GPIO", i, 0x138);
|
||||
|
||||
for (i = 0; i <= 11; i++)
|
||||
show_pinmux_uart(i);
|
||||
for (i = 0; i <= 98; i++)
|
||||
show_pinmux_periph(i);
|
||||
|
||||
ccprintf("\n");
|
||||
return EC_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user