1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * PCMCIA nexus 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #ifndef _PCMCIA_H 32*7c478bd9Sstevel@tonic-gate #define _PCMCIA_H 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37*7c478bd9Sstevel@tonic-gate extern "C" { 38*7c478bd9Sstevel@tonic-gate #endif 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) 41*7c478bd9Sstevel@tonic-gate #define PCMCIA_DEBUG 42*7c478bd9Sstevel@tonic-gate #endif 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_ADAPTERS 8 /* maximum distinct adapters */ 47*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_SOCKETS 64 /* maximum distinct sockets */ 48*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_WIN_ADAPT 40 49*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_WINDOWS (PCMCIA_MAX_ADAPTERS*PCMCIA_MAX_WIN_ADAPT) 50*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_POWER 16 /* maximum power table entries */ 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #define _VERSION(major, minor) ((major)<<16|(minor)) 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * DDI/Nexus stuff 56*7c478bd9Sstevel@tonic-gate */ 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define PCMCIA_NEXUS_NAME "pcmcia" 59*7c478bd9Sstevel@tonic-gate #define PCMCIA_ADAPTER_NODE "ddi_pcmcia:adapter" 60*7c478bd9Sstevel@tonic-gate #define PCMCIA_SOCKET_NODE "ddi_pcmcia:socket" 61*7c478bd9Sstevel@tonic-gate #define PCMCIA_PCCARD_NODE "ddi_pcmcia:pccard" 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate /* 64*7c478bd9Sstevel@tonic-gate * private interface between nexus and adapter specific driver 65*7c478bd9Sstevel@tonic-gate * This is only an "ops" type structure 66*7c478bd9Sstevel@tonic-gate */ 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate typedef struct pcmcia_if { 69*7c478bd9Sstevel@tonic-gate uint32_t pcif_magic; /* magic number to verify correct scructure */ 70*7c478bd9Sstevel@tonic-gate uint32_t pcif_version; 71*7c478bd9Sstevel@tonic-gate int (*pcif_set_callback)(); 72*7c478bd9Sstevel@tonic-gate int (*pcif_get_adapter)(); 73*7c478bd9Sstevel@tonic-gate int (*pcif_get_page)(); 74*7c478bd9Sstevel@tonic-gate int (*pcif_get_socket)(); 75*7c478bd9Sstevel@tonic-gate int (*pcif_get_status)(); 76*7c478bd9Sstevel@tonic-gate int (*pcif_get_window)(); 77*7c478bd9Sstevel@tonic-gate int (*pcif_inquire_adapter)(); 78*7c478bd9Sstevel@tonic-gate int (*pcif_inquire_socket)(); 79*7c478bd9Sstevel@tonic-gate int (*pcif_inquire_window)(); 80*7c478bd9Sstevel@tonic-gate int (*pcif_reset_socket)(); 81*7c478bd9Sstevel@tonic-gate int (*pcif_set_page)(); 82*7c478bd9Sstevel@tonic-gate int (*pcif_set_window)(); 83*7c478bd9Sstevel@tonic-gate int (*pcif_set_socket)(); 84*7c478bd9Sstevel@tonic-gate int (*pcif_set_interrupt)(); 85*7c478bd9Sstevel@tonic-gate int (*pcif_clr_interrupt)(); 86*7c478bd9Sstevel@tonic-gate int (*pcic_init_dev)(); 87*7c478bd9Sstevel@tonic-gate uint32_t (*pcic_get_tstamp)(); 88*7c478bd9Sstevel@tonic-gate } pcmcia_if_t; 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate /* 91*7c478bd9Sstevel@tonic-gate * magic number and version information to identify 92*7c478bd9Sstevel@tonic-gate * variant of the PCMCIA nexus. 93*7c478bd9Sstevel@tonic-gate */ 94*7c478bd9Sstevel@tonic-gate #define PCIF_MAGIC 0x50434946 95*7c478bd9Sstevel@tonic-gate #define PCIF_VERSION _VERSION(0, 1) 96*7c478bd9Sstevel@tonic-gate #define PCIF_MIN_VERSION _VERSION(0, 1) 97*7c478bd9Sstevel@tonic-gate #define DEFAULT_CS_NAME "cs" 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate /* 100*7c478bd9Sstevel@tonic-gate * all adapter drivers use a commonly defined structure for 101*7c478bd9Sstevel@tonic-gate * their private data. This structure must be filled in 102*7c478bd9Sstevel@tonic-gate * and set. The an_private member is for the driver writer's 103*7c478bd9Sstevel@tonic-gate * use and is not looked at by the nexus. 104*7c478bd9Sstevel@tonic-gate */ 105*7c478bd9Sstevel@tonic-gate struct pcmcia_adapter_nexus_private { 106*7c478bd9Sstevel@tonic-gate dev_info_t *an_dip; 107*7c478bd9Sstevel@tonic-gate pcmcia_if_t *an_if; 108*7c478bd9Sstevel@tonic-gate void *an_private; 109*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *an_iblock; /* high priority handler cookies */ 110*7c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *an_idev; 111*7c478bd9Sstevel@tonic-gate uint32_t an_ipl; 112*7c478bd9Sstevel@tonic-gate }; 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate typedef struct pcmcia_adapter_nexus_private anp_t; 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate struct pcm_regs { 117*7c478bd9Sstevel@tonic-gate uint32_t phys_hi; 118*7c478bd9Sstevel@tonic-gate uint32_t phys_lo; 119*7c478bd9Sstevel@tonic-gate uint32_t phys_len; 120*7c478bd9Sstevel@tonic-gate }; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate /* 123*7c478bd9Sstevel@tonic-gate * shared interrupts are handled by the 124*7c478bd9Sstevel@tonic-gate * nexus going through the list 125*7c478bd9Sstevel@tonic-gate */ 126*7c478bd9Sstevel@tonic-gate typedef struct inthandler { 127*7c478bd9Sstevel@tonic-gate struct inthandler *next; 128*7c478bd9Sstevel@tonic-gate struct inthandler *prev; 129*7c478bd9Sstevel@tonic-gate int flags; 130*7c478bd9Sstevel@tonic-gate uint32_t (*intr)(caddr_t, caddr_t); 131*7c478bd9Sstevel@tonic-gate unsigned handler_id; 132*7c478bd9Sstevel@tonic-gate void *arg1; 133*7c478bd9Sstevel@tonic-gate void *arg2; 134*7c478bd9Sstevel@tonic-gate unsigned socket; 135*7c478bd9Sstevel@tonic-gate unsigned irq; 136*7c478bd9Sstevel@tonic-gate unsigned priority; 137*7c478bd9Sstevel@tonic-gate ddi_softintr_t softid; 138*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t iblk_cookie; 139*7c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t idev_cookie; 140*7c478bd9Sstevel@tonic-gate } inthandler_t; 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate /* 143*7c478bd9Sstevel@tonic-gate * parent private data area 144*7c478bd9Sstevel@tonic-gate * not using the old style but will adapt on request 145*7c478bd9Sstevel@tonic-gate * this allows better framework handling and 1275 compliance 146*7c478bd9Sstevel@tonic-gate */ 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate struct pcmcia_parent_private { 149*7c478bd9Sstevel@tonic-gate int ppd_nreg; /* number of regs */ 150*7c478bd9Sstevel@tonic-gate struct pcm_regs *ppd_reg; /* array of regs in parsed form */ 151*7c478bd9Sstevel@tonic-gate int ppd_intr; /* number intrspecs (always 0 or 1) */ 152*7c478bd9Sstevel@tonic-gate struct intrspec *ppd_intrspec; 153*7c478bd9Sstevel@tonic-gate void *pcm_dummy[3]; /* fill for prtconf -v */ 154*7c478bd9Sstevel@tonic-gate struct pcm_regs *ppd_assigned; /* array of regs in parsed form */ 155*7c478bd9Sstevel@tonic-gate short ppd_socket; /* socket number of this instance */ 156*7c478bd9Sstevel@tonic-gate short ppd_function; /* function number */ 157*7c478bd9Sstevel@tonic-gate int ppd_active; /* is PC Card in a socket and active */ 158*7c478bd9Sstevel@tonic-gate uint32_t ppd_flags; 159*7c478bd9Sstevel@tonic-gate void *ppd_handle; /* client handle */ 160*7c478bd9Sstevel@tonic-gate }; 161*7c478bd9Sstevel@tonic-gate 162*7c478bd9Sstevel@tonic-gate #define PPD_CARD_MULTI 0x0001 /* card is multifunction card */ 163*7c478bd9Sstevel@tonic-gate #define PPD_CARD_CARDBUS 0x0002 /* card is CardBus type */ 164*7c478bd9Sstevel@tonic-gate #define PPD_CB_BUSMASTER 0x0004 /* card bus card is busmaster */ 165*7c478bd9Sstevel@tonic-gate #define PPD_SUSPENDED 0x0008 /* this device was pm suspended */ 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate /* 168*7c478bd9Sstevel@tonic-gate * macros to make indirect functions easier 169*7c478bd9Sstevel@tonic-gate * and shorter (makes cstyle happier) 170*7c478bd9Sstevel@tonic-gate */ 171*7c478bd9Sstevel@tonic-gate 172*7c478bd9Sstevel@tonic-gate #define GET_SOCKET_STATUS(f, dip, sock, stat)\ 173*7c478bd9Sstevel@tonic-gate (*(f)->pcif_get_socket_status)(dip, sock, stat) 174*7c478bd9Sstevel@tonic-gate #define SET_CALLBACK(f, dip, callback, sock)\ 175*7c478bd9Sstevel@tonic-gate (*(f)->pcif_set_callback)(dip, callback, sock) 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate #define GET_ADAPTER(f, dip, conf) (*(f)->pcif_get_adapter) (dip, conf) 178*7c478bd9Sstevel@tonic-gate #define GET_SOCKET(f, dip, sock) (*(f)->pcif_get_socket)(dip, sock) 179*7c478bd9Sstevel@tonic-gate #define GET_STATUS(f, dip, status) (*(f)->pcif_get_status)(dip, status) 180*7c478bd9Sstevel@tonic-gate #define GET_WINDOW(f, dip, window) (*(f)->pcif_get_window)(dip, window) 181*7c478bd9Sstevel@tonic-gate #define INQUIRE_ADAPTER(f, dip, inquire) (*(f)->pcif_inquire_adapter)(dip,\ 182*7c478bd9Sstevel@tonic-gate inquire) 183*7c478bd9Sstevel@tonic-gate #define GET_CONFIG(f, dip, conf) INQUIRE_ADAPTER(f, dip, conf) 184*7c478bd9Sstevel@tonic-gate #define INQUIRE_SOCKET(f, dip, sock) (*(f)->pcif_inquire_socket)(dip, \ 185*7c478bd9Sstevel@tonic-gate sock) 186*7c478bd9Sstevel@tonic-gate #define GET_PAGE(f, dip, page) (*(f)->pcif_get_page)(dip, page) 187*7c478bd9Sstevel@tonic-gate #define INQUIRE_WINDOW(f, dip, window) (*(f)->pcif_inquire_window)(dip, window) 188*7c478bd9Sstevel@tonic-gate #define RESET_SOCKET(f, dip, socket, mode) \ 189*7c478bd9Sstevel@tonic-gate (*(f)->pcif_reset_socket)(dip, socket, mode) 190*7c478bd9Sstevel@tonic-gate #define SET_PAGE(f, dip, page) (*(f)->pcif_set_page)(dip, page) 191*7c478bd9Sstevel@tonic-gate #define SET_WINDOW(f, dip, window) (*(f)->pcif_set_window)(dip, window) 192*7c478bd9Sstevel@tonic-gate #define SET_SOCKET(f, dip, socket) (*(f)->pcif_set_socket)(dip, socket) 193*7c478bd9Sstevel@tonic-gate #define SET_IRQ(f, dip, handler) (*(f)->pcif_set_interrupt)(dip, handler) 194*7c478bd9Sstevel@tonic-gate #define CLEAR_IRQ(f, dip, handler) (*(f)->pcif_clr_interrupt)(dip, handler) 195*7c478bd9Sstevel@tonic-gate 196*7c478bd9Sstevel@tonic-gate typedef struct pcmcia_cs { 197*7c478bd9Sstevel@tonic-gate uint32_t pccs_magic; /* magic number of verify correct structure */ 198*7c478bd9Sstevel@tonic-gate uint32_t pccs_version; 199*7c478bd9Sstevel@tonic-gate int (*pccs_callback)(); 200*7c478bd9Sstevel@tonic-gate int (*pccs_getconfig)(); 201*7c478bd9Sstevel@tonic-gate } pcmcia_cs_t; 202*7c478bd9Sstevel@tonic-gate 203*7c478bd9Sstevel@tonic-gate #define PCCS_MAGIC 0x50434353 204*7c478bd9Sstevel@tonic-gate #define PCCS_VERSION _VERSION(2, 1) 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* properties used by the nexus for setup */ 207*7c478bd9Sstevel@tonic-gate #define ADAPT_PROP "adapters" /* property used to find adapter list */ 208*7c478bd9Sstevel@tonic-gate #define CS_PROP "card-services" /* property specifying Card Services */ 209*7c478bd9Sstevel@tonic-gate #define DEF_DRV_PROP "default-driver" /* default driver to load if no CIS */ 210*7c478bd9Sstevel@tonic-gate 211*7c478bd9Sstevel@tonic-gate /* 212*7c478bd9Sstevel@tonic-gate * per adapter structure 213*7c478bd9Sstevel@tonic-gate * this structure defines everything necessary for the 214*7c478bd9Sstevel@tonic-gate * the nexus to interact with the adapter specific driver 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate struct pcmcia_adapter { 218*7c478bd9Sstevel@tonic-gate int pca_module; /* adapter major number */ 219*7c478bd9Sstevel@tonic-gate int pca_unit; /* adapter minor number */ 220*7c478bd9Sstevel@tonic-gate int pca_number; /* canonical adapter number */ 221*7c478bd9Sstevel@tonic-gate struct dev_ops *pca_ops; 222*7c478bd9Sstevel@tonic-gate dev_info_t *pca_dip; 223*7c478bd9Sstevel@tonic-gate pcmcia_if_t *pca_if; 224*7c478bd9Sstevel@tonic-gate void *pca_power; 225*7c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *pca_iblock; 226*7c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *pca_idev; 227*7c478bd9Sstevel@tonic-gate kmutex_t *pca_mutex; 228*7c478bd9Sstevel@tonic-gate int pca_numpower; 229*7c478bd9Sstevel@tonic-gate int pca_numsockets; 230*7c478bd9Sstevel@tonic-gate int pca_first_socket; 231*7c478bd9Sstevel@tonic-gate uint32_t pca_flags; 232*7c478bd9Sstevel@tonic-gate char pca_name[MODMAXNAMELEN]; 233*7c478bd9Sstevel@tonic-gate uint32_t pca_avail_intr; 234*7c478bd9Sstevel@tonic-gate inthandler_t pca_int_handlers; 235*7c478bd9Sstevel@tonic-gate }; 236*7c478bd9Sstevel@tonic-gate 237*7c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_IRQ 0x0001 /* needs IRQ allocation */ 238*7c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_IO 0x0002 /* needs I/O allocation */ 239*7c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_MEM 0x0004 /* needs memory allocation */ 240*7c478bd9Sstevel@tonic-gate #define PCA_RES_CONSTRAINT 0x0008 /* resource constraints defined */ 241*7c478bd9Sstevel@tonic-gate #define PCA_IRQ_SMI_SHARE 0x0010 /* SMI and child share */ 242*7c478bd9Sstevel@tonic-gate #define PCA_IRQ_SHAREABLE 0x0020 /* all interrupts sharable */ 243*7c478bd9Sstevel@tonic-gate #define PCA_IRQ_ISA 0x0040 /* ISA style (host) interrupts */ 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate /* These flags are for open/close -- hot-plug support in future */ 246*7c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_FUNCTIONS 8 247*7c478bd9Sstevel@tonic-gate #define PCS_CARD_PRESENT 0x0001 /* card in socket */ 248*7c478bd9Sstevel@tonic-gate #define PCS_MULTI_FUNCTION 0x0002 /* indicates dip is multifunction */ 249*7c478bd9Sstevel@tonic-gate #define PCS_SOCKET_ADDED 0x0004 /* CS knows about the socket */ 250*7c478bd9Sstevel@tonic-gate #define PCS_COOKIES_VALID 0x0008 /* iblk and idev valid */ 251*7c478bd9Sstevel@tonic-gate #define PCS_IRQ_ENABLED 0x0010 /* IRQ has been enabled */ 252*7c478bd9Sstevel@tonic-gate #define PCS_SUSPENDED 0x0020 /* PM SUSPEND was done */ 253*7c478bd9Sstevel@tonic-gate 254*7c478bd9Sstevel@tonic-gate typedef struct pcmcia_logical_window { 255*7c478bd9Sstevel@tonic-gate int lw_window; /* window number */ 256*7c478bd9Sstevel@tonic-gate int lw_socket; /* logical socket number assigned */ 257*7c478bd9Sstevel@tonic-gate struct pcmcia_adapter *lw_adapter; 258*7c478bd9Sstevel@tonic-gate pcmcia_if_t *lw_if; 259*7c478bd9Sstevel@tonic-gate uint32_t lw_status; 260*7c478bd9Sstevel@tonic-gate baseaddr_t lw_base; 261*7c478bd9Sstevel@tonic-gate int lw_len; 262*7c478bd9Sstevel@tonic-gate } pcmcia_logical_window_t; 263*7c478bd9Sstevel@tonic-gate 264*7c478bd9Sstevel@tonic-gate #define PCS_ENABLED 0x0002 /* window is enabled */ 265*7c478bd9Sstevel@tonic-gate 266*7c478bd9Sstevel@tonic-gate /* 267*7c478bd9Sstevel@tonic-gate * management interface hook 268*7c478bd9Sstevel@tonic-gate */ 269*7c478bd9Sstevel@tonic-gate #define EM_EVENTSIZE 4 270*7c478bd9Sstevel@tonic-gate struct pcmcia_mif { 271*7c478bd9Sstevel@tonic-gate struct pcmcia_mif *mif_next; 272*7c478bd9Sstevel@tonic-gate void (*mif_function)(); 273*7c478bd9Sstevel@tonic-gate uint32_t mif_id; 274*7c478bd9Sstevel@tonic-gate uchar_t mif_events[EM_EVENTSIZE]; /* events registered for */ 275*7c478bd9Sstevel@tonic-gate }; 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate #define PR_WORDSIZE 8 /* bits in word */ 278*7c478bd9Sstevel@tonic-gate #define PR_MASK 0x7 279*7c478bd9Sstevel@tonic-gate #define PR_GET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &\ 280*7c478bd9Sstevel@tonic-gate (1 << ((bit) & PR_MASK))) 281*7c478bd9Sstevel@tonic-gate #define PR_SET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] |=\ 282*7c478bd9Sstevel@tonic-gate (1 << ((bit) & PR_MASK))) 283*7c478bd9Sstevel@tonic-gate #define PR_CLEAR(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &=\ 284*7c478bd9Sstevel@tonic-gate ~(1 << ((bit) & PR_MASK))) 285*7c478bd9Sstevel@tonic-gate #define PR_ADDR(map, bit) (((uchar_t *)(map)) + ((bit)/PR_WORDSIZE)) 286*7c478bd9Sstevel@tonic-gate #define PR_ZERO(map) bzero((caddr_t)map, sizeof (map)) 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate /* socket bit map */ 289*7c478bd9Sstevel@tonic-gate typedef uchar_t socket_enum_t[PCMCIA_MAX_SOCKETS/PR_WORDSIZE]; 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate /* 292*7c478bd9Sstevel@tonic-gate * Max resoruce limits - all of these have to be power-of-2 aligned 293*7c478bd9Sstevel@tonic-gate * and the PR_MAX_IO_LEN and PR_MAX_MEM_LEN values must be at 294*7c478bd9Sstevel@tonic-gate * least 64 or the allocators will panic. 295*7c478bd9Sstevel@tonic-gate */ 296*7c478bd9Sstevel@tonic-gate #define PR_MAX_IO_LEN 1024 /* bytes of IO space */ 297*7c478bd9Sstevel@tonic-gate #define PR_MAX_IO_RANGES 4 298*7c478bd9Sstevel@tonic-gate #define PR_MAX_MEM_LEN 1024 /* pages or 4M bytes */ 299*7c478bd9Sstevel@tonic-gate #define PR_MAX_MEM_RANGES 32 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate #define PR_MAX_IOADDR 0xffffffff 302*7c478bd9Sstevel@tonic-gate #define PR_MAX_MEMADDR 0xffffffff 303*7c478bd9Sstevel@tonic-gate #define PR_MAX_INTERRUPTS 0xff 304*7c478bd9Sstevel@tonic-gate 305*7c478bd9Sstevel@tonic-gate 306*7c478bd9Sstevel@tonic-gate /* 307*7c478bd9Sstevel@tonic-gate * structures and definitions used in the private interface 308*7c478bd9Sstevel@tonic-gate */ 309*7c478bd9Sstevel@tonic-gate 310*7c478bd9Sstevel@tonic-gate /* general values */ 311*7c478bd9Sstevel@tonic-gate #define PC_SUCCESS 1 312*7c478bd9Sstevel@tonic-gate #define PC_FAILURE 0 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate /* set_mem() */ 315*7c478bd9Sstevel@tonic-gate #define PC_MEM_AM 0 316*7c478bd9Sstevel@tonic-gate #define PC_MEM_CM 1 317*7c478bd9Sstevel@tonic-gate 318*7c478bd9Sstevel@tonic-gate /* device classes */ 319*7c478bd9Sstevel@tonic-gate #define PCC_MULTI 0 320*7c478bd9Sstevel@tonic-gate #define PCC_MEMORY 1 321*7c478bd9Sstevel@tonic-gate #define PCC_SERIAL 2 322*7c478bd9Sstevel@tonic-gate #define PCC_PARALLEL 3 323*7c478bd9Sstevel@tonic-gate #define PCC_FIXED_DISK 4 324*7c478bd9Sstevel@tonic-gate #define PCC_VIDEO 5 325*7c478bd9Sstevel@tonic-gate #define PCC_LAN 6 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate /* 328*7c478bd9Sstevel@tonic-gate * device information structure information 329*7c478bd9Sstevel@tonic-gate * this is what is used for initial construction of a device node 330*7c478bd9Sstevel@tonic-gate */ 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate struct pcm_device_info { 333*7c478bd9Sstevel@tonic-gate int pd_socket; 334*7c478bd9Sstevel@tonic-gate int pd_function; 335*7c478bd9Sstevel@tonic-gate int pd_type; 336*7c478bd9Sstevel@tonic-gate uint32_t pd_handle; 337*7c478bd9Sstevel@tonic-gate uint32_t pd_tuples; 338*7c478bd9Sstevel@tonic-gate uint32_t pd_flags; 339*7c478bd9Sstevel@tonic-gate char pd_bind_name[MODMAXNAMELEN]; 340*7c478bd9Sstevel@tonic-gate char pd_vers1_name[MODMAXNAMELEN*4]; 341*7c478bd9Sstevel@tonic-gate char pd_generic_name[MODMAXNAMELEN]; 342*7c478bd9Sstevel@tonic-gate }; 343*7c478bd9Sstevel@tonic-gate 344*7c478bd9Sstevel@tonic-gate #define PCM_GET_SOCKET(socknum) ((socknum) & 0x1F) 345*7c478bd9Sstevel@tonic-gate #define PCM_GET_FUNCTION(socknum) (((socknum) >> 5) & 0x7) 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate #define PCM_DEFAULT_NODEID (-1) 348*7c478bd9Sstevel@tonic-gate #define PCM_DEV_MODEL "model" 349*7c478bd9Sstevel@tonic-gate #define PCM_DEV_ACTIVE "card-active" 350*7c478bd9Sstevel@tonic-gate #define PCM_DEV_SOCKET "socket" 351*7c478bd9Sstevel@tonic-gate #define PCM_DEV_R2TYPE "16bitcard" 352*7c478bd9Sstevel@tonic-gate #define PCM_DEV_CARDBUS "cardbus" 353*7c478bd9Sstevel@tonic-gate 354*7c478bd9Sstevel@tonic-gate typedef 355*7c478bd9Sstevel@tonic-gate struct init_dev { 356*7c478bd9Sstevel@tonic-gate int socket; 357*7c478bd9Sstevel@tonic-gate } init_dev_t; 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate /* 360*7c478bd9Sstevel@tonic-gate * device descriptions 361*7c478bd9Sstevel@tonic-gate * used to determine what driver to associate with a PC Card 362*7c478bd9Sstevel@tonic-gate * so that automatic creation of device information trees can 363*7c478bd9Sstevel@tonic-gate * be supported. 364*7c478bd9Sstevel@tonic-gate */ 365*7c478bd9Sstevel@tonic-gate 366*7c478bd9Sstevel@tonic-gate typedef 367*7c478bd9Sstevel@tonic-gate struct pcm_device_node { 368*7c478bd9Sstevel@tonic-gate struct pcm_device_node *pd_next; 369*7c478bd9Sstevel@tonic-gate dev_info_t *pd_dip; /* proto device info */ 370*7c478bd9Sstevel@tonic-gate char pd_name[16]; 371*7c478bd9Sstevel@tonic-gate int pd_flags; 372*7c478bd9Sstevel@tonic-gate int pd_devtype; /* from device tuple */ 373*7c478bd9Sstevel@tonic-gate int pd_funcid; 374*7c478bd9Sstevel@tonic-gate int pd_manfid; 375*7c478bd9Sstevel@tonic-gate int pd_manmask; 376*7c478bd9Sstevel@tonic-gate } pcm_dev_node_t; 377*7c478bd9Sstevel@tonic-gate 378*7c478bd9Sstevel@tonic-gate #define PCMD_DEVTYPE 0x0001 /* match device type */ 379*7c478bd9Sstevel@tonic-gate #define PCMD_FUNCID 0x0002 /* match function ID */ 380*7c478bd9Sstevel@tonic-gate #define PCMD_MANFID 0x0004 /* match manufacturer ID */ 381*7c478bd9Sstevel@tonic-gate #define PCMD_FUNCE 0x0008 /* match function extension */ 382*7c478bd9Sstevel@tonic-gate #define PCMD_VERS1 0x0010 /* match VERSION_1 string(s) */ 383*7c478bd9Sstevel@tonic-gate #define PCMD_JEDEC 0x0020 /* JEDEC ID */ 384*7c478bd9Sstevel@tonic-gate 385*7c478bd9Sstevel@tonic-gate #define PCM_NAME_1275 0x0001 386*7c478bd9Sstevel@tonic-gate #define PCM_NAME_VERS1 0x0002 387*7c478bd9Sstevel@tonic-gate #define PCM_NAME_GENERIC 0x0004 388*7c478bd9Sstevel@tonic-gate #define PCM_NO_CONFIG 0x0008 389*7c478bd9Sstevel@tonic-gate #define PCM_OTHER_NOCIS 0x0100 390*7c478bd9Sstevel@tonic-gate #define PCM_MULTI_FUNCTION 0x0200 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate #define PCM_MAX_R2_MEM 0x3ffffff 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate #define PCMDEV_PREFIX "PC," 395*7c478bd9Sstevel@tonic-gate #define PCMDEV_NAMEPREF "pccard" 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /* property names */ 398*7c478bd9Sstevel@tonic-gate #define PCM_PROP_DEVICE "device" 399*7c478bd9Sstevel@tonic-gate #define PCM_PROP_FUNCID "funcid" 400*7c478bd9Sstevel@tonic-gate 401*7c478bd9Sstevel@tonic-gate /* 1275 specific properties */ 402*7c478bd9Sstevel@tonic-gate #define PCM_1275_NUMWIN "#windows" 403*7c478bd9Sstevel@tonic-gate #define PCM_1275_NUMSOCK "#sockets" 404*7c478bd9Sstevel@tonic-gate #define PCM_1275_SCIC "status-change-int_caps" 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate /* basic device types */ 407*7c478bd9Sstevel@tonic-gate 408*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_MULTI 0 409*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_MEMORY 1 410*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_SERIAL 2 411*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_PARALLEL 3 412*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_FIXED 4 413*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_VIDEO 5 414*7c478bd9Sstevel@tonic-gate #define PCM_TYPE_LAN 6 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate 417*7c478bd9Sstevel@tonic-gate typedef 418*7c478bd9Sstevel@tonic-gate struct string_to_int { 419*7c478bd9Sstevel@tonic-gate char *sti_str; 420*7c478bd9Sstevel@tonic-gate uint32_t sti_int; 421*7c478bd9Sstevel@tonic-gate } str_int_t; 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate /* 424*7c478bd9Sstevel@tonic-gate * PCMCIA nexus/adapter specific ioctl commands 425*7c478bd9Sstevel@tonic-gate */ 426*7c478bd9Sstevel@tonic-gate 427*7c478bd9Sstevel@tonic-gate #define PCIOC ('P' << 8) 428*7c478bd9Sstevel@tonic-gate /* SS is temporary until design done */ 429*7c478bd9Sstevel@tonic-gate #define PC_SS_CMD(cmd) (PCIOC|(cmd)) 430*7c478bd9Sstevel@tonic-gate 431*7c478bd9Sstevel@tonic-gate /* stuff that used to be in obpdefs.h but no longer */ 432*7c478bd9Sstevel@tonic-gate #define PCM_DEVICETYPE "device_type" 433*7c478bd9Sstevel@tonic-gate 434*7c478bd9Sstevel@tonic-gate /* 435*7c478bd9Sstevel@tonic-gate * new regspec and other 1275 stuff 436*7c478bd9Sstevel@tonic-gate */ 437*7c478bd9Sstevel@tonic-gate #define PC_REG_RELOC(x) ((((uint32_t)x) & 0x1) << 31) 438*7c478bd9Sstevel@tonic-gate #define PC_REG_PREFETCH(x) (((x) & 0x1) << 30) 439*7c478bd9Sstevel@tonic-gate #define PC_REG_TYPE(x) (((x) & 0x1) << 29) 440*7c478bd9Sstevel@tonic-gate #define PC_REG_SPACE(x) (((x) & 0x7) << 24) 441*7c478bd9Sstevel@tonic-gate #define PC_REG_SOCKET(x) (((x) & 0x1f) << 11) 442*7c478bd9Sstevel@tonic-gate #define PC_REG_FUNCTION(x) (((x) & 0x7) << 8) 443*7c478bd9Sstevel@tonic-gate #define PC_REG_BASEREG(x) ((x) & 0xff) 444*7c478bd9Sstevel@tonic-gate /* solaris internal only */ 445*7c478bd9Sstevel@tonic-gate #define PC_REG_REFCNT(x) (((x) & 0xFF) << 16) 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_RELOC(x) (((x) >> 31) & 1) 448*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_PREFETCH(x) (((x) >> 30) & 1) 449*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_TYPE(x) (((x) >> 29) & 1) 450*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_SPACE(x) (((x) >> 24) & 7) 451*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_SOCKET(x) (((x) >> 11) & 0x1f) 452*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_FUNCTION(x) (((x) >> 8) & 0x7) 453*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_BASEREG(x) ((x) & 0xff) 454*7c478bd9Sstevel@tonic-gate /* solaris internal only */ 455*7c478bd9Sstevel@tonic-gate #define PC_GET_REG_REFCNT(x) (((x) >> 16) & 0xFF) 456*7c478bd9Sstevel@tonic-gate #define PC_INCR_REFCNT(x) (((x) & 0xFF00FFFF) | \ 457*7c478bd9Sstevel@tonic-gate PC_REG_REFCNT(PC_GET_REG_REFCNT(x) + 1)) 458*7c478bd9Sstevel@tonic-gate #define PC_DECR_REFCNT(x) (((x) & 0xFF00FFFF) | \ 459*7c478bd9Sstevel@tonic-gate PC_REG_REFCNT(PC_GET_REG_REFCNT(x) - 1)) 460*7c478bd9Sstevel@tonic-gate 461*7c478bd9Sstevel@tonic-gate #define PC_REG_PHYS_HI(n, p, t, c, s, f, r) (uint32_t)( \ 462*7c478bd9Sstevel@tonic-gate PC_REG_RELOC(n) | \ 463*7c478bd9Sstevel@tonic-gate PC_REG_PREFETCH(p) | \ 464*7c478bd9Sstevel@tonic-gate PC_REG_TYPE(t) | \ 465*7c478bd9Sstevel@tonic-gate PC_REG_SPACE(c) | \ 466*7c478bd9Sstevel@tonic-gate PC_REG_SOCKET(s) | \ 467*7c478bd9Sstevel@tonic-gate PC_REG_FUNCTION(f) | \ 468*7c478bd9Sstevel@tonic-gate PC_REG_BASEREG(r)) 469*7c478bd9Sstevel@tonic-gate 470*7c478bd9Sstevel@tonic-gate #define PC_REG_TYPE_CARDBUS 0 471*7c478bd9Sstevel@tonic-gate #define PC_REG_TYPE_16BIT 1 472*7c478bd9Sstevel@tonic-gate 473*7c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_CONFIG 0x0 474*7c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_IO 0x1 475*7c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_MEMORY 0x2 476*7c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_ATTRIBUTE 0x4 477*7c478bd9Sstevel@tonic-gate 478*7c478bd9Sstevel@tonic-gate /* 479*7c478bd9Sstevel@tonic-gate * internal properties and other prop_op defines 480*7c478bd9Sstevel@tonic-gate */ 481*7c478bd9Sstevel@tonic-gate 482*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_UNKNOWN 0x10000 /* pass to DDI decode */ 483*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_CIS 0x20000 /* need to get the tuple */ 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate /* specific known properties */ 486*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_SOCKET 0 /* "socket" */ 487*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_COMPAT 1 /* "compatible" */ 488*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_DEFAULT_PM 2 /* power managment timestamp */ 489*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_ACTIVE 3 /* card-active property */ 490*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_R2TYPE 4 /* 16 bit card */ 491*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_CARDBUS 5 /* card is cardbus */ 492*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_OLDCS 6 /* old card services property */ 493*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_REG 7 /* standard reg= property */ 494*7c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_INTR 8 /* interrupts property */ 495*7c478bd9Sstevel@tonic-gate 496*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 497*7c478bd9Sstevel@tonic-gate } 498*7c478bd9Sstevel@tonic-gate #endif 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate #endif /* _PCMCIA_H */ 501