espi_debug: Use switch case instead of if-else

This change updates espi_debug.c to use switch case instead of if-else
for operating frequency and i/o mode prints. This is done to address
the review comments received on CB:41254.

Signed-off-by: Furquan Shaikh <furquan@google.com>
Change-Id: I4f323b79f030818e2daa983d4f17ddf7a3192171
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41346
Reviewed-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Furquan Shaikh 2020-05-12 15:46:16 -07:00 committed by Patrick Georgi
parent 5181ac15c8
commit 69d5bbf073
1 changed files with 51 additions and 27 deletions

View File

@ -23,24 +23,34 @@ void espi_show_slave_general_configuration(uint32_t config)
printk(BIOS_DEBUG, " IO bit1 pin used to signal alert event\n"); printk(BIOS_DEBUG, " IO bit1 pin used to signal alert event\n");
io_mode = config & ESPI_SLAVE_IO_MODE_SEL_MASK; io_mode = config & ESPI_SLAVE_IO_MODE_SEL_MASK;
if (io_mode == ESPI_SLAVE_IO_MODE_SEL_SINGLE) switch (io_mode) {
case ESPI_SLAVE_IO_MODE_SEL_SINGLE:
printk(BIOS_DEBUG, " eSPI single IO mode selected\n"); printk(BIOS_DEBUG, " eSPI single IO mode selected\n");
else if (io_mode == ESPI_SLAVE_IO_MODE_SEL_DUAL) break;
case ESPI_SLAVE_IO_MODE_SEL_DUAL:
printk(BIOS_DEBUG, " eSPI dual IO mode selected\n"); printk(BIOS_DEBUG, " eSPI dual IO mode selected\n");
else if (io_mode == ESPI_SLAVE_IO_MODE_SEL_QUAD) break;
case ESPI_SLAVE_IO_MODE_SEL_QUAD:
printk(BIOS_DEBUG, " eSPI quad IO mode selected\n"); printk(BIOS_DEBUG, " eSPI quad IO mode selected\n");
else break;
default:
printk(BIOS_DEBUG, " Error: Invalid eSPI IO mode selected\n"); printk(BIOS_DEBUG, " Error: Invalid eSPI IO mode selected\n");
}
io_mode = config & ESPI_SLAVE_IO_MODE_SUPP_MASK; io_mode = config & ESPI_SLAVE_IO_MODE_SUPP_MASK;
if (io_mode == ESPI_SLAVE_IO_MODE_SUPP_SINGLE_QUAD) switch (io_mode) {
case ESPI_SLAVE_IO_MODE_SUPP_SINGLE_QUAD:
printk(BIOS_DEBUG, " eSPI quad and single IO modes supported\n"); printk(BIOS_DEBUG, " eSPI quad and single IO modes supported\n");
else if (io_mode == ESPI_SLAVE_IO_MODE_SUPP_SINGLE_DUAL) break;
printk(BIOS_DEBUG, " eSPI dual and single IO mode supported\n"); case ESPI_SLAVE_IO_MODE_SUPP_SINGLE_DUAL:
else if (io_mode == ESPI_SLAVE_IO_MODE_SUPP_SINGLE_DUAL_QUAD) printk(BIOS_DEBUG, " eSPI dual and single IO modes supported\n");
printk(BIOS_DEBUG, " eSPI quad, dual, and single IO modes supported\n"); break;
else case ESPI_SLAVE_IO_MODE_SUPP_SINGLE_DUAL_QUAD:
printk(BIOS_DEBUG, " eSPI quad, dual and single IO modes supported\n");
break;
default:
printk(BIOS_DEBUG, " Only eSPI single IO mode supported\n"); printk(BIOS_DEBUG, " Only eSPI single IO mode supported\n");
}
if (config & ESPI_SLAVE_OPEN_DRAIN_ALERT_SEL) if (config & ESPI_SLAVE_OPEN_DRAIN_ALERT_SEL)
printk(BIOS_DEBUG, " Alert# pin is open-drain\n"); printk(BIOS_DEBUG, " Alert# pin is open-drain\n");
@ -48,35 +58,49 @@ void espi_show_slave_general_configuration(uint32_t config)
printk(BIOS_DEBUG, " Alert# pin is driven\n"); printk(BIOS_DEBUG, " Alert# pin is driven\n");
op_freq = config & ESPI_SLAVE_OP_FREQ_SEL_MASK; op_freq = config & ESPI_SLAVE_OP_FREQ_SEL_MASK;
if (op_freq == ESPI_SLAVE_OP_FREQ_SEL_20_MHZ) switch (op_freq) {
case ESPI_SLAVE_OP_FREQ_SEL_20_MHZ:
printk(BIOS_DEBUG, " eSPI 20MHz selected\n"); printk(BIOS_DEBUG, " eSPI 20MHz selected\n");
else if (op_freq == ESPI_SLAVE_OP_FREQ_SEL_25_MHZ) break;
case ESPI_SLAVE_OP_FREQ_SEL_25_MHZ:
printk(BIOS_DEBUG, " eSPI 25MHz selected\n"); printk(BIOS_DEBUG, " eSPI 25MHz selected\n");
else if (op_freq == ESPI_SLAVE_OP_FREQ_SEL_33_MHZ) break;
case ESPI_SLAVE_OP_FREQ_SEL_33_MHZ:
printk(BIOS_DEBUG, " eSPI 33MHz selected\n"); printk(BIOS_DEBUG, " eSPI 33MHz selected\n");
else if (op_freq == ESPI_SLAVE_OP_FREQ_SEL_50_MHZ) break;
case ESPI_SLAVE_OP_FREQ_SEL_50_MHZ:
printk(BIOS_DEBUG, " eSPI 50MHz selected\n"); printk(BIOS_DEBUG, " eSPI 50MHz selected\n");
else if (op_freq == ESPI_SLAVE_OP_FREQ_SEL_66_MHZ) break;
case ESPI_SLAVE_OP_FREQ_SEL_66_MHZ:
printk(BIOS_DEBUG, " eSPI 66MHz selected\n"); printk(BIOS_DEBUG, " eSPI 66MHz selected\n");
else break;
default:
printk(BIOS_DEBUG, " Error: Invalid eSPI frequency\n"); printk(BIOS_DEBUG, " Error: Invalid eSPI frequency\n");
}
if (config & ESPI_SLAVE_OPEN_DRAIN_ALERT_SUPP) if (config & ESPI_SLAVE_OPEN_DRAIN_ALERT_SUPP)
printk(BIOS_DEBUG, " Open-drain Alert# pin supported\n"); printk(BIOS_DEBUG, " Open-drain Alert# pin supported\n");
op_freq = config & ESPI_SLAVE_OP_FREQ_SUPP_MASK; op_freq = config & ESPI_SLAVE_OP_FREQ_SUPP_MASK;
if (op_freq == ESPI_SLAVE_OP_FREQ_SUPP_20_MHZ) switch (op_freq) {
printk(BIOS_DEBUG, " eSPI 20MHz supported\n"); case ESPI_SLAVE_OP_FREQ_SUPP_20_MHZ:
else if (op_freq == ESPI_SLAVE_OP_FREQ_SUPP_25_MHZ) printk(BIOS_DEBUG, " eSPI up to 20MHz supported\n");
printk(BIOS_DEBUG, " eSPI 25MHz supported\n"); break;
else if (op_freq == ESPI_SLAVE_OP_FREQ_SUPP_33_MHZ) case ESPI_SLAVE_OP_FREQ_SUPP_25_MHZ:
printk(BIOS_DEBUG, " eSPI 33MHz supported\n"); printk(BIOS_DEBUG, " eSPI up to 25MHz supported\n");
else if (op_freq == ESPI_SLAVE_OP_FREQ_SUPP_50_MHZ) break;
printk(BIOS_DEBUG, " eSPI 50MHz supported\n"); case ESPI_SLAVE_OP_FREQ_SUPP_33_MHZ:
else if (op_freq == ESPI_SLAVE_OP_FREQ_SUPP_66_MHZ) printk(BIOS_DEBUG, " eSPI up to 33MHz supported\n");
printk(BIOS_DEBUG, " eSPI 66MHz supported\n"); break;
else case ESPI_SLAVE_OP_FREQ_SUPP_50_MHZ:
printk(BIOS_DEBUG, " eSPI up to 50MHz supported\n");
break;
case ESPI_SLAVE_OP_FREQ_SUPP_66_MHZ:
printk(BIOS_DEBUG, " eSPI up to 66MHz supported\n");
break;
default:
printk(BIOS_DEBUG, " Error: Invalid eSPI frequency\n"); printk(BIOS_DEBUG, " Error: Invalid eSPI frequency\n");
}
printk(BIOS_DEBUG, " Maximum Wait state: %d\n", printk(BIOS_DEBUG, " Maximum Wait state: %d\n",
(config & ESPI_SLAVE_MAX_WAIT_MASK) >> ESPI_SLAVE_MAX_WAIT_SHIFT); (config & ESPI_SLAVE_MAX_WAIT_MASK) >> ESPI_SLAVE_MAX_WAIT_SHIFT);