cardinfo.h revision 99943
110216Sphk/*
210216Sphk *	Include file for PCMCIA user process interface
310216Sphk *
410216Sphk *-------------------------------------------------------------------------
510216Sphk *
610216Sphk * Copyright (c) 1995 Andrew McRae.  All rights reserved.
710216Sphk *
810216Sphk * Redistribution and use in source and binary forms, with or without
910216Sphk * modification, are permitted provided that the following conditions
1010216Sphk * are met:
1110216Sphk * 1. Redistributions of source code must retain the above copyright
1210216Sphk *    notice, this list of conditions and the following disclaimer.
1310216Sphk * 2. Redistributions in binary form must reproduce the above copyright
1410216Sphk *    notice, this list of conditions and the following disclaimer in the
1510216Sphk *    documentation and/or other materials provided with the distribution.
1610216Sphk * 3. The name of the author may not be used to endorse or promote products
1710216Sphk *    derived from this software without specific prior written permission.
1810216Sphk *
1910216Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2010216Sphk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2110216Sphk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2210216Sphk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2310216Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2410216Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2510216Sphk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2610216Sphk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2710216Sphk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2810216Sphk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2910216Sphk */
3018444Sbde
3154021Simp/* $FreeBSD: head/sys/pccard/cardinfo.h 99943 2002-07-14 06:47:52Z imp $ */
3254021Simp
3331289Snate#ifndef	_PCCARD_CARDINFO_H_
3431289Snate#define	_PCCARD_CARDINFO_H_
3518444Sbde
3655206Speter#ifndef _KERNEL
3718444Sbde#include <sys/types.h>
3818444Sbde#endif
3918444Sbde#include <sys/ioccom.h>
4018444Sbde
4110216Sphk#define	PIOCGSTATE	_IOR('P', 1, struct slotstate)	/* Get slot state */
4210216Sphk#define	PIOCGMEM	_IOWR('P', 2, struct mem_desc)	/* Get memory map */
4310216Sphk#define	PIOCSMEM	_IOW('P', 3, struct mem_desc)	/* Set memory map */
4410216Sphk#define	PIOCGIO		_IOWR('P', 4, struct io_desc)	/* Get I/O map */
4510216Sphk#define	PIOCSIO		_IOW('P', 5, struct io_desc)	/* Set I/O map */
4656095Shosokawa#define PIOCSDRV	_IOWR('P', 6, struct dev_desc)	/* Set driver */
4710216Sphk#define PIOCRWFLAG	_IOW('P', 7, int)	/* Set flags for drv use */
4810216Sphk#define PIOCRWMEM	_IOWR('P', 8, unsigned long) /* Set mem for drv use */
4910216Sphk#define PIOCSPOW	_IOW('P', 9, struct power) /* Set power structure */
5054021Simp#define PIOCSVIR	_IOW('P', 10, int)	/* Virtual insert/remove */
5143964Skuriyama#define PIOCSBEEP	_IOW('P', 11, int)		/* Select Beep */
5265991Ssanpei#define PIOCSRESOURCE	_IOWR('P', 12, struct pccard_resource)	/* get resource info */
5310216Sphk/*
5410216Sphk *	Debug codes.
5510216Sphk */
5610216Sphk#define PIOCGREG	_IOWR('P',100, struct pcic_reg)	/* get reg */
5710216Sphk#define PIOCSREG	_IOW('P', 101, struct pcic_reg)	/* Set reg */
5810216Sphk
5910216Sphk/*
6010216Sphk *	Slot states for PIOCGSTATE
6180438Simp *
6280438Simp *	Here's a state diagram of all the possible states:
6380438Simp *
6480464Simp *                             power x 1
6580464Simp *                       -------------------
6680464Simp *                      /                   \
6780464Simp *                     /                     v
6880464Simp *    resume    +----------+   power x 0   +----------+
6980464Simp *      ------->| inactive |<--------------| filled   |
7080464Simp *     /        +----------+               +----------+
7180464Simp *    /           /     \                   ^   |
7280464Simp *  nil <---------       \        insert or |   | suspend or
7380464Simp *        suspend         \       power x 1 |   | eject
7480464Simp *                         \                |   v
7580464Simp *                          \            +----------+
7680464Simp *                           ----------->|  empty   |
7780464Simp *                             eject     +----------+
7880438Simp *
7980438Simp *	Note, the above diagram is for the state.  On suspend, the laststate
8080438Simp * gets set to suspend to tell pccardd what happened.  Also the nil state
8180439Simp * means that when the no state change has happened.  Note: if you eject
8280439Simp * while suspended in the inactive state, you will return to the
8380439Simp * empty state if you do not insert a new card and to the inactive state
8480439Simp * if you do insert a new card.
8580438Simp *
8680438Simp * Some might argue that inactive should be sticky forever and
8780438Simp * eject/insert shouldn't take it out of that state.  They might be
8880438Simp * right.  On the other hand, some would argue that eject resets all
8980438Simp * state.  They might be right.  They both can't be right.  The above
9080438Simp * represents a reasonable compromise between the two.
9180439Simp *
9280439Simp * Some bridges allow one to query to see if the card was changed while
9380439Simp * we were suspended.  Others do not.  We make no use of this functionality
9480439Simp * at this time.
9510216Sphk */
9664878Sumeenum cardstate { noslot, empty, suspend, filled, inactive };
9710216Sphk
9810216Sphk/*
9910216Sphk *	Descriptor structure for memory map.
10010216Sphk */
10112173Sphkstruct mem_desc {
10210216Sphk	int	window;		/* Memory map window number (0-4) */
10310216Sphk	int	flags;		/* Flags - see below */
10410216Sphk	caddr_t	start;		/* System memory start */
10510216Sphk	int	size;		/* Size of memory area */
10610216Sphk	unsigned long card;	/* Card memory address */
10712173Sphk};
10810216Sphk
10910216Sphk#define	MDF_16BITS	0x01	/* Memory is 16 bits wide */
11010216Sphk#define	MDF_ZEROWS	0x02	/* Set no wait states for memory */
11110216Sphk#define	MDF_WS0		0x04	/* Wait state flags */
11210216Sphk#define	MDF_WS1		0x08
11310216Sphk#define	MDF_ATTR	0x10	/* Memory is attribute memory */
11410216Sphk#define	MDF_WP		0x20	/* Write protect memory */
11510216Sphk#define	MDF_ACTIVE	0x40	/* Context active (read-only) */
11610216Sphk
11710216Sphk/*
11810216Sphk *	Descriptor structure for I/O map
11910216Sphk */
12012173Sphkstruct io_desc {
12110216Sphk	int	window;		/* I/O map number (0-1) */
12210216Sphk	int	flags;		/* Flags - see below */
12310216Sphk	int	start;		/* I/O port start */
12410216Sphk	int	size;		/* Number of port addresses */
12512173Sphk};
12610216Sphk
12710216Sphk#define	IODF_WS		0x01	/* Set wait states for 16 bit I/O access */
12810216Sphk#define	IODF_16BIT	0x02	/* I/O access are 16 bit */
12910216Sphk#define	IODF_CS16	0x04	/* Allow card selection of 16 bit access */
13010216Sphk#define	IODF_ZEROWS	0x08	/* No wait states for 8 bit I/O */
13110216Sphk#define	IODF_ACTIVE	0x10	/* Context active (read-only) */
13210216Sphk
13310216Sphk/*
13410216Sphk *	Device descriptor for allocation of driver.
13510216Sphk */
13630720Snatestruct dev_desc {
13799943Simp	char		name[16];	/* Driver name */
13899943Simp	int		unit;		/* Driver unit number */
13999943Simp	unsigned long	mem;		/* Memory address of driver */
14099943Simp	int		memsize;	/* Memory size (if used) */
14199943Simp	int		iobase;		/* base of I/O ports */
14299943Simp	int		iosize;		/* Length of I/O ports */
14399943Simp	int		irqmask;	/* Interrupt number(s) to allocate */
14499943Simp	int		flags;		/* Device flags */
14599943Simp	uint8_t		misc[116];	/* For any random info */
14699943Simp	uint32_t	manufacturer;	/* Manufacturer ID */
14799943Simp	uint32_t	product;	/* Product ID */
14899943Simp	uint32_t	prodext;	/* Product ID (extended) */
14912173Sphk};
15049352Simp#define DEV_DESC_HAS_SIZE 1
15110216Sphk
15212173Sphkstruct pcic_reg {
15310216Sphk	unsigned char reg;
15410216Sphk	unsigned char value;
15512173Sphk};
15612173Sphk
15710216Sphk/*
15810216Sphk *	Slot information. Used to read current status of slot.
15910216Sphk */
16012173Sphkstruct slotstate {
16199943Simp	enum cardstate	state;		/* Current state of slot */
16299943Simp	enum cardstate	laststate;	/* Previous state of slot */
16399943Simp	int		maxmem;		/* Max allowed memory windows */
16499943Simp	int		maxio;		/* Max allowed I/O windows */
16599943Simp	int		irqs;		/* Bitmap of IRQs allowed */
16699943Simp	int		flags;		/* Capability flags */
16712173Sphk};
16810216Sphk
16910216Sphk/*
17010216Sphk *	The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33.
17110216Sphk */
17212173Sphkstruct power {
17399943Simp	int		vcc;
17499943Simp	int		vpp;
17512173Sphk};
17610216Sphk
17710216Sphk/*
17876500Simp *	The PC-Card resource IOC_GET_RESOURCE_RANGE
17965991Ssanpei */
18065991Ssanpeistruct pccard_resource {
18165991Ssanpei	int		type;
18265991Ssanpei	u_long		size;
18365991Ssanpei	u_long		min;
18465991Ssanpei	u_long		max;
18565991Ssanpei	u_long		resource_addr;
18665991Ssanpei};
18765991Ssanpei
18865991Ssanpei
18965991Ssanpei/*
19010216Sphk *	Other system limits
19110216Sphk */
19210216Sphk#define MAXSLOT 16
19310216Sphk#define	NUM_MEM_WINDOWS	10
19410216Sphk#define	NUM_IO_WINDOWS	6
19567650Simp#define	CARD_DEVICE	"/dev/card%d"		/* String for snprintf */
19674807Simp#define	PCCARD_MEMSIZE	(4*1024)
19718444Sbde
19831289Snate#endif /* !_PCCARD_CARDINFO_H_ */
199