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