cardinfo.h revision 80439
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 80439 2001-07-27 07:32:59Z 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 * 6480438Simp * power x 1 6580438Simp * ------------------- 6680438Simp * / \ 6780438Simp * / v 6880438Simp * resume +----------+ power x 0 +----------+ 6980438Simp * ------->| inactive |<--------------| filled | 7080438Simp * / +----------+ +----------+ 7180438Simp * / / \ ^ | 7280438Simp * nil <--------- \ insert or | | suspend or 7380438Simp * suspend \ power x 1 | | eject 7480438Simp * \ | v 7580438Simp * \ +----------+ 7680438Simp * ------------->| empty | 7780438Simp * 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 */ 9680438Simp 9764878Sumeenum cardstate { noslot, empty, suspend, filled, inactive }; 9810216Sphk 9910216Sphk/* 10010216Sphk * Descriptor structure for memory map. 10110216Sphk */ 10212173Sphkstruct mem_desc { 10310216Sphk int window; /* Memory map window number (0-4) */ 10410216Sphk int flags; /* Flags - see below */ 10510216Sphk caddr_t start; /* System memory start */ 10610216Sphk int size; /* Size of memory area */ 10710216Sphk unsigned long card; /* Card memory address */ 10812173Sphk}; 10910216Sphk 11010216Sphk#define MDF_16BITS 0x01 /* Memory is 16 bits wide */ 11110216Sphk#define MDF_ZEROWS 0x02 /* Set no wait states for memory */ 11210216Sphk#define MDF_WS0 0x04 /* Wait state flags */ 11310216Sphk#define MDF_WS1 0x08 11410216Sphk#define MDF_ATTR 0x10 /* Memory is attribute memory */ 11510216Sphk#define MDF_WP 0x20 /* Write protect memory */ 11610216Sphk#define MDF_ACTIVE 0x40 /* Context active (read-only) */ 11710216Sphk 11810216Sphk/* 11910216Sphk * Descriptor structure for I/O map 12010216Sphk */ 12112173Sphkstruct io_desc { 12210216Sphk int window; /* I/O map number (0-1) */ 12310216Sphk int flags; /* Flags - see below */ 12410216Sphk int start; /* I/O port start */ 12510216Sphk int size; /* Number of port addresses */ 12612173Sphk}; 12710216Sphk 12810216Sphk#define IODF_WS 0x01 /* Set wait states for 16 bit I/O access */ 12910216Sphk#define IODF_16BIT 0x02 /* I/O access are 16 bit */ 13010216Sphk#define IODF_CS16 0x04 /* Allow card selection of 16 bit access */ 13110216Sphk#define IODF_ZEROWS 0x08 /* No wait states for 8 bit I/O */ 13210216Sphk#define IODF_ACTIVE 0x10 /* Context active (read-only) */ 13310216Sphk 13410216Sphk/* 13510216Sphk * Device descriptor for allocation of driver. 13610216Sphk */ 13730720Snatestruct dev_desc { 13810216Sphk char name[16]; /* Driver name */ 13910216Sphk int unit; /* Driver unit number */ 14010216Sphk unsigned long mem; /* Memory address of driver */ 14110216Sphk int memsize; /* Memory size (if used) */ 14210216Sphk int iobase; /* base of I/O ports */ 14349352Simp int iosize; /* Length of I/O ports */ 14410216Sphk int irqmask; /* Interrupt number(s) to allocate */ 14510216Sphk int flags; /* Device flags */ 14610914Sphk u_char misc[128]; /* For any random info */ 14712173Sphk}; 14849352Simp#define DEV_DESC_HAS_SIZE 1 14910216Sphk 15012173Sphkstruct pcic_reg { 15110216Sphk unsigned char reg; 15210216Sphk unsigned char value; 15312173Sphk}; 15412173Sphk 15510216Sphk/* 15610216Sphk * Slot information. Used to read current status of slot. 15710216Sphk */ 15812173Sphkstruct slotstate { 15910216Sphk enum cardstate state; /* Current state of slot */ 16035345Snate enum cardstate laststate; /* Previous state of slot */ 16110216Sphk int maxmem; /* Max allowed memory windows */ 16210216Sphk int maxio; /* Max allowed I/O windows */ 16310216Sphk int irqs; /* Bitmap of IRQs allowed */ 16410216Sphk int flags; /* Capability flags */ 16512173Sphk}; 16610216Sphk 16710216Sphk/* 16810216Sphk * The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33. 16910216Sphk */ 17012173Sphkstruct power { 17110216Sphk int vcc; 17210216Sphk int vpp; 17312173Sphk}; 17410216Sphk 17510216Sphk/* 17676500Simp * The PC-Card resource IOC_GET_RESOURCE_RANGE 17765991Ssanpei */ 17865991Ssanpeistruct pccard_resource { 17965991Ssanpei int type; 18065991Ssanpei u_long size; 18165991Ssanpei u_long min; 18265991Ssanpei u_long max; 18365991Ssanpei u_long resource_addr; 18465991Ssanpei}; 18565991Ssanpei 18665991Ssanpei 18765991Ssanpei/* 18810216Sphk * Other system limits 18910216Sphk */ 19010216Sphk#define MAXSLOT 16 19110216Sphk#define NUM_MEM_WINDOWS 10 19210216Sphk#define NUM_IO_WINDOWS 6 19367650Simp#define CARD_DEVICE "/dev/card%d" /* String for snprintf */ 19474807Simp#define PCCARD_MEMSIZE (4*1024) 19518444Sbde 19631289Snate#endif /* !_PCCARD_CARDINFO_H_ */ 197