Attention is currently required from: Thomas Heijligen.

Edward O'Callaghan has uploaded this change for review.

View Change

wbsio_spi.c: Convert to direct driver entry

Change-Id: I54b166048089bc502b99a345c02e91894590894e
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M Makefile
M include/programmer.h
M meson.build
M programmer_table.c
M wbsio_spi.c
5 files changed, 76 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/64/72864/1
diff --git a/Makefile b/Makefile
index 2ebd370..5eaf241 100644
--- a/Makefile
+++ b/Makefile
@@ -135,6 +135,7 @@
CONFIG_NICREALTEK \
CONFIG_RAYER_SPI \
CONFIG_SATAMV \
+ CONFIG_WBSIO_SPI \

DEPENDS_ON_LIBPCI := \
CONFIG_ATAHPT \
@@ -465,6 +466,9 @@
# Disables Parade LSPCON support until the i2c helper supports multiple systems.
CONFIG_PARADE_LSPCON ?= no

+# Disables wbsio_spi support.
+CONFIG_WBSIO_SPI ?= no
+
# Disables MediaTek support until the i2c helper supports multiple systems.
CONFIG_MEDIATEK_I2C_SPI ?= no

@@ -584,7 +588,7 @@
ifeq ($(CONFIG_INTERNAL) $(CONFIG_INTERNAL_X86), yes yes)
FEATURE_FLAGS += -D'CONFIG_INTERNAL=1'
PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o \
- internal.o it87spi.o sb600spi.o superio.o amd_imc.o wbsio_spi.o mcp6x_spi.o \
+ internal.o it87spi.o sb600spi.o superio.o amd_imc.o mcp6x_spi.o \
ichspi.o dmi.o known_boards.o
ACTIVE_PROGRAMMERS += internal
endif
@@ -696,6 +700,12 @@
ACTIVE_PROGRAMMERS += parade_lspcon
endif

+ifeq ($(CONFIG_WBSIO_SPI), yes)
+FEATURE_FLAGS += -D'CONFIG_WBSIO_SPI=1'
+PROGRAMMER_OBJS += wbsio_spi.o
+ACTIVE_PROGRAMMERS += wbsio_spi
+endif
+
ifeq ($(CONFIG_MEDIATEK_I2C_SPI), yes)
FEATURE_FLAGS += -D'CONFIG_MEDIATEK_I2C_SPI=1'
PROGRAMMER_OBJS += mediatek_i2c_spi.o
diff --git a/include/programmer.h b/include/programmer.h
index db32b2c..62e0779 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -73,6 +73,7 @@
extern const struct programmer_entry programmer_linux_mtd;
extern const struct programmer_entry programmer_linux_spi;
extern const struct programmer_entry programmer_parade_lspcon;
+extern const struct programmer_entry programmer_wbsio_spi;
extern const struct programmer_entry programmer_mediatek_i2c_spi;
extern const struct programmer_entry programmer_mstarddc_spi;
extern const struct programmer_entry programmer_ni845x_spi;
@@ -391,9 +392,6 @@

/* sb600spi.c */
int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev);
-
-/* wbsio_spi.c */
-int wbsio_check_for_spi(void);
#endif

/* opaque.c */
diff --git a/meson.build b/meson.build
index 57ac438..d0ed2b7 100644
--- a/meson.build
+++ b/meson.build
@@ -249,7 +249,6 @@
'sb600spi.c',
'superio.c',
'amd_imc.c',
- 'wbsio_spi.c',
'mcp6x_spi.c',
'ichspi.c',
'dmi.c',
@@ -308,6 +307,14 @@
'flags' : [ '-DCONFIG_PARADE_LSPCON=1' ],
'default' : false
},
+ 'wbsio_spi' : {
+ 'systems' : [ 'linux' ],
+ 'deps' : [ linux_headers ],
+ 'groups' : [ group_i2c ],
+ 'srcs' : files('wbsio_spi.c'),
+ 'flags' : [ '-DCONFIG_WBSIO_SPI=1' ],
+ 'default' : false,
+ },
'mediatek_i2c_spi' : {
'systems' : [ 'linux' ],
'deps' : [ linux_headers ],
diff --git a/programmer_table.c b/programmer_table.c
index d58a155..e1bb805 100644
--- a/programmer_table.c
+++ b/programmer_table.c
@@ -128,6 +128,10 @@
&programmer_parade_lspcon,
#endif

+#if CONFIG_WBSIO_SPI == 1
+ &programmer_wbsio_spi,
+#endif
+
#if CONFIG_MEDIATEK_I2C_SPI == 1
&programmer_mediatek_i2c_spi,
#endif
diff --git a/wbsio_spi.c b/wbsio_spi.c
index d635a09..d6c0f16 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -196,9 +196,44 @@
.probe_opcode = default_spi_probe_opcode,
};

-int wbsio_check_for_spi(void)
+static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
+{
+ char *param_str;
+ int ret = 0;
+
+ *allow_brick = false; /* Default behaviour is to bail. */
+ param_str = extract_programmer_param_str(cfg, "allow_brick");
+ if (param_str) {
+ if (!strcmp(param_str, "yes")) {
+ *allow_brick = true;
+ } else {
+ msg_perr("%s: Incorrect param format, allow_brick=yes.\n", __func__);
+ ret = SPI_GENERIC_ERROR;
+ }
+ }
+ free(param_str);
+
+ return ret;
+}
+
+static int wbsio_spi_init(const struct programmer_cfg *cfg)
{
uint16_t wbsio_spibase = 0;
+ bool allow_brick;
+
+ if (get_params(cfg, &allow_brick))
+ return SPI_GENERIC_ERROR;
+
+ /*
+ * TODO: Once board_enable can facilitate safe allow listing
+ * then this can be removed.
+ */
+ if (!allow_brick) {
+ msg_perr("%s: For Super I/O drivers you must explicitly 'allow_brick=yes'. ", __func__);
+ msg_perr("There is currently no way to determine if the programmer works on a board. "
+ "Set 'allow_brick=yes' if you are sure you know what you are doing.\n");
+ return SPI_GENERIC_ERROR;
+ }

if (0 == (wbsio_spibase = wbsio_get_spibase(WBSIO_PORT1)))
if (0 == (wbsio_spibase = wbsio_get_spibase(WBSIO_PORT2)))
@@ -219,3 +254,9 @@

return register_spi_master(&spi_master_wbsio, data);
}
+
+const struct programmer_entry programmer_wbsio_spi = {
+ .name = "wbsio_spi",
+ .type = OTHER,
+ .init = wbsio_spi_init,
+};

To view, visit change 72864. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I54b166048089bc502b99a345c02e91894590894e
Gerrit-Change-Number: 72864
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Attention: Thomas Heijligen <src@posteo.de>
Gerrit-MessageType: newchange