Skip to content

Commit a3daa62

Browse files
committed
[DeviceDrivers] Add RT_MTD_EECC_CORRECT code in MTD nand.
1 parent 33cda08 commit a3daa62

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

components/drivers/include/drivers/mtd_nand.h

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -33,98 +33,99 @@
3333
#include <rtdevice.h>
3434

3535
struct rt_mtd_nand_driver_ops;
36-
#define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device))
36+
#define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device))
3737

38-
#define RT_MTD_EOK 0 /* NO error */
39-
#define RT_MTD_EECC 1 /* ECC error */
40-
#define RT_MTD_EBUSY 2 /* hardware busy */
41-
#define RT_MTD_EIO 3 /* generic IO issue */
42-
#define RT_MTD_ENOMEM 4 /* out of memory */
43-
#define RT_MTD_ESRC 5 /* source issue */
38+
#define RT_MTD_EOK 0 /* NO error */
39+
#define RT_MTD_EECC 1 /* ECC error */
40+
#define RT_MTD_EBUSY 2 /* hardware busy */
41+
#define RT_MTD_EIO 3 /* generic IO issue */
42+
#define RT_MTD_ENOMEM 4 /* out of memory */
43+
#define RT_MTD_ESRC 5 /* source issue */
44+
#define RT_MTD_EECC_CORRECT 6 /* ECC error but correct */
4445

4546
struct rt_mtd_nand_device
4647
{
47-
struct rt_device parent;
48+
struct rt_device parent;
4849

49-
rt_uint16_t page_size; /* The Page size in the flash */
50-
rt_uint16_t oob_size; /* Out of bank size */
51-
rt_uint16_t oob_free; /* the free area in oob that flash driver not use */
52-
rt_uint16_t plane_num; /* the number of plane in the NAND Flash */
50+
rt_uint16_t page_size; /* The Page size in the flash */
51+
rt_uint16_t oob_size; /* Out of bank size */
52+
rt_uint16_t oob_free; /* the free area in oob that flash driver not use */
53+
rt_uint16_t plane_num; /* the number of plane in the NAND Flash */
5354

54-
rt_uint32_t pages_per_block; /* The number of page a block */
55+
rt_uint32_t pages_per_block; /* The number of page a block */
5556
rt_uint16_t block_total;
5657

57-
rt_uint32_t block_start; /* The start of available block*/
58-
rt_uint32_t block_end; /* The end of available block */
58+
rt_uint32_t block_start; /* The start of available block*/
59+
rt_uint32_t block_end; /* The end of available block */
5960

60-
/* operations interface */
61-
const struct rt_mtd_nand_driver_ops* ops;
61+
/* operations interface */
62+
const struct rt_mtd_nand_driver_ops* ops;
6263
};
6364

6465
struct rt_mtd_nand_driver_ops
6566
{
66-
rt_err_t (*read_id) (struct rt_mtd_nand_device* device);
67+
rt_err_t (*read_id) (struct rt_mtd_nand_device* device);
6768

68-
rt_err_t (*read_page)(struct rt_mtd_nand_device* device,
69+
rt_err_t (*read_page)(struct rt_mtd_nand_device* device,
6970
rt_off_t page,
7071
rt_uint8_t* data, rt_uint32_t data_len,
7172
rt_uint8_t * spare, rt_uint32_t spare_len);
7273

73-
rt_err_t (*write_page)(struct rt_mtd_nand_device * device,
74+
rt_err_t (*write_page)(struct rt_mtd_nand_device * device,
7475
rt_off_t page,
7576
const rt_uint8_t * data, rt_uint32_t data_len,
7677
const rt_uint8_t * spare, rt_uint32_t spare_len);
77-
rt_err_t (*move_page) (struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page);
78+
rt_err_t (*move_page) (struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page);
7879

79-
rt_err_t (*erase_block)(struct rt_mtd_nand_device* device, rt_uint32_t block);
80-
rt_err_t (*check_block)(struct rt_mtd_nand_device* device, rt_uint32_t block);
81-
rt_err_t (*mark_badblock)(struct rt_mtd_nand_device* device, rt_uint32_t block);
80+
rt_err_t (*erase_block)(struct rt_mtd_nand_device* device, rt_uint32_t block);
81+
rt_err_t (*check_block)(struct rt_mtd_nand_device* device, rt_uint32_t block);
82+
rt_err_t (*mark_badblock)(struct rt_mtd_nand_device* device, rt_uint32_t block);
8283
};
8384

8485
rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device* device);
8586

8687
rt_inline rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device* device)
8788
{
88-
return device->ops->read_id(device);
89+
return device->ops->read_id(device);
8990
}
9091

9192
rt_inline rt_err_t rt_mtd_nand_read(
92-
struct rt_mtd_nand_device* device,
93-
rt_off_t page,
94-
rt_uint8_t* data, rt_uint32_t data_len,
95-
rt_uint8_t * spare, rt_uint32_t spare_len)
93+
struct rt_mtd_nand_device* device,
94+
rt_off_t page,
95+
rt_uint8_t* data, rt_uint32_t data_len,
96+
rt_uint8_t * spare, rt_uint32_t spare_len)
9697
{
97-
return device->ops->read_page(device, page, data, data_len, spare, spare_len);
98+
return device->ops->read_page(device, page, data, data_len, spare, spare_len);
9899
}
99100

100101
rt_inline rt_err_t rt_mtd_nand_write(
101-
struct rt_mtd_nand_device* device,
102-
rt_off_t page,
103-
const rt_uint8_t* data, rt_uint32_t data_len,
104-
const rt_uint8_t * spare, rt_uint32_t spare_len)
102+
struct rt_mtd_nand_device* device,
103+
rt_off_t page,
104+
const rt_uint8_t* data, rt_uint32_t data_len,
105+
const rt_uint8_t * spare, rt_uint32_t spare_len)
105106
{
106-
return device->ops->write_page(device, page, data, data_len, spare, spare_len);
107+
return device->ops->write_page(device, page, data, data_len, spare, spare_len);
107108
}
108109

109110
rt_inline rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device* device,
110-
rt_off_t src_page, rt_off_t dst_page)
111+
rt_off_t src_page, rt_off_t dst_page)
111112
{
112-
return device->ops->move_page(device, src_page, dst_page);
113+
return device->ops->move_page(device, src_page, dst_page);
113114
}
114115

115116
rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device* device, rt_uint32_t block)
116117
{
117-
return device->ops->erase_block(device, block);
118+
return device->ops->erase_block(device, block);
118119
}
119120

120121
rt_inline rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device* device, rt_uint32_t block)
121122
{
122-
return device->ops->check_block(device, block);
123+
return device->ops->check_block(device, block);
123124
}
124125

125126
rt_inline rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device* device, rt_uint32_t block)
126127
{
127-
return device->ops->mark_badblock(device, block);
128+
return device->ops->mark_badblock(device, block);
128129
}
129130

130131
#endif /* MTD_NAND_H_ */

0 commit comments

Comments
 (0)