RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
mtd_nand.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2006-2023, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date Author Notes
8 * 2011-12-05 Bernard the first version
9 * 2011-04-02 prife add mark_badblock and check_block
10 */
11
12/*
13 * COPYRIGHT (C) 2012, Shanghai Real Thread
14 */
15
16#ifndef __MTD_NAND_H__
17#define __MTD_NAND_H__
18
19#include <rtthread.h>
20
22#define RT_MTD_NAND_DEVICE(device) ((struct rt_mtd_nand_device*)(device))
23
24#define RT_MTD_EOK 0 /* NO error */
25#define RT_MTD_EECC 101 /* ECC error */
26#define RT_MTD_EBUSY 102 /* hardware busy */
27#define RT_MTD_EIO 103 /* generic IO issue */
28#define RT_MTD_ENOMEM 104 /* out of memory */
29#define RT_MTD_ESRC 105 /* source issue */
30#define RT_MTD_EECC_CORRECT 106 /* ECC error but correct */
31
33{
35
36 rt_uint16_t page_size; /* The Page size in the flash */
37 rt_uint16_t oob_size; /* Out of bank size */
38 rt_uint16_t oob_free; /* the free area in oob that flash driver not use */
39 rt_uint16_t plane_num; /* the number of plane in the NAND Flash */
40
41 rt_uint32_t pages_per_block; /* The number of page a block */
43
44 /* Only be touched by driver */
45 rt_uint32_t block_start; /* The start of available block*/
46 rt_uint32_t block_end; /* The end of available block */
47
48 /* operations interface */
50
51 void *priv;
52};
54
56{
58
60 rt_off_t page,
61 rt_uint8_t *data, rt_uint32_t data_len,
62 rt_uint8_t *spare, rt_uint32_t spare_len);
63
65 rt_off_t page,
66 const rt_uint8_t *data, rt_uint32_t data_len,
67 const rt_uint8_t *spare, rt_uint32_t spare_len);
68 rt_err_t (*move_page)(struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page);
69
73};
74
78 struct rt_mtd_nand_device *device,
79 rt_off_t page,
80 rt_uint8_t *data, rt_uint32_t data_len,
81 rt_uint8_t *spare, rt_uint32_t spare_len);
83 struct rt_mtd_nand_device *device,
84 rt_off_t page,
85 const rt_uint8_t *data, rt_uint32_t data_len,
86 const rt_uint8_t *spare, rt_uint32_t spare_len);
88 rt_off_t src_page, rt_off_t dst_page);
92
93#endif /* MTD_NAND_H_ */
struct rt_mtd_nand_device * rt_mtd_nand_t
rt_err_t rt_mtd_nand_mark_badblock(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_err_t rt_mtd_nand_write(struct rt_mtd_nand_device *device, rt_off_t page, const rt_uint8_t *data, rt_uint32_t data_len, const rt_uint8_t *spare, rt_uint32_t spare_len)
rt_err_t rt_mtd_nand_check_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_err_t rt_mtd_nand_register_device(const char *name, struct rt_mtd_nand_device *device)
rt_err_t rt_mtd_nand_read(struct rt_mtd_nand_device *device, rt_off_t page, rt_uint8_t *data, rt_uint32_t data_len, rt_uint8_t *spare, rt_uint32_t spare_len)
rt_uint32_t rt_mtd_nand_read_id(struct rt_mtd_nand_device *device)
rt_err_t rt_mtd_nand_move_page(struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page)
rt_err_t rt_mtd_nand_erase_block(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_base_t rt_off_t
rt_base_t rt_err_t
unsigned char rt_uint8_t
unsigned short rt_uint16_t
unsigned int rt_uint32_t
rt_uint32_t block_start
rt_uint16_t page_size
rt_uint16_t block_total
rt_uint16_t plane_num
rt_uint32_t block_end
const struct rt_mtd_nand_driver_ops * ops
struct rt_device parent
rt_uint32_t pages_per_block
rt_err_t(* check_block)(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_err_t(* read_id)(struct rt_mtd_nand_device *device)
rt_err_t(* move_page)(struct rt_mtd_nand_device *device, rt_off_t src_page, rt_off_t dst_page)
rt_err_t(* erase_block)(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_err_t(* read_page)(struct rt_mtd_nand_device *device, rt_off_t page, rt_uint8_t *data, rt_uint32_t data_len, rt_uint8_t *spare, rt_uint32_t spare_len)
rt_err_t(* mark_badblock)(struct rt_mtd_nand_device *device, rt_uint32_t block)
rt_err_t(* write_page)(struct rt_mtd_nand_device *device, rt_off_t page, const rt_uint8_t *data, rt_uint32_t data_len, const rt_uint8_t *spare, rt_uint32_t spare_len)