17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate /* 287c478bd9Sstevel@tonic-gate * PCMCIA nexus 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _PCMCIA_H 327c478bd9Sstevel@tonic-gate #define _PCMCIA_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #if defined(DEBUG) 397c478bd9Sstevel@tonic-gate #define PCMCIA_DEBUG 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #include <sys/modctl.h> 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_ADAPTERS 8 /* maximum distinct adapters */ 457c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_SOCKETS 64 /* maximum distinct sockets */ 467c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_WIN_ADAPT 40 477c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_WINDOWS (PCMCIA_MAX_ADAPTERS*PCMCIA_MAX_WIN_ADAPT) 487c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_POWER 16 /* maximum power table entries */ 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #define _VERSION(major, minor) ((major)<<16|(minor)) 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * DDI/Nexus stuff 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define PCMCIA_NEXUS_NAME "pcmcia" 577c478bd9Sstevel@tonic-gate #define PCMCIA_ADAPTER_NODE "ddi_pcmcia:adapter" 587c478bd9Sstevel@tonic-gate #define PCMCIA_SOCKET_NODE "ddi_pcmcia:socket" 597c478bd9Sstevel@tonic-gate #define PCMCIA_PCCARD_NODE "ddi_pcmcia:pccard" 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate /* 627c478bd9Sstevel@tonic-gate * private interface between nexus and adapter specific driver 637c478bd9Sstevel@tonic-gate * This is only an "ops" type structure 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate typedef struct pcmcia_if { 677c478bd9Sstevel@tonic-gate uint32_t pcif_magic; /* magic number to verify correct scructure */ 687c478bd9Sstevel@tonic-gate uint32_t pcif_version; 697c478bd9Sstevel@tonic-gate int (*pcif_set_callback)(); 707c478bd9Sstevel@tonic-gate int (*pcif_get_adapter)(); 717c478bd9Sstevel@tonic-gate int (*pcif_get_page)(); 727c478bd9Sstevel@tonic-gate int (*pcif_get_socket)(); 737c478bd9Sstevel@tonic-gate int (*pcif_get_status)(); 747c478bd9Sstevel@tonic-gate int (*pcif_get_window)(); 757c478bd9Sstevel@tonic-gate int (*pcif_inquire_adapter)(); 767c478bd9Sstevel@tonic-gate int (*pcif_inquire_socket)(); 777c478bd9Sstevel@tonic-gate int (*pcif_inquire_window)(); 787c478bd9Sstevel@tonic-gate int (*pcif_reset_socket)(); 797c478bd9Sstevel@tonic-gate int (*pcif_set_page)(); 807c478bd9Sstevel@tonic-gate int (*pcif_set_window)(); 817c478bd9Sstevel@tonic-gate int (*pcif_set_socket)(); 827c478bd9Sstevel@tonic-gate int (*pcif_set_interrupt)(); 837c478bd9Sstevel@tonic-gate int (*pcif_clr_interrupt)(); 847c478bd9Sstevel@tonic-gate int (*pcic_init_dev)(); 857c478bd9Sstevel@tonic-gate uint32_t (*pcic_get_tstamp)(); 867c478bd9Sstevel@tonic-gate } pcmcia_if_t; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate /* 897c478bd9Sstevel@tonic-gate * magic number and version information to identify 907c478bd9Sstevel@tonic-gate * variant of the PCMCIA nexus. 917c478bd9Sstevel@tonic-gate */ 927c478bd9Sstevel@tonic-gate #define PCIF_MAGIC 0x50434946 937c478bd9Sstevel@tonic-gate #define PCIF_VERSION _VERSION(0, 1) 947c478bd9Sstevel@tonic-gate #define PCIF_MIN_VERSION _VERSION(0, 1) 957c478bd9Sstevel@tonic-gate #define DEFAULT_CS_NAME "cs" 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * all adapter drivers use a commonly defined structure for 997c478bd9Sstevel@tonic-gate * their private data. This structure must be filled in 1007c478bd9Sstevel@tonic-gate * and set. The an_private member is for the driver writer's 1017c478bd9Sstevel@tonic-gate * use and is not looked at by the nexus. 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate struct pcmcia_adapter_nexus_private { 1047c478bd9Sstevel@tonic-gate dev_info_t *an_dip; 1057c478bd9Sstevel@tonic-gate pcmcia_if_t *an_if; 1067c478bd9Sstevel@tonic-gate void *an_private; 1077c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *an_iblock; /* high priority handler cookies */ 1087c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *an_idev; 1097c478bd9Sstevel@tonic-gate uint32_t an_ipl; 1107c478bd9Sstevel@tonic-gate }; 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate typedef struct pcmcia_adapter_nexus_private anp_t; 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate struct pcm_regs { 1157c478bd9Sstevel@tonic-gate uint32_t phys_hi; 1167c478bd9Sstevel@tonic-gate uint32_t phys_lo; 1177c478bd9Sstevel@tonic-gate uint32_t phys_len; 1187c478bd9Sstevel@tonic-gate }; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate /* 1217c478bd9Sstevel@tonic-gate * shared interrupts are handled by the 1227c478bd9Sstevel@tonic-gate * nexus going through the list 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate typedef struct inthandler { 1257c478bd9Sstevel@tonic-gate struct inthandler *next; 1267c478bd9Sstevel@tonic-gate struct inthandler *prev; 1277c478bd9Sstevel@tonic-gate int flags; 1287c478bd9Sstevel@tonic-gate uint32_t (*intr)(caddr_t, caddr_t); 1297c478bd9Sstevel@tonic-gate unsigned handler_id; 1307c478bd9Sstevel@tonic-gate void *arg1; 1317c478bd9Sstevel@tonic-gate void *arg2; 1327c478bd9Sstevel@tonic-gate unsigned socket; 1337c478bd9Sstevel@tonic-gate unsigned irq; 1347c478bd9Sstevel@tonic-gate unsigned priority; 1357c478bd9Sstevel@tonic-gate ddi_softintr_t softid; 1367c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t iblk_cookie; 1377c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t idev_cookie; 1387c478bd9Sstevel@tonic-gate } inthandler_t; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * parent private data area 1427c478bd9Sstevel@tonic-gate * not using the old style but will adapt on request 1437c478bd9Sstevel@tonic-gate * this allows better framework handling and 1275 compliance 1447c478bd9Sstevel@tonic-gate */ 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate struct pcmcia_parent_private { 1477c478bd9Sstevel@tonic-gate int ppd_nreg; /* number of regs */ 1487c478bd9Sstevel@tonic-gate struct pcm_regs *ppd_reg; /* array of regs in parsed form */ 1497c478bd9Sstevel@tonic-gate int ppd_intr; /* number intrspecs (always 0 or 1) */ 1507c478bd9Sstevel@tonic-gate struct intrspec *ppd_intrspec; 1517c478bd9Sstevel@tonic-gate void *pcm_dummy[3]; /* fill for prtconf -v */ 1527c478bd9Sstevel@tonic-gate struct pcm_regs *ppd_assigned; /* array of regs in parsed form */ 1537c478bd9Sstevel@tonic-gate short ppd_socket; /* socket number of this instance */ 1547c478bd9Sstevel@tonic-gate short ppd_function; /* function number */ 1557c478bd9Sstevel@tonic-gate int ppd_active; /* is PC Card in a socket and active */ 1567c478bd9Sstevel@tonic-gate uint32_t ppd_flags; 1577c478bd9Sstevel@tonic-gate void *ppd_handle; /* client handle */ 1587c478bd9Sstevel@tonic-gate }; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate #define PPD_CARD_MULTI 0x0001 /* card is multifunction card */ 1617c478bd9Sstevel@tonic-gate #define PPD_CARD_CARDBUS 0x0002 /* card is CardBus type */ 1627c478bd9Sstevel@tonic-gate #define PPD_CB_BUSMASTER 0x0004 /* card bus card is busmaster */ 1637c478bd9Sstevel@tonic-gate #define PPD_SUSPENDED 0x0008 /* this device was pm suspended */ 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate /* 1667c478bd9Sstevel@tonic-gate * macros to make indirect functions easier 1677c478bd9Sstevel@tonic-gate * and shorter (makes cstyle happier) 1687c478bd9Sstevel@tonic-gate */ 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #define GET_SOCKET_STATUS(f, dip, sock, stat)\ 1717c478bd9Sstevel@tonic-gate (*(f)->pcif_get_socket_status)(dip, sock, stat) 1727c478bd9Sstevel@tonic-gate #define SET_CALLBACK(f, dip, callback, sock)\ 1737c478bd9Sstevel@tonic-gate (*(f)->pcif_set_callback)(dip, callback, sock) 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate #define GET_ADAPTER(f, dip, conf) (*(f)->pcif_get_adapter) (dip, conf) 1767c478bd9Sstevel@tonic-gate #define GET_SOCKET(f, dip, sock) (*(f)->pcif_get_socket)(dip, sock) 1777c478bd9Sstevel@tonic-gate #define GET_STATUS(f, dip, status) (*(f)->pcif_get_status)(dip, status) 1787c478bd9Sstevel@tonic-gate #define GET_WINDOW(f, dip, window) (*(f)->pcif_get_window)(dip, window) 1797c478bd9Sstevel@tonic-gate #define INQUIRE_ADAPTER(f, dip, inquire) (*(f)->pcif_inquire_adapter)(dip,\ 1807c478bd9Sstevel@tonic-gate inquire) 1817c478bd9Sstevel@tonic-gate #define GET_CONFIG(f, dip, conf) INQUIRE_ADAPTER(f, dip, conf) 1827c478bd9Sstevel@tonic-gate #define INQUIRE_SOCKET(f, dip, sock) (*(f)->pcif_inquire_socket)(dip, \ 1837c478bd9Sstevel@tonic-gate sock) 1847c478bd9Sstevel@tonic-gate #define GET_PAGE(f, dip, page) (*(f)->pcif_get_page)(dip, page) 1857c478bd9Sstevel@tonic-gate #define INQUIRE_WINDOW(f, dip, window) (*(f)->pcif_inquire_window)(dip, window) 1867c478bd9Sstevel@tonic-gate #define RESET_SOCKET(f, dip, socket, mode) \ 1877c478bd9Sstevel@tonic-gate (*(f)->pcif_reset_socket)(dip, socket, mode) 1887c478bd9Sstevel@tonic-gate #define SET_PAGE(f, dip, page) (*(f)->pcif_set_page)(dip, page) 1897c478bd9Sstevel@tonic-gate #define SET_WINDOW(f, dip, window) (*(f)->pcif_set_window)(dip, window) 1907c478bd9Sstevel@tonic-gate #define SET_SOCKET(f, dip, socket) (*(f)->pcif_set_socket)(dip, socket) 1917c478bd9Sstevel@tonic-gate #define SET_IRQ(f, dip, handler) (*(f)->pcif_set_interrupt)(dip, handler) 1927c478bd9Sstevel@tonic-gate #define CLEAR_IRQ(f, dip, handler) (*(f)->pcif_clr_interrupt)(dip, handler) 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate typedef struct pcmcia_cs { 1957c478bd9Sstevel@tonic-gate uint32_t pccs_magic; /* magic number of verify correct structure */ 1967c478bd9Sstevel@tonic-gate uint32_t pccs_version; 1977c478bd9Sstevel@tonic-gate int (*pccs_callback)(); 1987c478bd9Sstevel@tonic-gate int (*pccs_getconfig)(); 1997c478bd9Sstevel@tonic-gate } pcmcia_cs_t; 2007c478bd9Sstevel@tonic-gate 2017c478bd9Sstevel@tonic-gate #define PCCS_MAGIC 0x50434353 2027c478bd9Sstevel@tonic-gate #define PCCS_VERSION _VERSION(2, 1) 2037c478bd9Sstevel@tonic-gate 2047c478bd9Sstevel@tonic-gate /* properties used by the nexus for setup */ 2057c478bd9Sstevel@tonic-gate #define ADAPT_PROP "adapters" /* property used to find adapter list */ 2067c478bd9Sstevel@tonic-gate #define CS_PROP "card-services" /* property specifying Card Services */ 2077c478bd9Sstevel@tonic-gate #define DEF_DRV_PROP "default-driver" /* default driver to load if no CIS */ 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * per adapter structure 2117c478bd9Sstevel@tonic-gate * this structure defines everything necessary for the 2127c478bd9Sstevel@tonic-gate * the nexus to interact with the adapter specific driver 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate struct pcmcia_adapter { 2167c478bd9Sstevel@tonic-gate int pca_module; /* adapter major number */ 2177c478bd9Sstevel@tonic-gate int pca_unit; /* adapter minor number */ 2187c478bd9Sstevel@tonic-gate int pca_number; /* canonical adapter number */ 2197c478bd9Sstevel@tonic-gate struct dev_ops *pca_ops; 2207c478bd9Sstevel@tonic-gate dev_info_t *pca_dip; 2217c478bd9Sstevel@tonic-gate pcmcia_if_t *pca_if; 2227c478bd9Sstevel@tonic-gate void *pca_power; 2237c478bd9Sstevel@tonic-gate ddi_iblock_cookie_t *pca_iblock; 2247c478bd9Sstevel@tonic-gate ddi_idevice_cookie_t *pca_idev; 2257c478bd9Sstevel@tonic-gate kmutex_t *pca_mutex; 2267c478bd9Sstevel@tonic-gate int pca_numpower; 2277c478bd9Sstevel@tonic-gate int pca_numsockets; 2287c478bd9Sstevel@tonic-gate int pca_first_socket; 2297c478bd9Sstevel@tonic-gate uint32_t pca_flags; 2307c478bd9Sstevel@tonic-gate char pca_name[MODMAXNAMELEN]; 2317c478bd9Sstevel@tonic-gate uint32_t pca_avail_intr; 2327c478bd9Sstevel@tonic-gate inthandler_t pca_int_handlers; 2337c478bd9Sstevel@tonic-gate }; 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_IRQ 0x0001 /* needs IRQ allocation */ 2367c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_IO 0x0002 /* needs I/O allocation */ 2377c478bd9Sstevel@tonic-gate #define PCA_RES_NEED_MEM 0x0004 /* needs memory allocation */ 2387c478bd9Sstevel@tonic-gate #define PCA_RES_CONSTRAINT 0x0008 /* resource constraints defined */ 2397c478bd9Sstevel@tonic-gate #define PCA_IRQ_SMI_SHARE 0x0010 /* SMI and child share */ 2407c478bd9Sstevel@tonic-gate #define PCA_IRQ_SHAREABLE 0x0020 /* all interrupts sharable */ 2417c478bd9Sstevel@tonic-gate #define PCA_IRQ_ISA 0x0040 /* ISA style (host) interrupts */ 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate /* These flags are for open/close -- hot-plug support in future */ 2447c478bd9Sstevel@tonic-gate #define PCMCIA_MAX_FUNCTIONS 8 2457c478bd9Sstevel@tonic-gate #define PCS_CARD_PRESENT 0x0001 /* card in socket */ 2467c478bd9Sstevel@tonic-gate #define PCS_MULTI_FUNCTION 0x0002 /* indicates dip is multifunction */ 2477c478bd9Sstevel@tonic-gate #define PCS_SOCKET_ADDED 0x0004 /* CS knows about the socket */ 2487c478bd9Sstevel@tonic-gate #define PCS_COOKIES_VALID 0x0008 /* iblk and idev valid */ 2497c478bd9Sstevel@tonic-gate #define PCS_IRQ_ENABLED 0x0010 /* IRQ has been enabled */ 2507c478bd9Sstevel@tonic-gate #define PCS_SUSPENDED 0x0020 /* PM SUSPEND was done */ 2517c478bd9Sstevel@tonic-gate 2527c478bd9Sstevel@tonic-gate typedef struct pcmcia_logical_window { 2537c478bd9Sstevel@tonic-gate int lw_window; /* window number */ 2547c478bd9Sstevel@tonic-gate int lw_socket; /* logical socket number assigned */ 2557c478bd9Sstevel@tonic-gate struct pcmcia_adapter *lw_adapter; 2567c478bd9Sstevel@tonic-gate pcmcia_if_t *lw_if; 2577c478bd9Sstevel@tonic-gate uint32_t lw_status; 2587c478bd9Sstevel@tonic-gate baseaddr_t lw_base; 2597c478bd9Sstevel@tonic-gate int lw_len; 2607c478bd9Sstevel@tonic-gate } pcmcia_logical_window_t; 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate #define PCS_ENABLED 0x0002 /* window is enabled */ 2637c478bd9Sstevel@tonic-gate 2647c478bd9Sstevel@tonic-gate /* 2657c478bd9Sstevel@tonic-gate * management interface hook 2667c478bd9Sstevel@tonic-gate */ 2677c478bd9Sstevel@tonic-gate #define EM_EVENTSIZE 4 2687c478bd9Sstevel@tonic-gate struct pcmcia_mif { 2697c478bd9Sstevel@tonic-gate struct pcmcia_mif *mif_next; 2707c478bd9Sstevel@tonic-gate void (*mif_function)(); 2717c478bd9Sstevel@tonic-gate uint32_t mif_id; 2727c478bd9Sstevel@tonic-gate uchar_t mif_events[EM_EVENTSIZE]; /* events registered for */ 2737c478bd9Sstevel@tonic-gate }; 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate #define PR_WORDSIZE 8 /* bits in word */ 2767c478bd9Sstevel@tonic-gate #define PR_MASK 0x7 2777c478bd9Sstevel@tonic-gate #define PR_GET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &\ 2787c478bd9Sstevel@tonic-gate (1 << ((bit) & PR_MASK))) 2797c478bd9Sstevel@tonic-gate #define PR_SET(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] |=\ 2807c478bd9Sstevel@tonic-gate (1 << ((bit) & PR_MASK))) 2817c478bd9Sstevel@tonic-gate #define PR_CLEAR(map, bit) (((uchar_t *)(map))[(bit)/PR_WORDSIZE] &=\ 2827c478bd9Sstevel@tonic-gate ~(1 << ((bit) & PR_MASK))) 2837c478bd9Sstevel@tonic-gate #define PR_ADDR(map, bit) (((uchar_t *)(map)) + ((bit)/PR_WORDSIZE)) 284*24a150c1SToomas Soome #define PR_ZERO(map) \ 285*24a150c1SToomas Soome bzero((caddr_t)map, PCMCIA_MAX_SOCKETS / PR_WORDSIZE) 2867c478bd9Sstevel@tonic-gate 2877c478bd9Sstevel@tonic-gate /* socket bit map */ 2887c478bd9Sstevel@tonic-gate typedef uchar_t socket_enum_t[PCMCIA_MAX_SOCKETS/PR_WORDSIZE]; 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate * Max resoruce limits - all of these have to be power-of-2 aligned 2927c478bd9Sstevel@tonic-gate * and the PR_MAX_IO_LEN and PR_MAX_MEM_LEN values must be at 2937c478bd9Sstevel@tonic-gate * least 64 or the allocators will panic. 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate #define PR_MAX_IO_LEN 1024 /* bytes of IO space */ 2967c478bd9Sstevel@tonic-gate #define PR_MAX_IO_RANGES 4 2977c478bd9Sstevel@tonic-gate #define PR_MAX_MEM_LEN 1024 /* pages or 4M bytes */ 2987c478bd9Sstevel@tonic-gate #define PR_MAX_MEM_RANGES 32 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate #define PR_MAX_IOADDR 0xffffffff 3017c478bd9Sstevel@tonic-gate #define PR_MAX_MEMADDR 0xffffffff 3027c478bd9Sstevel@tonic-gate #define PR_MAX_INTERRUPTS 0xff 3037c478bd9Sstevel@tonic-gate 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate /* 3067c478bd9Sstevel@tonic-gate * structures and definitions used in the private interface 3077c478bd9Sstevel@tonic-gate */ 3087c478bd9Sstevel@tonic-gate 3097c478bd9Sstevel@tonic-gate /* general values */ 3107c478bd9Sstevel@tonic-gate #define PC_SUCCESS 1 3117c478bd9Sstevel@tonic-gate #define PC_FAILURE 0 3127c478bd9Sstevel@tonic-gate 3137c478bd9Sstevel@tonic-gate /* set_mem() */ 3147c478bd9Sstevel@tonic-gate #define PC_MEM_AM 0 3157c478bd9Sstevel@tonic-gate #define PC_MEM_CM 1 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* device classes */ 3187c478bd9Sstevel@tonic-gate #define PCC_MULTI 0 3197c478bd9Sstevel@tonic-gate #define PCC_MEMORY 1 3207c478bd9Sstevel@tonic-gate #define PCC_SERIAL 2 3217c478bd9Sstevel@tonic-gate #define PCC_PARALLEL 3 3227c478bd9Sstevel@tonic-gate #define PCC_FIXED_DISK 4 3237c478bd9Sstevel@tonic-gate #define PCC_VIDEO 5 3247c478bd9Sstevel@tonic-gate #define PCC_LAN 6 3257c478bd9Sstevel@tonic-gate 3267c478bd9Sstevel@tonic-gate /* 3277c478bd9Sstevel@tonic-gate * device information structure information 3287c478bd9Sstevel@tonic-gate * this is what is used for initial construction of a device node 3297c478bd9Sstevel@tonic-gate */ 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate struct pcm_device_info { 3327c478bd9Sstevel@tonic-gate int pd_socket; 3337c478bd9Sstevel@tonic-gate int pd_function; 3347c478bd9Sstevel@tonic-gate int pd_type; 3357c478bd9Sstevel@tonic-gate uint32_t pd_handle; 3367c478bd9Sstevel@tonic-gate uint32_t pd_tuples; 3377c478bd9Sstevel@tonic-gate uint32_t pd_flags; 3387c478bd9Sstevel@tonic-gate char pd_bind_name[MODMAXNAMELEN]; 3397c478bd9Sstevel@tonic-gate char pd_vers1_name[MODMAXNAMELEN*4]; 3407c478bd9Sstevel@tonic-gate char pd_generic_name[MODMAXNAMELEN]; 3417c478bd9Sstevel@tonic-gate }; 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate #define PCM_GET_SOCKET(socknum) ((socknum) & 0x1F) 3447c478bd9Sstevel@tonic-gate #define PCM_GET_FUNCTION(socknum) (((socknum) >> 5) & 0x7) 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate #define PCM_DEFAULT_NODEID (-1) 3477c478bd9Sstevel@tonic-gate #define PCM_DEV_MODEL "model" 3487c478bd9Sstevel@tonic-gate #define PCM_DEV_ACTIVE "card-active" 3497c478bd9Sstevel@tonic-gate #define PCM_DEV_SOCKET "socket" 3507c478bd9Sstevel@tonic-gate #define PCM_DEV_R2TYPE "16bitcard" 3517c478bd9Sstevel@tonic-gate #define PCM_DEV_CARDBUS "cardbus" 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate typedef 3547c478bd9Sstevel@tonic-gate struct init_dev { 3557c478bd9Sstevel@tonic-gate int socket; 3567c478bd9Sstevel@tonic-gate } init_dev_t; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate /* 3597c478bd9Sstevel@tonic-gate * device descriptions 3607c478bd9Sstevel@tonic-gate * used to determine what driver to associate with a PC Card 3617c478bd9Sstevel@tonic-gate * so that automatic creation of device information trees can 3627c478bd9Sstevel@tonic-gate * be supported. 3637c478bd9Sstevel@tonic-gate */ 3647c478bd9Sstevel@tonic-gate 3657c478bd9Sstevel@tonic-gate typedef 3667c478bd9Sstevel@tonic-gate struct pcm_device_node { 3677c478bd9Sstevel@tonic-gate struct pcm_device_node *pd_next; 3687c478bd9Sstevel@tonic-gate dev_info_t *pd_dip; /* proto device info */ 3697c478bd9Sstevel@tonic-gate char pd_name[16]; 3707c478bd9Sstevel@tonic-gate int pd_flags; 3717c478bd9Sstevel@tonic-gate int pd_devtype; /* from device tuple */ 3727c478bd9Sstevel@tonic-gate int pd_funcid; 3737c478bd9Sstevel@tonic-gate int pd_manfid; 3747c478bd9Sstevel@tonic-gate int pd_manmask; 3757c478bd9Sstevel@tonic-gate } pcm_dev_node_t; 3767c478bd9Sstevel@tonic-gate 3777c478bd9Sstevel@tonic-gate #define PCMD_DEVTYPE 0x0001 /* match device type */ 3787c478bd9Sstevel@tonic-gate #define PCMD_FUNCID 0x0002 /* match function ID */ 3797c478bd9Sstevel@tonic-gate #define PCMD_MANFID 0x0004 /* match manufacturer ID */ 3807c478bd9Sstevel@tonic-gate #define PCMD_FUNCE 0x0008 /* match function extension */ 3817c478bd9Sstevel@tonic-gate #define PCMD_VERS1 0x0010 /* match VERSION_1 string(s) */ 3827c478bd9Sstevel@tonic-gate #define PCMD_JEDEC 0x0020 /* JEDEC ID */ 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate #define PCM_NAME_1275 0x0001 3857c478bd9Sstevel@tonic-gate #define PCM_NAME_VERS1 0x0002 3867c478bd9Sstevel@tonic-gate #define PCM_NAME_GENERIC 0x0004 3877c478bd9Sstevel@tonic-gate #define PCM_NO_CONFIG 0x0008 3887c478bd9Sstevel@tonic-gate #define PCM_OTHER_NOCIS 0x0100 3897c478bd9Sstevel@tonic-gate #define PCM_MULTI_FUNCTION 0x0200 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate #define PCM_MAX_R2_MEM 0x3ffffff 3927c478bd9Sstevel@tonic-gate 3937c478bd9Sstevel@tonic-gate #define PCMDEV_PREFIX "PC," 3947c478bd9Sstevel@tonic-gate #define PCMDEV_NAMEPREF "pccard" 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* property names */ 3977c478bd9Sstevel@tonic-gate #define PCM_PROP_DEVICE "device" 3987c478bd9Sstevel@tonic-gate #define PCM_PROP_FUNCID "funcid" 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* 1275 specific properties */ 4017c478bd9Sstevel@tonic-gate #define PCM_1275_NUMWIN "#windows" 4027c478bd9Sstevel@tonic-gate #define PCM_1275_NUMSOCK "#sockets" 4037c478bd9Sstevel@tonic-gate #define PCM_1275_SCIC "status-change-int_caps" 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate /* basic device types */ 4067c478bd9Sstevel@tonic-gate 4077c478bd9Sstevel@tonic-gate #define PCM_TYPE_MULTI 0 4087c478bd9Sstevel@tonic-gate #define PCM_TYPE_MEMORY 1 4097c478bd9Sstevel@tonic-gate #define PCM_TYPE_SERIAL 2 4107c478bd9Sstevel@tonic-gate #define PCM_TYPE_PARALLEL 3 4117c478bd9Sstevel@tonic-gate #define PCM_TYPE_FIXED 4 4127c478bd9Sstevel@tonic-gate #define PCM_TYPE_VIDEO 5 4137c478bd9Sstevel@tonic-gate #define PCM_TYPE_LAN 6 4147c478bd9Sstevel@tonic-gate 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate typedef 4177c478bd9Sstevel@tonic-gate struct string_to_int { 4187c478bd9Sstevel@tonic-gate char *sti_str; 4197c478bd9Sstevel@tonic-gate uint32_t sti_int; 4207c478bd9Sstevel@tonic-gate } str_int_t; 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate /* 4237c478bd9Sstevel@tonic-gate * PCMCIA nexus/adapter specific ioctl commands 4247c478bd9Sstevel@tonic-gate */ 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate #define PCIOC ('P' << 8) 4277c478bd9Sstevel@tonic-gate /* SS is temporary until design done */ 4287c478bd9Sstevel@tonic-gate #define PC_SS_CMD(cmd) (PCIOC|(cmd)) 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate /* stuff that used to be in obpdefs.h but no longer */ 4317c478bd9Sstevel@tonic-gate #define PCM_DEVICETYPE "device_type" 4327c478bd9Sstevel@tonic-gate 4337c478bd9Sstevel@tonic-gate /* 4347c478bd9Sstevel@tonic-gate * new regspec and other 1275 stuff 4357c478bd9Sstevel@tonic-gate */ 4367c478bd9Sstevel@tonic-gate #define PC_REG_RELOC(x) ((((uint32_t)x) & 0x1) << 31) 4377c478bd9Sstevel@tonic-gate #define PC_REG_PREFETCH(x) (((x) & 0x1) << 30) 4387c478bd9Sstevel@tonic-gate #define PC_REG_TYPE(x) (((x) & 0x1) << 29) 4397c478bd9Sstevel@tonic-gate #define PC_REG_SPACE(x) (((x) & 0x7) << 24) 4407c478bd9Sstevel@tonic-gate #define PC_REG_SOCKET(x) (((x) & 0x1f) << 11) 4417c478bd9Sstevel@tonic-gate #define PC_REG_FUNCTION(x) (((x) & 0x7) << 8) 4427c478bd9Sstevel@tonic-gate #define PC_REG_BASEREG(x) ((x) & 0xff) 4437c478bd9Sstevel@tonic-gate /* solaris internal only */ 4447c478bd9Sstevel@tonic-gate #define PC_REG_REFCNT(x) (((x) & 0xFF) << 16) 4457c478bd9Sstevel@tonic-gate 4467c478bd9Sstevel@tonic-gate #define PC_GET_REG_RELOC(x) (((x) >> 31) & 1) 4477c478bd9Sstevel@tonic-gate #define PC_GET_REG_PREFETCH(x) (((x) >> 30) & 1) 4487c478bd9Sstevel@tonic-gate #define PC_GET_REG_TYPE(x) (((x) >> 29) & 1) 4497c478bd9Sstevel@tonic-gate #define PC_GET_REG_SPACE(x) (((x) >> 24) & 7) 4507c478bd9Sstevel@tonic-gate #define PC_GET_REG_SOCKET(x) (((x) >> 11) & 0x1f) 4517c478bd9Sstevel@tonic-gate #define PC_GET_REG_FUNCTION(x) (((x) >> 8) & 0x7) 4527c478bd9Sstevel@tonic-gate #define PC_GET_REG_BASEREG(x) ((x) & 0xff) 4537c478bd9Sstevel@tonic-gate /* solaris internal only */ 4547c478bd9Sstevel@tonic-gate #define PC_GET_REG_REFCNT(x) (((x) >> 16) & 0xFF) 4557c478bd9Sstevel@tonic-gate #define PC_INCR_REFCNT(x) (((x) & 0xFF00FFFF) | \ 4567c478bd9Sstevel@tonic-gate PC_REG_REFCNT(PC_GET_REG_REFCNT(x) + 1)) 4577c478bd9Sstevel@tonic-gate #define PC_DECR_REFCNT(x) (((x) & 0xFF00FFFF) | \ 4587c478bd9Sstevel@tonic-gate PC_REG_REFCNT(PC_GET_REG_REFCNT(x) - 1)) 4597c478bd9Sstevel@tonic-gate 4607c478bd9Sstevel@tonic-gate #define PC_REG_PHYS_HI(n, p, t, c, s, f, r) (uint32_t)( \ 4617c478bd9Sstevel@tonic-gate PC_REG_RELOC(n) | \ 4627c478bd9Sstevel@tonic-gate PC_REG_PREFETCH(p) | \ 4637c478bd9Sstevel@tonic-gate PC_REG_TYPE(t) | \ 4647c478bd9Sstevel@tonic-gate PC_REG_SPACE(c) | \ 4657c478bd9Sstevel@tonic-gate PC_REG_SOCKET(s) | \ 4667c478bd9Sstevel@tonic-gate PC_REG_FUNCTION(f) | \ 4677c478bd9Sstevel@tonic-gate PC_REG_BASEREG(r)) 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate #define PC_REG_TYPE_CARDBUS 0 4707c478bd9Sstevel@tonic-gate #define PC_REG_TYPE_16BIT 1 4717c478bd9Sstevel@tonic-gate 4727c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_CONFIG 0x0 4737c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_IO 0x1 4747c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_MEMORY 0x2 4757c478bd9Sstevel@tonic-gate #define PC_REG_SPACE_ATTRIBUTE 0x4 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate /* 4787c478bd9Sstevel@tonic-gate * internal properties and other prop_op defines 4797c478bd9Sstevel@tonic-gate */ 4807c478bd9Sstevel@tonic-gate 4817c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_UNKNOWN 0x10000 /* pass to DDI decode */ 4827c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_CIS 0x20000 /* need to get the tuple */ 4837c478bd9Sstevel@tonic-gate 4847c478bd9Sstevel@tonic-gate /* specific known properties */ 4857c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_SOCKET 0 /* "socket" */ 4867c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_COMPAT 1 /* "compatible" */ 4877c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_DEFAULT_PM 2 /* power managment timestamp */ 4887c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_ACTIVE 3 /* card-active property */ 4897c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_R2TYPE 4 /* 16 bit card */ 4907c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_CARDBUS 5 /* card is cardbus */ 4917c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_OLDCS 6 /* old card services property */ 4927c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_REG 7 /* standard reg= property */ 4937c478bd9Sstevel@tonic-gate #define PCMCIA_PROP_INTR 8 /* interrupts property */ 4947c478bd9Sstevel@tonic-gate 4957c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4967c478bd9Sstevel@tonic-gate } 4977c478bd9Sstevel@tonic-gate #endif 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate #endif /* _PCMCIA_H */ 500