summaryrefslogtreecommitdiff
blob: ae2641af4a0a9468566b0e1cfbc56d4371a44dd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
Backported upstream commit
https://github.com/flashrom/flashrom/commit/e1f30bbce7a603d518ecec9d7e6885719f396719

This commit didn't apply straight because const/non-const changes were
made inbetween, so there are some additional changes to silence more
picky compilers like https://bugs.gentoo.org/915617

--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -148,7 +148,6 @@
 	.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)
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -183,7 +183,6 @@
 	.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[] = {
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -418,7 +418,6 @@
 	.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(const struct programmer_cfg *cfg)
--- a/dediprog.c
+++ b/dediprog.c
@@ -1038,7 +1038,6 @@
 	.write_256	= dediprog_spi_write_256,
 	.write_aai	= dediprog_spi_write_aai,
 	.shutdown	= dediprog_shutdown,
-	.probe_opcode	= default_spi_probe_opcode,
 };
 
 /*
--- a/digilent_spi.c
+++ b/digilent_spi.c
@@ -338,7 +338,6 @@
 	.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)
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -198,7 +198,6 @@
 	.write_256	= default_spi_write_256,
 	.write_aai	= default_spi_write_aai,
 	.shutdown	= dirtyjtag_spi_shutdown,
-	.probe_opcode	= default_spi_probe_opcode,
 };
 
 static int dirtyjtag_spi_init(const struct programmer_cfg *cfg)
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -301,7 +301,6 @@
 	.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. */
--- a/include/chipdrivers.h
+++ b/include/chipdrivers.h
@@ -26,6 +26,7 @@
 int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
 int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
 int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
+bool spi_probe_opcode(struct flashctx *flash, uint8_t opcode);
 
 /* spi25.c */
 int probe_spi_rdid(struct flashctx *flash);
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -312,7 +312,7 @@
 	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);
+	bool (*probe_opcode)(const struct flashctx *flash, uint8_t opcode); /* NULL func implies true. */
 	void *data;
 };
 
@@ -322,7 +322,6 @@
 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. */
--- a/it87spi.c
+++ b/it87spi.c
@@ -320,7 +320,6 @@
 	.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(const struct programmer_cfg *cfg, uint16_t port)
--- a/jlink_spi.c
+++ b/jlink_spi.c
@@ -190,7 +190,6 @@
 	.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(const struct programmer_cfg *cfg)
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -121,7 +121,6 @@
 	.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. */
--- a/mediatek_i2c_spi.c
+++ b/mediatek_i2c_spi.c
@@ -461,7 +461,6 @@
 	.write_256	= default_spi_write_256,
 	.write_aai	= default_spi_write_aai,
 	.shutdown	= mediatek_shutdown,
-	.probe_opcode	= default_spi_probe_opcode,
 };
 
 static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
--- a/mstarddc_spi.c
+++ b/mstarddc_spi.c
@@ -147,7 +147,6 @@
 	.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. */
--- a/ni845x_spi.c
+++ b/ni845x_spi.c
@@ -537,7 +537,6 @@
 	.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(const struct programmer_cfg *cfg)
--- a/parade_lspcon.c
+++ b/parade_lspcon.c
@@ -435,7 +435,6 @@
 	.write_256	= parade_lspcon_write_256,
 	.write_aai	= parade_lspcon_write_aai,
 	.shutdown	= parade_lspcon_shutdown,
-	.probe_opcode	= default_spi_probe_opcode,
 };
 
 static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
--- a/pickit2_spi.c
+++ b/pickit2_spi.c
@@ -385,7 +385,6 @@
 	.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(const struct programmer_cfg *cfg)
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1325,7 +1325,6 @@
 	.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,
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -440,7 +440,6 @@
 	.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(const struct programmer_cfg *cfg, bool *reset, bool *enter_isp, bool *allow_brick)
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -581,7 +581,6 @@
 	.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 = {
@@ -595,7 +594,6 @@
 	.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(const struct programmer_cfg *cfg, struct pci_dev *dev)
--- a/serprog.c
+++ b/serprog.c
@@ -463,7 +463,6 @@
 	.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)
--- a/spi.c
+++ b/spi.c
@@ -131,9 +131,11 @@
 	return flash->mst->spi.write_aai(flash, buf, start, len);
 }
 
-bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
+bool spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
 {
-	return true;
+	if (!flash->mst->spi.probe_opcode)
+		return true; /* no probe_opcode implies default of supported. */
+	return flash->mst->spi.probe_opcode(flash, opcode);
 }
 
 int register_spi_master(const struct spi_master *mst, void *data)
@@ -148,7 +150,7 @@
 	}
 
 	if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command ||
-	    !mst->multicommand || !mst->probe_opcode ||
+	    !mst->multicommand ||
 	    ((mst->command == default_spi_send_command) &&
 	     (mst->multicommand == default_spi_send_multicommand))) {
 		msg_perr("%s called with incomplete master definition. "
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -471,7 +471,6 @@
 	.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(const struct programmer_cfg *cfg)
--- a/usbblaster_spi.c
+++ b/usbblaster_spi.c
@@ -173,7 +173,6 @@
 	.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. */
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -193,7 +193,6 @@
 	.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)