Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / bus / pccard / cis.h
1 /*
2  *      PCMCIA card structures and defines.
3  *      These defines relate to the user level
4  *      structures and card information, not
5  *      driver/process communication.
6  *-------------------------------------------------------------------------
7  *
8  * Copyright (c) 1995 Andrew McRae.  All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * $FreeBSD: src/sys/pccard/cis.h,v 1.3.10.1 2000/05/23 03:56:58 imp Exp $
33  *
34  */
35
36 /*
37  *      Card Information Structure tuples definitions
38  *      The structure of a tuple is basically:
39  *
40  *              Tuple_code
41  *              Tuple_data_length
42  *              Tuple_data ...
43  *
44  *      Tuples are contiguous in attribute memory, and
45  *      are terminated with a 0xFF for the tuple code or
46  *      the tuple length.
47  */
48 #ifndef _PCCARD_CIS_H
49 #define _PCCARD_CIS_H
50
51 #define CIS_NULL        0       /* Empty tuple */
52 #define CIS_MEM_COMMON  0x01    /* Device descriptor, common memory */
53 #define CIS_LONGLINK_CB 0x02    /* Long link to next chain for CardBus */
54 #define CIS_INDIRECT    0x03    /* Indirect access */
55 #define CIS_CONF_MAP_CB 0x04    /* Card Configuration map for CardBus */
56 #define CIS_CONFIG_CB   0x05    /* Card Configuration entry for CardBus */
57 #define CIS_LONGLINK_MFC        0x06    /* Long link to next chain for Multi function card */
58 #define CIS_BAR         0x07    /* Base address register for CardBus */
59 #define CIS_CHECKSUM    0x10    /* Checksum */
60 #define CIS_LONGLINK_A  0x11    /* Link to Attribute memory */
61 #define CIS_LONGLINK_C  0x12    /* Link to Common memory */
62 #define CIS_LINKTARGET  0x13    /* Linked tuple must start with this. */
63 #define CIS_NOLINK      0x14    /* Assume no common memory link tuple. */
64 #define CIS_INFO_V1     0x15    /* Card info data, version 1 */
65 #define CIS_ALTSTR      0x16    /* Alternate language string tuple. */
66 #define CIS_MEM_ATTR    0x17    /* Device descriptor, Attribute memory */
67 #define CIS_JEDEC_C     0x18    /* JEDEC descr for common memory */
68 #define CIS_JEDEC_A     0x19    /* JEDEC descr for Attribute memory */
69 #define CIS_CONF_MAP    0x1A    /* Card Configuration map */
70 #define CIS_CONFIG      0x1B    /* Card Configuration entry */
71 #define CIS_DEVICE_OC   0x1C    /* Other conditions info - common memory */
72 #define CIS_DEVICE_OA   0x1D    /* Other conditions info - attribute memory */
73 #define CIS_DEVICEGEO   0x1E    /* Geometry info for common memory */
74 #define CIS_DEVICEGEO_A 0x1F    /* Geometry info for attribute memory */
75 #define CIS_MANUF_ID    0x20    /* Card manufacturer's ID */
76 #define CIS_FUNC_ID     0x21    /* Function of card */
77 #define CIS_FUNC_EXT    0x22    /* Functional extension */
78 /*
79  *      Data recording format tuples.
80  */
81 #define CIS_SW_INTERLV  0x23    /* Software interleave */
82 #define CIS_VERS_2      0x40    /* Card info data, version 2 */
83 #define CIS_FORMAT      0x41    /* Memory card format */
84 #define CIS_GEOMETRY    0x42    /* Disk sector layout */
85 #define CIS_BYTEORDER   0x43    /* Byte order of memory data */
86 #define CIS_DATE        0x44    /* Format data/time */
87 #define CIS_BATTERY     0x45    /* Battery replacement date */
88 #define CIS_ORG         0x46    /* Organization of data on card */
89 #define CIS_END         0xFF    /* Termination code */
90
91 /*
92  *      Internal tuple definitions.
93  *
94  *      Device descriptor for memory (CIS_MEM_ATTR, CIS_MEM_COMMON)
95  *
96  *      Byte 1:
97  *              0xF0 - Device type
98  *              0x08 - Write protect switch
99  *              0x07 - Speed index (7 = extended speed)
100  *      Byte 2: Extended speed (bit 7 = another follows)
101  *      Byte 3: (ignored if 0xFF)
102  *              0xF8 - Addressable units (0's numbered)
103  *              0x07 - Unit size
104  *      The three byte sequence is repeated until byte 1 == 0xFF
105  */
106
107 /*
108  *      CIS_INFO_V1 - Version one card information.
109  *
110  *      Byte 1:   Major version number (should be 4)
111  *      Byte 2:   Minor version number (should be 1)
112  *      Byte 3-x: Null terminated Manufacturer name
113  *      Byte x-x: Null terminated product name
114  *      Byte x-x: Null terminated additional info 1
115  *      Byte x-x: Null terminated additional info 2
116  *      Byte x:   final byte must be 0xFF
117  */
118 #define CIS_MAJOR_VERSION       4
119 #define CIS_MINOR_VERSION       1
120
121 /*
122  *      CIS_CONF_MAP - Provides an address map for the card
123  *                      configuration register(s), and a max value
124  *                      identifying the last configuration tuple.
125  *
126  *      Byte 1:
127  *              0x3C - Register mask size (0's numbered)
128  *              0x03 - Register address size (0's numbered)
129  *      Byte 2:
130  *              0x3F - ID of last configuration.
131  *      Byte 3-n: Card register address (size is determined by
132  *                      the value in byte 1).
133  *      Byte x-x: Card register masks (size determined by the
134  *                      value in byte 1)
135  */
136
137 /*
138  *      CIS_CONFIG - Card configuration entry. Multiple tuples may
139  *              exist of this type, each one describing a different
140  *              memory/I-O map that can be used to address this card.
141  *              The first one usually has extra config data about the
142  *              card features. The final configuration tuple number
143  *              is stored in the CIS_CONF_MAP tuple so that the complete
144  *              list can be scanned.
145  *
146  *      Byte 1:
147  *              0x3F - Configuration ID number.
148  *              0x40 - Indicates this is the default configuration
149  *              0x80 - Interface byte exists
150  *      Byte 2: (exists only if bit 0x80 set in byte 1)
151  *              0x0F - Interface type value
152  *              0x10 - Battery voltage detect
153  *              0x20 - Write protect active
154  *              0x40 - RdyBsy active bit
155  *              0x80 - Wait signal required
156  *      Byte 3: (features byte)
157  *              0x03 - Power sub-tuple(s) exists
158  *              0x04 - Timing sub-tuple exists
159  *              0x08 - I/O space sub-tuple exists
160  *              0x10 - IRQ sub-tuple exists
161  *              0x60 - Memory space sub-tuple(s) exists
162  *              0x80 - Miscellaneous sub-tuple exists
163  */
164 #define CIS_FEAT_POWER(x)       ((x) & 0x3)
165 #define CIS_FEAT_TIMING         0x4
166 #define CIS_FEAT_I_O            0x8
167 #define CIS_FEAT_IRQ            0x10
168 #define CIS_FEAT_MEMORY(x)      (((x) >> 5) & 0x3)
169 #define CIS_FEAT_MISC           0x80
170 /*
171  *      Depending on whether the "features" byte has the corresponding
172  *      bit set, a number of sub-tuples follow. Some features have
173  *      more than one sub-tuple, depending on the count within the
174  *      features byte (e.g power feature bits allows up to 3 sub-tuples).
175  *
176  *      Power structure sub-tuple:
177  *      Byte 1: parameter exists - Each bit (starting from 0x01) indicates
178  *              that a parameter block exists - up to 8 parameter blocks
179  *              are therefore allowed).
180  *      Byte 2:
181  *              0x7F - Parameter data
182  *              0x80 - More bytes follow (0 = last byte)
183  *
184  *      Timing sub-tuple
185  *      Byte 1:
186  *              0x03 - Wait scale
187  *              0x1C - Ready scale
188  *              0xE0 - Reserved scale
189  *      Byte 2: extended wait scale if wait scale != 3
190  *      Byte 3: extended ready scale if ready scale != 7
191  *      Byte 4: extended reserved scale if reserved scale != 7
192  */
193 #define CIS_WAIT_SCALE(x)       ((x) & 0x3)
194 #define CIS_READY_SCALE(x)      (((x)>>2) & 0x7)
195 #define CIS_RESERVED_SCALE(x)   (((x)>>5) & 0x7)
196 /*
197  *      I/O mapping sub-tuple:
198  *      Byte 1:
199  *              0x1F - I/O address lines
200  *              0x20 - 8 bit I/O
201  *              0x40 - 16 bit I/O
202  *              0x80 - I/O range??
203  *      Byte 2:
204  *              0x0F - 0's numbered count of I/O block subtuples following.
205  *              0x30 - Size of I/O address value within subtuple. Values
206  *                      can be 1 (8 bits), 2 (16 bits) or 3 (32 bits).
207  *              0xC0 - Size of I/O port block size value within subtuple.
208  *      I/O block sub-tuples, count from previous block:
209  *              Byte 1-n: I/O start address
210  *              Byte x-x: Size of I/O port block.
211  */
212 #define CIS_IO_ADDR(x)  ((x) & 0x1F)
213 #define CIS_IO_8BIT     0x20
214 #define CIS_IO_16BIT    0x40
215 #define CIS_IO_RANGE    0x80
216 #define CIS_IO_BLKS(x)  ((x) & 0xF)
217 #define CIS_IO_ADSZ(x)  (((x)>>4) & 3)
218 #define CIS_IO_BLKSZ(x) (((x)>>6) & 3)
219 /*
220  *      IRQ sub-tuple.
221  *      Byte 1:
222  *              0x0F - Irq number or mask bits
223  *              0x10 - IRQ mask values exist
224  *              0x20 - Level triggered interrupts
225  *              0x40 - Pulse triggered requests
226  *              0x80 - Interrupt sharing.
227  *      Byte 2-3: Interrupt req mask (if 0x10 of byte 1 set).
228  */
229 #define CIS_IRQ_IRQN(x)         ((x) & 0xF)
230 #define CIS_IRQ_MASK            0x10
231 #define CIS_IRQ_LEVEL           0x20
232 #define CIS_IRQ_PULSE           0x40
233 #define CIS_IRQ_SHARING         0x80
234 /*
235  *      Memory block subtuple. Depending on the features bits, the
236  *      following subtuples are used:
237  *      mem features == 1
238  *              Byte 1-2: upper 16 bits of 24 bit memory length.
239  *      mem features == 2
240  *              Byte 1-2: upper 16 bits of 24 bit memory length.
241  *              Byte 3-4: upper 16 bits of 24 bit memory address.
242  *      mem_features == 3
243  *              Byte 1:
244  *                      0x07 - 0's numbered count of memory sub-tuples
245  *                      0x18 - Memory length size (1's numbered)
246  *                      0x60 - Memory address size (1's numbered)
247  *                      0x80 - Host address value exists
248  *              Memory sub-tuples follow:
249  *                      Byte 1-n: Memory length value (<< 8)
250  *                      Byte n-n: Memory card address value (<< 8)
251  *                      Byte n-n: Memory host address value (<< 8)
252  */
253 #define CIS_FEAT_MEM_NONE       0       /* No memory config */
254 #define CIS_FEAT_MEM_LEN        1       /* Just length */
255 #define CIS_FEAT_MEM_ADDR       2       /* Card address & length */
256 #define CIS_FEAT_MEM_WIN        3       /* Multiple windows */
257
258 #define CIS_MEM_WINS(x)         (((x) & 0x7)+1)
259 #define CIS_MEM_LENSZ(x)        (((x) >> 3) & 0x3)
260 #define CIS_MEM_ADDRSZ(x)       (((x) >> 5) & 0x3)
261 #define CIS_MEM_HOST            0x80
262 /*
263  *      Misc sub-tuple.
264  *      Byte 1:
265  *      Byte 2:
266  *              0x0c - DMA Request Signal
267  *                      00 - not support DMA
268  *                      01 - use SPKR# line
269  *                      10 - use IOIS16# line
270  *                      11 - use INPACK# line
271  *              0x10 - DMA Width
272  *                      0 - 8 bit DMA
273  *                      1 - 16 bit DMA
274  */
275 #define CIS_MISC_DMA_WIDTH(x)   (((x) & 0x10) >> 4)
276 #define CIS_MISC_DMA_REQ(x)     (((x) >> 2) & 0x3)
277
278 #endif  /* _PCCARD_CIS_H */