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 *-------------------------------------------------------------------------
7139825Simp */
8139825Simp/*-
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.
3259656Siwasaki *
3359656Siwasaki * $FreeBSD$
3459656Siwasaki *
3510216Sphk */
3610216Sphk
3710216Sphk/*
3810216Sphk *	Card Information Structure tuples definitions
3910216Sphk *	The structure of a tuple is basically:
4010216Sphk *
4110216Sphk *		Tuple_code
4210216Sphk *		Tuple_data_length
4310216Sphk *		Tuple_data ...
4410216Sphk *
4510216Sphk *	Tuples are contiguous in attribute memory, and
4610216Sphk *	are terminated with a 0xFF for the tuple code or
4710216Sphk *	the tuple length.
4810216Sphk */
4959656Siwasaki#ifndef	_PCCARD_CIS_H
5059656Siwasaki#define	_PCCARD_CIS_H
5159656Siwasaki
5210216Sphk#define	CIS_NULL	0	/* Empty tuple */
5310216Sphk#define	CIS_MEM_COMMON	0x01	/* Device descriptor, common memory */
5459656Siwasaki#define	CIS_LONGLINK_CB	0x02	/* Long link to next chain for CardBus */
5559656Siwasaki#define	CIS_INDIRECT	0x03	/* Indirect access */
5659656Siwasaki#define	CIS_CONF_MAP_CB	0x04	/* Card Configuration map for CardBus */
5759656Siwasaki#define	CIS_CONFIG_CB	0x05	/* Card Configuration entry for CardBus */
5859656Siwasaki#define	CIS_LONGLINK_MFC	0x06	/* Long link to next chain for Multi function card */
5959656Siwasaki#define	CIS_BAR		0x07	/* Base address register for CardBus */
6010216Sphk#define	CIS_CHECKSUM	0x10	/* Checksum */
6110216Sphk#define	CIS_LONGLINK_A	0x11	/* Link to Attribute memory */
6210216Sphk#define	CIS_LONGLINK_C	0x12	/* Link to Common memory */
6310216Sphk#define	CIS_LINKTARGET	0x13	/* Linked tuple must start with this. */
6410216Sphk#define	CIS_NOLINK	0x14	/* Assume no common memory link tuple. */
6510216Sphk#define	CIS_INFO_V1	0x15	/* Card info data, version 1 */
6610216Sphk#define	CIS_ALTSTR	0x16	/* Alternate language string tuple. */
6710216Sphk#define	CIS_MEM_ATTR	0x17	/* Device descriptor, Attribute memory */
6810216Sphk#define	CIS_JEDEC_C	0x18	/* JEDEC descr for common memory */
6910216Sphk#define	CIS_JEDEC_A	0x19	/* JEDEC descr for Attribute memory */
7010216Sphk#define	CIS_CONF_MAP	0x1A	/* Card Configuration map */
7110216Sphk#define	CIS_CONFIG	0x1B	/* Card Configuration entry */
7210216Sphk#define	CIS_DEVICE_OC	0x1C	/* Other conditions info - common memory */
7310216Sphk#define	CIS_DEVICE_OA	0x1D	/* Other conditions info - attribute memory */
7410216Sphk#define	CIS_DEVICEGEO	0x1E	/* Geometry info for common memory */
7510216Sphk#define	CIS_DEVICEGEO_A	0x1F	/* Geometry info for attribute memory */
7610216Sphk#define	CIS_MANUF_ID	0x20	/* Card manufacturer's ID */
7710216Sphk#define	CIS_FUNC_ID	0x21	/* Function of card */
7810216Sphk#define	CIS_FUNC_EXT	0x22	/* Functional extension */
7910216Sphk/*
8010216Sphk *	Data recording format tuples.
8110216Sphk */
8210216Sphk#define	CIS_SW_INTERLV	0x23	/* Software interleave */
8310216Sphk#define	CIS_VERS_2	0x40	/* Card info data, version 2 */
8410216Sphk#define	CIS_FORMAT	0x41	/* Memory card format */
8510216Sphk#define	CIS_GEOMETRY	0x42	/* Disk sector layout */
8610216Sphk#define	CIS_BYTEORDER	0x43	/* Byte order of memory data */
8710216Sphk#define	CIS_DATE	0x44	/* Format data/time */
8810216Sphk#define	CIS_BATTERY	0x45	/* Battery replacement date */
8913765Smpp#define	CIS_ORG		0x46	/* Organization of data on card */
9010216Sphk#define	CIS_END		0xFF	/* Termination code */
9110216Sphk
9210216Sphk/*
9310216Sphk *	Internal tuple definitions.
9410216Sphk *
9510216Sphk *	Device descriptor for memory (CIS_MEM_ATTR, CIS_MEM_COMMON)
9610216Sphk *
9710216Sphk *	Byte 1:
9810216Sphk *		0xF0 - Device type
9910216Sphk *		0x08 - Write protect switch
10010216Sphk *		0x07 - Speed index (7 = extended speed)
10110216Sphk *	Byte 2: Extended speed (bit 7 = another follows)
10210216Sphk *	Byte 3: (ignored if 0xFF)
10310216Sphk *		0xF8 - Addressable units (0's numbered)
10410216Sphk *		0x07 - Unit size
10510216Sphk *	The three byte sequence is repeated until byte 1 == 0xFF
10610216Sphk */
10710216Sphk
10810216Sphk/*
10910216Sphk *	CIS_INFO_V1 - Version one card information.
11010216Sphk *
11110216Sphk *	Byte 1:   Major version number (should be 4)
11210216Sphk *	Byte 2:   Minor version number (should be 1)
11310216Sphk *	Byte 3-x: Null terminated Manufacturer name
11410216Sphk *	Byte x-x: Null terminated product name
11510216Sphk *	Byte x-x: Null terminated additional info 1
11610216Sphk *	Byte x-x: Null terminated additional info 2
11710216Sphk *	Byte x:   final byte must be 0xFF
11810216Sphk */
11910216Sphk#define	CIS_MAJOR_VERSION	4
12010216Sphk#define	CIS_MINOR_VERSION	1
12110216Sphk
12210216Sphk/*
12310216Sphk *	CIS_CONF_MAP - Provides an address map for the card
12410216Sphk *			configuration register(s), and a max value
12510216Sphk *			identifying the last configuration tuple.
12610216Sphk *
12710216Sphk *	Byte 1:
12810216Sphk *		0x3C - Register mask size (0's numbered)
12910216Sphk *		0x03 - Register address size (0's numbered)
13010216Sphk *	Byte 2:
13110216Sphk *		0x3F - ID of last configuration.
13210216Sphk *	Byte 3-n: Card register address (size is determined by
13310216Sphk *			the value in byte 1).
13410216Sphk *	Byte x-x: Card register masks (size determined by the
13510216Sphk *			value in byte 1)
13610216Sphk */
13710216Sphk
13810216Sphk/*
13910216Sphk *	CIS_CONFIG - Card configuration entry. Multiple tuples may
14010216Sphk *		exist of this type, each one describing a different
14110216Sphk *		memory/I-O map that can be used to address this card.
14210216Sphk *		The first one usually has extra config data about the
14310216Sphk *		card features. The final configuration tuple number
14410216Sphk *		is stored in the CIS_CONF_MAP tuple so that the complete
14510216Sphk *		list can be scanned.
14610216Sphk *
14710216Sphk *	Byte 1:
14810216Sphk *		0x3F - Configuration ID number.
14910216Sphk *		0x40 - Indicates this is the default configuration
15010216Sphk *		0x80 - Interface byte exists
15110216Sphk *	Byte 2: (exists only if bit 0x80 set in byte 1)
15210216Sphk *		0x0F - Interface type value
15310216Sphk *		0x10 - Battery voltage detect
15410216Sphk *		0x20 - Write protect active
15510216Sphk *		0x40 - RdyBsy active bit
15610216Sphk *		0x80 - Wait signal required
15710216Sphk *	Byte 3: (features byte)
15810216Sphk *		0x03 - Power sub-tuple(s) exists
15910216Sphk *		0x04 - Timing sub-tuple exists
16010216Sphk *		0x08 - I/O space sub-tuple exists
16110216Sphk *		0x10 - IRQ sub-tuple exists
16210216Sphk *		0x60 - Memory space sub-tuple(s) exists
16310216Sphk *		0x80 - Miscellaneous sub-tuple exists
16410216Sphk */
16510216Sphk#define	CIS_FEAT_POWER(x)	((x) & 0x3)
16610216Sphk#define	CIS_FEAT_TIMING		0x4
16710216Sphk#define	CIS_FEAT_I_O		0x8
16810216Sphk#define	CIS_FEAT_IRQ		0x10
16910216Sphk#define	CIS_FEAT_MEMORY(x)	(((x) >> 5) & 0x3)
17010216Sphk#define	CIS_FEAT_MISC		0x80
17110216Sphk/*
17210216Sphk *	Depending on whether the "features" byte has the corresponding
17310216Sphk *	bit set, a number of sub-tuples follow. Some features have
17410216Sphk *	more than one sub-tuple, depending on the count within the
17510216Sphk *	features byte (e.g power feature bits allows up to 3 sub-tuples).
17610216Sphk *
17710216Sphk *	Power structure sub-tuple:
17810216Sphk *	Byte 1: parameter exists - Each bit (starting from 0x01) indicates
17910216Sphk *		that a parameter block exists - up to 8 parameter blocks
18010216Sphk *		are therefore allowed).
18110216Sphk *	Byte 2:
18210216Sphk *		0x7F - Parameter data
18310216Sphk *		0x80 - More bytes follow (0 = last byte)
18410216Sphk *
18510216Sphk *	Timing sub-tuple
18610216Sphk *	Byte 1:
18710216Sphk *		0x03 - Wait scale
18810216Sphk *		0x1C - Ready scale
18910216Sphk *		0xE0 - Reserved scale
19010216Sphk *	Byte 2: extended wait scale if wait scale != 3
19110216Sphk *	Byte 3: extended ready scale if ready scale != 7
19210216Sphk *	Byte 4: extended reserved scale if reserved scale != 7
19310216Sphk */
19410216Sphk#define	CIS_WAIT_SCALE(x)	((x) & 0x3)
19510216Sphk#define	CIS_READY_SCALE(x)	(((x)>>2) & 0x7)
19610216Sphk#define	CIS_RESERVED_SCALE(x)	(((x)>>5) & 0x7)
19710216Sphk/*
19810216Sphk *	I/O mapping sub-tuple:
19910216Sphk *	Byte 1:
20010216Sphk *		0x1F - I/O address lines
20110216Sphk *		0x20 - 8 bit I/O
20210216Sphk *		0x40 - 16 bit I/O
20310216Sphk *		0x80 - I/O range??
20410216Sphk *	Byte 2:
20510216Sphk *		0x0F - 0's numbered count of I/O block subtuples following.
20610216Sphk *		0x30 - Size of I/O address value within subtuple. Values
20710216Sphk *			can be 1 (8 bits), 2 (16 bits) or 3 (32 bits).
20810216Sphk *		0xC0 - Size of I/O port block size value within subtuple.
20910216Sphk *	I/O block sub-tuples, count from previous block:
21010216Sphk *		Byte 1-n: I/O start address
21110216Sphk *		Byte x-x: Size of I/O port block.
21210216Sphk */
21310216Sphk#define	CIS_IO_ADDR(x)	((x) & 0x1F)
21410216Sphk#define	CIS_IO_8BIT	0x20
21510216Sphk#define	CIS_IO_16BIT	0x40
21610216Sphk#define	CIS_IO_RANGE	0x80
21710216Sphk#define	CIS_IO_BLKS(x)	((x) & 0xF)
21810216Sphk#define	CIS_IO_ADSZ(x)	(((x)>>4) & 3)
21910216Sphk#define	CIS_IO_BLKSZ(x)	(((x)>>6) & 3)
22010216Sphk/*
22110216Sphk *	IRQ sub-tuple.
22210216Sphk *	Byte 1:
22310216Sphk *		0x0F - Irq number or mask bits
22410216Sphk *		0x10 - IRQ mask values exist
22510216Sphk *		0x20 - Level triggered interrupts
22610216Sphk *		0x40 - Pulse triggered requests
22710216Sphk *		0x80 - Interrupt sharing.
22810216Sphk *	Byte 2-3: Interrupt req mask (if 0x10 of byte 1 set).
22910216Sphk */
23010216Sphk#define	CIS_IRQ_IRQN(x)		((x) & 0xF)
23110216Sphk#define	CIS_IRQ_MASK		0x10
23210216Sphk#define	CIS_IRQ_LEVEL		0x20
23310216Sphk#define	CIS_IRQ_PULSE		0x40
23410216Sphk#define	CIS_IRQ_SHARING		0x80
23510216Sphk/*
23610216Sphk *	Memory block subtuple. Depending on the features bits, the
23710216Sphk *	following subtuples are used:
23810216Sphk *	mem features == 1
23910216Sphk *		Byte 1-2: upper 16 bits of 24 bit memory length.
24010216Sphk *	mem features == 2
24110216Sphk *		Byte 1-2: upper 16 bits of 24 bit memory length.
24210216Sphk *		Byte 3-4: upper 16 bits of 24 bit memory address.
24310216Sphk *	mem_features == 3
24410216Sphk *		Byte 1:
24510216Sphk *			0x07 - 0's numbered count of memory sub-tuples
24610216Sphk *			0x18 - Memory length size (1's numbered)
24710216Sphk *			0x60 - Memory address size (1's numbered)
24810216Sphk *			0x80 - Host address value exists
24910216Sphk *		Memory sub-tuples follow:
25010216Sphk *			Byte 1-n: Memory length value (<< 8)
25110216Sphk *			Byte n-n: Memory card address value (<< 8)
25210216Sphk *			Byte n-n: Memory host address value (<< 8)
25310216Sphk */
25410216Sphk#define	CIS_FEAT_MEM_NONE	0	/* No memory config */
25510216Sphk#define	CIS_FEAT_MEM_LEN	1	/* Just length */
25610216Sphk#define	CIS_FEAT_MEM_ADDR	2	/* Card address & length */
25710216Sphk#define	CIS_FEAT_MEM_WIN	3	/* Multiple windows */
25810216Sphk
25910216Sphk#define	CIS_MEM_WINS(x)		(((x) & 0x7)+1)
26010216Sphk#define	CIS_MEM_LENSZ(x)	(((x) >> 3) & 0x3)
26110216Sphk#define	CIS_MEM_ADDRSZ(x)	(((x) >> 5) & 0x3)
26210216Sphk#define	CIS_MEM_HOST		0x80
26359656Siwasaki/*
26459656Siwasaki *	Misc sub-tuple.
26559656Siwasaki *	Byte 1:
26659656Siwasaki *	Byte 2:
26759656Siwasaki *		0x0c - DMA Request Signal
26859656Siwasaki *                      00 - not support DMA
26959656Siwasaki *                      01 - use SPKR# line
27059656Siwasaki *                      10 - use IOIS16# line
27159656Siwasaki *                      11 - use INPACK# line
27259656Siwasaki *		0x10 - DMA Width
27359656Siwasaki *                      0 - 8 bit DMA
27459656Siwasaki *                      1 - 16 bit DMA
27559656Siwasaki */
27659656Siwasaki#define	CIS_MISC_DMA_WIDTH(x)	(((x) & 0x10) >> 4)
27759656Siwasaki#define	CIS_MISC_DMA_REQ(x)	(((x) >> 2) & 0x3)
27859656Siwasaki
27959656Siwasaki#endif	/* _PCCARD_CIS_H */
280