1168404Spjd/* 2168404Spjd * PCMCIA card structures and defines. 3168404Spjd * These defines relate to the user level 4168404Spjd * structures and card information, not 5168404Spjd * driver/process communication. 6168404Spjd *------------------------------------------------------------------------- 7168404Spjd */ 8168404Spjd/*- 9168404Spjd * Copyright (c) 1995 Andrew McRae. All rights reserved. 10168404Spjd * 11168404Spjd * Redistribution and use in source and binary forms, with or without 12168404Spjd * modification, are permitted provided that the following conditions 13168404Spjd * are met: 14168404Spjd * 1. Redistributions of source code must retain the above copyright 15168404Spjd * notice, this list of conditions and the following disclaimer. 16168404Spjd * 2. Redistributions in binary form must reproduce the above copyright 17168404Spjd * notice, this list of conditions and the following disclaimer in the 18168404Spjd * documentation and/or other materials provided with the distribution. 19168404Spjd * 3. The name of the author may not be used to endorse or promote products 20168404Spjd * derived from this software without specific prior written permission. 21168404Spjd * 22168404Spjd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23219089Spjd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24332525Smav * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25236145Smm * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26236155Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27254758Sdelphij * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28296537Smav * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29297763Smav * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30324010Savg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31168404Spjd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32168404Spjd * 33168404Spjd * $FreeBSD$ 34168404Spjd * 35168404Spjd */ 36168404Spjd 37168404Spjd/* 38168404Spjd * Card Information Structure tuples definitions 39332547Smav * The structure of a tuple is basically: 40168404Spjd * 41168404Spjd * Tuple_code 42168404Spjd * Tuple_data_length 43168404Spjd * Tuple_data ... 44168404Spjd * 45168404Spjd * Tuples are contiguous in attribute memory, and 46168404Spjd * are terminated with a 0xFF for the tuple code or 47168404Spjd * the tuple length. 48168404Spjd */ 49168404Spjd#ifndef _PCCARD_CIS_H 50185029Spjd#define _PCCARD_CIS_H 51185029Spjd 52168404Spjd#define CIS_NULL 0 /* Empty tuple */ 53236155Smm#define CIS_MEM_COMMON 0x01 /* Device descriptor, common memory */ 54168404Spjd#define CIS_LONGLINK_CB 0x02 /* Long link to next chain for CardBus */ 55168404Spjd#define CIS_INDIRECT 0x03 /* Indirect access */ 56168404Spjd#define CIS_CONF_MAP_CB 0x04 /* Card Configuration map for CardBus */ 57168404Spjd#define CIS_CONFIG_CB 0x05 /* Card Configuration entry for CardBus */ 58168404Spjd#define CIS_LONGLINK_MFC 0x06 /* Long link to next chain for Multi function card */ 59168404Spjd#define CIS_BAR 0x07 /* Base address register for CardBus */ 60185029Spjd#define CIS_CHECKSUM 0x10 /* Checksum */ 61236884Smm#define CIS_LONGLINK_A 0x11 /* Link to Attribute memory */ 62168404Spjd#define CIS_LONGLINK_C 0x12 /* Link to Common memory */ 63219089Spjd#define CIS_LINKTARGET 0x13 /* Linked tuple must start with this. */ 64219089Spjd#define CIS_NOLINK 0x14 /* Assume no common memory link tuple. */ 65359754Skevans#define CIS_INFO_V1 0x15 /* Card info data, version 1 */ 66359754Skevans#define CIS_ALTSTR 0x16 /* Alternate language string tuple. */ 67168404Spjd#define CIS_MEM_ATTR 0x17 /* Device descriptor, Attribute memory */ 68168404Spjd#define CIS_JEDEC_C 0x18 /* JEDEC descr for common memory */ 69168404Spjd#define CIS_JEDEC_A 0x19 /* JEDEC descr for Attribute memory */ 70168404Spjd#define CIS_CONF_MAP 0x1A /* Card Configuration map */ 71168404Spjd#define CIS_CONFIG 0x1B /* Card Configuration entry */ 72224171Sgibbs#define CIS_DEVICE_OC 0x1C /* Other conditions info - common memory */ 73168404Spjd#define CIS_DEVICE_OA 0x1D /* Other conditions info - attribute memory */ 74332547Smav#define CIS_DEVICEGEO 0x1E /* Geometry info for common memory */ 75332547Smav#define CIS_DEVICEGEO_A 0x1F /* Geometry info for attribute memory */ 76168404Spjd#define CIS_MANUF_ID 0x20 /* Card manufacturer's ID */ 77168404Spjd#define CIS_FUNC_ID 0x21 /* Function of card */ 78168404Spjd#define CIS_FUNC_EXT 0x22 /* Functional extension */ 79168404Spjd/* 80168404Spjd * Data recording format tuples. 81168404Spjd */ 82168404Spjd#define CIS_SW_INTERLV 0x23 /* Software interleave */ 83236155Smm#define CIS_VERS_2 0x40 /* Card info data, version 2 */ 84168404Spjd#define CIS_FORMAT 0x41 /* Memory card format */ 85228103Smm#define CIS_GEOMETRY 0x42 /* Disk sector layout */ 86228103Smm#define CIS_BYTEORDER 0x43 /* Byte order of memory data */ 87168404Spjd#define CIS_DATE 0x44 /* Format data/time */ 88168404Spjd#define CIS_BATTERY 0x45 /* Battery replacement date */ 89168404Spjd#define CIS_ORG 0x46 /* Organization of data on card */ 90219089Spjd#define CIS_END 0xFF /* Termination code */ 91168404Spjd 92339111Smav/* 93168404Spjd * Internal tuple definitions. 94168404Spjd * 95168404Spjd * Device descriptor for memory (CIS_MEM_ATTR, CIS_MEM_COMMON) 96168404Spjd * 97168404Spjd * Byte 1: 98168404Spjd * 0xF0 - Device type 99168404Spjd * 0x08 - Write protect switch 100168404Spjd * 0x07 - Speed index (7 = extended speed) 101168404Spjd * Byte 2: Extended speed (bit 7 = another follows) 102168404Spjd * Byte 3: (ignored if 0xFF) 103168404Spjd * 0xF8 - Addressable units (0's numbered) 104168404Spjd * 0x07 - Unit size 105168404Spjd * The three byte sequence is repeated until byte 1 == 0xFF 106168404Spjd */ 107168404Spjd 108168404Spjd/* 109185029Spjd * CIS_INFO_V1 - Version one card information. 110185029Spjd * 111168404Spjd * Byte 1: Major version number (should be 4) 112168404Spjd * Byte 2: Minor version number (should be 1) 113168404Spjd * Byte 3-x: Null terminated Manufacturer name 114168404Spjd * Byte x-x: Null terminated product name 115168404Spjd * Byte x-x: Null terminated additional info 1 116168404Spjd * Byte x-x: Null terminated additional info 2 117168404Spjd * Byte x: final byte must be 0xFF 118168404Spjd */ 119168404Spjd#define CIS_MAJOR_VERSION 4 120168404Spjd#define CIS_MINOR_VERSION 1 121168404Spjd 122185029Spjd/* 123168404Spjd * CIS_CONF_MAP - Provides an address map for the card 124168404Spjd * configuration register(s), and a max value 125168404Spjd * identifying the last configuration tuple. 126168404Spjd * 127168404Spjd * Byte 1: 128168404Spjd * 0x3C - Register mask size (0's numbered) 129332547Smav * 0x03 - Register address size (0's numbered) 130168404Spjd * Byte 2: 131168404Spjd * 0x3F - ID of last configuration. 132168404Spjd * Byte 3-n: Card register address (size is determined by 133168404Spjd * the value in byte 1). 134168404Spjd * Byte x-x: Card register masks (size determined by the 135168404Spjd * value in byte 1) 136224171Sgibbs */ 137168404Spjd 138168404Spjd/* 139168404Spjd * CIS_CONFIG - Card configuration entry. Multiple tuples may 140168404Spjd * exist of this type, each one describing a different 141168404Spjd * memory/I-O map that can be used to address this card. 142339111Smav * The first one usually has extra config data about the 143168404Spjd * card features. The final configuration tuple number 144168404Spjd * is stored in the CIS_CONF_MAP tuple so that the complete 145168404Spjd * list can be scanned. 146168404Spjd * 147219089Spjd * Byte 1: 148228103Smm * 0x3F - Configuration ID number. 149236155Smm * 0x40 - Indicates this is the default configuration 150236155Smm * 0x80 - Interface byte exists 151168404Spjd * Byte 2: (exists only if bit 0x80 set in byte 1) 152168404Spjd * 0x0F - Interface type value 153168404Spjd * 0x10 - Battery voltage detect 154168404Spjd * 0x20 - Write protect active 155168404Spjd * 0x40 - RdyBsy active bit 156168404Spjd * 0x80 - Wait signal required 157168404Spjd * Byte 3: (features byte) 158168404Spjd * 0x03 - Power sub-tuple(s) exists 159168404Spjd * 0x04 - Timing sub-tuple exists 160168404Spjd * 0x08 - I/O space sub-tuple exists 161168404Spjd * 0x10 - IRQ sub-tuple exists 162168404Spjd * 0x60 - Memory space sub-tuple(s) exists 163168404Spjd * 0x80 - Miscellaneous sub-tuple exists 164168404Spjd */ 165168404Spjd#define CIS_FEAT_POWER(x) ((x) & 0x3) 166168404Spjd#define CIS_FEAT_TIMING 0x4 167168404Spjd#define CIS_FEAT_I_O 0x8 168168404Spjd#define CIS_FEAT_IRQ 0x10 169168404Spjd#define CIS_FEAT_MEMORY(x) (((x) >> 5) & 0x3) 170168404Spjd#define CIS_FEAT_MISC 0x80 171168404Spjd/* 172168404Spjd * Depending on whether the "features" byte has the corresponding 173168404Spjd * bit set, a number of sub-tuples follow. Some features have 174168404Spjd * more than one sub-tuple, depending on the count within the 175168404Spjd * features byte (e.g power feature bits allows up to 3 sub-tuples). 176224171Sgibbs * 177224171Sgibbs * Power structure sub-tuple: 178332547Smav * Byte 1: parameter exists - Each bit (starting from 0x01) indicates 179332547Smav * that a parameter block exists - up to 8 parameter blocks 180168404Spjd * are therefore allowed). 181168404Spjd * Byte 2: 182168404Spjd * 0x7F - Parameter data 183168404Spjd * 0x80 - More bytes follow (0 = last byte) 184168404Spjd * 185168404Spjd * Timing sub-tuple 186168404Spjd * Byte 1: 187236155Smm * 0x03 - Wait scale 188168404Spjd * 0x1C - Ready scale 189168404Spjd * 0xE0 - Reserved scale 190168404Spjd * Byte 2: extended wait scale if wait scale != 3 191168404Spjd * Byte 3: extended ready scale if ready scale != 7 192219089Spjd * Byte 4: extended reserved scale if reserved scale != 7 193168404Spjd */ 194339111Smav#define CIS_WAIT_SCALE(x) ((x) & 0x3) 195168404Spjd#define CIS_READY_SCALE(x) (((x)>>2) & 0x7) 196168404Spjd#define CIS_RESERVED_SCALE(x) (((x)>>5) & 0x7) 197168404Spjd/* 198168404Spjd * I/O mapping sub-tuple: 199168404Spjd * Byte 1: 200228103Smm * 0x1F - I/O address lines 201168404Spjd * 0x20 - 8 bit I/O 202168404Spjd * 0x40 - 16 bit I/O 203168404Spjd * 0x80 - I/O range?? 204168404Spjd * Byte 2: 205168404Spjd * 0x0F - 0's numbered count of I/O block subtuples following. 206168404Spjd * 0x30 - Size of I/O address value within subtuple. Values 207168404Spjd * can be 1 (8 bits), 2 (16 bits) or 3 (32 bits). 208168404Spjd * 0xC0 - Size of I/O port block size value within subtuple. 209248571Smm * I/O block sub-tuples, count from previous block: 210185029Spjd * Byte 1-n: I/O start address 211248571Smm * Byte x-x: Size of I/O port block. 212219089Spjd */ 213219089Spjd#define CIS_IO_ADDR(x) ((x) & 0x1F) 214168404Spjd#define CIS_IO_8BIT 0x20 215289562Smav#define CIS_IO_16BIT 0x40 216289562Smav#define CIS_IO_RANGE 0x80 217168404Spjd#define CIS_IO_BLKS(x) ((x) & 0xF) 218168404Spjd#define CIS_IO_ADSZ(x) (((x)>>4) & 3) 219168404Spjd#define CIS_IO_BLKSZ(x) (((x)>>6) & 3) 220168404Spjd/* 221168404Spjd * IRQ sub-tuple. 222185029Spjd * Byte 1: 223168404Spjd * 0x0F - Irq number or mask bits 224219089Spjd * 0x10 - IRQ mask values exist 225168404Spjd * 0x20 - Level triggered interrupts 226331395Smav * 0x40 - Pulse triggered requests 227331395Smav * 0x80 - Interrupt sharing. 228333194Savg * Byte 2-3: Interrupt req mask (if 0x10 of byte 1 set). 229333194Savg */ 230333194Savg#define CIS_IRQ_IRQN(x) ((x) & 0xF) 231332547Smav#define CIS_IRQ_MASK 0x10 232332547Smav#define CIS_IRQ_LEVEL 0x20 233168404Spjd#define CIS_IRQ_PULSE 0x40 234168404Spjd#define CIS_IRQ_SHARING 0x80 235168404Spjd/* 236168404Spjd * Memory block subtuple. Depending on the features bits, the 237168404Spjd * following subtuples are used: 238168404Spjd * mem features == 1 239168404Spjd * Byte 1-2: upper 16 bits of 24 bit memory length. 240185029Spjd * mem features == 2 241168404Spjd * Byte 1-2: upper 16 bits of 24 bit memory length. 242168404Spjd * Byte 3-4: upper 16 bits of 24 bit memory address. 243185029Spjd * mem_features == 3 244219089Spjd * Byte 1: 245219089Spjd * 0x07 - 0's numbered count of memory sub-tuples 246185029Spjd * 0x18 - Memory length size (1's numbered) 247219089Spjd * 0x60 - Memory address size (1's numbered) 248333194Savg * 0x80 - Host address value exists 249332547Smav * Memory sub-tuples follow: 250168404Spjd * Byte 1-n: Memory length value (<< 8) 251219089Spjd * Byte n-n: Memory card address value (<< 8) 252168404Spjd * Byte n-n: Memory host address value (<< 8) 253224171Sgibbs */ 254224171Sgibbs#define CIS_FEAT_MEM_NONE 0 /* No memory config */ 255168404Spjd#define CIS_FEAT_MEM_LEN 1 /* Just length */ 256263889Sdelphij#define CIS_FEAT_MEM_ADDR 2 /* Card address & length */ 257219089Spjd#define CIS_FEAT_MEM_WIN 3 /* Multiple windows */ 258168404Spjd 259168404Spjd#define CIS_MEM_WINS(x) (((x) & 0x7)+1) 260168404Spjd#define CIS_MEM_LENSZ(x) (((x) >> 3) & 0x3) 261228020Smm#define CIS_MEM_ADDRSZ(x) (((x) >> 5) & 0x3) 262168404Spjd#define CIS_MEM_HOST 0x80 263168404Spjd/* 264185029Spjd * Misc sub-tuple. 265168404Spjd * Byte 1: 266332525Smav * Byte 2: 267236155Smm * 0x0c - DMA Request Signal 268260138Sdelphij * 00 - not support DMA 269339111Smav * 01 - use SPKR# line 270339111Smav * 10 - use IOIS16# line 271168404Spjd * 11 - use INPACK# line 272324010Savg * 0x10 - DMA Width 273168404Spjd * 0 - 8 bit DMA 274219089Spjd * 1 - 16 bit DMA 275219089Spjd */ 276168404Spjd#define CIS_MISC_DMA_WIDTH(x) (((x) & 0x10) >> 4) 277228020Smm#define CIS_MISC_DMA_REQ(x) (((x) >> 2) & 0x3) 278185029Spjd 279168404Spjd#endif /* _PCCARD_CIS_H */ 280263889Sdelphij