14
14
#define MACRONIX_ECCSR_BF_LAST_PAGE (eccsr ) FIELD_GET(GENMASK(3, 0), eccsr)
15
15
#define MACRONIX_ECCSR_BF_ACCUMULATED_PAGES (eccsr ) FIELD_GET(GENMASK(7, 4), eccsr)
16
16
#define MACRONIX_CFG_CONT_READ BIT(2)
17
+ #define MACRONIX_FEATURE_ADDR_READ_RETRY 0x70
18
+ #define MACRONIX_NUM_READ_RETRY_MODES 5
17
19
18
20
#define STATUS_ECC_HAS_BITFLIPS_THRESHOLD (3 << 4)
19
21
@@ -136,6 +138,23 @@ static int macronix_set_cont_read(struct spinand_device *spinand, bool enable)
136
138
return 0 ;
137
139
}
138
140
141
+ /**
142
+ * macronix_set_read_retry - Set the retry mode
143
+ * @spinand: SPI NAND device
144
+ * @retry_mode: Specify which retry mode to set
145
+ *
146
+ * Return: 0 on success, a negative error code otherwise.
147
+ */
148
+ static int macronix_set_read_retry (struct spinand_device * spinand ,
149
+ unsigned int retry_mode )
150
+ {
151
+ struct spi_mem_op op = SPINAND_SET_FEATURE_OP (MACRONIX_FEATURE_ADDR_READ_RETRY ,
152
+ spinand -> scratchbuf );
153
+
154
+ * spinand -> scratchbuf = retry_mode ;
155
+ return spi_mem_exec_op (spinand -> spimem , & op );
156
+ }
157
+
139
158
static const struct spinand_info macronix_spinand_table [] = {
140
159
SPINAND_INFO ("MX35LF1GE4AB" ,
141
160
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x12 ),
@@ -168,7 +187,9 @@ static const struct spinand_info macronix_spinand_table[] = {
168
187
SPINAND_HAS_QE_BIT ,
169
188
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
170
189
macronix_ecc_get_status ),
171
- SPINAND_CONT_READ (macronix_set_cont_read )),
190
+ SPINAND_CONT_READ (macronix_set_cont_read )
191
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
192
+ macronix_set_read_retry )),
172
193
SPINAND_INFO ("MX35LF4GE4AD" ,
173
194
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x37 , 0x03 ),
174
195
NAND_MEMORG (1 , 4096 , 128 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -179,7 +200,9 @@ static const struct spinand_info macronix_spinand_table[] = {
179
200
SPINAND_HAS_QE_BIT ,
180
201
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
181
202
macronix_ecc_get_status ),
182
- SPINAND_CONT_READ (macronix_set_cont_read )),
203
+ SPINAND_CONT_READ (macronix_set_cont_read )
204
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
205
+ macronix_set_read_retry )),
183
206
SPINAND_INFO ("MX35LF1G24AD" ,
184
207
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x14 , 0x03 ),
185
208
NAND_MEMORG (1 , 2048 , 128 , 64 , 1024 , 20 , 1 , 1 , 1 ),
@@ -188,7 +211,9 @@ static const struct spinand_info macronix_spinand_table[] = {
188
211
& write_cache_variants ,
189
212
& update_cache_variants ),
190
213
SPINAND_HAS_QE_BIT ,
191
- SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL )),
214
+ SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL ),
215
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
216
+ macronix_set_read_retry )),
192
217
SPINAND_INFO ("MX35LF2G24AD" ,
193
218
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x24 , 0x03 ),
194
219
NAND_MEMORG (1 , 2048 , 128 , 64 , 2048 , 40 , 2 , 1 , 1 ),
@@ -198,7 +223,9 @@ static const struct spinand_info macronix_spinand_table[] = {
198
223
& update_cache_variants ),
199
224
SPINAND_HAS_QE_BIT |
200
225
SPINAND_HAS_PROG_PLANE_SELECT_BIT ,
201
- SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL )),
226
+ SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL ),
227
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
228
+ macronix_set_read_retry )),
202
229
SPINAND_INFO ("MX35LF2G24AD-Z4I8" ,
203
230
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x64 , 0x03 ),
204
231
NAND_MEMORG (1 , 2048 , 128 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -207,7 +234,9 @@ static const struct spinand_info macronix_spinand_table[] = {
207
234
& write_cache_variants ,
208
235
& update_cache_variants ),
209
236
SPINAND_HAS_QE_BIT ,
210
- SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL )),
237
+ SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL ),
238
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
239
+ macronix_set_read_retry )),
211
240
SPINAND_INFO ("MX35LF4G24AD" ,
212
241
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x35 , 0x03 ),
213
242
NAND_MEMORG (1 , 4096 , 256 , 64 , 2048 , 40 , 2 , 1 , 1 ),
@@ -217,7 +246,9 @@ static const struct spinand_info macronix_spinand_table[] = {
217
246
& update_cache_variants ),
218
247
SPINAND_HAS_QE_BIT |
219
248
SPINAND_HAS_PROG_PLANE_SELECT_BIT ,
220
- SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL )),
249
+ SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL ),
250
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
251
+ macronix_set_read_retry )),
221
252
SPINAND_INFO ("MX35LF4G24AD-Z4I8" ,
222
253
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x75 , 0x03 ),
223
254
NAND_MEMORG (1 , 4096 , 256 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -226,7 +257,9 @@ static const struct spinand_info macronix_spinand_table[] = {
226
257
& write_cache_variants ,
227
258
& update_cache_variants ),
228
259
SPINAND_HAS_QE_BIT ,
229
- SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL )),
260
+ SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout , NULL ),
261
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
262
+ macronix_set_read_retry )),
230
263
SPINAND_INFO ("MX31LF1GE4BC" ,
231
264
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x1e ),
232
265
NAND_MEMORG (1 , 2048 , 64 , 64 , 1024 , 20 , 1 , 1 , 1 ),
@@ -270,7 +303,9 @@ static const struct spinand_info macronix_spinand_table[] = {
270
303
SPINAND_HAS_QE_BIT |
271
304
SPINAND_HAS_PROG_PLANE_SELECT_BIT ,
272
305
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
273
- macronix_ecc_get_status )),
306
+ macronix_ecc_get_status ),
307
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
308
+ macronix_set_read_retry )),
274
309
SPINAND_INFO ("MX35UF4G24AD-Z4I8" ,
275
310
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xf5 , 0x03 ),
276
311
NAND_MEMORG (1 , 4096 , 256 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -280,7 +315,9 @@ static const struct spinand_info macronix_spinand_table[] = {
280
315
& update_cache_variants ),
281
316
SPINAND_HAS_QE_BIT ,
282
317
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
283
- macronix_ecc_get_status )),
318
+ macronix_ecc_get_status ),
319
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
320
+ macronix_set_read_retry )),
284
321
SPINAND_INFO ("MX35UF4GE4AD" ,
285
322
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xb7 , 0x03 ),
286
323
NAND_MEMORG (1 , 4096 , 256 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -291,7 +328,9 @@ static const struct spinand_info macronix_spinand_table[] = {
291
328
SPINAND_HAS_QE_BIT ,
292
329
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
293
330
macronix_ecc_get_status ),
294
- SPINAND_CONT_READ (macronix_set_cont_read )),
331
+ SPINAND_CONT_READ (macronix_set_cont_read )
332
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
333
+ macronix_set_read_retry )),
295
334
SPINAND_INFO ("MX35UF2G14AC" ,
296
335
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xa0 ),
297
336
NAND_MEMORG (1 , 2048 , 64 , 64 , 2048 , 40 , 2 , 1 , 1 ),
@@ -314,7 +353,9 @@ static const struct spinand_info macronix_spinand_table[] = {
314
353
SPINAND_HAS_QE_BIT |
315
354
SPINAND_HAS_PROG_PLANE_SELECT_BIT ,
316
355
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
317
- macronix_ecc_get_status )),
356
+ macronix_ecc_get_status ),
357
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
358
+ macronix_set_read_retry )),
318
359
SPINAND_INFO ("MX35UF2G24AD-Z4I8" ,
319
360
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xe4 , 0x03 ),
320
361
NAND_MEMORG (1 , 2048 , 128 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -324,7 +365,9 @@ static const struct spinand_info macronix_spinand_table[] = {
324
365
& update_cache_variants ),
325
366
SPINAND_HAS_QE_BIT ,
326
367
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
327
- macronix_ecc_get_status )),
368
+ macronix_ecc_get_status ),
369
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
370
+ macronix_set_read_retry )),
328
371
SPINAND_INFO ("MX35UF2GE4AD" ,
329
372
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xa6 , 0x03 ),
330
373
NAND_MEMORG (1 , 2048 , 128 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -335,7 +378,9 @@ static const struct spinand_info macronix_spinand_table[] = {
335
378
SPINAND_HAS_QE_BIT ,
336
379
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
337
380
macronix_ecc_get_status ),
338
- SPINAND_CONT_READ (macronix_set_cont_read )),
381
+ SPINAND_CONT_READ (macronix_set_cont_read )
382
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
383
+ macronix_set_read_retry )),
339
384
SPINAND_INFO ("MX35UF2GE4AC" ,
340
385
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0xa2 , 0x01 ),
341
386
NAND_MEMORG (1 , 2048 , 64 , 64 , 2048 , 40 , 1 , 1 , 1 ),
@@ -366,7 +411,9 @@ static const struct spinand_info macronix_spinand_table[] = {
366
411
& update_cache_variants ),
367
412
SPINAND_HAS_QE_BIT ,
368
413
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
369
- macronix_ecc_get_status )),
414
+ macronix_ecc_get_status ),
415
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
416
+ macronix_set_read_retry )),
370
417
SPINAND_INFO ("MX35UF1GE4AD" ,
371
418
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x96 , 0x03 ),
372
419
NAND_MEMORG (1 , 2048 , 128 , 64 , 1024 , 20 , 1 , 1 , 1 ),
@@ -377,7 +424,9 @@ static const struct spinand_info macronix_spinand_table[] = {
377
424
SPINAND_HAS_QE_BIT ,
378
425
SPINAND_ECCINFO (& mx35lfxge4ab_ooblayout ,
379
426
macronix_ecc_get_status ),
380
- SPINAND_CONT_READ (macronix_set_cont_read )),
427
+ SPINAND_CONT_READ (macronix_set_cont_read )
428
+ SPINAND_READ_RETRY (MACRONIX_NUM_READ_RETRY_MODES ,
429
+ macronix_set_read_retry )),
381
430
SPINAND_INFO ("MX35UF1GE4AC" ,
382
431
SPINAND_ID (SPINAND_READID_METHOD_OPCODE_DUMMY , 0x92 , 0x01 ),
383
432
NAND_MEMORG (1 , 2048 , 64 , 64 , 1024 , 20 , 1 , 1 , 1 ),
0 commit comments