20
20
#include " drivers/QSPI.h"
21
21
#include " blockdevice/BlockDevice.h"
22
22
#include " platform/Callback.h"
23
+ #include " bch.h"
23
24
24
25
#ifndef MBED_CONF_SPINAND_QSPI_IO0
25
26
#define MBED_CONF_SPINAND_QSPI_IO0 NC
@@ -237,6 +238,10 @@ class SPINANDBlockDevice : public mbed::BlockDevice {
237
238
*/
238
239
virtual const char *get_type () const ;
239
240
241
+ virtual bool is_bad_block (uint16_t blk_idx);
242
+
243
+ virtual int mark_bad_block (uint16_t blk_idx);
244
+
240
245
private:
241
246
/* *******************************/
242
247
/* Different Device Csel Mgmt */
@@ -258,6 +263,9 @@ class SPINANDBlockDevice : public mbed::BlockDevice {
258
263
// Send Read command to Driver
259
264
qspi_status_t _qspi_send_read_command (mbed::qspi_inst_t read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
260
265
266
+ // Send Continuous Read command to Driver
267
+ qspi_status_t _qspi_send_continuous_read_command (mbed::qspi_inst_t read_instruction, void *buffer, mbed::bd_addr_t addr, mbed::bd_size_t size);
268
+
261
269
// Send Erase Instruction using command_transfer command to Driver
262
270
qspi_status_t _qspi_send_erase_command (mbed::qspi_inst_t erase_instruction, mbed::bd_addr_t addr, mbed::bd_size_t size);
263
271
@@ -272,6 +280,13 @@ class SPINANDBlockDevice : public mbed::BlockDevice {
272
280
/* Flash Configuration Functions */
273
281
/* ********************************/
274
282
283
+ // Read OTP ONFI parameters
284
+ bool _read_otp_onfi ();
285
+
286
+ int _read_oob (void *buffer, bd_addr_t addr, bd_size_t size);
287
+
288
+ int _program_oob (const void *buffer, bd_addr_t addr, bd_size_t size);
289
+
275
290
// Quad Enable in Security Register
276
291
int _set_quad_enable ();
277
292
@@ -281,9 +296,19 @@ class SPINANDBlockDevice : public mbed::BlockDevice {
281
296
// Configure Write Enable in Status Register
282
297
int _set_write_enable ();
283
298
299
+ int _set_conti_read_enable ();
300
+
301
+ int _set_conti_read_disable ();
302
+
303
+ int _conti_read_exit ();
304
+
284
305
// Wait on status register until write not-in-progress
285
306
bool _is_mem_ready ();
286
307
308
+ void _bch_init (uint8_t ecc_bits);
309
+ void _bch_free ();
310
+ int _bch_calculate_ecc (unsigned char *buf, unsigned char *code);
311
+ int _bch_correct_data (unsigned char *buf, unsigned char *read_ecc, unsigned char *calc_ecc);
287
312
private:
288
313
289
314
// QSPI Driver Object
@@ -320,6 +345,23 @@ class SPINANDBlockDevice : public mbed::BlockDevice {
320
345
321
346
uint32_t _init_ref_count;
322
347
bool _is_initialized;
348
+ char _name[32 ];
349
+ uint32_t _page_size, _block_size, _flash_size;
350
+ uint8_t _page_shift, _block_shift;
351
+ uint16_t _block_num, _page_num, _oob_size;
352
+ uint8_t _ecc_bits, _ecc_bytes, _ecc_steps, _ecc_layout_pos;
353
+ uint32_t _ecc_size;
354
+ uint8_t *_ecc_calc;
355
+ uint8_t *_ecc_code;
356
+ uint8_t *_page_buf;
357
+ uint8_t _continuous_read;
358
+
359
+ struct nand_bch_control {
360
+ struct bch_code *bch;
361
+ unsigned int *errloc;
362
+ unsigned char *eccmask;
363
+ };
364
+ struct nand_bch_control _nbc;
323
365
};
324
366
325
367
#endif
0 commit comments