doc2000.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /* Linux driver for Disk-On-Chip 2000 */
  2. /* (c) 1999 Machine Vision Holdings, Inc. */
  3. /* Author: David Woodhouse <dwmw2@mvhi.com> */
  4. /* $Id: doc2000.h,v 1.15 2001/09/19 00:22:15 dwmw2 Exp $ */
  5. #ifndef __MTD_DOC2000_H__
  6. #define __MTD_DOC2000_H__
  7. struct DiskOnChip;
  8. #include <linux/mtd/nftl.h>
  9. #define DoC_Sig1 0
  10. #define DoC_Sig2 1
  11. #define DoC_ChipID 0x1000
  12. #define DoC_DOCStatus 0x1001
  13. #define DoC_DOCControl 0x1002
  14. #define DoC_FloorSelect 0x1003
  15. #define DoC_CDSNControl 0x1004
  16. #define DoC_CDSNDeviceSelect 0x1005
  17. #define DoC_ECCConf 0x1006
  18. #define DoC_2k_ECCStatus 0x1007
  19. #define DoC_CDSNSlowIO 0x100d
  20. #define DoC_ECCSyndrome0 0x1010
  21. #define DoC_ECCSyndrome1 0x1011
  22. #define DoC_ECCSyndrome2 0x1012
  23. #define DoC_ECCSyndrome3 0x1013
  24. #define DoC_ECCSyndrome4 0x1014
  25. #define DoC_ECCSyndrome5 0x1015
  26. #define DoC_AliasResolution 0x101b
  27. #define DoC_ConfigInput 0x101c
  28. #define DoC_ReadPipeInit 0x101d
  29. #define DoC_WritePipeTerm 0x101e
  30. #define DoC_LastDataRead 0x101f
  31. #define DoC_NOP 0x1020
  32. #define DoC_Mil_CDSN_IO 0x0800
  33. #define DoC_2k_CDSN_IO 0x1800
  34. #define ReadDOC_(adr, reg) ((volatile unsigned char)(*(volatile __u8 *)(((unsigned long)adr)+((reg)))))
  35. #define WriteDOC_(d, adr, reg) do{ *(volatile __u8 *)(((unsigned long)adr)+((reg))) = (__u8)d; eieio();} while(0)
  36. #define DOC_IOREMAP_LEN 0x4000
  37. /* These are provided to directly use the DoC_xxx defines */
  38. #define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg)
  39. #define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg)
  40. #define DOC_MODE_RESET 0
  41. #define DOC_MODE_NORMAL 1
  42. #define DOC_MODE_RESERVED1 2
  43. #define DOC_MODE_RESERVED2 3
  44. #define DOC_MODE_MDWREN 4
  45. #define DOC_MODE_CLR_ERR 0x80
  46. #define DOC_ChipID_UNKNOWN 0x00
  47. #define DOC_ChipID_Doc2k 0x20
  48. #define DOC_ChipID_DocMil 0x30
  49. #define CDSN_CTRL_FR_B 0x80
  50. #define CDSN_CTRL_ECC_IO 0x20
  51. #define CDSN_CTRL_FLASH_IO 0x10
  52. #define CDSN_CTRL_WP 0x08
  53. #define CDSN_CTRL_ALE 0x04
  54. #define CDSN_CTRL_CLE 0x02
  55. #define CDSN_CTRL_CE 0x01
  56. #define DOC_ECC_RESET 0
  57. #define DOC_ECC_ERROR 0x80
  58. #define DOC_ECC_RW 0x20
  59. #define DOC_ECC__EN 0x08
  60. #define DOC_TOGGLE_BIT 0x04
  61. #define DOC_ECC_RESV 0x02
  62. #define DOC_ECC_IGNORE 0x01
  63. /* We have to also set the reserved bit 1 for enable */
  64. #define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV)
  65. #define DOC_ECC_DIS (DOC_ECC_RESV)
  66. #define MAX_FLOORS 4
  67. #define MAX_CHIPS 4
  68. #define MAX_FLOORS_MIL 4
  69. #define MAX_CHIPS_MIL 1
  70. #define ADDR_COLUMN 1
  71. #define ADDR_PAGE 2
  72. #define ADDR_COLUMN_PAGE 3
  73. struct Nand {
  74. char floor, chip;
  75. unsigned long curadr;
  76. unsigned char curmode;
  77. /* Also some erase/write/pipeline info when we get that far */
  78. };
  79. struct DiskOnChip {
  80. unsigned long physadr;
  81. unsigned long virtadr;
  82. unsigned long totlen;
  83. char* name;
  84. char ChipID; /* Type of DiskOnChip */
  85. int ioreg;
  86. char* chips_name;
  87. unsigned long mfr; /* Flash IDs - only one type of flash per device */
  88. unsigned long id;
  89. int chipshift;
  90. char page256;
  91. char pageadrlen;
  92. unsigned long erasesize;
  93. int curfloor;
  94. int curchip;
  95. int numchips;
  96. struct Nand *chips;
  97. int nftl_found;
  98. struct NFTLrecord nftl;
  99. };
  100. #define SECTORSIZE 512
  101. /* Return codes from doc_write(), doc_read(), and doc_erase().
  102. */
  103. #define DOC_OK 0
  104. #define DOC_EIO 1
  105. #define DOC_EINVAL 2
  106. #define DOC_EECC 3
  107. #define DOC_ETIMEOUT 4
  108. /*
  109. * Function Prototypes
  110. */
  111. int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);
  112. int doc_rw(struct DiskOnChip* this, int cmd, loff_t from, size_t len,
  113. size_t *retlen, u_char *buf);
  114. int doc_read_ecc(struct DiskOnChip* this, loff_t from, size_t len,
  115. size_t *retlen, u_char *buf, u_char *eccbuf);
  116. int doc_write_ecc(struct DiskOnChip* this, loff_t to, size_t len,
  117. size_t *retlen, const u_char *buf, u_char *eccbuf);
  118. int doc_read_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
  119. size_t *retlen, u_char *buf);
  120. int doc_write_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
  121. size_t *retlen, const u_char *buf);
  122. int doc_erase (struct DiskOnChip* this, loff_t ofs, size_t len);
  123. void doc_probe(unsigned long physadr);
  124. void doc_print(struct DiskOnChip*);
  125. /*
  126. * Standard NAND flash commands
  127. */
  128. #define NAND_CMD_READ0 0
  129. #define NAND_CMD_READ1 1
  130. #define NAND_CMD_PAGEPROG 0x10
  131. #define NAND_CMD_READOOB 0x50
  132. #define NAND_CMD_ERASE1 0x60
  133. #define NAND_CMD_STATUS 0x70
  134. #define NAND_CMD_SEQIN 0x80
  135. #define NAND_CMD_READID 0x90
  136. #define NAND_CMD_ERASE2 0xd0
  137. #define NAND_CMD_RESET 0xff
  138. /*
  139. * NAND Flash Manufacturer ID Codes
  140. */
  141. #define NAND_MFR_TOSHIBA 0x98
  142. #define NAND_MFR_SAMSUNG 0xec
  143. /*
  144. * NAND Flash Device ID Structure
  145. *
  146. * Structure overview:
  147. *
  148. * name - Complete name of device
  149. *
  150. * manufacture_id - manufacturer ID code of device.
  151. *
  152. * model_id - model ID code of device.
  153. *
  154. * chipshift - total number of address bits for the device which
  155. * is used to calculate address offsets and the total
  156. * number of bytes the device is capable of.
  157. *
  158. * page256 - denotes if flash device has 256 byte pages or not.
  159. *
  160. * pageadrlen - number of bytes minus one needed to hold the
  161. * complete address into the flash array. Keep in
  162. * mind that when a read or write is done to a
  163. * specific address, the address is input serially
  164. * 8 bits at a time. This structure member is used
  165. * by the read/write routines as a loop index for
  166. * shifting the address out 8 bits at a time.
  167. *
  168. * erasesize - size of an erase block in the flash device.
  169. */
  170. struct nand_flash_dev {
  171. char * name;
  172. int manufacture_id;
  173. int model_id;
  174. int chipshift;
  175. char page256;
  176. char pageadrlen;
  177. unsigned long erasesize;
  178. int bus16;
  179. };
  180. #endif /* __MTD_DOC2000_H__ */