Blame view
include/nand.h
4.42 KB
83d290c56
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
932394ac4
|
2 3 4 5 |
/* * (C) Copyright 2005 * 2N Telekomunikace, a.s. <www.2n.cz> * Ladislav Michl <michl@2n.cz> |
932394ac4
|
6 7 8 9 |
*/ #ifndef _NAND_H_ #define _NAND_H_ |
c17834749
|
10 11 12 13 14 15 16 |
#include <config.h> /* * All boards using a given driver must convert to self-init * at the same time, so do it here. When all drivers are * converted, this will go away. */ |
0b0b4f598
|
17 18 19 20 21 |
#ifdef CONFIG_SPL_BUILD #if defined(CONFIG_NAND_FSL_ELBC) || defined(CONFIG_NAND_FSL_IFC) #define CONFIG_SYS_NAND_SELF_INIT #endif #else |
a1b81ab26
|
22 23 |
#if defined(CONFIG_NAND_FSL_ELBC) || defined(CONFIG_NAND_ATMEL)\ || defined(CONFIG_NAND_FSL_IFC) |
c17834749
|
24 25 |
#define CONFIG_SYS_NAND_SELF_INIT #endif |
0b0b4f598
|
26 |
#endif |
c17834749
|
27 |
|
9d2e3947b
|
28 |
extern void nand_init(void); |
203db38a9
|
29 |
unsigned long nand_size(void); |
9d2e3947b
|
30 |
|
7b15e2bb9
|
31 |
#include <linux/compat.h> |
932394ac4
|
32 |
#include <linux/mtd/mtd.h> |
6ae3900a8
|
33 |
#include <linux/mtd/rawnand.h> |
932394ac4
|
34 |
|
b616d9b0a
|
35 |
int nand_mtd_to_devnum(struct mtd_info *mtd); |
578931b34
|
36 37 |
#ifdef CONFIG_SYS_NAND_SELF_INIT void board_nand_init(void); |
b616d9b0a
|
38 |
int nand_register(int devnum, struct mtd_info *mtd); |
578931b34
|
39 |
#else |
69fb8be4f
|
40 |
extern int board_nand_init(struct nand_chip *nand); |
578931b34
|
41 |
#endif |
69fb8be4f
|
42 |
|
932394ac4
|
43 |
extern int nand_curr_device; |
932394ac4
|
44 |
|
151c06ec6
|
45 46 |
static inline int nand_read(struct mtd_info *info, loff_t ofs, size_t *len, u_char *buf) |
932394ac4
|
47 |
{ |
dfe64e2c8
|
48 |
return mtd_read(info, ofs, *len, (size_t *)len, buf); |
932394ac4
|
49 |
} |
151c06ec6
|
50 51 |
static inline int nand_write(struct mtd_info *info, loff_t ofs, size_t *len, u_char *buf) |
932394ac4
|
52 |
{ |
dfe64e2c8
|
53 |
return mtd_write(info, ofs, *len, (size_t *)len, buf); |
932394ac4
|
54 |
} |
151c06ec6
|
55 |
static inline int nand_block_isbad(struct mtd_info *info, loff_t ofs) |
932394ac4
|
56 |
{ |
dfe64e2c8
|
57 |
return mtd_block_isbad(info, ofs); |
932394ac4
|
58 |
} |
151c06ec6
|
59 |
static inline int nand_erase(struct mtd_info *info, loff_t off, size_t size) |
932394ac4
|
60 |
{ |
8e9655f86
|
61 62 63 64 65 66 |
struct erase_info instr; instr.mtd = info; instr.addr = off; instr.len = size; instr.callback = 0; |
dfe64e2c8
|
67 |
return mtd_erase(info, &instr); |
932394ac4
|
68 |
} |
2255b2d20
|
69 70 71 72 |
/***************************************************************************** * declarations from nand_util.c ****************************************************************************/ |
cfa460adf
|
73 |
typedef struct mtd_oob_ops mtd_oob_ops_t; |
2255b2d20
|
74 |
|
2255b2d20
|
75 |
struct nand_erase_options { |
304863225
|
76 77 |
loff_t length; /* number of bytes to erase */ loff_t offset; /* first address in NAND to erase */ |
2255b2d20
|
78 79 80 81 82 |
int quiet; /* don't display progress messages */ int jffs2; /* if true: format for jffs2 usage * (write appropriate cleanmarker blocks) */ int scrub; /* if true, really clean NAND by erasing * bad blocks (UNSAFE) */ |
304863225
|
83 84 85 |
/* Don't include skipped bad blocks in size to be erased */ int spread; |
a67cc37e6
|
86 87 |
/* maximum size that actual may be in order to not exceed the buf */ loff_t lim; |
2255b2d20
|
88 89 90 |
}; typedef struct nand_erase_options nand_erase_options_t; |
151c06ec6
|
91 |
int nand_read_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length, |
c39d6a0ea
|
92 |
size_t *actual, loff_t lim, u_char *buffer); |
a6c9aa1f9
|
93 |
|
004a1fdb4
|
94 95 |
#define WITH_DROP_FFS (1 << 0) /* drop trailing all-0xff pages */ #define WITH_WR_VERIFY (1 << 1) /* verify data was written correctly */ |
a6c9aa1f9
|
96 |
|
151c06ec6
|
97 |
int nand_write_skip_bad(struct mtd_info *mtd, loff_t offset, size_t *length, |
c39d6a0ea
|
98 |
size_t *actual, loff_t lim, u_char *buffer, int flags); |
151c06ec6
|
99 100 101 102 103 104 |
int nand_erase_opts(struct mtd_info *mtd, const nand_erase_options_t *opts); int nand_torture(struct mtd_info *mtd, loff_t offset); int nand_verify_page_oob(struct mtd_info *mtd, struct mtd_oob_ops *ops, loff_t ofs); int nand_verify(struct mtd_info *mtd, loff_t ofs, size_t len, u_char *buf); |
2255b2d20
|
105 106 |
#define NAND_LOCK_STATUS_TIGHT 0x01 |
2255b2d20
|
107 |
#define NAND_LOCK_STATUS_UNLOCK 0x04 |
151c06ec6
|
108 109 110 111 |
int nand_lock(struct mtd_info *mtd, int tight); int nand_unlock(struct mtd_info *mtd, loff_t start, size_t length, int allexcept); int nand_get_lock_status(struct mtd_info *mtd, loff_t offset); |
2255b2d20
|
112 |
|
12c2f1ee3
|
113 |
int nand_spl_load_image(uint32_t offs, unsigned int size, void *dst); |
e1a89e935
|
114 |
int nand_spl_read_block(int block, int offset, int len, void *dst); |
bb085b87e
|
115 |
void nand_deselect(void); |
6d0f6bcf3
|
116 |
#ifdef CONFIG_SYS_NAND_SELECT_DEVICE |
43a2b0e76
|
117 118 |
void board_nand_select_device(struct nand_chip *nand, int chip); #endif |
e4c095085
|
119 |
__attribute__((noreturn)) void nand_boot(void); |
c9f7351b5
|
120 121 122 123 124 125 |
#ifdef CONFIG_ENV_OFFSET_OOB #define ENV_OOB_MARKER 0x30425645 /*"EVB0" in little-endian -- offset is stored as block number*/ #define ENV_OOB_MARKER_OLD 0x30564e45 /*"ENV0" in little-endian -- offset is stored as byte number */ #define ENV_OFFSET_SIZE 8 |
151c06ec6
|
126 |
int get_nand_env_oob(struct mtd_info *mtd, unsigned long *result); |
c9f7351b5
|
127 |
#endif |
4dfd36058
|
128 |
int spl_nand_erase_one(int block, int page); |
4ccae81cd
|
129 130 131 |
/* platform specific init functions */ void sunxi_nand_init(void); |
2afc741a2
|
132 |
|
ad92dff28
|
133 134 135 136 137 138 139 140 |
/* * get_nand_dev_by_index - Get the nand info based in index. * * @dev - index to the nand device. * * returns pointer to the nand device info structure or NULL on failure. */ struct mtd_info *get_nand_dev_by_index(int dev); |
2afc741a2
|
141 |
#endif /* _NAND_H_ */ |