cis.h revision 13765
110216Sphk
210216Sphk/*
310216Sphk *	PCMCIA card structures and defines.
410216Sphk *	These defines relate to the user level
510216Sphk *	structures and card information, not
610216Sphk *	driver/process communication.
710216Sphk *-------------------------------------------------------------------------
810216Sphk *
910216Sphk * Copyright (c) 1995 Andrew McRae.  All rights reserved.
1010216Sphk *
1110216Sphk * Redistribution and use in source and binary forms, with or without
1210216Sphk * modification, are permitted provided that the following conditions
1310216Sphk * are met:
1410216Sphk * 1. Redistributions of source code must retain the above copyright
1510216Sphk *    notice, this list of conditions and the following disclaimer.
1610216Sphk * 2. Redistributions in binary form must reproduce the above copyright
1710216Sphk *    notice, this list of conditions and the following disclaimer in the
1810216Sphk *    documentation and/or other materials provided with the distribution.
1910216Sphk * 3. The name of the author may not be used to endorse or promote products
2010216Sphk *    derived from this software without specific prior written permission.
2110216Sphk *
2210216Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2310216Sphk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2410216Sphk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2510216Sphk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2610216Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2710216Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2810216Sphk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2910216Sphk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3010216Sphk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3110216Sphk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3210216Sphk */
3310216Sphk
3410216Sphk/*
3510216Sphk *	Card Information Structure tuples definitions
3610216Sphk *	The structure of a tuple is basically:
3710216Sphk *
3810216Sphk *		Tuple_code
3910216Sphk *		Tuple_data_length
4010216Sphk *		Tuple_data ...
4110216Sphk *
4210216Sphk *	Tuples are contiguous in attribute memory, and
4310216Sphk *	are terminated with a 0xFF for the tuple code or
4410216Sphk *	the tuple length.
4510216Sphk */
4610216Sphk#define	CIS_NULL	0	/* Empty tuple */
4710216Sphk#define	CIS_MEM_COMMON	0x01	/* Device descriptor, common memory */
4810216Sphk#define	CIS_CHECKSUM	0x10	/* Checksum */
4910216Sphk#define	CIS_LONGLINK_A	0x11	/* Link to Attribute memory */
5010216Sphk#define	CIS_LONGLINK_C	0x12	/* Link to Common memory */
5110216Sphk#define	CIS_LINKTARGET	0x13	/* Linked tuple must start with this. */
5210216Sphk#define	CIS_NOLINK	0x14	/* Assume no common memory link tuple. */
5310216Sphk#define	CIS_INFO_V1	0x15	/* Card info data, version 1 */
5410216Sphk#define	CIS_ALTSTR	0x16	/* Alternate language string tuple. */
5510216Sphk#define	CIS_MEM_ATTR	0x17	/* Device descriptor, Attribute memory */
5610216Sphk#define	CIS_JEDEC_C	0x18	/* JEDEC descr for common memory */
5710216Sphk#define	CIS_JEDEC_A	0x19	/* JEDEC descr for Attribute memory */
5810216Sphk#define	CIS_CONF_MAP	0x1A	/* Card Configuration map */
5910216Sphk#define	CIS_CONFIG	0x1B	/* Card Configuration entry */
6010216Sphk#define	CIS_DEVICE_OC	0x1C	/* Other conditions info - common memory */
6110216Sphk#define	CIS_DEVICE_OA	0x1D	/* Other conditions info - attribute memory */
6210216Sphk#define	CIS_DEVICEGEO	0x1E	/* Geometry info for common memory */
6310216Sphk#define	CIS_DEVICEGEO_A	0x1F	/* Geometry info for attribute memory */
6410216Sphk#define	CIS_MANUF_ID	0x20	/* Card manufacturer's ID */
6510216Sphk#define	CIS_FUNC_ID	0x21	/* Function of card */
6610216Sphk#define	CIS_FUNC_EXT	0x22	/* Functional extension */
6710216Sphk/*
6810216Sphk *	Data recording format tuples.
6910216Sphk */
7010216Sphk#define	CIS_SW_INTERLV	0x23	/* Software interleave */
7110216Sphk#define	CIS_VERS_2	0x40	/* Card info data, version 2 */
7210216Sphk#define	CIS_FORMAT	0x41	/* Memory card format */
7310216Sphk#define	CIS_GEOMETRY	0x42	/* Disk sector layout */
7410216Sphk#define	CIS_BYTEORDER	0x43	/* Byte order of memory data */
7510216Sphk#define	CIS_DATE	0x44	/* Format data/time */
7610216Sphk#define	CIS_BATTERY	0x45	/* Battery replacement date */
7713765Smpp#define	CIS_ORG		0x46	/* Organization of data on card */
7810216Sphk#define	CIS_END		0xFF	/* Termination code */
7910216Sphk
8010216Sphk/*
8110216Sphk *	Internal tuple definitions.
8210216Sphk *
8310216Sphk *	Device descriptor for memory (CIS_MEM_ATTR, CIS_MEM_COMMON)
8410216Sphk *
8510216Sphk *	Byte 1:
8610216Sphk *		0xF0 - Device type
8710216Sphk *		0x08 - Write protect switch
8810216Sphk *		0x07 - Speed index (7 = extended speed)
8910216Sphk *	Byte 2: Extended speed (bit 7 = another follows)
9010216Sphk *	Byte 3: (ignored if 0xFF)
9110216Sphk *		0xF8 - Addressable units (0's numbered)
9210216Sphk *		0x07 - Unit size
9310216Sphk *	The three byte sequence is repeated until byte 1 == 0xFF
9410216Sphk */
9510216Sphk
9610216Sphk/*
9710216Sphk *	CIS_INFO_V1 - Version one card information.
9810216Sphk *
9910216Sphk *	Byte 1:   Major version number (should be 4)
10010216Sphk *	Byte 2:   Minor version number (should be 1)
10110216Sphk *	Byte 3-x: Null terminated Manufacturer name
10210216Sphk *	Byte x-x: Null terminated product name
10310216Sphk *	Byte x-x: Null terminated additional info 1
10410216Sphk *	Byte x-x: Null terminated additional info 2
10510216Sphk *	Byte x:   final byte must be 0xFF
10610216Sphk */
10710216Sphk#define	CIS_MAJOR_VERSION	4
10810216Sphk#define	CIS_MINOR_VERSION	1
10910216Sphk
11010216Sphk/*
11110216Sphk *	CIS_CONF_MAP - Provides an address map for the card
11210216Sphk *			configuration register(s), and a max value
11310216Sphk *			identifying the last configuration tuple.
11410216Sphk *
11510216Sphk *	Byte 1:
11610216Sphk *		0x3C - Register mask size (0's numbered)
11710216Sphk *		0x03 - Register address size (0's numbered)
11810216Sphk *	Byte 2:
11910216Sphk *		0x3F - ID of last configuration.
12010216Sphk *	Byte 3-n: Card register address (size is determined by
12110216Sphk *			the value in byte 1).
12210216Sphk *	Byte x-x: Card register masks (size determined by the
12310216Sphk *			value in byte 1)
12410216Sphk */
12510216Sphk
12610216Sphk/*
12710216Sphk *	CIS_CONFIG - Card configuration entry. Multiple tuples may
12810216Sphk *		exist of this type, each one describing a different
12910216Sphk *		memory/I-O map that can be used to address this card.
13010216Sphk *		The first one usually has extra config data about the
13110216Sphk *		card features. The final configuration tuple number
13210216Sphk *		is stored in the CIS_CONF_MAP tuple so that the complete
13310216Sphk *		list can be scanned.
13410216Sphk *
13510216Sphk *	Byte 1:
13610216Sphk *		0x3F - Configuration ID number.
13710216Sphk *		0x40 - Indicates this is the default configuration
13810216Sphk *		0x80 - Interface byte exists
13910216Sphk *	Byte 2: (exists only if bit 0x80 set in byte 1)
14010216Sphk *		0x0F - Interface type value
14110216Sphk *		0x10 - Battery voltage detect
14210216Sphk *		0x20 - Write protect active
14310216Sphk *		0x40 - RdyBsy active bit
14410216Sphk *		0x80 - Wait signal required
14510216Sphk *	Byte 3: (features byte)
14610216Sphk *		0x03 - Power sub-tuple(s) exists
14710216Sphk *		0x04 - Timing sub-tuple exists
14810216Sphk *		0x08 - I/O space sub-tuple exists
14910216Sphk *		0x10 - IRQ sub-tuple exists
15010216Sphk *		0x60 - Memory space sub-tuple(s) exists
15110216Sphk *		0x80 - Miscellaneous sub-tuple exists
15210216Sphk */
15310216Sphk#define	CIS_FEAT_POWER(x)	((x) & 0x3)
15410216Sphk#define	CIS_FEAT_TIMING		0x4
15510216Sphk#define	CIS_FEAT_I_O		0x8
15610216Sphk#define	CIS_FEAT_IRQ		0x10
15710216Sphk#define	CIS_FEAT_MEMORY(x)	(((x) >> 5) & 0x3)
15810216Sphk#define	CIS_FEAT_MISC		0x80
15910216Sphk/*
16010216Sphk *	Depending on whether the "features" byte has the corresponding
16110216Sphk *	bit set, a number of sub-tuples follow. Some features have
16210216Sphk *	more than one sub-tuple, depending on the count within the
16310216Sphk *	features byte (e.g power feature bits allows up to 3 sub-tuples).
16410216Sphk *
16510216Sphk *	Power structure sub-tuple:
16610216Sphk *	Byte 1: parameter exists - Each bit (starting from 0x01) indicates
16710216Sphk *		that a parameter block exists - up to 8 parameter blocks
16810216Sphk *		are therefore allowed).
16910216Sphk *	Byte 2:
17010216Sphk *		0x7F - Parameter data
17110216Sphk *		0x80 - More bytes follow (0 = last byte)
17210216Sphk *
17310216Sphk *	Timing sub-tuple
17410216Sphk *	Byte 1:
17510216Sphk *		0x03 - Wait scale
17610216Sphk *		0x1C - Ready scale
17710216Sphk *		0xE0 - Reserved scale
17810216Sphk *	Byte 2: extended wait scale if wait scale != 3
17910216Sphk *	Byte 3: extended ready scale if ready scale != 7
18010216Sphk *	Byte 4: extended reserved scale if reserved scale != 7
18110216Sphk */
18210216Sphk#define	CIS_WAIT_SCALE(x)	((x) & 0x3)
18310216Sphk#define	CIS_READY_SCALE(x)	(((x)>>2) & 0x7)
18410216Sphk#define	CIS_RESERVED_SCALE(x)	(((x)>>5) & 0x7)
18510216Sphk/*
18610216Sphk *	I/O mapping sub-tuple:
18710216Sphk *	Byte 1:
18810216Sphk *		0x1F - I/O address lines
18910216Sphk *		0x20 - 8 bit I/O
19010216Sphk *		0x40 - 16 bit I/O
19110216Sphk *		0x80 - I/O range??
19210216Sphk *	Byte 2:
19310216Sphk *		0x0F - 0's numbered count of I/O block subtuples following.
19410216Sphk *		0x30 - Size of I/O address value within subtuple. Values
19510216Sphk *			can be 1 (8 bits), 2 (16 bits) or 3 (32 bits).
19610216Sphk *		0xC0 - Size of I/O port block size value within subtuple.
19710216Sphk *	I/O block sub-tuples, count from previous block:
19810216Sphk *		Byte 1-n: I/O start address
19910216Sphk *		Byte x-x: Size of I/O port block.
20010216Sphk */
20110216Sphk#define	CIS_IO_ADDR(x)	((x) & 0x1F)
20210216Sphk#define	CIS_IO_8BIT	0x20
20310216Sphk#define	CIS_IO_16BIT	0x40
20410216Sphk#define	CIS_IO_RANGE	0x80
20510216Sphk#define	CIS_IO_BLKS(x)	((x) & 0xF)
20610216Sphk#define	CIS_IO_ADSZ(x)	(((x)>>4) & 3)
20710216Sphk#define	CIS_IO_BLKSZ(x)	(((x)>>6) & 3)
20810216Sphk/*
20910216Sphk *	IRQ sub-tuple.
21010216Sphk *	Byte 1:
21110216Sphk *		0x0F - Irq number or mask bits
21210216Sphk *		0x10 - IRQ mask values exist
21310216Sphk *		0x20 - Level triggered interrupts
21410216Sphk *		0x40 - Pulse triggered requests
21510216Sphk *		0x80 - Interrupt sharing.
21610216Sphk *	Byte 2-3: Interrupt req mask (if 0x10 of byte 1 set).
21710216Sphk */
21810216Sphk#define	CIS_IRQ_IRQN(x)		((x) & 0xF)
21910216Sphk#define	CIS_IRQ_MASK		0x10
22010216Sphk#define	CIS_IRQ_LEVEL		0x20
22110216Sphk#define	CIS_IRQ_PULSE		0x40
22210216Sphk#define	CIS_IRQ_SHARING		0x80
22310216Sphk/*
22410216Sphk *	Memory block subtuple. Depending on the features bits, the
22510216Sphk *	following subtuples are used:
22610216Sphk *	mem features == 1
22710216Sphk *		Byte 1-2: upper 16 bits of 24 bit memory length.
22810216Sphk *	mem features == 2
22910216Sphk *		Byte 1-2: upper 16 bits of 24 bit memory length.
23010216Sphk *		Byte 3-4: upper 16 bits of 24 bit memory address.
23110216Sphk *	mem_features == 3
23210216Sphk *		Byte 1:
23310216Sphk *			0x07 - 0's numbered count of memory sub-tuples
23410216Sphk *			0x18 - Memory length size (1's numbered)
23510216Sphk *			0x60 - Memory address size (1's numbered)
23610216Sphk *			0x80 - Host address value exists
23710216Sphk *		Memory sub-tuples follow:
23810216Sphk *			Byte 1-n: Memory length value (<< 8)
23910216Sphk *			Byte n-n: Memory card address value (<< 8)
24010216Sphk *			Byte n-n: Memory host address value (<< 8)
24110216Sphk */
24210216Sphk#define	CIS_FEAT_MEM_NONE	0	/* No memory config */
24310216Sphk#define	CIS_FEAT_MEM_LEN	1	/* Just length */
24410216Sphk#define	CIS_FEAT_MEM_ADDR	2	/* Card address & length */
24510216Sphk#define	CIS_FEAT_MEM_WIN	3	/* Multiple windows */
24610216Sphk
24710216Sphk#define	CIS_MEM_WINS(x)		(((x) & 0x7)+1)
24810216Sphk#define	CIS_MEM_LENSZ(x)	(((x) >> 3) & 0x3)
24910216Sphk#define	CIS_MEM_ADDRSZ(x)	(((x) >> 5) & 0x3)
25010216Sphk#define	CIS_MEM_HOST		0x80
251