2 /* Linux driver for Disk-On-Chip 2000 */
3 /* (c) 1999 Machine Vision Holdings, Inc. */
5 /* $Id: doc2000.h,v 1.15 2001/09/19 00:22:15 dwmw2 Exp $ */
7 #ifndef __MTD_DOC2000_H__
8 #define __MTD_DOC2000_H__
12 #include <linux/mtd/nftl.h>
17 #define DoC_ChipID 0x1000
18 #define DoC_DOCStatus 0x1001
19 #define DoC_DOCControl 0x1002
20 #define DoC_FloorSelect 0x1003
21 #define DoC_CDSNControl 0x1004
22 #define DoC_CDSNDeviceSelect 0x1005
23 #define DoC_ECCConf 0x1006
24 #define DoC_2k_ECCStatus 0x1007
26 #define DoC_CDSNSlowIO 0x100d
27 #define DoC_ECCSyndrome0 0x1010
28 #define DoC_ECCSyndrome1 0x1011
29 #define DoC_ECCSyndrome2 0x1012
30 #define DoC_ECCSyndrome3 0x1013
31 #define DoC_ECCSyndrome4 0x1014
32 #define DoC_ECCSyndrome5 0x1015
33 #define DoC_AliasResolution 0x101b
34 #define DoC_ConfigInput 0x101c
35 #define DoC_ReadPipeInit 0x101d
36 #define DoC_WritePipeTerm 0x101e
37 #define DoC_LastDataRead 0x101f
38 #define DoC_NOP 0x1020
40 #define DoC_Mil_CDSN_IO 0x0800
41 #define DoC_2k_CDSN_IO 0x1800
43 #define ReadDOC_(adr, reg) ((volatile unsigned char)(*(volatile __u8 *)(((unsigned long)adr)+((reg)))))
44 #define WriteDOC_(d, adr, reg) do{ *(volatile __u8 *)(((unsigned long)adr)+((reg))) = (__u8)d; eieio();} while(0)
46 #define DOC_IOREMAP_LEN 0x4000
48 /* These are provided to directly use the DoC_xxx defines */
49 #define ReadDOC(adr, reg) ReadDOC_(adr,DoC_##reg)
50 #define WriteDOC(d, adr, reg) WriteDOC_(d,adr,DoC_##reg)
52 #define DOC_MODE_RESET 0
53 #define DOC_MODE_NORMAL 1
54 #define DOC_MODE_RESERVED1 2
55 #define DOC_MODE_RESERVED2 3
57 #define DOC_MODE_MDWREN 4
58 #define DOC_MODE_CLR_ERR 0x80
60 #define DOC_ChipID_UNKNOWN 0x00
61 #define DOC_ChipID_Doc2k 0x20
62 #define DOC_ChipID_DocMil 0x30
64 #define CDSN_CTRL_FR_B 0x80
65 #define CDSN_CTRL_ECC_IO 0x20
66 #define CDSN_CTRL_FLASH_IO 0x10
67 #define CDSN_CTRL_WP 0x08
68 #define CDSN_CTRL_ALE 0x04
69 #define CDSN_CTRL_CLE 0x02
70 #define CDSN_CTRL_CE 0x01
72 #define DOC_ECC_RESET 0
73 #define DOC_ECC_ERROR 0x80
74 #define DOC_ECC_RW 0x20
75 #define DOC_ECC__EN 0x08
76 #define DOC_TOGGLE_BIT 0x04
77 #define DOC_ECC_RESV 0x02
78 #define DOC_ECC_IGNORE 0x01
80 /* We have to also set the reserved bit 1 for enable */
81 #define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV)
82 #define DOC_ECC_DIS (DOC_ECC_RESV)
87 #define MAX_FLOORS_MIL 4
88 #define MAX_CHIPS_MIL 1
92 #define ADDR_COLUMN_PAGE 3
97 unsigned char curmode;
98 /* Also some erase/write/pipeline info when we get that far */
102 unsigned long physadr;
103 unsigned long virtadr;
104 unsigned long totlen;
106 char ChipID; /* Type of DiskOnChip */
110 unsigned long mfr; /* Flash IDs - only one type of flash per device */
115 unsigned long erasesize;
124 struct NFTLrecord nftl;
127 #define SECTORSIZE 512
129 /* Return codes from doc_write(), doc_read(), and doc_erase().
135 #define DOC_ETIMEOUT 4
138 * Function Prototypes
140 int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);
142 int doc_rw(struct DiskOnChip* this, int cmd, loff_t from, size_t len,
143 size_t *retlen, u_char *buf);
144 int doc_read_ecc(struct DiskOnChip* this, loff_t from, size_t len,
145 size_t *retlen, u_char *buf, u_char *eccbuf);
146 int doc_write_ecc(struct DiskOnChip* this, loff_t to, size_t len,
147 size_t *retlen, const u_char *buf, u_char *eccbuf);
148 int doc_read_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
149 size_t *retlen, u_char *buf);
150 int doc_write_oob(struct DiskOnChip* this, loff_t ofs, size_t len,
151 size_t *retlen, const u_char *buf);
152 int doc_erase (struct DiskOnChip* this, loff_t ofs, size_t len);
154 void doc_probe(unsigned long physadr);
156 void doc_print(struct DiskOnChip*);
159 * Standard NAND flash commands
161 #define NAND_CMD_READ0 0
162 #define NAND_CMD_READ1 1
163 #define NAND_CMD_PAGEPROG 0x10
164 #define NAND_CMD_READOOB 0x50
165 #define NAND_CMD_ERASE1 0x60
166 #define NAND_CMD_STATUS 0x70
167 #define NAND_CMD_SEQIN 0x80
168 #define NAND_CMD_READID 0x90
169 #define NAND_CMD_ERASE2 0xd0
170 #define NAND_CMD_RESET 0xff
173 * NAND Flash Manufacturer ID Codes
175 #define NAND_MFR_TOSHIBA 0x98
176 #define NAND_MFR_SAMSUNG 0xec
179 * NAND Flash Device ID Structure
181 * Structure overview:
183 * name - Complete name of device
185 * manufacture_id - manufacturer ID code of device.
187 * model_id - model ID code of device.
189 * chipshift - total number of address bits for the device which
190 * is used to calculate address offsets and the total
191 * number of bytes the device is capable of.
193 * page256 - denotes if flash device has 256 byte pages or not.
195 * pageadrlen - number of bytes minus one needed to hold the
196 * complete address into the flash array. Keep in
197 * mind that when a read or write is done to a
198 * specific address, the address is input serially
199 * 8 bits at a time. This structure member is used
200 * by the read/write routines as a loop index for
201 * shifting the address out 8 bits at a time.
203 * erasesize - size of an erase block in the flash device.
205 struct nand_flash_dev {
212 unsigned long erasesize;
216 #endif /* __MTD_DOC2000_H__ */