From 1a9175f272e39bcbd01e2d0e742fe5eaa6e43f6f Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Tue, 2 Aug 2022 11:38:18 +1000 Subject: ich_descriptors.c: Reduce i/o op paths in read_descriptor_reg() Simplify I/O operations to one path after all branch logic is complete. Work towards consolidated enum ich gen branch logic. Change-Id: I37d22217a7cfc4cffc4f6cfe7b1df6f30df3ca92 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/66349 Tested-by: build bot (Jenkins) Reviewed-by: Felix Singer Reviewed-by: Thomas Heijligen --- ich_descriptors.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ich_descriptors.c b/ich_descriptors.c index 870960375..1cb75830f 100644 --- a/ich_descriptors.c +++ b/ich_descriptors.c @@ -1278,8 +1278,11 @@ int getFCBA_component_density(enum ich_chipset cs, const struct ich_descriptors static uint32_t read_descriptor_reg(enum ich_chipset cs, uint8_t section, uint16_t offset, void *spibar) { uint32_t control = 0; + uint32_t woffset, roffset; + control |= (section << FDOC_FDSS_OFF) & FDOC_FDSS; control |= (offset << FDOC_FDSI_OFF) & FDOC_FDSI; + switch (cs) { case CHIPSET_100_SERIES_SUNRISE_POINT: case CHIPSET_C620_SERIES_LEWISBURG: @@ -1292,12 +1295,16 @@ static uint32_t read_descriptor_reg(enum ich_chipset cs, uint8_t section, uint16 case CHIPSET_GEMINI_LAKE: case CHIPSET_JASPER_LAKE: case CHIPSET_ELKHART_LAKE: - mmio_le_writel(control, spibar + PCH100_REG_FDOC); - return mmio_le_readl(spibar + PCH100_REG_FDOD); + woffset = PCH100_REG_FDOC; + roffset = PCH100_REG_FDOD; + break; default: - mmio_le_writel(control, spibar + ICH9_REG_FDOC); - return mmio_le_readl(spibar + ICH9_REG_FDOD); + woffset = ICH9_REG_FDOC; + roffset = ICH9_REG_FDOD; } + + mmio_le_writel(control, spibar + woffset); + return mmio_le_readl(spibar + roffset); } int read_ich_descriptors_via_fdo(enum ich_chipset cs, void *spibar, struct ich_descriptors *desc) -- cgit v1.2.3