|
33 | 33 | #include <rtdevice.h> |
34 | 34 |
|
35 | 35 | 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)) |
37 | 37 |
|
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 */ |
44 | 45 |
|
45 | 46 | struct rt_mtd_nand_device |
46 | 47 | { |
47 | | - struct rt_device parent; |
| 48 | + struct rt_device parent; |
48 | 49 |
|
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 */ |
53 | 54 |
|
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 */ |
55 | 56 | rt_uint16_t block_total; |
56 | 57 |
|
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 */ |
59 | 60 |
|
60 | | - /* operations interface */ |
61 | | - const struct rt_mtd_nand_driver_ops* ops; |
| 61 | + /* operations interface */ |
| 62 | + const struct rt_mtd_nand_driver_ops* ops; |
62 | 63 | }; |
63 | 64 |
|
64 | 65 | struct rt_mtd_nand_driver_ops |
65 | 66 | { |
66 | | - rt_err_t (*read_id) (struct rt_mtd_nand_device* device); |
| 67 | + rt_err_t (*read_id) (struct rt_mtd_nand_device* device); |
67 | 68 |
|
68 | | - rt_err_t (*read_page)(struct rt_mtd_nand_device* device, |
| 69 | + rt_err_t (*read_page)(struct rt_mtd_nand_device* device, |
69 | 70 | rt_off_t page, |
70 | 71 | rt_uint8_t* data, rt_uint32_t data_len, |
71 | 72 | rt_uint8_t * spare, rt_uint32_t spare_len); |
72 | 73 |
|
73 | | - rt_err_t (*write_page)(struct rt_mtd_nand_device * device, |
| 74 | + rt_err_t (*write_page)(struct rt_mtd_nand_device * device, |
74 | 75 | rt_off_t page, |
75 | 76 | const rt_uint8_t * data, rt_uint32_t data_len, |
76 | 77 | 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); |
78 | 79 |
|
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); |
82 | 83 | }; |
83 | 84 |
|
84 | 85 | rt_err_t rt_mtd_nand_register_device(const char* name, struct rt_mtd_nand_device* device); |
85 | 86 |
|
86 | 87 | rt_inline rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device* device) |
87 | 88 | { |
88 | | - return device->ops->read_id(device); |
| 89 | + return device->ops->read_id(device); |
89 | 90 | } |
90 | 91 |
|
91 | 92 | 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) |
96 | 97 | { |
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); |
98 | 99 | } |
99 | 100 |
|
100 | 101 | 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) |
105 | 106 | { |
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); |
107 | 108 | } |
108 | 109 |
|
109 | 110 | 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) |
111 | 112 | { |
112 | | - return device->ops->move_page(device, src_page, dst_page); |
| 113 | + return device->ops->move_page(device, src_page, dst_page); |
113 | 114 | } |
114 | 115 |
|
115 | 116 | rt_inline rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device* device, rt_uint32_t block) |
116 | 117 | { |
117 | | - return device->ops->erase_block(device, block); |
| 118 | + return device->ops->erase_block(device, block); |
118 | 119 | } |
119 | 120 |
|
120 | 121 | rt_inline rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device* device, rt_uint32_t block) |
121 | 122 | { |
122 | | - return device->ops->check_block(device, block); |
| 123 | + return device->ops->check_block(device, block); |
123 | 124 | } |
124 | 125 |
|
125 | 126 | rt_inline rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device* device, rt_uint32_t block) |
126 | 127 | { |
127 | | - return device->ops->mark_badblock(device, block); |
| 128 | + return device->ops->mark_badblock(device, block); |
128 | 129 | } |
129 | 130 |
|
130 | 131 | #endif /* MTD_NAND_H_ */ |
0 commit comments