diff options
-rw-r--r-- | bitbang_spi.c | 1 | ||||
-rw-r--r-- | buspirate_spi.c | 1 | ||||
-rw-r--r-- | ch341a_spi.c | 1 | ||||
-rw-r--r-- | dediprog.c | 1 | ||||
-rw-r--r-- | digilent_spi.c | 1 | ||||
-rw-r--r-- | dummyflasher.c | 12 | ||||
-rw-r--r-- | ft2232_spi.c | 1 | ||||
-rw-r--r-- | ichspi.c | 7 | ||||
-rw-r--r-- | include/programmer.h | 2 | ||||
-rw-r--r-- | it87spi.c | 1 | ||||
-rw-r--r-- | jlink_spi.c | 1 | ||||
-rw-r--r-- | linux_spi.c | 1 | ||||
-rw-r--r-- | lspcon_i2c_spi.c | 1 | ||||
-rw-r--r-- | mediatek_i2c_spi.c | 1 | ||||
-rw-r--r-- | mstarddc_spi.c | 1 | ||||
-rw-r--r-- | ni845x_spi.c | 1 | ||||
-rw-r--r-- | pickit2_spi.c | 1 | ||||
-rw-r--r-- | raiden_debug_spi.c | 1 | ||||
-rw-r--r-- | realtek_mst_i2c_spi.c | 1 | ||||
-rw-r--r-- | sb600spi.c | 3 | ||||
-rw-r--r-- | serprog.c | 1 | ||||
-rw-r--r-- | spi.c | 7 | ||||
-rw-r--r-- | stlinkv3_spi.c | 1 | ||||
-rw-r--r-- | usbblaster_spi.c | 1 | ||||
-rw-r--r-- | wbsio_spi.c | 1 |
25 files changed, 50 insertions, 1 deletions
diff --git a/bitbang_spi.c b/bitbang_spi.c index 7c9a04d1..a926b103 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -148,6 +148,7 @@ static const struct spi_master spi_master_bitbang = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = bitbang_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data) diff --git a/buspirate_spi.c b/buspirate_spi.c index 11b107bd..f905a969 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -182,6 +182,7 @@ static struct spi_master spi_master_buspirate = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = buspirate_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static const struct buspirate_speeds spispeeds[] = { diff --git a/ch341a_spi.c b/ch341a_spi.c index 3848af95..3978d992 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -417,6 +417,7 @@ static const struct spi_master spi_master_ch341a_spi = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = ch341a_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int ch341a_spi_init(void) @@ -1039,6 +1039,7 @@ static struct spi_master spi_master_dediprog = { .write_256 = dediprog_spi_write_256, .write_aai = dediprog_spi_write_aai, .shutdown = dediprog_shutdown, + .probe_opcode = default_spi_probe_opcode, }; /* diff --git a/digilent_spi.c b/digilent_spi.c index 857dd433..ac42ba5a 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -338,6 +338,7 @@ static const struct spi_master spi_master_digilent_spi = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = digilent_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static bool default_reset(struct libusb_device_handle *handle) diff --git a/dummyflasher.c b/dummyflasher.c index 3d3cbf38..96d43d34 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -121,6 +121,17 @@ static int dummy_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsig emu_data->spi_write_256_chunksize); } +static bool dummy_spi_probe_opcode(struct flashctx *flash, uint8_t opcode) +{ + size_t i; + struct emu_data *emu_data = flash->mst->spi.data; + for (i = 0; i < emu_data->spi_blacklist_size; i++) { + if (emu_data->spi_blacklist[i] == opcode) + return false; + } + return true; +} + static int probe_variable_size(struct flashctx *flash) { const struct emu_data *emu_data = flash->mst->opaque.data; @@ -916,6 +927,7 @@ static const struct spi_master spi_master_dummyflasher = { .read = default_spi_read, .write_256 = dummy_spi_write_256, .write_aai = default_spi_write_aai, + .probe_opcode = dummy_spi_probe_opcode, }; static const struct par_master par_master_dummyflasher = { diff --git a/ft2232_spi.c b/ft2232_spi.c index 145a7e00..f4070ed9 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -298,6 +298,7 @@ static const struct spi_master spi_master_ft2232 = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = ft2232_shutdown, + .probe_opcode = default_spi_probe_opcode, }; /* Returns 0 upon success, a negative number upon errors. */ @@ -1670,6 +1670,11 @@ static int ich_spi_send_multicommand(const struct flashctx *flash, return ret; } +static bool ich_spi_probe_opcode(struct flashctx *flash, uint8_t opcode) +{ + return find_opcode(curopcodes, opcode) >= 0; +} + #define ICH_BMWAG(x) ((x >> 24) & 0xff) #define ICH_BMRAG(x) ((x >> 16) & 0xff) #define ICH_BRWA(x) ((x >> 8) & 0xff) @@ -1802,6 +1807,7 @@ static const struct spi_master spi_master_ich9 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .probe_opcode = ich_spi_probe_opcode, }; static const struct opaque_master opaque_master_ich_hwseq = { @@ -2215,6 +2221,7 @@ static const struct spi_master spi_master_via = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .probe_opcode = ich_spi_probe_opcode, }; int via_init_spi(uint32_t mmio_base) diff --git a/include/programmer.h b/include/programmer.h index 5bdf6cae..38a17610 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -311,6 +311,7 @@ struct spi_master { int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int (*shutdown)(void *data); + bool (*probe_opcode)(struct flashctx *flash, uint8_t opcode); void *data; }; @@ -320,6 +321,7 @@ int default_spi_send_multicommand(const struct flashctx *flash, struct spi_comma int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); +bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode); int register_spi_master(const struct spi_master *mst, void *data); /* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */ @@ -318,6 +318,7 @@ static const struct spi_master spi_master_it87xx = { .write_256 = it8716f_spi_chip_write_256, .write_aai = spi_chip_write_1, .shutdown = it8716f_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static uint16_t it87spi_probe(uint16_t port) diff --git a/jlink_spi.c b/jlink_spi.c index 9a61c03b..deab8daa 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -190,6 +190,7 @@ static const struct spi_master spi_master_jlink_spi = { .write_aai = default_spi_write_aai, .features = SPI_MASTER_4BA, .shutdown = jlink_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int jlink_spi_init(void) diff --git a/linux_spi.c b/linux_spi.c index a0c22356..233650e5 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -121,6 +121,7 @@ static const struct spi_master spi_master_linux = { .write_256 = linux_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = linux_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; /* Read max buffer size from sysfs, or use page size as fallback. */ diff --git a/lspcon_i2c_spi.c b/lspcon_i2c_spi.c index 42e79f52..6e1d65ef 100644 --- a/lspcon_i2c_spi.c +++ b/lspcon_i2c_spi.c @@ -437,6 +437,7 @@ static const struct spi_master spi_master_i2c_lspcon = { .write_256 = lspcon_i2c_spi_write_256, .write_aai = lspcon_i2c_spi_write_aai, .shutdown = lspcon_i2c_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int lspcon_i2c_spi_init(void) diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c index 4e7dbff4..c59f3c85 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -448,6 +448,7 @@ static const struct spi_master spi_master_i2c_mediatek = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .probe_opcode = default_spi_probe_opcode, }; static int mediatek_shutdown(void *data) diff --git a/mstarddc_spi.c b/mstarddc_spi.c index 05452970..c59f9439 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -146,6 +146,7 @@ static const struct spi_master spi_master_mstarddc = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = mstarddc_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; /* Returns 0 upon success, a negative number upon errors. */ diff --git a/ni845x_spi.c b/ni845x_spi.c index 30ef61c0..14bebce8 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -537,6 +537,7 @@ static const struct spi_master spi_programmer_ni845x = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = ni845x_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int ni845x_spi_init(void) diff --git a/pickit2_spi.c b/pickit2_spi.c index c1194b61..b4789180 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -385,6 +385,7 @@ static const struct spi_master spi_master_pickit2 = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = pickit2_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int pickit2_spi_init(void) diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 813c7662..a291f969 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1320,6 +1320,7 @@ static const struct spi_master spi_master_raiden_debug = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = raiden_debug_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int match_endpoint(struct libusb_endpoint_descriptor const *descriptor, diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 8c9bae1a..bfd21147 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -441,6 +441,7 @@ static const struct spi_master spi_master_i2c_realtek_mst = { .write_256 = realtek_mst_i2c_spi_write_256, .write_aai = realtek_mst_i2c_spi_write_aai, .shutdown = realtek_mst_i2c_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int get_params(int *reset, int *enter_isp) @@ -603,6 +603,7 @@ static const struct spi_master spi_master_sb600 = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static const struct spi_master spi_master_yangtze = { @@ -614,6 +615,7 @@ static const struct spi_master spi_master_yangtze = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static const struct spi_master spi_master_promontory = { @@ -625,6 +627,7 @@ static const struct spi_master spi_master_promontory = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = sb600spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; int sb600_probe_spi(struct pci_dev *dev) @@ -446,6 +446,7 @@ static struct spi_master spi_master_serprog = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .probe_opcode = default_spi_probe_opcode, }; static int sp_check_opbuf_usage(int bytes_to_be_added) @@ -134,6 +134,11 @@ int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start return flash->mst->spi.write_aai(flash, buf, start, len); } +bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode) +{ + return true; +} + int register_spi_master(const struct spi_master *mst, void *data) { struct registered_master rmst = {0}; @@ -146,7 +151,7 @@ int register_spi_master(const struct spi_master *mst, void *data) } if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command || - !mst->multicommand || + !mst->multicommand || !mst->probe_opcode || ((mst->command == default_spi_send_command) && (mst->multicommand == default_spi_send_multicommand))) { msg_perr("%s called with incomplete master definition. " diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index c0e3f72c..62ed5f97 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -468,6 +468,7 @@ static const struct spi_master spi_programmer_stlinkv3 = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = stlinkv3_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; static int stlinkv3_spi_init(void) diff --git a/usbblaster_spi.c b/usbblaster_spi.c index 8957df87..b1ab80a3 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -173,6 +173,7 @@ static const struct spi_master spi_master_usbblaster = { .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, .shutdown = usbblaster_shutdown, + .probe_opcode = default_spi_probe_opcode, }; /* Returns 0 upon success, a negative number upon errors. */ diff --git a/wbsio_spi.c b/wbsio_spi.c index 06bb556b..95ca1e99 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -191,6 +191,7 @@ static const struct spi_master spi_master_wbsio = { .write_256 = spi_chip_write_1, .write_aai = spi_chip_write_1, .shutdown = wbsio_spi_shutdown, + .probe_opcode = default_spi_probe_opcode, }; int wbsio_check_for_spi(void) |