From a8d838d9d3a0373b51408a2ecb647c320e1aaff9 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Sun, 6 Nov 2011 23:51:09 +0000 Subject: ichspi: use a variable to distinguish ich generations instead of spi_programmer->type The type member is enough most of the time to derive the wanted information, but - not always (e.g. ich_set_bbar), - only available after registration, which we want to delay till the end of init, and - we really want to distinguish between chipset version-grained attributes which are not reflected by the registered programmer. Hence this patch introduces a new static variable which is set up early by the init functions and allows us to get rid of all "switch (spi_programmer->type)" in ichspi.c. We reuse the enum introduced for descriptor mode for the type of the new variable. Previously magic numbers were passed by chipset_enable wrappers. Now they use the enumeration items too. To get this working the enum definition had to be moved to programmer.h. Another noteworthy detail: previously we have checked for a valid programmer/ich generation all over the place. I have removed those checks and added one single check in the init method. Calling any function of a programmer without executing the init method first, is undefined behavior. Corresponding to flashrom svn r1460. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- ich_descriptors.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'ich_descriptors.h') diff --git a/ich_descriptors.h b/ich_descriptors.h index 4e2ad0a..714eda9 100644 --- a/ich_descriptors.h +++ b/ich_descriptors.h @@ -24,6 +24,7 @@ #define __ICH_DESCRIPTORS_H__ 1 #include +#include "programmer.h" /* for enum ich_chipset */ /* FIXME: Replace with generic return codes */ #define ICH_RET_OK 0 @@ -63,20 +64,6 @@ #define ICH_FREG_BASE(flreg) (((flreg) << 12) & 0x01fff000) #define ICH_FREG_LIMIT(flreg) (((flreg) >> 4) & 0x01fff000) -/* Used to select the right descriptor printing function. - * Currently only ICH8 and Ibex Peak are supported. - */ -enum ich_chipset { - CHIPSET_ICH_UNKNOWN, - CHIPSET_ICH7 = 7, - CHIPSET_ICH8, - CHIPSET_ICH9, - CHIPSET_ICH10, - CHIPSET_5_SERIES_IBEX_PEAK, - CHIPSET_6_SERIES_COUGAR_POINT, - CHIPSET_7_SERIES_PANTHER_POINT -}; - void prettyprint_ich_reg_vscc(uint32_t reg_val, int verbosity); struct ich_desc_content { -- cgit v1.1