diff options
Diffstat (limited to 'include/linux/mtd/nand.h')
-rw-r--r-- | include/linux/mtd/nand.h | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 9a19c65abd74..9b5b76217584 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * Steven J. Hill <sjhill@realitydiluted.com> | 5 | * Steven J. Hill <sjhill@realitydiluted.com> |
6 | * Thomas Gleixner <tglx@linutronix.de> | 6 | * Thomas Gleixner <tglx@linutronix.de> |
7 | * | 7 | * |
8 | * $Id: nand.h,v 1.68 2004/11/12 10:40:37 gleixner Exp $ | 8 | * $Id: nand.h,v 1.73 2005/05/31 19:39:17 gleixner Exp $ |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
11 | * it under the terms of the GNU General Public License version 2 as | 11 | * it under the terms of the GNU General Public License version 2 as |
@@ -48,6 +48,10 @@ | |||
48 | * 02-08-2004 tglx added option field to nand structure for chip anomalities | 48 | * 02-08-2004 tglx added option field to nand structure for chip anomalities |
49 | * 05-25-2004 tglx added bad block table support, ST-MICRO manufacturer id | 49 | * 05-25-2004 tglx added bad block table support, ST-MICRO manufacturer id |
50 | * update of nand_chip structure description | 50 | * update of nand_chip structure description |
51 | * 01-17-2005 dmarlin added extended commands for AG-AND device and added option | ||
52 | * for BBT_AUTO_REFRESH. | ||
53 | * 01-20-2005 dmarlin added optional pointer to hardware specific callback for | ||
54 | * extra error status checks. | ||
51 | */ | 55 | */ |
52 | #ifndef __LINUX_MTD_NAND_H | 56 | #ifndef __LINUX_MTD_NAND_H |
53 | #define __LINUX_MTD_NAND_H | 57 | #define __LINUX_MTD_NAND_H |
@@ -115,6 +119,25 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
115 | #define NAND_CMD_READSTART 0x30 | 119 | #define NAND_CMD_READSTART 0x30 |
116 | #define NAND_CMD_CACHEDPROG 0x15 | 120 | #define NAND_CMD_CACHEDPROG 0x15 |
117 | 121 | ||
122 | /* Extended commands for AG-AND device */ | ||
123 | /* | ||
124 | * Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but | ||
125 | * there is no way to distinguish that from NAND_CMD_READ0 | ||
126 | * until the remaining sequence of commands has been completed | ||
127 | * so add a high order bit and mask it off in the command. | ||
128 | */ | ||
129 | #define NAND_CMD_DEPLETE1 0x100 | ||
130 | #define NAND_CMD_DEPLETE2 0x38 | ||
131 | #define NAND_CMD_STATUS_MULTI 0x71 | ||
132 | #define NAND_CMD_STATUS_ERROR 0x72 | ||
133 | /* multi-bank error status (banks 0-3) */ | ||
134 | #define NAND_CMD_STATUS_ERROR0 0x73 | ||
135 | #define NAND_CMD_STATUS_ERROR1 0x74 | ||
136 | #define NAND_CMD_STATUS_ERROR2 0x75 | ||
137 | #define NAND_CMD_STATUS_ERROR3 0x76 | ||
138 | #define NAND_CMD_STATUS_RESET 0x7f | ||
139 | #define NAND_CMD_STATUS_CLEAR 0xff | ||
140 | |||
118 | /* Status bits */ | 141 | /* Status bits */ |
119 | #define NAND_STATUS_FAIL 0x01 | 142 | #define NAND_STATUS_FAIL 0x01 |
120 | #define NAND_STATUS_FAIL_N1 0x02 | 143 | #define NAND_STATUS_FAIL_N1 0x02 |
@@ -143,7 +166,7 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
143 | 166 | ||
144 | /* | 167 | /* |
145 | * Constants for Hardware ECC | 168 | * Constants for Hardware ECC |
146 | */ | 169 | */ |
147 | /* Reset Hardware ECC for read */ | 170 | /* Reset Hardware ECC for read */ |
148 | #define NAND_ECC_READ 0 | 171 | #define NAND_ECC_READ 0 |
149 | /* Reset Hardware ECC for write */ | 172 | /* Reset Hardware ECC for write */ |
@@ -151,6 +174,10 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
151 | /* Enable Hardware ECC before syndrom is read back from flash */ | 174 | /* Enable Hardware ECC before syndrom is read back from flash */ |
152 | #define NAND_ECC_READSYN 2 | 175 | #define NAND_ECC_READSYN 2 |
153 | 176 | ||
177 | /* Bit mask for flags passed to do_nand_read_ecc */ | ||
178 | #define NAND_GET_DEVICE 0x80 | ||
179 | |||
180 | |||
154 | /* Option constants for bizarre disfunctionality and real | 181 | /* Option constants for bizarre disfunctionality and real |
155 | * features | 182 | * features |
156 | */ | 183 | */ |
@@ -170,6 +197,10 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
170 | /* Chip has a array of 4 pages which can be read without | 197 | /* Chip has a array of 4 pages which can be read without |
171 | * additional ready /busy waits */ | 198 | * additional ready /busy waits */ |
172 | #define NAND_4PAGE_ARRAY 0x00000040 | 199 | #define NAND_4PAGE_ARRAY 0x00000040 |
200 | /* Chip requires that BBT is periodically rewritten to prevent | ||
201 | * bits from adjacent blocks from 'leaking' in altering data. | ||
202 | * This happens with the Renesas AG-AND chips, possibly others. */ | ||
203 | #define BBT_AUTO_REFRESH 0x00000080 | ||
173 | 204 | ||
174 | /* Options valid for Samsung large page devices */ | 205 | /* Options valid for Samsung large page devices */ |
175 | #define NAND_SAMSUNG_LP_OPTIONS \ | 206 | #define NAND_SAMSUNG_LP_OPTIONS \ |
@@ -192,7 +223,8 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
192 | * This can only work if we have the ecc bytes directly behind the | 223 | * This can only work if we have the ecc bytes directly behind the |
193 | * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */ | 224 | * data bytes. Applies for DOC and AG-AND Renesas HW Reed Solomon generators */ |
194 | #define NAND_HWECC_SYNDROME 0x00020000 | 225 | #define NAND_HWECC_SYNDROME 0x00020000 |
195 | 226 | /* This option skips the bbt scan during initialization. */ | |
227 | #define NAND_SKIP_BBTSCAN 0x00040000 | ||
196 | 228 | ||
197 | /* Options set by nand scan */ | 229 | /* Options set by nand scan */ |
198 | /* Nand scan has allocated oob_buf */ | 230 | /* Nand scan has allocated oob_buf */ |
@@ -221,10 +253,13 @@ struct nand_chip; | |||
221 | * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independend devices | 253 | * struct nand_hw_control - Control structure for hardware controller (e.g ECC generator) shared among independend devices |
222 | * @lock: protection lock | 254 | * @lock: protection lock |
223 | * @active: the mtd device which holds the controller currently | 255 | * @active: the mtd device which holds the controller currently |
256 | * @wq: wait queue to sleep on if a NAND operation is in progress | ||
257 | * used instead of the per chip wait queue when a hw controller is available | ||
224 | */ | 258 | */ |
225 | struct nand_hw_control { | 259 | struct nand_hw_control { |
226 | spinlock_t lock; | 260 | spinlock_t lock; |
227 | struct nand_chip *active; | 261 | struct nand_chip *active; |
262 | wait_queue_head_t wq; | ||
228 | }; | 263 | }; |
229 | 264 | ||
230 | /** | 265 | /** |
@@ -283,6 +318,8 @@ struct nand_hw_control { | |||
283 | * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial bad block scan | 318 | * @badblock_pattern: [REPLACEABLE] bad block scan pattern used for initial bad block scan |
284 | * @controller: [OPTIONAL] a pointer to a hardware controller structure which is shared among multiple independend devices | 319 | * @controller: [OPTIONAL] a pointer to a hardware controller structure which is shared among multiple independend devices |
285 | * @priv: [OPTIONAL] pointer to private chip date | 320 | * @priv: [OPTIONAL] pointer to private chip date |
321 | * @errstat: [OPTIONAL] hardware specific function to perform additional error status checks | ||
322 | * (determine if errors are correctable) | ||
286 | */ | 323 | */ |
287 | 324 | ||
288 | struct nand_chip { | 325 | struct nand_chip { |
@@ -338,6 +375,7 @@ struct nand_chip { | |||
338 | struct nand_bbt_descr *badblock_pattern; | 375 | struct nand_bbt_descr *badblock_pattern; |
339 | struct nand_hw_control *controller; | 376 | struct nand_hw_control *controller; |
340 | void *priv; | 377 | void *priv; |
378 | int (*errstat)(struct mtd_info *mtd, struct nand_chip *this, int state, int status, int page); | ||
341 | }; | 379 | }; |
342 | 380 | ||
343 | /* | 381 | /* |
@@ -349,6 +387,7 @@ struct nand_chip { | |||
349 | #define NAND_MFR_NATIONAL 0x8f | 387 | #define NAND_MFR_NATIONAL 0x8f |
350 | #define NAND_MFR_RENESAS 0x07 | 388 | #define NAND_MFR_RENESAS 0x07 |
351 | #define NAND_MFR_STMICRO 0x20 | 389 | #define NAND_MFR_STMICRO 0x20 |
390 | #define NAND_MFR_HYNIX 0xad | ||
352 | 391 | ||
353 | /** | 392 | /** |
354 | * struct nand_flash_dev - NAND Flash Device ID Structure | 393 | * struct nand_flash_dev - NAND Flash Device ID Structure |
@@ -459,6 +498,9 @@ extern int nand_update_bbt (struct mtd_info *mtd, loff_t offs); | |||
459 | extern int nand_default_bbt (struct mtd_info *mtd); | 498 | extern int nand_default_bbt (struct mtd_info *mtd); |
460 | extern int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt); | 499 | extern int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt); |
461 | extern int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt); | 500 | extern int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt); |
501 | extern int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | ||
502 | size_t * retlen, u_char * buf, u_char * oob_buf, | ||
503 | struct nand_oobinfo *oobsel, int flags); | ||
462 | 504 | ||
463 | /* | 505 | /* |
464 | * Constants for oob configuration | 506 | * Constants for oob configuration |