ichspi: Split ICH7 init out
The original, ICH7 init only shared about three lines with the newer,
ever growing ICH9+ init. That's not worth an indentation level in an
endlessly long function, so split it out.
We introduce a kind of "breakpoint" into the `ich_chipset' enum:
SPI_ENGINE_ICH9
This marks all chipset entries below it as supporting this code path
and should help to avoid long `case' lists.
Tested read/erase/write on ThinkPad T60 (ICH7).
Change-Id: I41e46d12e02c1343e636b47b2378db86e76af95e
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/173
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/chipset_enable.c b/chipset_enable.c
index 2d958e3..1200005 100644
--- a/chipset_enable.c
+++ b/chipset_enable.c
@@ -807,7 +807,11 @@
void *spibar = rcrb + spibar_offset;
/* This adds BUS_SPI */
- int ret_spi = ich_init_spi(spibar, ich_generation);
+ int ret_spi;
+ if (ich_generation < SPI_ENGINE_ICH9)
+ ret_spi = ich7_init_spi(spibar, ich_generation);
+ else
+ ret_spi = ich9_init_spi(spibar, ich_generation);
if (ret_spi == ERROR_FATAL)
return ret_spi;
@@ -951,7 +955,7 @@
msg_pdbg("SPIBAR = 0x%0*" PRIxPTR " (phys = 0x%08x)\n", PRIxPTR_WIDTH, (uintptr_t)spibar, phys_spibar);
/* This adds BUS_SPI */
- const int ret_spi = ich_init_spi(spibar, pch_generation);
+ const int ret_spi = ich9_init_spi(spibar, pch_generation);
if (ret_spi != ERROR_FATAL) {
if (ret_bc || ret_spi)
ret = ERROR_NONFATAL;
@@ -1055,7 +1059,7 @@
*/
enable_flash_ich_bios_cntl_memmapped(ich_generation, spibar + 0xFC);
- int ret_spi = ich_init_spi(spibar, ich_generation);
+ int ret_spi = ich9_init_spi(spibar, ich_generation);
if (ret_spi == ERROR_FATAL)
return ret_spi;