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