1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 *** To edit the content of this header, modify the corresponding 11 *** source file (e.g. under external/kernel-headers/original/) then 12 *** run bionic/libc/kernel/tools/update_all.py 13 *** 14 *** Any manual change here will be lost the next time this script will 15 *** be run. You've been warned! 16 *** 17 **************************************************************************** 18 ****************************************************************************/ 19 #ifndef __LINUX_MTD_NAND_H 20 #define __LINUX_MTD_NAND_H 21 #include <linux/wait.h> 22 #include <linux/spinlock.h> 23 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 24 #include <linux/mtd/mtd.h> 25 struct mtd_info; 26 #define NAND_MAX_CHIPS 8 27 #define NAND_MAX_OOBSIZE 64 28 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 29 #define NAND_MAX_PAGESIZE 2048 30 #define NAND_NCE 0x01 31 #define NAND_CLE 0x02 32 #define NAND_ALE 0x04 33 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 34 #define NAND_CTRL_CLE (NAND_NCE | NAND_CLE) 35 #define NAND_CTRL_ALE (NAND_NCE | NAND_ALE) 36 #define NAND_CTRL_CHANGE 0x80 37 #define NAND_CMD_READ0 0 38 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 39 #define NAND_CMD_READ1 1 40 #define NAND_CMD_RNDOUT 5 41 #define NAND_CMD_PAGEPROG 0x10 42 #define NAND_CMD_READOOB 0x50 43 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 44 #define NAND_CMD_ERASE1 0x60 45 #define NAND_CMD_STATUS 0x70 46 #define NAND_CMD_STATUS_MULTI 0x71 47 #define NAND_CMD_SEQIN 0x80 48 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 49 #define NAND_CMD_RNDIN 0x85 50 #define NAND_CMD_READID 0x90 51 #define NAND_CMD_ERASE2 0xd0 52 #define NAND_CMD_RESET 0xff 53 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 54 #define NAND_CMD_READSTART 0x30 55 #define NAND_CMD_RNDOUTSTART 0xE0 56 #define NAND_CMD_CACHEDPROG 0x15 57 #define NAND_CMD_DEPLETE1 0x100 58 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 59 #define NAND_CMD_DEPLETE2 0x38 60 #define NAND_CMD_STATUS_MULTI 0x71 61 #define NAND_CMD_STATUS_ERROR 0x72 62 #define NAND_CMD_STATUS_ERROR0 0x73 63 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 64 #define NAND_CMD_STATUS_ERROR1 0x74 65 #define NAND_CMD_STATUS_ERROR2 0x75 66 #define NAND_CMD_STATUS_ERROR3 0x76 67 #define NAND_CMD_STATUS_RESET 0x7f 68 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 69 #define NAND_CMD_STATUS_CLEAR 0xff 70 #define NAND_CMD_NONE -1 71 #define NAND_STATUS_FAIL 0x01 72 #define NAND_STATUS_FAIL_N1 0x02 73 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 74 #define NAND_STATUS_TRUE_READY 0x20 75 #define NAND_STATUS_READY 0x40 76 #define NAND_STATUS_WP 0x80 77 typedef enum { 78 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 79 NAND_ECC_NONE, 80 NAND_ECC_SOFT, 81 NAND_ECC_HW, 82 NAND_ECC_HW_SYNDROME, 83 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 84 } nand_ecc_modes_t; 85 #define NAND_ECC_READ 0 86 #define NAND_ECC_WRITE 1 87 #define NAND_ECC_READSYN 2 88 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 89 #define NAND_GET_DEVICE 0x80 90 #define NAND_NO_AUTOINCR 0x00000001 91 #define NAND_BUSWIDTH_16 0x00000002 92 #define NAND_NO_PADDING 0x00000004 93 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 94 #define NAND_CACHEPRG 0x00000008 95 #define NAND_COPYBACK 0x00000010 96 #define NAND_IS_AND 0x00000020 97 #define NAND_4PAGE_ARRAY 0x00000040 98 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 99 #define BBT_AUTO_REFRESH 0x00000080 100 #define NAND_NO_READRDY 0x00000100 101 #define NAND_SAMSUNG_LP_OPTIONS (NAND_NO_PADDING | NAND_CACHEPRG | NAND_COPYBACK) 102 #define NAND_CANAUTOINCR(chip) (!(chip->options & NAND_NO_AUTOINCR)) 103 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 104 #define NAND_MUST_PAD(chip) (!(chip->options & NAND_NO_PADDING)) 105 #define NAND_HAS_CACHEPROG(chip) ((chip->options & NAND_CACHEPRG)) 106 #define NAND_HAS_COPYBACK(chip) ((chip->options & NAND_COPYBACK)) 107 #define NAND_CHIPOPTIONS_MSK (0x0000ffff & ~NAND_NO_AUTOINCR) 108 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 109 #define NAND_USE_FLASH_BBT 0x00010000 110 #define NAND_SKIP_BBTSCAN 0x00020000 111 #define NAND_CONTROLLER_ALLOC 0x80000000 112 typedef enum { 113 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 114 FL_READY, 115 FL_READING, 116 FL_WRITING, 117 FL_ERASING, 118 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 119 FL_SYNCING, 120 FL_CACHEDPRG, 121 FL_PM_SUSPENDED, 122 } nand_state_t; 123 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 124 struct nand_chip; 125 struct nand_hw_control { 126 spinlock_t lock; 127 struct nand_chip *active; 128 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 129 wait_queue_head_t wq; 130 }; 131 struct nand_ecc_ctrl { 132 nand_ecc_modes_t mode; 133 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 134 int steps; 135 int size; 136 int bytes; 137 int total; 138 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 139 int prepad; 140 int postpad; 141 struct nand_ecclayout *layout; 142 void (*hwctl)(struct mtd_info *mtd, int mode); 143 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 144 int (*calculate)(struct mtd_info *mtd, 145 const uint8_t *dat, 146 uint8_t *ecc_code); 147 int (*correct)(struct mtd_info *mtd, uint8_t *dat, 148 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 149 uint8_t *read_ecc, 150 uint8_t *calc_ecc); 151 int (*read_page)(struct mtd_info *mtd, 152 struct nand_chip *chip, 153 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 154 uint8_t *buf); 155 void (*write_page)(struct mtd_info *mtd, 156 struct nand_chip *chip, 157 const uint8_t *buf); 158 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 159 int (*read_oob)(struct mtd_info *mtd, 160 struct nand_chip *chip, 161 int page, 162 int sndcmd); 163 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 164 int (*write_oob)(struct mtd_info *mtd, 165 struct nand_chip *chip, 166 int page); 167 }; 168 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 169 struct nand_buffers { 170 uint8_t ecccalc[NAND_MAX_OOBSIZE]; 171 uint8_t ecccode[NAND_MAX_OOBSIZE]; 172 uint8_t oobwbuf[NAND_MAX_OOBSIZE]; 173 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 174 uint8_t databuf[NAND_MAX_PAGESIZE]; 175 uint8_t oobrbuf[NAND_MAX_OOBSIZE]; 176 }; 177 struct nand_chip { 178 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 179 void __iomem *IO_ADDR_R; 180 void __iomem *IO_ADDR_W; 181 uint8_t (*read_byte)(struct mtd_info *mtd); 182 u16 (*read_word)(struct mtd_info *mtd); 183 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 184 void (*write_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); 185 void (*read_buf)(struct mtd_info *mtd, uint8_t *buf, int len); 186 int (*verify_buf)(struct mtd_info *mtd, const uint8_t *buf, int len); 187 void (*select_chip)(struct mtd_info *mtd, int chip); 188 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 189 int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); 190 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); 191 void (*cmd_ctrl)(struct mtd_info *mtd, int dat, 192 unsigned int ctrl); 193 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 194 int (*dev_ready)(struct mtd_info *mtd); 195 void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); 196 int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this); 197 void (*erase_cmd)(struct mtd_info *mtd, int page); 198 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 199 int (*scan_bbt)(struct mtd_info *mtd); 200 int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page); 201 int chip_delay; 202 unsigned int options; 203 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 204 int page_shift; 205 int phys_erase_shift; 206 int bbt_erase_shift; 207 int chip_shift; 208 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 209 int numchips; 210 unsigned long chipsize; 211 int pagemask; 212 int pagebuf; 213 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 214 int badblockpos; 215 nand_state_t state; 216 uint8_t *oob_poi; 217 struct nand_hw_control *controller; 218 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 219 struct nand_ecclayout *ecclayout; 220 struct nand_ecc_ctrl ecc; 221 struct nand_buffers buffers; 222 struct nand_hw_control hwcontrol; 223 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 224 struct mtd_oob_ops ops; 225 uint8_t *bbt; 226 struct nand_bbt_descr *bbt_td; 227 struct nand_bbt_descr *bbt_md; 228 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 229 struct nand_bbt_descr *badblock_pattern; 230 void *priv; 231 }; 232 #define NAND_MFR_TOSHIBA 0x98 233 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 234 #define NAND_MFR_SAMSUNG 0xec 235 #define NAND_MFR_FUJITSU 0x04 236 #define NAND_MFR_NATIONAL 0x8f 237 #define NAND_MFR_RENESAS 0x07 238 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 239 #define NAND_MFR_STMICRO 0x20 240 #define NAND_MFR_HYNIX 0xad 241 struct nand_flash_dev { 242 char *name; 243 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 244 int id; 245 unsigned long pagesize; 246 unsigned long chipsize; 247 unsigned long erasesize; 248 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 249 unsigned long options; 250 }; 251 struct nand_manufacturers { 252 int id; 253 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 254 char * name; 255 }; 256 struct nand_bbt_descr { 257 int options; 258 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 259 int pages[NAND_MAX_CHIPS]; 260 int offs; 261 int veroffs; 262 uint8_t version[NAND_MAX_CHIPS]; 263 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 264 int len; 265 int maxblocks; 266 int reserved_block_code; 267 uint8_t *pattern; 268 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 269 }; 270 #define NAND_BBT_NRBITS_MSK 0x0000000F 271 #define NAND_BBT_1BIT 0x00000001 272 #define NAND_BBT_2BIT 0x00000002 273 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 274 #define NAND_BBT_4BIT 0x00000004 275 #define NAND_BBT_8BIT 0x00000008 276 #define NAND_BBT_LASTBLOCK 0x00000010 277 #define NAND_BBT_ABSPAGE 0x00000020 278 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 279 #define NAND_BBT_SEARCH 0x00000040 280 #define NAND_BBT_PERCHIP 0x00000080 281 #define NAND_BBT_VERSION 0x00000100 282 #define NAND_BBT_CREATE 0x00000200 283 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 284 #define NAND_BBT_SCANALLPAGES 0x00000400 285 #define NAND_BBT_SCANEMPTY 0x00000800 286 #define NAND_BBT_WRITE 0x00001000 287 #define NAND_BBT_SAVECONTENT 0x00002000 288 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 289 #define NAND_BBT_SCAN2NDPAGE 0x00004000 290 #define NAND_BBT_SCAN_MAXBLOCKS 4 291 #define NAND_SMALL_BADBLOCK_POS 5 292 #define NAND_LARGE_BADBLOCK_POS 0 293 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 294 struct platform_nand_chip { 295 int nr_chips; 296 int chip_offset; 297 int nr_partitions; 298 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 299 struct mtd_partition *partitions; 300 struct nand_ecclayout *ecclayout; 301 int chip_delay; 302 unsigned int options; 303 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 304 void *priv; 305 }; 306 struct platform_nand_ctrl { 307 void (*hwcontrol)(struct mtd_info *mtd, int cmd); 308 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 309 int (*dev_ready)(struct mtd_info *mtd); 310 void (*select_chip)(struct mtd_info *mtd, int chip); 311 void *priv; 312 }; 313 /* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */ 314 #endif 315