nand.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /*
  2. * linux/include/linux/mtd/nand.h
  3. *
  4. * Copyright (c) 2000 David Woodhouse <dwmw2@mvhi.com>
  5. * Steven J. Hill <sjhill@cotw.com>
  6. * Thomas Gleixner <gleixner@autronix.de>
  7. *
  8. * $Id: nand.h,v 1.7 2003/07/24 23:30:46 a0384864 Exp $
  9. *
  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
  12. * published by the Free Software Foundation.
  13. *
  14. * Info:
  15. * Contains standard defines and IDs for NAND flash devices
  16. *
  17. * Changelog:
  18. * 01-31-2000 DMW Created
  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. */
  36. #ifndef __LINUX_MTD_NAND_H
  37. #define __LINUX_MTD_NAND_H
  38. #ifdef CONFIG_NEW_NAND_CODE
  39. #include "nand_new.h"
  40. #else
  41. /*
  42. * Standard NAND flash commands
  43. */
  44. #define NAND_CMD_READ0 0
  45. #define NAND_CMD_READ1 1
  46. #define NAND_CMD_PAGEPROG 0x10
  47. #define NAND_CMD_READOOB 0x50
  48. #define NAND_CMD_ERASE1 0x60
  49. #define NAND_CMD_STATUS 0x70
  50. #define NAND_CMD_SEQIN 0x80
  51. #define NAND_CMD_READID 0x90
  52. #define NAND_CMD_ERASE2 0xd0
  53. #define NAND_CMD_RESET 0xff
  54. /*
  55. * Enumeration for NAND flash chip state
  56. */
  57. typedef enum {
  58. FL_READY,
  59. FL_READING,
  60. FL_WRITING,
  61. FL_ERASING,
  62. FL_SYNCING
  63. } nand_state_t;
  64. /*
  65. * NAND Private Flash Chip Data
  66. *
  67. * Structure overview:
  68. *
  69. * IO_ADDR - address to access the 8 I/O lines of the flash device
  70. *
  71. * hwcontrol - hardwarespecific function for accesing control-lines
  72. *
  73. * dev_ready - hardwarespecific function for accesing device ready/busy line
  74. *
  75. * chip_lock - spinlock used to protect access to this structure
  76. *
  77. * wq - wait queue to sleep on if a NAND operation is in progress
  78. *
  79. * state - give the current state of the NAND device
  80. *
  81. * page_shift - number of address bits in a page (column address bits)
  82. *
  83. * data_buf - data buffer passed to/from MTD user modules
  84. *
  85. * data_cache - data cache for redundant page access and shadow for
  86. * ECC failure
  87. *
  88. * ecc_code_buf - used only for holding calculated or read ECCs for
  89. * a page read or written when ECC is in use
  90. *
  91. * reserved - padding to make structure fall on word boundary if
  92. * when ECC is in use
  93. */
  94. struct Nand {
  95. char floor, chip;
  96. unsigned long curadr;
  97. unsigned char curmode;
  98. /* Also some erase/write/pipeline info when we get that far */
  99. };
  100. struct nand_chip {
  101. int page_shift;
  102. u_char *data_buf;
  103. u_char *data_cache;
  104. int cache_page;
  105. u_char ecc_code_buf[6];
  106. u_char reserved[2];
  107. char ChipID; /* Type of DiskOnChip */
  108. struct Nand *chips;
  109. int chipshift;
  110. char* chips_name;
  111. unsigned long erasesize;
  112. unsigned long mfr; /* Flash IDs - only one type of flash per device */
  113. unsigned long id;
  114. char* name;
  115. int numchips;
  116. char page256;
  117. char pageadrlen;
  118. unsigned long IO_ADDR; /* address to access the 8 I/O lines to the flash device */
  119. unsigned long totlen;
  120. uint oobblock; /* Size of OOB blocks (e.g. 512) */
  121. uint oobsize; /* Amount of OOB data per block (e.g. 16) */
  122. uint eccsize;
  123. int bus16;
  124. };
  125. /*
  126. * NAND Flash Manufacturer ID Codes
  127. */
  128. #define NAND_MFR_TOSHIBA 0x98
  129. #define NAND_MFR_SAMSUNG 0xec
  130. /*
  131. * NAND Flash Device ID Structure
  132. *
  133. * Structure overview:
  134. *
  135. * name - Complete name of device
  136. *
  137. * manufacture_id - manufacturer ID code of device.
  138. *
  139. * model_id - model ID code of device.
  140. *
  141. * chipshift - total number of address bits for the device which
  142. * is used to calculate address offsets and the total
  143. * number of bytes the device is capable of.
  144. *
  145. * page256 - denotes if flash device has 256 byte pages or not.
  146. *
  147. * pageadrlen - number of bytes minus one needed to hold the
  148. * complete address into the flash array. Keep in
  149. * mind that when a read or write is done to a
  150. * specific address, the address is input serially
  151. * 8 bits at a time. This structure member is used
  152. * by the read/write routines as a loop index for
  153. * shifting the address out 8 bits at a time.
  154. *
  155. * erasesize - size of an erase block in the flash device.
  156. */
  157. struct nand_flash_dev {
  158. char * name;
  159. int manufacture_id;
  160. int model_id;
  161. int chipshift;
  162. char page256;
  163. char pageadrlen;
  164. unsigned long erasesize;
  165. int bus16;
  166. };
  167. /*
  168. * Constants for oob configuration
  169. */
  170. #define NAND_NOOB_ECCPOS0 0
  171. #define NAND_NOOB_ECCPOS1 1
  172. #define NAND_NOOB_ECCPOS2 2
  173. #define NAND_NOOB_ECCPOS3 3
  174. #define NAND_NOOB_ECCPOS4 6
  175. #define NAND_NOOB_ECCPOS5 7
  176. #define NAND_NOOB_BADBPOS -1
  177. #define NAND_NOOB_ECCVPOS -1
  178. #define NAND_JFFS2_OOB_ECCPOS0 0
  179. #define NAND_JFFS2_OOB_ECCPOS1 1
  180. #define NAND_JFFS2_OOB_ECCPOS2 2
  181. #define NAND_JFFS2_OOB_ECCPOS3 3
  182. #define NAND_JFFS2_OOB_ECCPOS4 6
  183. #define NAND_JFFS2_OOB_ECCPOS5 7
  184. #define NAND_JFFS2_OOB_BADBPOS 5
  185. #define NAND_JFFS2_OOB_ECCVPOS 4
  186. #define NAND_JFFS2_OOB8_FSDAPOS 6
  187. #define NAND_JFFS2_OOB16_FSDAPOS 8
  188. #define NAND_JFFS2_OOB8_FSDALEN 2
  189. #define NAND_JFFS2_OOB16_FSDALEN 8
  190. unsigned long nand_probe(unsigned long physadr);
  191. #endif /* !CONFIG_NEW_NAND_CODE */
  192. #endif /* __LINUX_MTD_NAND_H */