diff options
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 104 | ||||
-rw-r--r-- | include/linux/mtd/nand.h | 103 |
2 files changed, 96 insertions, 111 deletions
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 7933ca273c95..6ef1893996ce 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -10,7 +10,7 @@ | |||
10 | * http://www.linux-mtd.infradead.org/tech/nand.html | 10 | * http://www.linux-mtd.infradead.org/tech/nand.html |
11 | * | 11 | * |
12 | * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) | 12 | * Copyright (C) 2000 Steven J. Hill (sjhill@realitydiluted.com) |
13 | * 2002 Thomas Gleixner (tglx@linutronix.de) | 13 | * 2002 Thomas Gleixner (tglx@linutronix.de) |
14 | * | 14 | * |
15 | * 02-08-2004 tglx: support for strange chips, which cannot auto increment | 15 | * 02-08-2004 tglx: support for strange chips, which cannot auto increment |
16 | * pages on read / read_oob | 16 | * pages on read / read_oob |
@@ -25,26 +25,30 @@ | |||
25 | * 05-19-2004 tglx: Basic support for Renesas AG-AND chips | 25 | * 05-19-2004 tglx: Basic support for Renesas AG-AND chips |
26 | * | 26 | * |
27 | * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared | 27 | * 09-24-2004 tglx: add support for hardware controllers (e.g. ECC) shared |
28 | * among multiple independend devices. Suggestions and initial patch | 28 | * among multiple independend devices. Suggestions and initial |
29 | * from Ben Dooks <ben-mtd@fluff.org> | 29 | * patch from Ben Dooks <ben-mtd@fluff.org> |
30 | * | 30 | * |
31 | * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" issue. | 31 | * 12-05-2004 dmarlin: add workaround for Renesas AG-AND chips "disturb" |
32 | * Basically, any block not rewritten may lose data when surrounding blocks | 32 | * issue. Basically, any block not rewritten may lose data when |
33 | * are rewritten many times. JFFS2 ensures this doesn't happen for blocks | 33 | * surrounding blocks are rewritten many times. JFFS2 ensures |
34 | * it uses, but the Bad Block Table(s) may not be rewritten. To ensure they | 34 | * this doesn't happen for blocks it uses, but the Bad Block |
35 | * do not lose data, force them to be rewritten when some of the surrounding | 35 | * Table(s) may not be rewritten. To ensure they do not lose |
36 | * blocks are erased. Rather than tracking a specific nearby block (which | 36 | * data, force them to be rewritten when some of the surrounding |
37 | * could itself go bad), use a page address 'mask' to select several blocks | 37 | * blocks are erased. Rather than tracking a specific nearby |
38 | * in the same area, and rewrite the BBT when any of them are erased. | 38 | * block (which could itself go bad), use a page address 'mask' to |
39 | * | 39 | * select several blocks in the same area, and rewrite the BBT |
40 | * 01-03-2005 dmarlin: added support for the device recovery command sequence for Renesas | 40 | * when any of them are erased. |
41 | * AG-AND chips. If there was a sudden loss of power during an erase operation, | 41 | * |
42 | * a "device recovery" operation must be performed when power is restored | 42 | * 01-03-2005 dmarlin: added support for the device recovery command sequence |
43 | * to ensure correct operation. | 43 | * for Renesas AG-AND chips. If there was a sudden loss of power |
44 | * | 44 | * during an erase operation, a "device recovery" operation must |
45 | * 01-20-2005 dmarlin: added support for optional hardware specific callback routine to | 45 | * be performed when power is restored to ensure correct |
46 | * perform extra error status checks on erase and write failures. This required | 46 | * operation. |
47 | * adding a wrapper function for nand_read_ecc. | 47 | * |
48 | * 01-20-2005 dmarlin: added support for optional hardware specific callback | ||
49 | * routine to perform extra error status checks on erase and write | ||
50 | * failures. This required adding a wrapper function for | ||
51 | * nand_read_ecc. | ||
48 | * | 52 | * |
49 | * 08-20-2005 vwool: suspend/resume added | 53 | * 08-20-2005 vwool: suspend/resume added |
50 | * | 54 | * |
@@ -132,32 +136,43 @@ static void nand_write_buf(struct mtd_info *mtd, const u_char *buf, int len); | |||
132 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); | 136 | static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len); |
133 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); | 137 | static int nand_verify_buf(struct mtd_info *mtd, const u_char *buf, int len); |
134 | 138 | ||
135 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); | 139 | static int nand_read(struct mtd_info *mtd, loff_t from, size_t len, |
140 | size_t *retlen, u_char *buf); | ||
136 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, | 141 | static int nand_read_ecc(struct mtd_info *mtd, loff_t from, size_t len, |
137 | size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); | 142 | size_t *retlen, u_char *buf, u_char *eccbuf, |
138 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf); | 143 | struct nand_oobinfo *oobsel); |
139 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); | 144 | static int nand_read_oob(struct mtd_info *mtd, loff_t from, size_t len, |
145 | size_t *retlen, u_char *buf); | ||
146 | static int nand_write(struct mtd_info *mtd, loff_t to, size_t len, | ||
147 | size_t *retlen, const u_char *buf); | ||
140 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, | 148 | static int nand_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, |
141 | size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel); | 149 | size_t *retlen, const u_char *buf, u_char *eccbuf, |
142 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf); | 150 | struct nand_oobinfo *oobsel); |
143 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, unsigned long count, loff_t to, size_t *retlen); | 151 | static int nand_write_oob(struct mtd_info *mtd, loff_t to, size_t len, |
152 | size_t *retlen, const u_char *buf); | ||
153 | static int nand_writev(struct mtd_info *mtd, const struct kvec *vecs, | ||
154 | unsigned long count, loff_t to, size_t *retlen); | ||
144 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, | 155 | static int nand_writev_ecc(struct mtd_info *mtd, const struct kvec *vecs, |
145 | unsigned long count, loff_t to, size_t *retlen, u_char *eccbuf, | 156 | unsigned long count, loff_t to, size_t *retlen, |
146 | struct nand_oobinfo *oobsel); | 157 | u_char *eccbuf, struct nand_oobinfo *oobsel); |
147 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); | 158 | static int nand_erase(struct mtd_info *mtd, struct erase_info *instr); |
148 | static void nand_sync(struct mtd_info *mtd); | 159 | static void nand_sync(struct mtd_info *mtd); |
149 | 160 | ||
150 | /* Some internal functions */ | 161 | /* Some internal functions */ |
151 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int page, u_char * oob_buf, | 162 | static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, |
163 | int page, u_char * oob_buf, | ||
152 | struct nand_oobinfo *oobsel, int mode); | 164 | struct nand_oobinfo *oobsel, int mode); |
153 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE | 165 | #ifdef CONFIG_MTD_NAND_VERIFY_WRITE |
154 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, int page, int numpages, | 166 | static int nand_verify_pages(struct mtd_info *mtd, struct nand_chip *this, |
155 | u_char *oob_buf, struct nand_oobinfo *oobsel, int chipnr, int oobmode); | 167 | int page, int numpages, u_char *oob_buf, |
168 | struct nand_oobinfo *oobsel, int chipnr, | ||
169 | int oobmode); | ||
156 | #else | 170 | #else |
157 | #define nand_verify_pages(...) (0) | 171 | #define nand_verify_pages(...) (0) |
158 | #endif | 172 | #endif |
159 | 173 | ||
160 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state); | 174 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, |
175 | int new_state); | ||
161 | 176 | ||
162 | /** | 177 | /** |
163 | * nand_release_device - [GENERIC] release chip | 178 | * nand_release_device - [GENERIC] release chip |
@@ -424,14 +439,16 @@ static int nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip) | |||
424 | page = (int)ofs; | 439 | page = (int)ofs; |
425 | 440 | ||
426 | if (this->options & NAND_BUSWIDTH_16) { | 441 | if (this->options & NAND_BUSWIDTH_16) { |
427 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, page & this->pagemask); | 442 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos & 0xFE, |
443 | page & this->pagemask); | ||
428 | bad = cpu_to_le16(this->read_word(mtd)); | 444 | bad = cpu_to_le16(this->read_word(mtd)); |
429 | if (this->badblockpos & 0x1) | 445 | if (this->badblockpos & 0x1) |
430 | bad >>= 8; | 446 | bad >>= 8; |
431 | if ((bad & 0xFF) != 0xff) | 447 | if ((bad & 0xFF) != 0xff) |
432 | res = 1; | 448 | res = 1; |
433 | } else { | 449 | } else { |
434 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, page & this->pagemask); | 450 | this->cmdfunc(mtd, NAND_CMD_READOOB, this->badblockpos, |
451 | page & this->pagemask); | ||
435 | if (this->read_byte(mtd) != 0xff) | 452 | if (this->read_byte(mtd) != 0xff) |
436 | res = 1; | 453 | res = 1; |
437 | } | 454 | } |
@@ -498,7 +515,8 @@ static int nand_check_wp(struct mtd_info *mtd) | |||
498 | * Check, if the block is bad. Either by reading the bad block table or | 515 | * Check, if the block is bad. Either by reading the bad block table or |
499 | * calling of the scan function. | 516 | * calling of the scan function. |
500 | */ | 517 | */ |
501 | static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, int allowbbt) | 518 | static int nand_block_checkbad(struct mtd_info *mtd, loff_t ofs, int getchip, |
519 | int allowbbt) | ||
502 | { | 520 | { |
503 | struct nand_chip *this = mtd->priv; | 521 | struct nand_chip *this = mtd->priv; |
504 | 522 | ||
@@ -540,7 +558,8 @@ static void nand_wait_ready(struct mtd_info *mtd) | |||
540 | * Send command to NAND device. This function is used for small page | 558 | * Send command to NAND device. This function is used for small page |
541 | * devices (256/512 Bytes per page) | 559 | * devices (256/512 Bytes per page) |
542 | */ | 560 | */ |
543 | static void nand_command(struct mtd_info *mtd, unsigned command, int column, int page_addr) | 561 | static void nand_command(struct mtd_info *mtd, unsigned command, int column, |
562 | int page_addr) | ||
544 | { | 563 | { |
545 | register struct nand_chip *this = mtd->priv; | 564 | register struct nand_chip *this = mtd->priv; |
546 | 565 | ||
@@ -755,7 +774,8 @@ static void nand_command_lp(struct mtd_info *mtd, unsigned command, int column, | |||
755 | * | 774 | * |
756 | * Get the device and lock it for exclusive access | 775 | * Get the device and lock it for exclusive access |
757 | */ | 776 | */ |
758 | static int nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) | 777 | static int |
778 | nand_get_device(struct nand_chip *this, struct mtd_info *mtd, int new_state) | ||
759 | { | 779 | { |
760 | spinlock_t *lock = &this->controller->lock; | 780 | spinlock_t *lock = &this->controller->lock; |
761 | wait_queue_head_t *wq = &this->controller->wq; | 781 | wait_queue_head_t *wq = &this->controller->wq; |
@@ -942,7 +962,7 @@ static int nand_write_page(struct mtd_info *mtd, struct nand_chip *this, int pag | |||
942 | * nand_verify_pages - [GENERIC] verify the chip contents after a write | 962 | * nand_verify_pages - [GENERIC] verify the chip contents after a write |
943 | * @mtd: MTD device structure | 963 | * @mtd: MTD device structure |
944 | * @this: NAND chip structure | 964 | * @this: NAND chip structure |
945 | * @page: startpage inside the chip, must be called with (page & this->pagemask) | 965 | * @page: startpage inside the chip, must be called with (page & this->pagemask) |
946 | * @numpages: number of pages to verify | 966 | * @numpages: number of pages to verify |
947 | * @oob_buf: out of band data buffer | 967 | * @oob_buf: out of band data buffer |
948 | * @oobsel: out of band selecttion structre | 968 | * @oobsel: out of band selecttion structre |
@@ -2293,8 +2313,8 @@ static void nand_resume(struct mtd_info *mtd) | |||
2293 | if (this->state == FL_PM_SUSPENDED) | 2313 | if (this->state == FL_PM_SUSPENDED) |
2294 | nand_release_device(mtd); | 2314 | nand_release_device(mtd); |
2295 | else | 2315 | else |
2296 | printk(KERN_ERR "resume() called for the chip which is not in suspended state\n"); | 2316 | printk(KERN_ERR "nand_resume() called for a chip which is not " |
2297 | 2317 | "in suspended state\n"); | |
2298 | } | 2318 | } |
2299 | 2319 | ||
2300 | /* | 2320 | /* |
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h index 05c6ecc07036..014ceefbec0e 100644 --- a/include/linux/mtd/nand.h +++ b/include/linux/mtd/nand.h | |||
@@ -11,47 +11,11 @@ | |||
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 |
12 | * published by the Free Software Foundation. | 12 | * published by the Free Software Foundation. |
13 | * | 13 | * |
14 | * Info: | 14 | * Info: |
15 | * Contains standard defines and IDs for NAND flash devices | 15 | * Contains standard defines and IDs for NAND flash devices |
16 | * | 16 | * |
17 | * Changelog: | 17 | * Changelog: |
18 | * 01-31-2000 DMW Created | 18 | * See git changelog. |
19 | * 09-18-2000 SJH Moved structure out of the Disk-On-Chip drivers | ||
20 | * so it can be used by other NAND flash device | ||
21 | * drivers. I also changed the copyright since none | ||
22 | * of the original contents of this file are specific | ||
23 | * to DoC devices. David can whack me with a baseball | ||
24 | * bat later if I did something naughty. | ||
25 | * 10-11-2000 SJH Added private NAND flash structure for driver | ||
26 | * 10-24-2000 SJH Added prototype for 'nand_scan' function | ||
27 | * 10-29-2001 TG changed nand_chip structure to support | ||
28 | * hardwarespecific function for accessing control lines | ||
29 | * 02-21-2002 TG added support for different read/write adress and | ||
30 | * ready/busy line access function | ||
31 | * 02-26-2002 TG added chip_delay to nand_chip structure to optimize | ||
32 | * command delay times for different chips | ||
33 | * 04-28-2002 TG OOB config defines moved from nand.c to avoid duplicate | ||
34 | * defines in jffs2/wbuf.c | ||
35 | * 08-07-2002 TG forced bad block location to byte 5 of OOB, even if | ||
36 | * CONFIG_MTD_NAND_ECC_JFFS2 is not set | ||
37 | * 08-10-2002 TG extensions to nand_chip structure to support HW-ECC | ||
38 | * | ||
39 | * 08-29-2002 tglx nand_chip structure: data_poi for selecting | ||
40 | * internal / fs-driver buffer | ||
41 | * support for 6byte/512byte hardware ECC | ||
42 | * read_ecc, write_ecc extended for different oob-layout | ||
43 | * oob layout selections: NAND_NONE_OOB, NAND_JFFS2_OOB, | ||
44 | * NAND_YAFFS_OOB | ||
45 | * 11-25-2002 tglx Added Manufacturer code FUJITSU, NATIONAL | ||
46 | * Split manufacturer and device ID structures | ||
47 | * | ||
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 | ||
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. | ||
55 | */ | 19 | */ |
56 | #ifndef __LINUX_MTD_NAND_H | 20 | #ifndef __LINUX_MTD_NAND_H |
57 | #define __LINUX_MTD_NAND_H | 21 | #define __LINUX_MTD_NAND_H |
@@ -68,7 +32,8 @@ extern int nand_scan (struct mtd_info *mtd, int max_chips); | |||
68 | extern void nand_release (struct mtd_info *mtd); | 32 | extern void nand_release (struct mtd_info *mtd); |
69 | 33 | ||
70 | /* Read raw data from the device without ECC */ | 34 | /* Read raw data from the device without ECC */ |
71 | extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_t len, size_t ooblen); | 35 | extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, |
36 | size_t len, size_t ooblen); | ||
72 | 37 | ||
73 | 38 | ||
74 | /* The maximum number of NAND chips in an array */ | 39 | /* The maximum number of NAND chips in an array */ |
@@ -84,7 +49,7 @@ extern int nand_read_raw (struct mtd_info *mtd, uint8_t *buf, loff_t from, size_ | |||
84 | * Constants for hardware specific CLE/ALE/NCE function | 49 | * Constants for hardware specific CLE/ALE/NCE function |
85 | */ | 50 | */ |
86 | /* Select the chip by setting nCE to low */ | 51 | /* Select the chip by setting nCE to low */ |
87 | #define NAND_CTL_SETNCE 1 | 52 | #define NAND_CTL_SETNCE 1 |
88 | /* Deselect the chip by setting nCE to high */ | 53 | /* Deselect the chip by setting nCE to high */ |
89 | #define NAND_CTL_CLRNCE 2 | 54 | #define NAND_CTL_CLRNCE 2 |
90 | /* Select the command latch by setting CLE to high */ | 55 | /* Select the command latch by setting CLE to high */ |
@@ -285,19 +250,19 @@ struct nand_hw_control { | |||
285 | * is read from the chip status register | 250 | * is read from the chip status register |
286 | * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip | 251 | * @cmdfunc: [REPLACEABLE] hardwarespecific function for writing commands to the chip |
287 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready | 252 | * @waitfunc: [REPLACEABLE] hardwarespecific function for wait on ready |
288 | * @calculate_ecc: [REPLACEABLE] function for ecc calculation or readback from ecc hardware | 253 | * @calculate_ecc: [REPLACEABLE] function for ecc calculation or readback from ecc hardware |
289 | * @correct_data: [REPLACEABLE] function for ecc correction, matching to ecc generator (sw/hw) | 254 | * @correct_data: [REPLACEABLE] function for ecc correction, matching to ecc generator (sw/hw) |
290 | * @enable_hwecc: [BOARDSPECIFIC] function to enable (reset) hardware ecc generator. Must only | 255 | * @enable_hwecc: [BOARDSPECIFIC] function to enable (reset) hardware ecc generator. Must only |
291 | * be provided if a hardware ECC is available | 256 | * be provided if a hardware ECC is available |
292 | * @erase_cmd: [INTERN] erase command write function, selectable due to AND support | 257 | * @erase_cmd: [INTERN] erase command write function, selectable due to AND support |
293 | * @scan_bbt: [REPLACEABLE] function to scan bad block table | 258 | * @scan_bbt: [REPLACEABLE] function to scan bad block table |
294 | * @eccmode: [BOARDSPECIFIC] mode of ecc, see defines | 259 | * @eccmode: [BOARDSPECIFIC] mode of ecc, see defines |
295 | * @eccsize: [INTERN] databytes used per ecc-calculation | 260 | * @eccsize: [INTERN] databytes used per ecc-calculation |
296 | * @eccbytes: [INTERN] number of ecc bytes per ecc-calculation step | 261 | * @eccbytes: [INTERN] number of ecc bytes per ecc-calculation step |
297 | * @eccsteps: [INTERN] number of ecc calculation steps per page | 262 | * @eccsteps: [INTERN] number of ecc calculation steps per page |
298 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) | 263 | * @chip_delay: [BOARDSPECIFIC] chip dependent delay for transfering data from array to read regs (tR) |
299 | * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress | 264 | * @wq: [INTERN] wait queue to sleep on if a NAND operation is in progress |
300 | * @state: [INTERN] the current state of the NAND device | 265 | * @state: [INTERN] the current state of the NAND device |
301 | * @page_shift: [INTERN] number of address bits in a page (column address bits) | 266 | * @page_shift: [INTERN] number of address bits in a page (column address bits) |
302 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock | 267 | * @phys_erase_shift: [INTERN] number of address bits in a physical eraseblock |
303 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry | 268 | * @bbt_erase_shift: [INTERN] number of address bits in a bbt entry |
@@ -327,7 +292,7 @@ struct nand_hw_control { | |||
327 | 292 | ||
328 | struct nand_chip { | 293 | struct nand_chip { |
329 | void __iomem *IO_ADDR_R; | 294 | void __iomem *IO_ADDR_R; |
330 | void __iomem *IO_ADDR_W; | 295 | void __iomem *IO_ADDR_W; |
331 | 296 | ||
332 | u_char (*read_byte)(struct mtd_info *mtd); | 297 | u_char (*read_byte)(struct mtd_info *mtd); |
333 | void (*write_byte)(struct mtd_info *mtd, u_char byte); | 298 | void (*write_byte)(struct mtd_info *mtd, u_char byte); |
@@ -340,12 +305,12 @@ struct nand_chip { | |||
340 | void (*select_chip)(struct mtd_info *mtd, int chip); | 305 | void (*select_chip)(struct mtd_info *mtd, int chip); |
341 | int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); | 306 | int (*block_bad)(struct mtd_info *mtd, loff_t ofs, int getchip); |
342 | int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); | 307 | int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); |
343 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); | 308 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); |
344 | int (*dev_ready)(struct mtd_info *mtd); | 309 | int (*dev_ready)(struct mtd_info *mtd); |
345 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); | 310 | void (*cmdfunc)(struct mtd_info *mtd, unsigned command, int column, int page_addr); |
346 | int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); | 311 | int (*waitfunc)(struct mtd_info *mtd, struct nand_chip *this, int state); |
347 | int (*calculate_ecc)(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); | 312 | int (*calculate_ecc)(struct mtd_info *mtd, const u_char *dat, u_char *ecc_code); |
348 | int (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); | 313 | int (*correct_data)(struct mtd_info *mtd, u_char *dat, u_char *read_ecc, u_char *calc_ecc); |
349 | void (*enable_hwecc)(struct mtd_info *mtd, int mode); | 314 | void (*enable_hwecc)(struct mtd_info *mtd, int mode); |
350 | void (*erase_cmd)(struct mtd_info *mtd, int page); | 315 | void (*erase_cmd)(struct mtd_info *mtd, int page); |
351 | int (*scan_bbt)(struct mtd_info *mtd); | 316 | int (*scan_bbt)(struct mtd_info *mtd); |
@@ -353,14 +318,14 @@ struct nand_chip { | |||
353 | int eccsize; | 318 | int eccsize; |
354 | int eccbytes; | 319 | int eccbytes; |
355 | int eccsteps; | 320 | int eccsteps; |
356 | int chip_delay; | 321 | int chip_delay; |
357 | wait_queue_head_t wq; | 322 | wait_queue_head_t wq; |
358 | nand_state_t state; | 323 | nand_state_t state; |
359 | int page_shift; | 324 | int page_shift; |
360 | int phys_erase_shift; | 325 | int phys_erase_shift; |
361 | int bbt_erase_shift; | 326 | int bbt_erase_shift; |
362 | int chip_shift; | 327 | int chip_shift; |
363 | u_char *data_buf; | 328 | u_char *data_buf; |
364 | u_char *oob_buf; | 329 | u_char *oob_buf; |
365 | int oobdirty; | 330 | int oobdirty; |
366 | u_char *data_poi; | 331 | u_char *data_poi; |
@@ -389,19 +354,19 @@ struct nand_chip { | |||
389 | #define NAND_MFR_NATIONAL 0x8f | 354 | #define NAND_MFR_NATIONAL 0x8f |
390 | #define NAND_MFR_RENESAS 0x07 | 355 | #define NAND_MFR_RENESAS 0x07 |
391 | #define NAND_MFR_STMICRO 0x20 | 356 | #define NAND_MFR_STMICRO 0x20 |
392 | #define NAND_MFR_HYNIX 0xad | 357 | #define NAND_MFR_HYNIX 0xad |
393 | 358 | ||
394 | /** | 359 | /** |
395 | * struct nand_flash_dev - NAND Flash Device ID Structure | 360 | * struct nand_flash_dev - NAND Flash Device ID Structure |
396 | * | 361 | * |
397 | * @name: Identify the device type | 362 | * @name: Identify the device type |
398 | * @id: device ID code | 363 | * @id: device ID code |
399 | * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 | 364 | * @pagesize: Pagesize in bytes. Either 256 or 512 or 0 |
400 | * If the pagesize is 0, then the real pagesize | 365 | * If the pagesize is 0, then the real pagesize |
401 | * and the eraseize are determined from the | 366 | * and the eraseize are determined from the |
402 | * extended id bytes in the chip | 367 | * extended id bytes in the chip |
403 | * @erasesize: Size of an erase block in the flash device. | 368 | * @erasesize: Size of an erase block in the flash device. |
404 | * @chipsize: Total chipsize in Mega Bytes | 369 | * @chipsize: Total chipsize in Mega Bytes |
405 | * @options: Bitfield to store chip relevant options | 370 | * @options: Bitfield to store chip relevant options |
406 | */ | 371 | */ |
407 | struct nand_flash_dev { | 372 | struct nand_flash_dev { |
@@ -416,7 +381,7 @@ struct nand_flash_dev { | |||
416 | /** | 381 | /** |
417 | * struct nand_manufacturers - NAND Flash Manufacturer ID Structure | 382 | * struct nand_manufacturers - NAND Flash Manufacturer ID Structure |
418 | * @name: Manufacturer name | 383 | * @name: Manufacturer name |
419 | * @id: manufacturer ID code of device. | 384 | * @id: manufacturer ID code of device. |
420 | */ | 385 | */ |
421 | struct nand_manufacturers { | 386 | struct nand_manufacturers { |
422 | int id; | 387 | int id; |
@@ -456,7 +421,7 @@ struct nand_bbt_descr { | |||
456 | int veroffs; | 421 | int veroffs; |
457 | uint8_t version[NAND_MAX_CHIPS]; | 422 | uint8_t version[NAND_MAX_CHIPS]; |
458 | int len; | 423 | int len; |
459 | int maxblocks; | 424 | int maxblocks; |
460 | int reserved_block_code; | 425 | int reserved_block_code; |
461 | uint8_t *pattern; | 426 | uint8_t *pattern; |
462 | }; | 427 | }; |
@@ -501,8 +466,8 @@ extern int nand_default_bbt (struct mtd_info *mtd); | |||
501 | extern int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt); | 466 | extern int nand_isbad_bbt (struct mtd_info *mtd, loff_t offs, int allowbbt); |
502 | extern int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt); | 467 | extern int nand_erase_nand (struct mtd_info *mtd, struct erase_info *instr, int allowbbt); |
503 | extern int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, | 468 | extern int nand_do_read_ecc (struct mtd_info *mtd, loff_t from, size_t len, |
504 | size_t * retlen, u_char * buf, u_char * oob_buf, | 469 | size_t * retlen, u_char * buf, u_char * oob_buf, |
505 | struct nand_oobinfo *oobsel, int flags); | 470 | struct nand_oobinfo *oobsel, int flags); |
506 | 471 | ||
507 | /* | 472 | /* |
508 | * Constants for oob configuration | 473 | * Constants for oob configuration |
@@ -526,7 +491,7 @@ struct platform_nand_chip { | |||
526 | int chip_offset; | 491 | int chip_offset; |
527 | int nr_partitions; | 492 | int nr_partitions; |
528 | struct mtd_partition *partitions; | 493 | struct mtd_partition *partitions; |
529 | int chip_delay; | 494 | int chip_delay; |
530 | unsigned int options; | 495 | unsigned int options; |
531 | void *priv; | 496 | void *priv; |
532 | }; | 497 | }; |
@@ -542,8 +507,8 @@ struct platform_nand_chip { | |||
542 | * All fields are optional and depend on the hardware driver requirements | 507 | * All fields are optional and depend on the hardware driver requirements |
543 | */ | 508 | */ |
544 | struct platform_nand_ctrl { | 509 | struct platform_nand_ctrl { |
545 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); | 510 | void (*hwcontrol)(struct mtd_info *mtd, int cmd); |
546 | int (*dev_ready)(struct mtd_info *mtd); | 511 | int (*dev_ready)(struct mtd_info *mtd); |
547 | void (*select_chip)(struct mtd_info *mtd, int chip); | 512 | void (*select_chip)(struct mtd_info *mtd, int chip); |
548 | void *priv; | 513 | void *priv; |
549 | }; | 514 | }; |