Add latest ia64 patches.
[linux-flexiantxendom0-3.2.10.git] / include / linux / mtd / doc2000.h
1
2 /* Linux driver for Disk-On-Chip 2000       */
3 /* (c) 1999 Machine Vision Holdings, Inc.   */
4 /* Author: David Woodhouse <dwmw2@mvhi.com> */
5 /* $Id: doc2000.h,v 1.17 2003/06/12 01:20:46 gerg Exp $ */
6
7 #ifndef __MTD_DOC2000_H__
8 #define __MTD_DOC2000_H__
9
10 #include <linux/mtd/mtd.h>
11
12 #define DoC_Sig1 0
13 #define DoC_Sig2 1
14
15 #define DoC_ChipID              0x1000
16 #define DoC_DOCStatus           0x1001
17 #define DoC_DOCControl          0x1002
18 #define DoC_FloorSelect         0x1003
19 #define DoC_CDSNControl         0x1004
20 #define DoC_CDSNDeviceSelect    0x1005
21 #define DoC_ECCConf             0x1006
22 #define DoC_2k_ECCStatus        0x1007
23
24 #define DoC_CDSNSlowIO          0x100d
25 #define DoC_ECCSyndrome0        0x1010
26 #define DoC_ECCSyndrome1        0x1011
27 #define DoC_ECCSyndrome2        0x1012
28 #define DoC_ECCSyndrome3        0x1013
29 #define DoC_ECCSyndrome4        0x1014
30 #define DoC_ECCSyndrome5        0x1015
31 #define DoC_AliasResolution     0x101b
32 #define DoC_ConfigInput         0x101c
33 #define DoC_ReadPipeInit        0x101d
34 #define DoC_WritePipeTerm       0x101e
35 #define DoC_LastDataRead        0x101f
36 #define DoC_NOP                 0x1020
37
38 #define DoC_Mil_CDSN_IO         0x0800
39 #define DoC_2k_CDSN_IO          0x1800
40
41 #define DoC_Mplus_NOP                   0x1002
42 #define DoC_Mplus_AliasResolution       0x1004
43 #define DoC_Mplus_DOCControl            0x1006
44 #define DoC_Mplus_AccessStatus          0x1008
45 #define DoC_Mplus_DeviceSelect          0x1008
46 #define DoC_Mplus_Configuration         0x100a
47 #define DoC_Mplus_OutputControl         0x100c
48 #define DoC_Mplus_FlashControl          0x1020
49 #define DoC_Mplus_FlashSelect           0x1022
50 #define DoC_Mplus_FlashCmd              0x1024
51 #define DoC_Mplus_FlashAddress          0x1026
52 #define DoC_Mplus_FlashData0            0x1028
53 #define DoC_Mplus_FlashData1            0x1029
54 #define DoC_Mplus_ReadPipeInit          0x102a
55 #define DoC_Mplus_LastDataRead          0x102c
56 #define DoC_Mplus_LastDataRead1         0x102d
57 #define DoC_Mplus_WritePipeTerm         0x102e
58 #define DoC_Mplus_ECCSyndrome0          0x1040
59 #define DoC_Mplus_ECCSyndrome1          0x1041
60 #define DoC_Mplus_ECCSyndrome2          0x1042
61 #define DoC_Mplus_ECCSyndrome3          0x1043
62 #define DoC_Mplus_ECCSyndrome4          0x1044
63 #define DoC_Mplus_ECCSyndrome5          0x1045
64 #define DoC_Mplus_ECCConf               0x1046
65 #define DoC_Mplus_Toggle                0x1046
66 #define DoC_Mplus_DownloadStatus        0x1074
67 #define DoC_Mplus_CtrlConfirm           0x1076
68 #define DoC_Mplus_Power                 0x1fff
69
70 /* How to access the device? 
71  * On ARM, it'll be mmap'd directly with 32-bit wide accesses. 
72  * On PPC, it's mmap'd and 16-bit wide.
73  * Others use readb/writeb 
74  */
75 #if defined(__arm__)
76 #define ReadDOC_(adr, reg)      ((unsigned char)(*(__u32 *)(((unsigned long)adr)+((reg)<<2))))
77 #define WriteDOC_(d, adr, reg)  do{ *(__u32 *)(((unsigned long)adr)+((reg)<<2)) = (__u32)d; wmb();} while(0)
78 #define DOC_IOREMAP_LEN 0x8000
79 #elif defined(__ppc__)
80 #define ReadDOC_(adr, reg)      ((unsigned char)(*(__u16 *)(((unsigned long)adr)+((reg)<<1))))
81 #define WriteDOC_(d, adr, reg)  do{ *(__u16 *)(((unsigned long)adr)+((reg)<<1)) = (__u16)d; wmb();} while(0)
82 #define DOC_IOREMAP_LEN 0x4000
83 #else
84 #define ReadDOC_(adr, reg)      readb(((unsigned long)adr) + (reg))
85 #define WriteDOC_(d, adr, reg)  writeb(d, ((unsigned long)adr) + (reg))
86 #define DOC_IOREMAP_LEN 0x2000
87
88 #endif
89
90 #if defined(__i386__) || defined(__x86_64__)
91 #define USE_MEMCPY
92 #endif
93
94 /* These are provided to directly use the DoC_xxx defines */
95 #define ReadDOC(adr, reg)      ReadDOC_(adr,DoC_##reg)
96 #define WriteDOC(d, adr, reg)  WriteDOC_(d,adr,DoC_##reg)
97
98 #define DOC_MODE_RESET          0
99 #define DOC_MODE_NORMAL         1
100 #define DOC_MODE_RESERVED1      2
101 #define DOC_MODE_RESERVED2      3
102
103 #define DOC_MODE_CLR_ERR        0x80
104 #define DOC_MODE_RST_LAT        0x10
105 #define DOC_MODE_BDECT          0x08
106 #define DOC_MODE_MDWREN         0x04
107
108 #define DOC_ChipID_Doc2k        0x20
109 #define DOC_ChipID_DocMil       0x30
110 #define DOC_ChipID_DocMilPlus32 0x40
111 #define DOC_ChipID_DocMilPlus16 0x41
112
113 #define CDSN_CTRL_FR_B          0x80
114 #define CDSN_CTRL_FR_B0         0x40
115 #define CDSN_CTRL_FR_B1         0x80
116
117 #define CDSN_CTRL_ECC_IO        0x20
118 #define CDSN_CTRL_FLASH_IO      0x10
119 #define CDSN_CTRL_WP            0x08
120 #define CDSN_CTRL_ALE           0x04
121 #define CDSN_CTRL_CLE           0x02
122 #define CDSN_CTRL_CE            0x01
123
124 #define DOC_ECC_RESET           0
125 #define DOC_ECC_ERROR           0x80
126 #define DOC_ECC_RW              0x20
127 #define DOC_ECC__EN             0x08
128 #define DOC_TOGGLE_BIT          0x04
129 #define DOC_ECC_RESV            0x02
130 #define DOC_ECC_IGNORE          0x01
131
132 #define DOC_FLASH_CE            0x80
133 #define DOC_FLASH_WP            0x40
134 #define DOC_FLASH_BANK          0x02
135
136 /* We have to also set the reserved bit 1 for enable */
137 #define DOC_ECC_EN (DOC_ECC__EN | DOC_ECC_RESV)
138 #define DOC_ECC_DIS (DOC_ECC_RESV)
139
140 struct Nand {
141         char floor, chip;
142         unsigned long curadr;
143         unsigned char curmode;
144         /* Also some erase/write/pipeline info when we get that far */
145 };
146
147 #define MAX_FLOORS 4
148 #define MAX_CHIPS 4
149
150 #define MAX_FLOORS_MIL 4
151 #define MAX_CHIPS_MIL 1
152
153 #define MAX_FLOORS_MPLUS 1
154 #define MAX_CHIPS_MPLUS 1
155
156 #define ADDR_COLUMN 1
157 #define ADDR_PAGE 2
158 #define ADDR_COLUMN_PAGE 3
159
160 struct DiskOnChip {
161         unsigned long physadr;
162         unsigned long virtadr;
163         unsigned long totlen;
164         char ChipID; /* Type of DiskOnChip */
165         int ioreg;
166         
167         unsigned long mfr; /* Flash IDs - only one type of flash per device */
168         unsigned long id;
169         int chipshift;
170         char page256;
171         char pageadrlen;
172         char interleave; /* Internal interleaving - Millennium Plus style */
173         unsigned long erasesize;
174         
175         int curfloor;
176         int curchip;
177         
178         int numchips;
179         struct Nand *chips;
180         struct mtd_info *nextdoc;
181         struct semaphore lock;
182 };
183
184 int doc_decode_ecc(unsigned char sector[512], unsigned char ecc1[6]);
185
186 #endif /* __MTD_DOC2000_H__ */