tree/: Move the CrOS EC-alias mechanism into its own dispatch
The alias mechanism is a layering violation and was not well
thoughtout. The follow attempts to create a proper entry-point
for the mechanism and hook it into the expect main-entry dispatch
table. In this way proper control flow can be restored and we
can avoid the hacks and corner cases of a bespoke internal.c
BUG=b:148755493
BRANCH=none
TEST=
```
localhost ~ # flashrom -p ec --flash-name
flashrom 0.9.9 : : on Linux 4.14.150-13595-gf8d893b42c590d (x86_64)
flashrom is free software, get the source code at https://flashrom.org
Calibrating delay loop... OK.
Found Nuvoton flash chip "NPCX796F" (512 kB, Programmer-specific) mapped
at physical address 0x0000000000000000.
vendor="Nuvoton" name="NPCX796F"
```
&&
```
# flashrom -p internal --flash-name 2>&1 | grep vendor
vendor="GigaDevice" name="GD25Q127C/GD25Q128C"
# flashrom -p host --flash-name 2>&1 | grep vendor
vendor="GigaDevice" name="GD25Q127C/GD25Q128C"
# flashrom --flash-name 2>&1 | grep vendor
vendor="GigaDevice" name="GD25Q127C/GD25Q128C"
# flashrom -p ec --flash-name 2>&1 | grep vendor
vendor="Nuvoton" name="NPCX796F"
# flashrom -p ec:type=fp --flash-name 2>&1 | grep vendor
vendor="stm" name="stm32h7x3"
```
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Change-Id: I43e9e390a0934293e1c9f1d48da772f99dd317b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/2484119
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Sam McNally <sammc@chromium.org>
Auto-Submit: Edward O'Callaghan <quasisec@chromium.org>
diff --git a/programmer.h b/programmer.h
index 315d6e9..b2d1964 100644
--- a/programmer.h
+++ b/programmer.h
@@ -145,12 +145,14 @@
#if CONFIG_GOOGLE_EC == 1
PROGRAMMER_GOOGLE_EC,
#endif
+#if CONFIG_CROS_ALIAS == 1
+ PROGRAMMER_GOOGLE_EC_ALIAS,
+#endif
PROGRAMMER_INVALID /* This must always be the last entry. */
};
enum alias_type {
ALIAS_NONE = 0, /* no alias (default) */
- ALIAS_EC, /* embedded controller */
ALIAS_HOST, /* chipset / PCH / SoC / etc. */
};
@@ -166,9 +168,7 @@
* This function returns 'true' if current flashrom invocation is programming
* the EC.
*/
-static inline int programming_ec(void) {
- return alias && (alias->type == ALIAS_EC);
-}
+int programming_ec(void);
enum programmer_type {
PCI = 1, /* to detect uninitialized values */
@@ -912,4 +912,9 @@
int realtek_mst_i2c_spi_init(void);
#endif
+/* cros_alias.c */
+#if CONFIG_CROS_ALIAS == 1
+int cros_ec_alias_init(void);
+#endif
+
#endif /* !__PROGRAMMER_H__ */