110216Sphk/* 210216Sphk * Include file for PCMCIA user process interface 310216Sphk * 410216Sphk *------------------------------------------------------------------------- 5139825Simp */ 6139825Simp/*- 710216Sphk * Copyright (c) 1995 Andrew McRae. All rights reserved. 810216Sphk * 910216Sphk * Redistribution and use in source and binary forms, with or without 1010216Sphk * modification, are permitted provided that the following conditions 1110216Sphk * are met: 1210216Sphk * 1. Redistributions of source code must retain the above copyright 1310216Sphk * notice, this list of conditions and the following disclaimer. 1410216Sphk * 2. Redistributions in binary form must reproduce the above copyright 1510216Sphk * notice, this list of conditions and the following disclaimer in the 1610216Sphk * documentation and/or other materials provided with the distribution. 1710216Sphk * 3. The name of the author may not be used to endorse or promote products 1810216Sphk * derived from this software without specific prior written permission. 1910216Sphk * 2010216Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 2110216Sphk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2210216Sphk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2310216Sphk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2410216Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2510216Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2610216Sphk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2710216Sphk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2810216Sphk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2910216Sphk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3010216Sphk */ 3118444Sbde 3254021Simp/* $FreeBSD$ */ 3354021Simp 3431289Snate#ifndef _PCCARD_CARDINFO_H_ 3531289Snate#define _PCCARD_CARDINFO_H_ 3618444Sbde 3755206Speter#ifndef _KERNEL 3818444Sbde#include <sys/types.h> 3918444Sbde#endif 4018444Sbde#include <sys/ioccom.h> 4118444Sbde 4210216Sphk#define PIOCGSTATE _IOR('P', 1, struct slotstate) /* Get slot state */ 4310216Sphk#define PIOCGMEM _IOWR('P', 2, struct mem_desc) /* Get memory map */ 4410216Sphk#define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */ 4510216Sphk#define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */ 4610216Sphk#define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */ 4756095Shosokawa#define PIOCSDRV _IOWR('P', 6, struct dev_desc) /* Set driver */ 4810216Sphk#define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */ 4910216Sphk#define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */ 5010216Sphk#define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */ 5154021Simp#define PIOCSVIR _IOW('P', 10, int) /* Virtual insert/remove */ 5243964Skuriyama#define PIOCSBEEP _IOW('P', 11, int) /* Select Beep */ 5365991Ssanpei#define PIOCSRESOURCE _IOWR('P', 12, struct pccard_resource) /* get resource info */ 5410216Sphk/* 5510216Sphk * Debug codes. 5610216Sphk */ 5710216Sphk#define PIOCGREG _IOWR('P',100, struct pcic_reg) /* get reg */ 5810216Sphk#define PIOCSREG _IOW('P', 101, struct pcic_reg) /* Set reg */ 5910216Sphk 6010216Sphk/* 6110216Sphk * Slot states for PIOCGSTATE 6280438Simp * 6380438Simp * Here's a state diagram of all the possible states: 6480438Simp * 6580464Simp * power x 1 6680464Simp * ------------------- 6780464Simp * / \ 6880464Simp * / v 6980464Simp * resume +----------+ power x 0 +----------+ 7080464Simp * ------->| inactive |<--------------| filled | 7180464Simp * / +----------+ +----------+ 7280464Simp * / / \ ^ | 7380464Simp * nil <--------- \ insert or | | suspend or 7480464Simp * suspend \ power x 1 | | eject 7580464Simp * \ | v 7680464Simp * \ +----------+ 7780464Simp * ----------->| empty | 7880464Simp * eject +----------+ 7980438Simp * 8080438Simp * Note, the above diagram is for the state. On suspend, the laststate 8180438Simp * gets set to suspend to tell pccardd what happened. Also the nil state 8280439Simp * means that when the no state change has happened. Note: if you eject 8380439Simp * while suspended in the inactive state, you will return to the 8480439Simp * empty state if you do not insert a new card and to the inactive state 8580439Simp * if you do insert a new card. 8680438Simp * 8780438Simp * Some might argue that inactive should be sticky forever and 8880438Simp * eject/insert shouldn't take it out of that state. They might be 8980438Simp * right. On the other hand, some would argue that eject resets all 9080438Simp * state. They might be right. They both can't be right. The above 9180438Simp * represents a reasonable compromise between the two. 9280439Simp * 9380439Simp * Some bridges allow one to query to see if the card was changed while 9480439Simp * we were suspended. Others do not. We make no use of this functionality 9580439Simp * at this time. 9610216Sphk */ 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 */ 137100484Simp#define DEV_MISC_LEN 36 138100484Simp#define DEV_MAX_CIS_LEN 40 13930720Snatestruct dev_desc { 14099943Simp char name[16]; /* Driver name */ 14199943Simp int unit; /* Driver unit number */ 14299943Simp unsigned long mem; /* Memory address of driver */ 14399943Simp int memsize; /* Memory size (if used) */ 14499943Simp int iobase; /* base of I/O ports */ 14599943Simp int iosize; /* Length of I/O ports */ 14699943Simp int irqmask; /* Interrupt number(s) to allocate */ 14799943Simp int flags; /* Device flags */ 148100484Simp uint8_t misc[DEV_MISC_LEN]; /* For any random info */ 149100484Simp uint8_t manufstr[DEV_MAX_CIS_LEN]; 150100484Simp uint8_t versstr[DEV_MAX_CIS_LEN]; 151113946Simp uint8_t cis3str[DEV_MAX_CIS_LEN]; 152113946Simp uint8_t cis4str[DEV_MAX_CIS_LEN]; 15399943Simp uint32_t manufacturer; /* Manufacturer ID */ 15499943Simp uint32_t product; /* Product ID */ 15599943Simp uint32_t prodext; /* Product ID (extended) */ 15612173Sphk}; 15749352Simp#define DEV_DESC_HAS_SIZE 1 15810216Sphk 15912173Sphkstruct pcic_reg { 16010216Sphk unsigned char reg; 16110216Sphk unsigned char value; 16212173Sphk}; 16312173Sphk 16410216Sphk/* 16510216Sphk * Slot information. Used to read current status of slot. 16610216Sphk */ 16712173Sphkstruct slotstate { 16899943Simp enum cardstate state; /* Current state of slot */ 16999943Simp enum cardstate laststate; /* Previous state of slot */ 17099943Simp int maxmem; /* Max allowed memory windows */ 17199943Simp int maxio; /* Max allowed I/O windows */ 17299943Simp int irqs; /* Bitmap of IRQs allowed */ 17399943Simp int flags; /* Capability flags */ 17412173Sphk}; 17510216Sphk 17610216Sphk/* 17710216Sphk * The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33. 17810216Sphk */ 17912173Sphkstruct power { 18099943Simp int vcc; 18199943Simp int vpp; 18212173Sphk}; 18310216Sphk 18410216Sphk/* 18576500Simp * The PC-Card resource IOC_GET_RESOURCE_RANGE 18665991Ssanpei */ 18765991Ssanpeistruct pccard_resource { 18865991Ssanpei int type; 18965991Ssanpei u_long size; 19065991Ssanpei u_long min; 19165991Ssanpei u_long max; 19265991Ssanpei u_long resource_addr; 19365991Ssanpei}; 19465991Ssanpei 19565991Ssanpei 19665991Ssanpei/* 19710216Sphk * Other system limits 19810216Sphk */ 19910216Sphk#define MAXSLOT 16 20010216Sphk#define NUM_MEM_WINDOWS 10 20110216Sphk#define NUM_IO_WINDOWS 6 20267650Simp#define CARD_DEVICE "/dev/card%d" /* String for snprintf */ 20374807Simp#define PCCARD_MEMSIZE (4*1024) 20418444Sbde 20531289Snate#endif /* !_PCCARD_CARDINFO_H_ */ 206