1f7911ae5SWarner Losh /* 2f7911ae5SWarner Losh * Include file for PCMCIA user process interface 3f7911ae5SWarner Losh * 4f7911ae5SWarner Losh *------------------------------------------------------------------------- 5f7911ae5SWarner Losh */ 6f7911ae5SWarner Losh /*- 7*1de7b4b8SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 8*1de7b4b8SPedro F. Giffuni * 9f7911ae5SWarner Losh * Copyright (c) 1995 Andrew McRae. All rights reserved. 10f7911ae5SWarner Losh * 11f7911ae5SWarner Losh * Redistribution and use in source and binary forms, with or without 12f7911ae5SWarner Losh * modification, are permitted provided that the following conditions 13f7911ae5SWarner Losh * are met: 14f7911ae5SWarner Losh * 1. Redistributions of source code must retain the above copyright 15f7911ae5SWarner Losh * notice, this list of conditions and the following disclaimer. 16f7911ae5SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 17f7911ae5SWarner Losh * notice, this list of conditions and the following disclaimer in the 18f7911ae5SWarner Losh * documentation and/or other materials provided with the distribution. 19f7911ae5SWarner Losh * 3. The name of the author may not be used to endorse or promote products 20f7911ae5SWarner Losh * derived from this software without specific prior written permission. 21f7911ae5SWarner Losh * 22f7911ae5SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23f7911ae5SWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24f7911ae5SWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25f7911ae5SWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26f7911ae5SWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27f7911ae5SWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28f7911ae5SWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29f7911ae5SWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30f7911ae5SWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31f7911ae5SWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32f7911ae5SWarner Losh */ 33f7911ae5SWarner Losh 34f7911ae5SWarner Losh 35f7911ae5SWarner Losh #ifndef _PCCARD_CARDINFO_H_ 36f7911ae5SWarner Losh #define _PCCARD_CARDINFO_H_ 37f7911ae5SWarner Losh 38f7911ae5SWarner Losh #ifndef _KERNEL 39f7911ae5SWarner Losh #include <sys/types.h> 40f7911ae5SWarner Losh #endif 41f7911ae5SWarner Losh #include <sys/ioccom.h> 42f7911ae5SWarner Losh 43f7911ae5SWarner Losh #define PIOCGSTATE _IOR('P', 1, struct slotstate) /* Get slot state */ 44f7911ae5SWarner Losh #define PIOCGMEM _IOWR('P', 2, struct mem_desc) /* Get memory map */ 45f7911ae5SWarner Losh #define PIOCSMEM _IOW('P', 3, struct mem_desc) /* Set memory map */ 46f7911ae5SWarner Losh #define PIOCGIO _IOWR('P', 4, struct io_desc) /* Get I/O map */ 47f7911ae5SWarner Losh #define PIOCSIO _IOW('P', 5, struct io_desc) /* Set I/O map */ 48f7911ae5SWarner Losh #define PIOCSDRV _IOWR('P', 6, struct dev_desc) /* Set driver */ 49f7911ae5SWarner Losh #define PIOCRWFLAG _IOW('P', 7, int) /* Set flags for drv use */ 50f7911ae5SWarner Losh #define PIOCRWMEM _IOWR('P', 8, unsigned long) /* Set mem for drv use */ 51f7911ae5SWarner Losh #define PIOCSPOW _IOW('P', 9, struct power) /* Set power structure */ 52f7911ae5SWarner Losh #define PIOCSVIR _IOW('P', 10, int) /* Virtual insert/remove */ 53f7911ae5SWarner Losh #define PIOCSBEEP _IOW('P', 11, int) /* Select Beep */ 54f7911ae5SWarner Losh #define PIOCSRESOURCE _IOWR('P', 12, struct pccard_resource) /* get resource info */ 55f7911ae5SWarner Losh /* 56f7911ae5SWarner Losh * Debug codes. 57f7911ae5SWarner Losh */ 58f7911ae5SWarner Losh #define PIOCGREG _IOWR('P',100, struct pcic_reg) /* get reg */ 59f7911ae5SWarner Losh #define PIOCSREG _IOW('P', 101, struct pcic_reg) /* Set reg */ 60f7911ae5SWarner Losh 61f7911ae5SWarner Losh /* 62f7911ae5SWarner Losh * Slot states for PIOCGSTATE 63f7911ae5SWarner Losh * 64f7911ae5SWarner Losh * Here's a state diagram of all the possible states: 65f7911ae5SWarner Losh * 66f7911ae5SWarner Losh * power x 1 67f7911ae5SWarner Losh * ------------------- 68f7911ae5SWarner Losh * / \ 69f7911ae5SWarner Losh * / v 70f7911ae5SWarner Losh * resume +----------+ power x 0 +----------+ 71f7911ae5SWarner Losh * ------->| inactive |<--------------| filled | 72f7911ae5SWarner Losh * / +----------+ +----------+ 73f7911ae5SWarner Losh * / / \ ^ | 74f7911ae5SWarner Losh * nil <--------- \ insert or | | suspend or 75f7911ae5SWarner Losh * suspend \ power x 1 | | eject 76f7911ae5SWarner Losh * \ | v 77f7911ae5SWarner Losh * \ +----------+ 78f7911ae5SWarner Losh * ----------->| empty | 79f7911ae5SWarner Losh * eject +----------+ 80f7911ae5SWarner Losh * 81f7911ae5SWarner Losh * Note, the above diagram is for the state. On suspend, the laststate 82f7911ae5SWarner Losh * gets set to suspend to tell pccardd what happened. Also the nil state 83f7911ae5SWarner Losh * means that when the no state change has happened. Note: if you eject 84f7911ae5SWarner Losh * while suspended in the inactive state, you will return to the 85f7911ae5SWarner Losh * empty state if you do not insert a new card and to the inactive state 86f7911ae5SWarner Losh * if you do insert a new card. 87f7911ae5SWarner Losh * 88f7911ae5SWarner Losh * Some might argue that inactive should be sticky forever and 89f7911ae5SWarner Losh * eject/insert shouldn't take it out of that state. They might be 90f7911ae5SWarner Losh * right. On the other hand, some would argue that eject resets all 91f7911ae5SWarner Losh * state. They might be right. They both can't be right. The above 92f7911ae5SWarner Losh * represents a reasonable compromise between the two. 93f7911ae5SWarner Losh * 94f7911ae5SWarner Losh * Some bridges allow one to query to see if the card was changed while 95f7911ae5SWarner Losh * we were suspended. Others do not. We make no use of this functionality 96f7911ae5SWarner Losh * at this time. 97f7911ae5SWarner Losh */ 98f7911ae5SWarner Losh enum cardstate { noslot, empty, suspend, filled, inactive }; 99f7911ae5SWarner Losh 100f7911ae5SWarner Losh /* 101f7911ae5SWarner Losh * Descriptor structure for memory map. 102f7911ae5SWarner Losh */ 103f7911ae5SWarner Losh struct mem_desc { 104f7911ae5SWarner Losh int window; /* Memory map window number (0-4) */ 105f7911ae5SWarner Losh int flags; /* Flags - see below */ 106f7911ae5SWarner Losh caddr_t start; /* System memory start */ 107f7911ae5SWarner Losh int size; /* Size of memory area */ 108f7911ae5SWarner Losh unsigned long card; /* Card memory address */ 109f7911ae5SWarner Losh }; 110f7911ae5SWarner Losh 111f7911ae5SWarner Losh #define MDF_16BITS 0x01 /* Memory is 16 bits wide */ 112f7911ae5SWarner Losh #define MDF_ZEROWS 0x02 /* Set no wait states for memory */ 113f7911ae5SWarner Losh #define MDF_WS0 0x04 /* Wait state flags */ 114f7911ae5SWarner Losh #define MDF_WS1 0x08 115f7911ae5SWarner Losh #define MDF_ATTR 0x10 /* Memory is attribute memory */ 116f7911ae5SWarner Losh #define MDF_WP 0x20 /* Write protect memory */ 117f7911ae5SWarner Losh #define MDF_ACTIVE 0x40 /* Context active (read-only) */ 118f7911ae5SWarner Losh 119f7911ae5SWarner Losh /* 120f7911ae5SWarner Losh * Descriptor structure for I/O map 121f7911ae5SWarner Losh */ 122f7911ae5SWarner Losh struct io_desc { 123f7911ae5SWarner Losh int window; /* I/O map number (0-1) */ 124f7911ae5SWarner Losh int flags; /* Flags - see below */ 125f7911ae5SWarner Losh int start; /* I/O port start */ 126f7911ae5SWarner Losh int size; /* Number of port addresses */ 127f7911ae5SWarner Losh }; 128f7911ae5SWarner Losh 129f7911ae5SWarner Losh #define IODF_WS 0x01 /* Set wait states for 16 bit I/O access */ 130f7911ae5SWarner Losh #define IODF_16BIT 0x02 /* I/O access are 16 bit */ 131f7911ae5SWarner Losh #define IODF_CS16 0x04 /* Allow card selection of 16 bit access */ 132f7911ae5SWarner Losh #define IODF_ZEROWS 0x08 /* No wait states for 8 bit I/O */ 133f7911ae5SWarner Losh #define IODF_ACTIVE 0x10 /* Context active (read-only) */ 134f7911ae5SWarner Losh 135f7911ae5SWarner Losh /* 136f7911ae5SWarner Losh * Device descriptor for allocation of driver. 137f7911ae5SWarner Losh */ 138f7911ae5SWarner Losh #define DEV_MISC_LEN 36 139f7911ae5SWarner Losh #define DEV_MAX_CIS_LEN 40 140f7911ae5SWarner Losh struct dev_desc { 141f7911ae5SWarner Losh char name[16]; /* Driver name */ 142f7911ae5SWarner Losh int unit; /* Driver unit number */ 143f7911ae5SWarner Losh unsigned long mem; /* Memory address of driver */ 144f7911ae5SWarner Losh int memsize; /* Memory size (if used) */ 145f7911ae5SWarner Losh int iobase; /* base of I/O ports */ 146f7911ae5SWarner Losh int iosize; /* Length of I/O ports */ 147f7911ae5SWarner Losh int irqmask; /* Interrupt number(s) to allocate */ 148f7911ae5SWarner Losh int flags; /* Device flags */ 149f7911ae5SWarner Losh uint8_t misc[DEV_MISC_LEN]; /* For any random info */ 150f7911ae5SWarner Losh uint8_t manufstr[DEV_MAX_CIS_LEN]; 151f7911ae5SWarner Losh uint8_t versstr[DEV_MAX_CIS_LEN]; 152f7911ae5SWarner Losh uint8_t cis3str[DEV_MAX_CIS_LEN]; 153f7911ae5SWarner Losh uint8_t cis4str[DEV_MAX_CIS_LEN]; 154f7911ae5SWarner Losh uint32_t manufacturer; /* Manufacturer ID */ 155f7911ae5SWarner Losh uint32_t product; /* Product ID */ 156f7911ae5SWarner Losh uint32_t prodext; /* Product ID (extended) */ 157f7911ae5SWarner Losh }; 158f7911ae5SWarner Losh #define DEV_DESC_HAS_SIZE 1 159f7911ae5SWarner Losh 160f7911ae5SWarner Losh struct pcic_reg { 161f7911ae5SWarner Losh unsigned char reg; 162f7911ae5SWarner Losh unsigned char value; 163f7911ae5SWarner Losh }; 164f7911ae5SWarner Losh 165f7911ae5SWarner Losh /* 166f7911ae5SWarner Losh * Slot information. Used to read current status of slot. 167f7911ae5SWarner Losh */ 168f7911ae5SWarner Losh struct slotstate { 169f7911ae5SWarner Losh enum cardstate state; /* Current state of slot */ 170f7911ae5SWarner Losh enum cardstate laststate; /* Previous state of slot */ 171f7911ae5SWarner Losh int maxmem; /* Max allowed memory windows */ 172f7911ae5SWarner Losh int maxio; /* Max allowed I/O windows */ 173f7911ae5SWarner Losh int irqs; /* Bitmap of IRQs allowed */ 174f7911ae5SWarner Losh int flags; /* Capability flags */ 175f7911ae5SWarner Losh }; 176f7911ae5SWarner Losh 177f7911ae5SWarner Losh /* 178f7911ae5SWarner Losh * The power values are in volts * 10, e.g. 5V is 50, 3.3V is 33. 179f7911ae5SWarner Losh */ 180f7911ae5SWarner Losh struct power { 181f7911ae5SWarner Losh int vcc; 182f7911ae5SWarner Losh int vpp; 183f7911ae5SWarner Losh }; 184f7911ae5SWarner Losh 185f7911ae5SWarner Losh /* 186f7911ae5SWarner Losh * The PC-Card resource IOC_GET_RESOURCE_RANGE 187f7911ae5SWarner Losh */ 188f7911ae5SWarner Losh struct pccard_resource { 189f7911ae5SWarner Losh int type; 190f7911ae5SWarner Losh u_long size; 191f7911ae5SWarner Losh u_long min; 192f7911ae5SWarner Losh u_long max; 193f7911ae5SWarner Losh u_long resource_addr; 194f7911ae5SWarner Losh }; 195f7911ae5SWarner Losh 196f7911ae5SWarner Losh 197f7911ae5SWarner Losh /* 198f7911ae5SWarner Losh * Other system limits 199f7911ae5SWarner Losh */ 200f7911ae5SWarner Losh #define MAXSLOT 16 201f7911ae5SWarner Losh #define NUM_MEM_WINDOWS 10 202f7911ae5SWarner Losh #define NUM_IO_WINDOWS 6 203f7911ae5SWarner Losh #define CARD_DEVICE "/dev/card%d" /* String for snprintf */ 204f7911ae5SWarner Losh #define PCCARD_MEMSIZE (4*1024) 205f7911ae5SWarner Losh 206f7911ae5SWarner Losh #endif /* !_PCCARD_CARDINFO_H_ */ 207