1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Include file for PCMCIA user process interface
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
2005-01-07 02:29:27 +00:00
|
|
|
*/
|
|
|
|
/*-
|
1995-08-24 08:56:20 +00:00
|
|
|
* Copyright (c) 1995 Andrew McRae. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
1996-09-21 14:59:43 +00:00
|
|
|
|
1999-12-02 05:46:22 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
|
1997-11-18 21:04:01 +00:00
|
|
|
#ifndef _PCCARD_CARDINFO_H_
|
|
|
|
#define _PCCARD_CARDINFO_H_
|
1996-09-21 14:59:43 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifndef _KERNEL
|
1996-09-21 14:59:43 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/ioccom.h>
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
#define PIOCGSTATE _IOR('P', 1, struct slotstate) /* Get slot state */
|
|
|
|
#define PIOCGMEM _IOWR('P', 2, struct mem_desc) /* Get memory map */
|
|
|
|
#define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */
|
|
|
|
#define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */
|
|
|
|
#define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */
|
2000-01-16 06:44:48 +00:00
|
|
|
#define PIOCSDRV _IOWR('P', 6, struct dev_desc) /* Set driver */
|
1995-08-24 08:56:20 +00:00
|
|
|
#define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */
|
|
|
|
#define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */
|
|
|
|
#define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */
|
1999-12-02 05:46:22 +00:00
|
|
|
#define PIOCSVIR _IOW('P', 10, int) /* Virtual insert/remove */
|
1999-02-13 11:32:00 +00:00
|
|
|
#define PIOCSBEEP _IOW('P', 11, int) /* Select Beep */
|
2000-09-17 15:37:53 +00:00
|
|
|
#define PIOCSRESOURCE _IOWR('P', 12, struct pccard_resource) /* get resource info */
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Debug codes.
|
|
|
|
*/
|
|
|
|
#define PIOCGREG _IOWR('P',100, struct pcic_reg) /* get reg */
|
|
|
|
#define PIOCSREG _IOW('P', 101, struct pcic_reg) /* Set reg */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Slot states for PIOCGSTATE
|
2001-07-27 07:21:42 +00:00
|
|
|
*
|
|
|
|
* Here's a state diagram of all the possible states:
|
|
|
|
*
|
2001-07-28 03:45:55 +00:00
|
|
|
* power x 1
|
|
|
|
* -------------------
|
|
|
|
* / \
|
|
|
|
* / v
|
|
|
|
* resume +----------+ power x 0 +----------+
|
|
|
|
* ------->| inactive |<--------------| filled |
|
|
|
|
* / +----------+ +----------+
|
|
|
|
* / / \ ^ |
|
|
|
|
* nil <--------- \ insert or | | suspend or
|
|
|
|
* suspend \ power x 1 | | eject
|
|
|
|
* \ | v
|
|
|
|
* \ +----------+
|
|
|
|
* ----------->| empty |
|
|
|
|
* eject +----------+
|
2001-07-27 07:21:42 +00:00
|
|
|
*
|
|
|
|
* Note, the above diagram is for the state. On suspend, the laststate
|
|
|
|
* gets set to suspend to tell pccardd what happened. Also the nil state
|
2001-07-27 07:32:59 +00:00
|
|
|
* means that when the no state change has happened. Note: if you eject
|
|
|
|
* while suspended in the inactive state, you will return to the
|
|
|
|
* empty state if you do not insert a new card and to the inactive state
|
|
|
|
* if you do insert a new card.
|
2001-07-27 07:21:42 +00:00
|
|
|
*
|
|
|
|
* Some might argue that inactive should be sticky forever and
|
|
|
|
* eject/insert shouldn't take it out of that state. They might be
|
|
|
|
* right. On the other hand, some would argue that eject resets all
|
|
|
|
* state. They might be right. They both can't be right. The above
|
|
|
|
* represents a reasonable compromise between the two.
|
2001-07-27 07:32:59 +00:00
|
|
|
*
|
|
|
|
* Some bridges allow one to query to see if the card was changed while
|
|
|
|
* we were suspended. Others do not. We make no use of this functionality
|
|
|
|
* at this time.
|
1995-08-24 08:56:20 +00:00
|
|
|
*/
|
2000-08-20 16:16:57 +00:00
|
|
|
enum cardstate { noslot, empty, suspend, filled, inactive };
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Descriptor structure for memory map.
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
struct mem_desc {
|
1995-08-24 08:56:20 +00:00
|
|
|
int window; /* Memory map window number (0-4) */
|
|
|
|
int flags; /* Flags - see below */
|
|
|
|
caddr_t start; /* System memory start */
|
|
|
|
int size; /* Size of memory area */
|
|
|
|
unsigned long card; /* Card memory address */
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#define MDF_16BITS 0x01 /* Memory is 16 bits wide */
|
|
|
|
#define MDF_ZEROWS 0x02 /* Set no wait states for memory */
|
|
|
|
#define MDF_WS0 0x04 /* Wait state flags */
|
|
|
|
#define MDF_WS1 0x08
|
|
|
|
#define MDF_ATTR 0x10 /* Memory is attribute memory */
|
|
|
|
#define MDF_WP 0x20 /* Write protect memory */
|
|
|
|
#define MDF_ACTIVE 0x40 /* Context active (read-only) */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Descriptor structure for I/O map
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
struct io_desc {
|
1995-08-24 08:56:20 +00:00
|
|
|
int window; /* I/O map number (0-1) */
|
|
|
|
int flags; /* Flags - see below */
|
|
|
|
int start; /* I/O port start */
|
|
|
|
int size; /* Number of port addresses */
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
#define IODF_WS 0x01 /* Set wait states for 16 bit I/O access */
|
|
|
|
#define IODF_16BIT 0x02 /* I/O access are 16 bit */
|
|
|
|
#define IODF_CS16 0x04 /* Allow card selection of 16 bit access */
|
|
|
|
#define IODF_ZEROWS 0x08 /* No wait states for 8 bit I/O */
|
|
|
|
#define IODF_ACTIVE 0x10 /* Context active (read-only) */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device descriptor for allocation of driver.
|
|
|
|
*/
|
2002-07-22 06:46:10 +00:00
|
|
|
#define DEV_MISC_LEN 36
|
|
|
|
#define DEV_MAX_CIS_LEN 40
|
1997-10-26 04:36:24 +00:00
|
|
|
struct dev_desc {
|
2002-07-14 06:47:52 +00:00
|
|
|
char name[16]; /* Driver name */
|
|
|
|
int unit; /* Driver unit number */
|
|
|
|
unsigned long mem; /* Memory address of driver */
|
|
|
|
int memsize; /* Memory size (if used) */
|
|
|
|
int iobase; /* base of I/O ports */
|
|
|
|
int iosize; /* Length of I/O ports */
|
|
|
|
int irqmask; /* Interrupt number(s) to allocate */
|
|
|
|
int flags; /* Device flags */
|
2002-07-22 06:46:10 +00:00
|
|
|
uint8_t misc[DEV_MISC_LEN]; /* For any random info */
|
|
|
|
uint8_t manufstr[DEV_MAX_CIS_LEN];
|
|
|
|
uint8_t versstr[DEV_MAX_CIS_LEN];
|
2003-04-23 23:39:21 +00:00
|
|
|
uint8_t cis3str[DEV_MAX_CIS_LEN];
|
|
|
|
uint8_t cis4str[DEV_MAX_CIS_LEN];
|
2002-07-14 06:47:52 +00:00
|
|
|
uint32_t manufacturer; /* Manufacturer ID */
|
|
|
|
uint32_t product; /* Product ID */
|
|
|
|
uint32_t prodext; /* Product ID (extended) */
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
1999-08-01 18:12:51 +00:00
|
|
|
#define DEV_DESC_HAS_SIZE 1
|
1995-08-24 08:56:20 +00:00
|
|
|
|
1995-11-09 20:44:36 +00:00
|
|
|
struct pcic_reg {
|
1995-08-24 08:56:20 +00:00
|
|
|
unsigned char reg;
|
|
|
|
unsigned char value;
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Slot information. Used to read current status of slot.
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
struct slotstate {
|
2002-07-14 06:47:52 +00:00
|
|
|
enum cardstate state; /* Current state of slot */
|
|
|
|
enum cardstate laststate; /* Previous state of slot */
|
|
|
|
int maxmem; /* Max allowed memory windows */
|
|
|
|
int maxio; /* Max allowed I/O windows */
|
|
|
|
int irqs; /* Bitmap of IRQs allowed */
|
|
|
|
int flags; /* Capability flags */
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
1995-08-24 08:56:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33.
|
|
|
|
*/
|
1995-11-09 20:44:36 +00:00
|
|
|
struct power {
|
2002-07-14 06:47:52 +00:00
|
|
|
int vcc;
|
|
|
|
int vpp;
|
1995-11-09 20:44:36 +00:00
|
|
|
};
|
1995-08-24 08:56:20 +00:00
|
|
|
|
2000-09-17 15:37:53 +00:00
|
|
|
/*
|
2001-05-12 06:04:02 +00:00
|
|
|
* The PC-Card resource IOC_GET_RESOURCE_RANGE
|
2000-09-17 15:37:53 +00:00
|
|
|
*/
|
|
|
|
struct pccard_resource {
|
|
|
|
int type;
|
|
|
|
u_long size;
|
|
|
|
u_long min;
|
|
|
|
u_long max;
|
|
|
|
u_long resource_addr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
1995-08-24 08:56:20 +00:00
|
|
|
/*
|
|
|
|
* Other system limits
|
|
|
|
*/
|
|
|
|
#define MAXSLOT 16
|
|
|
|
#define NUM_MEM_WINDOWS 10
|
|
|
|
#define NUM_IO_WINDOWS 6
|
2000-10-26 19:46:20 +00:00
|
|
|
#define CARD_DEVICE "/dev/card%d" /* String for snprintf */
|
2001-03-26 08:05:20 +00:00
|
|
|
#define PCCARD_MEMSIZE (4*1024)
|
1996-09-21 14:59:43 +00:00
|
|
|
|
1997-11-18 21:04:01 +00:00
|
|
|
#endif /* !_PCCARD_CARDINFO_H_ */
|