xref: /openbmc/linux/include/pcmcia/cistpl.h (revision 05bcf503)
1 /*
2  * cistpl.h
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * The initial developer of the original code is David A. Hinds
9  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
10  * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
11  *
12  * (C) 1999             David A. Hinds
13  */
14 
15 #ifndef _LINUX_CISTPL_H
16 #define _LINUX_CISTPL_H
17 
18 typedef unsigned char cisdata_t;
19 
20 #define CISTPL_NULL		0x00
21 #define CISTPL_DEVICE		0x01
22 #define CISTPL_LONGLINK_CB	0x02
23 #define CISTPL_INDIRECT		0x03
24 #define CISTPL_CONFIG_CB	0x04
25 #define CISTPL_CFTABLE_ENTRY_CB	0x05
26 #define CISTPL_LONGLINK_MFC	0x06
27 #define CISTPL_BAR		0x07
28 #define CISTPL_PWR_MGMNT	0x08
29 #define CISTPL_EXTDEVICE	0x09
30 #define CISTPL_CHECKSUM		0x10
31 #define CISTPL_LONGLINK_A	0x11
32 #define CISTPL_LONGLINK_C	0x12
33 #define CISTPL_LINKTARGET	0x13
34 #define CISTPL_NO_LINK		0x14
35 #define CISTPL_VERS_1		0x15
36 #define CISTPL_ALTSTR		0x16
37 #define CISTPL_DEVICE_A		0x17
38 #define CISTPL_JEDEC_C		0x18
39 #define CISTPL_JEDEC_A		0x19
40 #define CISTPL_CONFIG		0x1a
41 #define CISTPL_CFTABLE_ENTRY	0x1b
42 #define CISTPL_DEVICE_OC	0x1c
43 #define CISTPL_DEVICE_OA	0x1d
44 #define CISTPL_DEVICE_GEO	0x1e
45 #define CISTPL_DEVICE_GEO_A	0x1f
46 #define CISTPL_MANFID		0x20
47 #define CISTPL_FUNCID		0x21
48 #define CISTPL_FUNCE		0x22
49 #define CISTPL_SWIL		0x23
50 #define CISTPL_END		0xff
51 /* Layer 2 tuples */
52 #define CISTPL_VERS_2		0x40
53 #define CISTPL_FORMAT		0x41
54 #define CISTPL_GEOMETRY		0x42
55 #define CISTPL_BYTEORDER	0x43
56 #define CISTPL_DATE		0x44
57 #define CISTPL_BATTERY		0x45
58 #define CISTPL_FORMAT_A		0x47
59 /* Layer 3 tuples */
60 #define CISTPL_ORG		0x46
61 #define CISTPL_SPCL		0x90
62 
63 typedef struct cistpl_longlink_t {
64     u_int	addr;
65 } cistpl_longlink_t;
66 
67 typedef struct cistpl_checksum_t {
68     u_short	addr;
69     u_short	len;
70     u_char	sum;
71 } cistpl_checksum_t;
72 
73 #define CISTPL_MAX_FUNCTIONS	8
74 #define CISTPL_MFC_ATTR		0x00
75 #define CISTPL_MFC_COMMON	0x01
76 
77 typedef struct cistpl_longlink_mfc_t {
78     u_char	nfn;
79     struct {
80 	u_char	space;
81 	u_int	addr;
82     } fn[CISTPL_MAX_FUNCTIONS];
83 } cistpl_longlink_mfc_t;
84 
85 #define CISTPL_MAX_ALTSTR_STRINGS	4
86 
87 typedef struct cistpl_altstr_t {
88     u_char	ns;
89     u_char	ofs[CISTPL_MAX_ALTSTR_STRINGS];
90     char	str[254];
91 } cistpl_altstr_t;
92 
93 #define CISTPL_DTYPE_NULL	0x00
94 #define CISTPL_DTYPE_ROM	0x01
95 #define CISTPL_DTYPE_OTPROM	0x02
96 #define CISTPL_DTYPE_EPROM	0x03
97 #define CISTPL_DTYPE_EEPROM	0x04
98 #define CISTPL_DTYPE_FLASH	0x05
99 #define CISTPL_DTYPE_SRAM	0x06
100 #define CISTPL_DTYPE_DRAM	0x07
101 #define CISTPL_DTYPE_FUNCSPEC	0x0d
102 #define CISTPL_DTYPE_EXTEND	0x0e
103 
104 #define CISTPL_MAX_DEVICES	4
105 
106 typedef struct cistpl_device_t {
107     u_char	ndev;
108     struct {
109 	u_char 	type;
110 	u_char	wp;
111 	u_int	speed;
112 	u_int	size;
113     } dev[CISTPL_MAX_DEVICES];
114 } cistpl_device_t;
115 
116 #define CISTPL_DEVICE_MWAIT	0x01
117 #define CISTPL_DEVICE_3VCC	0x02
118 
119 typedef struct cistpl_device_o_t {
120     u_char		flags;
121     cistpl_device_t	device;
122 } cistpl_device_o_t;
123 
124 #define CISTPL_VERS_1_MAX_PROD_STRINGS	4
125 
126 typedef struct cistpl_vers_1_t {
127     u_char	major;
128     u_char	minor;
129     u_char	ns;
130     u_char	ofs[CISTPL_VERS_1_MAX_PROD_STRINGS];
131     char	str[254];
132 } cistpl_vers_1_t;
133 
134 typedef struct cistpl_jedec_t {
135     u_char	nid;
136     struct {
137 	u_char	mfr;
138 	u_char	info;
139     } id[CISTPL_MAX_DEVICES];
140 } cistpl_jedec_t;
141 
142 typedef struct cistpl_manfid_t {
143     u_short	manf;
144     u_short	card;
145 } cistpl_manfid_t;
146 
147 #define CISTPL_FUNCID_MULTI	0x00
148 #define CISTPL_FUNCID_MEMORY	0x01
149 #define CISTPL_FUNCID_SERIAL	0x02
150 #define CISTPL_FUNCID_PARALLEL	0x03
151 #define CISTPL_FUNCID_FIXED	0x04
152 #define CISTPL_FUNCID_VIDEO	0x05
153 #define CISTPL_FUNCID_NETWORK	0x06
154 #define CISTPL_FUNCID_AIMS	0x07
155 #define CISTPL_FUNCID_SCSI	0x08
156 
157 #define CISTPL_SYSINIT_POST	0x01
158 #define CISTPL_SYSINIT_ROM	0x02
159 
160 typedef struct cistpl_funcid_t {
161     u_char	func;
162     u_char	sysinit;
163 } cistpl_funcid_t;
164 
165 typedef struct cistpl_funce_t {
166     u_char	type;
167     u_char	data[0];
168 } cistpl_funce_t;
169 
170 /*======================================================================
171 
172     Modem Function Extension Tuples
173 
174 ======================================================================*/
175 
176 #define CISTPL_FUNCE_SERIAL_IF		0x00
177 #define CISTPL_FUNCE_SERIAL_CAP		0x01
178 #define CISTPL_FUNCE_SERIAL_SERV_DATA	0x02
179 #define CISTPL_FUNCE_SERIAL_SERV_FAX	0x03
180 #define CISTPL_FUNCE_SERIAL_SERV_VOICE	0x04
181 #define CISTPL_FUNCE_SERIAL_CAP_DATA	0x05
182 #define CISTPL_FUNCE_SERIAL_CAP_FAX	0x06
183 #define CISTPL_FUNCE_SERIAL_CAP_VOICE	0x07
184 #define CISTPL_FUNCE_SERIAL_IF_DATA	0x08
185 #define CISTPL_FUNCE_SERIAL_IF_FAX	0x09
186 #define CISTPL_FUNCE_SERIAL_IF_VOICE	0x0a
187 
188 /* UART identification */
189 #define CISTPL_SERIAL_UART_8250		0x00
190 #define CISTPL_SERIAL_UART_16450	0x01
191 #define CISTPL_SERIAL_UART_16550	0x02
192 #define CISTPL_SERIAL_UART_8251		0x03
193 #define CISTPL_SERIAL_UART_8530		0x04
194 #define CISTPL_SERIAL_UART_85230	0x05
195 
196 /* UART capabilities */
197 #define CISTPL_SERIAL_UART_SPACE	0x01
198 #define CISTPL_SERIAL_UART_MARK		0x02
199 #define CISTPL_SERIAL_UART_ODD		0x04
200 #define CISTPL_SERIAL_UART_EVEN		0x08
201 #define CISTPL_SERIAL_UART_5BIT		0x01
202 #define CISTPL_SERIAL_UART_6BIT		0x02
203 #define CISTPL_SERIAL_UART_7BIT		0x04
204 #define CISTPL_SERIAL_UART_8BIT		0x08
205 #define CISTPL_SERIAL_UART_1STOP	0x10
206 #define CISTPL_SERIAL_UART_MSTOP	0x20
207 #define CISTPL_SERIAL_UART_2STOP	0x40
208 
209 typedef struct cistpl_serial_t {
210     u_char	uart_type;
211     u_char	uart_cap_0;
212     u_char	uart_cap_1;
213 } cistpl_serial_t;
214 
215 typedef struct cistpl_modem_cap_t {
216     u_char	flow;
217     u_char	cmd_buf;
218     u_char	rcv_buf_0, rcv_buf_1, rcv_buf_2;
219     u_char	xmit_buf_0, xmit_buf_1, xmit_buf_2;
220 } cistpl_modem_cap_t;
221 
222 #define CISTPL_SERIAL_MOD_103		0x01
223 #define CISTPL_SERIAL_MOD_V21		0x02
224 #define CISTPL_SERIAL_MOD_V23		0x04
225 #define CISTPL_SERIAL_MOD_V22		0x08
226 #define CISTPL_SERIAL_MOD_212A		0x10
227 #define CISTPL_SERIAL_MOD_V22BIS	0x20
228 #define CISTPL_SERIAL_MOD_V26		0x40
229 #define CISTPL_SERIAL_MOD_V26BIS	0x80
230 #define CISTPL_SERIAL_MOD_V27BIS	0x01
231 #define CISTPL_SERIAL_MOD_V29		0x02
232 #define CISTPL_SERIAL_MOD_V32		0x04
233 #define CISTPL_SERIAL_MOD_V32BIS	0x08
234 #define CISTPL_SERIAL_MOD_V34		0x10
235 
236 #define CISTPL_SERIAL_ERR_MNP2_4	0x01
237 #define CISTPL_SERIAL_ERR_V42_LAPM	0x02
238 
239 #define CISTPL_SERIAL_CMPR_V42BIS	0x01
240 #define CISTPL_SERIAL_CMPR_MNP5		0x02
241 
242 #define CISTPL_SERIAL_CMD_AT1		0x01
243 #define CISTPL_SERIAL_CMD_AT2		0x02
244 #define CISTPL_SERIAL_CMD_AT3		0x04
245 #define CISTPL_SERIAL_CMD_MNP_AT	0x08
246 #define CISTPL_SERIAL_CMD_V25BIS	0x10
247 #define CISTPL_SERIAL_CMD_V25A		0x20
248 #define CISTPL_SERIAL_CMD_DMCL		0x40
249 
250 typedef struct cistpl_data_serv_t {
251     u_char	max_data_0;
252     u_char	max_data_1;
253     u_char	modulation_0;
254     u_char	modulation_1;
255     u_char	error_control;
256     u_char	compression;
257     u_char	cmd_protocol;
258     u_char	escape;
259     u_char	encrypt;
260     u_char	misc_features;
261     u_char	ccitt_code[0];
262 } cistpl_data_serv_t;
263 
264 typedef struct cistpl_fax_serv_t {
265     u_char	max_data_0;
266     u_char	max_data_1;
267     u_char	modulation;
268     u_char	encrypt;
269     u_char	features_0;
270     u_char	features_1;
271     u_char	ccitt_code[0];
272 } cistpl_fax_serv_t;
273 
274 typedef struct cistpl_voice_serv_t {
275     u_char	max_data_0;
276     u_char	max_data_1;
277 } cistpl_voice_serv_t;
278 
279 /*======================================================================
280 
281     LAN Function Extension Tuples
282 
283 ======================================================================*/
284 
285 #define CISTPL_FUNCE_LAN_TECH		0x01
286 #define CISTPL_FUNCE_LAN_SPEED		0x02
287 #define CISTPL_FUNCE_LAN_MEDIA		0x03
288 #define CISTPL_FUNCE_LAN_NODE_ID	0x04
289 #define CISTPL_FUNCE_LAN_CONNECTOR	0x05
290 
291 /* LAN technologies */
292 #define CISTPL_LAN_TECH_ARCNET		0x01
293 #define CISTPL_LAN_TECH_ETHERNET	0x02
294 #define CISTPL_LAN_TECH_TOKENRING	0x03
295 #define CISTPL_LAN_TECH_LOCALTALK	0x04
296 #define CISTPL_LAN_TECH_FDDI		0x05
297 #define CISTPL_LAN_TECH_ATM		0x06
298 #define CISTPL_LAN_TECH_WIRELESS	0x07
299 
300 typedef struct cistpl_lan_tech_t {
301     u_char	tech;
302 } cistpl_lan_tech_t;
303 
304 typedef struct cistpl_lan_speed_t {
305     u_int	speed;
306 } cistpl_lan_speed_t;
307 
308 /* LAN media definitions */
309 #define CISTPL_LAN_MEDIA_UTP		0x01
310 #define CISTPL_LAN_MEDIA_STP		0x02
311 #define CISTPL_LAN_MEDIA_THIN_COAX	0x03
312 #define CISTPL_LAN_MEDIA_THICK_COAX	0x04
313 #define CISTPL_LAN_MEDIA_FIBER		0x05
314 #define CISTPL_LAN_MEDIA_900MHZ		0x06
315 #define CISTPL_LAN_MEDIA_2GHZ		0x07
316 #define CISTPL_LAN_MEDIA_5GHZ		0x08
317 #define CISTPL_LAN_MEDIA_DIFF_IR	0x09
318 #define CISTPL_LAN_MEDIA_PTP_IR		0x0a
319 
320 typedef struct cistpl_lan_media_t {
321     u_char	media;
322 } cistpl_lan_media_t;
323 
324 typedef struct cistpl_lan_node_id_t {
325     u_char	nb;
326     u_char	id[16];
327 } cistpl_lan_node_id_t;
328 
329 typedef struct cistpl_lan_connector_t {
330     u_char	code;
331 } cistpl_lan_connector_t;
332 
333 /*======================================================================
334 
335     IDE Function Extension Tuples
336 
337 ======================================================================*/
338 
339 #define CISTPL_IDE_INTERFACE		0x01
340 
341 typedef struct cistpl_ide_interface_t {
342     u_char	interface;
343 } cistpl_ide_interface_t;
344 
345 /* First feature byte */
346 #define CISTPL_IDE_SILICON		0x04
347 #define CISTPL_IDE_UNIQUE		0x08
348 #define CISTPL_IDE_DUAL			0x10
349 
350 /* Second feature byte */
351 #define CISTPL_IDE_HAS_SLEEP		0x01
352 #define CISTPL_IDE_HAS_STANDBY		0x02
353 #define CISTPL_IDE_HAS_IDLE		0x04
354 #define CISTPL_IDE_LOW_POWER		0x08
355 #define CISTPL_IDE_REG_INHIBIT		0x10
356 #define CISTPL_IDE_HAS_INDEX		0x20
357 #define CISTPL_IDE_IOIS16		0x40
358 
359 typedef struct cistpl_ide_feature_t {
360     u_char	feature1;
361     u_char	feature2;
362 } cistpl_ide_feature_t;
363 
364 #define CISTPL_FUNCE_IDE_IFACE		0x01
365 #define CISTPL_FUNCE_IDE_MASTER		0x02
366 #define CISTPL_FUNCE_IDE_SLAVE		0x03
367 
368 /*======================================================================
369 
370     Configuration Table Entries
371 
372 ======================================================================*/
373 
374 #define CISTPL_BAR_SPACE	0x07
375 #define CISTPL_BAR_SPACE_IO	0x10
376 #define CISTPL_BAR_PREFETCH	0x20
377 #define CISTPL_BAR_CACHEABLE	0x40
378 #define CISTPL_BAR_1MEG_MAP	0x80
379 
380 typedef struct cistpl_bar_t {
381     u_char	attr;
382     u_int	size;
383 } cistpl_bar_t;
384 
385 typedef struct cistpl_config_t {
386     u_char	last_idx;
387     u_int	base;
388     u_int	rmask[4];
389     u_char	subtuples;
390 } cistpl_config_t;
391 
392 /* These are bits in the 'present' field, and indices in 'param' */
393 #define CISTPL_POWER_VNOM	0
394 #define CISTPL_POWER_VMIN	1
395 #define CISTPL_POWER_VMAX	2
396 #define CISTPL_POWER_ISTATIC	3
397 #define CISTPL_POWER_IAVG	4
398 #define CISTPL_POWER_IPEAK	5
399 #define CISTPL_POWER_IDOWN	6
400 
401 #define CISTPL_POWER_HIGHZ_OK	0x01
402 #define CISTPL_POWER_HIGHZ_REQ	0x02
403 
404 typedef struct cistpl_power_t {
405     u_char	present;
406     u_char	flags;
407     u_int	param[7];
408 } cistpl_power_t;
409 
410 typedef struct cistpl_timing_t {
411     u_int	wait, waitscale;
412     u_int	ready, rdyscale;
413     u_int	reserved, rsvscale;
414 } cistpl_timing_t;
415 
416 #define CISTPL_IO_LINES_MASK	0x1f
417 #define CISTPL_IO_8BIT		0x20
418 #define CISTPL_IO_16BIT		0x40
419 #define CISTPL_IO_RANGE		0x80
420 
421 #define CISTPL_IO_MAX_WIN	16
422 
423 typedef struct cistpl_io_t {
424     u_char	flags;
425     u_char	nwin;
426     struct {
427 	u_int	base;
428 	u_int	len;
429     } win[CISTPL_IO_MAX_WIN];
430 } cistpl_io_t;
431 
432 typedef struct cistpl_irq_t {
433     u_int	IRQInfo1;
434     u_int	IRQInfo2;
435 } cistpl_irq_t;
436 
437 #define CISTPL_MEM_MAX_WIN	8
438 
439 typedef struct cistpl_mem_t {
440     u_char	flags;
441     u_char	nwin;
442     struct {
443 	u_int	len;
444 	u_int	card_addr;
445 	u_int	host_addr;
446     } win[CISTPL_MEM_MAX_WIN];
447 } cistpl_mem_t;
448 
449 #define CISTPL_CFTABLE_DEFAULT		0x0001
450 #define CISTPL_CFTABLE_BVDS		0x0002
451 #define CISTPL_CFTABLE_WP		0x0004
452 #define CISTPL_CFTABLE_RDYBSY		0x0008
453 #define CISTPL_CFTABLE_MWAIT		0x0010
454 #define CISTPL_CFTABLE_AUDIO		0x0800
455 #define CISTPL_CFTABLE_READONLY		0x1000
456 #define CISTPL_CFTABLE_PWRDOWN		0x2000
457 
458 typedef struct cistpl_cftable_entry_t {
459     u_char		index;
460     u_short		flags;
461     u_char		interface;
462     cistpl_power_t	vcc, vpp1, vpp2;
463     cistpl_timing_t	timing;
464     cistpl_io_t		io;
465     cistpl_irq_t	irq;
466     cistpl_mem_t	mem;
467     u_char		subtuples;
468 } cistpl_cftable_entry_t;
469 
470 #define CISTPL_CFTABLE_MASTER		0x000100
471 #define CISTPL_CFTABLE_INVALIDATE	0x000200
472 #define CISTPL_CFTABLE_VGA_PALETTE	0x000400
473 #define CISTPL_CFTABLE_PARITY		0x000800
474 #define CISTPL_CFTABLE_WAIT		0x001000
475 #define CISTPL_CFTABLE_SERR		0x002000
476 #define CISTPL_CFTABLE_FAST_BACK	0x004000
477 #define CISTPL_CFTABLE_BINARY_AUDIO	0x010000
478 #define CISTPL_CFTABLE_PWM_AUDIO	0x020000
479 
480 typedef struct cistpl_cftable_entry_cb_t {
481     u_char		index;
482     u_int		flags;
483     cistpl_power_t	vcc, vpp1, vpp2;
484     u_char		io;
485     cistpl_irq_t	irq;
486     u_char		mem;
487     u_char		subtuples;
488 } cistpl_cftable_entry_cb_t;
489 
490 typedef struct cistpl_device_geo_t {
491     u_char		ngeo;
492     struct {
493 	u_char		buswidth;
494 	u_int		erase_block;
495 	u_int		read_block;
496 	u_int		write_block;
497 	u_int		partition;
498 	u_int		interleave;
499     } geo[CISTPL_MAX_DEVICES];
500 } cistpl_device_geo_t;
501 
502 typedef struct cistpl_vers_2_t {
503     u_char	vers;
504     u_char	comply;
505     u_short	dindex;
506     u_char	vspec8, vspec9;
507     u_char	nhdr;
508     u_char	vendor, info;
509     char	str[244];
510 } cistpl_vers_2_t;
511 
512 typedef struct cistpl_org_t {
513     u_char	data_org;
514     char	desc[30];
515 } cistpl_org_t;
516 
517 #define CISTPL_ORG_FS		0x00
518 #define CISTPL_ORG_APPSPEC	0x01
519 #define CISTPL_ORG_XIP		0x02
520 
521 typedef struct cistpl_format_t {
522     u_char	type;
523     u_char	edc;
524     u_int	offset;
525     u_int	length;
526 } cistpl_format_t;
527 
528 #define CISTPL_FORMAT_DISK	0x00
529 #define CISTPL_FORMAT_MEM	0x01
530 
531 #define CISTPL_EDC_NONE		0x00
532 #define CISTPL_EDC_CKSUM	0x01
533 #define CISTPL_EDC_CRC		0x02
534 #define CISTPL_EDC_PCC		0x03
535 
536 typedef union cisparse_t {
537     cistpl_device_t		device;
538     cistpl_checksum_t		checksum;
539     cistpl_longlink_t		longlink;
540     cistpl_longlink_mfc_t	longlink_mfc;
541     cistpl_vers_1_t		version_1;
542     cistpl_altstr_t		altstr;
543     cistpl_jedec_t		jedec;
544     cistpl_manfid_t		manfid;
545     cistpl_funcid_t		funcid;
546     cistpl_funce_t		funce;
547     cistpl_bar_t		bar;
548     cistpl_config_t		config;
549     cistpl_cftable_entry_t	cftable_entry;
550     cistpl_cftable_entry_cb_t	cftable_entry_cb;
551     cistpl_device_geo_t		device_geo;
552     cistpl_vers_2_t		vers_2;
553     cistpl_org_t		org;
554     cistpl_format_t		format;
555 } cisparse_t;
556 
557 typedef struct tuple_t {
558     u_int	Attributes;
559     cisdata_t 	DesiredTuple;
560     u_int	Flags;		/* internal use */
561     u_int	LinkOffset;	/* internal use */
562     u_int	CISOffset;	/* internal use */
563     cisdata_t	TupleCode;
564     cisdata_t	TupleLink;
565     cisdata_t	TupleOffset;
566     cisdata_t	TupleDataMax;
567     cisdata_t	TupleDataLen;
568     cisdata_t	*TupleData;
569 } tuple_t;
570 
571 /* Special cisdata_t value */
572 #define RETURN_FIRST_TUPLE	0xff
573 
574 /* Attributes for tuple calls */
575 #define TUPLE_RETURN_LINK	0x01
576 #define TUPLE_RETURN_COMMON	0x02
577 
578 #define CISTPL_MAX_CIS_SIZE	0x200
579 
580 #endif /* LINUX_CISTPL_H */
581