18456e16eSWarner Losh /* $NetBSD: pcmciavar.h,v 1.12 2000/02/08 12:51:31 enami Exp $ */ 2c2380338SWarner Losh /* $FreeBSD$ */ 3c2380338SWarner Losh 4c2380338SWarner Losh /* 5c2380338SWarner Losh * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6c2380338SWarner Losh * 7c2380338SWarner Losh * Redistribution and use in source and binary forms, with or without 8c2380338SWarner Losh * modification, are permitted provided that the following conditions 9c2380338SWarner Losh * are met: 10c2380338SWarner Losh * 1. Redistributions of source code must retain the above copyright 11c2380338SWarner Losh * notice, this list of conditions and the following disclaimer. 12c2380338SWarner Losh * 2. Redistributions in binary form must reproduce the above copyright 13c2380338SWarner Losh * notice, this list of conditions and the following disclaimer in the 14c2380338SWarner Losh * documentation and/or other materials provided with the distribution. 15c2380338SWarner Losh * 3. All advertising materials mentioning features or use of this software 16c2380338SWarner Losh * must display the following acknowledgement: 17c2380338SWarner Losh * This product includes software developed by Marc Horowitz. 18c2380338SWarner Losh * 4. The name of the author may not be used to endorse or promote products 19c2380338SWarner Losh * derived from this software without specific prior written permission. 20c2380338SWarner Losh * 21c2380338SWarner Losh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22c2380338SWarner Losh * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 23c2380338SWarner Losh * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 24c2380338SWarner Losh * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 25c2380338SWarner Losh * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26c2380338SWarner Losh * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27c2380338SWarner Losh * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28c2380338SWarner Losh * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29c2380338SWarner Losh * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30c2380338SWarner Losh * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31c2380338SWarner Losh */ 32c2380338SWarner Losh 33c2380338SWarner Losh #include <sys/types.h> 34c2380338SWarner Losh #include <sys/queue.h> 35c2380338SWarner Losh 36c2380338SWarner Losh #include <machine/bus.h> 37c33c1284SWarner Losh #include "card_if.h" 38c2380338SWarner Losh 39c2380338SWarner Losh extern int pccard_verbose; 40c2380338SWarner Losh 41c2380338SWarner Losh /* 42c2380338SWarner Losh * Contains information about mapped/allocated i/o spaces. 43c2380338SWarner Losh */ 44c2380338SWarner Losh struct pccard_io_handle { 45c2380338SWarner Losh bus_space_tag_t iot; /* bus space tag (from chipset) */ 46c2380338SWarner Losh bus_space_handle_t ioh; /* mapped space handle */ 47c2380338SWarner Losh bus_addr_t addr; /* resulting address in bus space */ 48c2380338SWarner Losh bus_size_t size; /* size of i/o space */ 49c2380338SWarner Losh int flags; /* misc. information */ 5081047394SWarner Losh int width; 51c2380338SWarner Losh }; 52c2380338SWarner Losh 53c2380338SWarner Losh #define PCCARD_IO_ALLOCATED 0x01 /* i/o space was allocated */ 54c2380338SWarner Losh 55c2380338SWarner Losh /* 56c2380338SWarner Losh * Contains information about allocated memory space. 57c2380338SWarner Losh */ 58c2380338SWarner Losh struct pccard_mem_handle { 59c2380338SWarner Losh bus_space_tag_t memt; /* bus space tag (from chipset) */ 60c2380338SWarner Losh bus_space_handle_t memh; /* mapped space handle */ 61c2380338SWarner Losh bus_addr_t addr; /* resulting address in bus space */ 62c2380338SWarner Losh bus_size_t size; /* size of mem space */ 63c2380338SWarner Losh bus_size_t realsize; /* how much we really allocated */ 64a91e0069SWarner Losh long offset; /* mapped Offset on card */ 65a91e0069SWarner Losh bus_addr_t cardaddr; /* Absolute address on card */ 6681047394SWarner Losh int kind; 67c2380338SWarner Losh }; 68c2380338SWarner Losh 69c2380338SWarner Losh /* pccard itself */ 70c2380338SWarner Losh 71c2380338SWarner Losh #define PCCARD_CFE_MWAIT_REQUIRED 0x0001 72c2380338SWarner Losh #define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 73c2380338SWarner Losh #define PCCARD_CFE_WP_ACTIVE 0x0004 74c2380338SWarner Losh #define PCCARD_CFE_BVD_ACTIVE 0x0008 75c2380338SWarner Losh #define PCCARD_CFE_IO8 0x0010 76c2380338SWarner Losh #define PCCARD_CFE_IO16 0x0020 77c2380338SWarner Losh #define PCCARD_CFE_IRQSHARE 0x0040 78c2380338SWarner Losh #define PCCARD_CFE_IRQPULSE 0x0080 79c2380338SWarner Losh #define PCCARD_CFE_IRQLEVEL 0x0100 80c2380338SWarner Losh #define PCCARD_CFE_POWERDOWN 0x0200 81c2380338SWarner Losh #define PCCARD_CFE_READONLY 0x0400 82c2380338SWarner Losh #define PCCARD_CFE_AUDIO 0x0800 83c2380338SWarner Losh 84c2380338SWarner Losh struct pccard_config_entry { 85c2380338SWarner Losh int number; 86c2380338SWarner Losh u_int32_t flags; 87c2380338SWarner Losh int iftype; 88c2380338SWarner Losh int num_iospace; 89c2380338SWarner Losh 90c2380338SWarner Losh /* 91c2380338SWarner Losh * The card will only decode this mask in any case, so we can 92c2380338SWarner Losh * do dynamic allocation with this in mind, in case the suggestions 93c2380338SWarner Losh * below are no good. 94c2380338SWarner Losh */ 95c2380338SWarner Losh u_long iomask; 96c2380338SWarner Losh struct { 97c2380338SWarner Losh u_long length; 98c2380338SWarner Losh u_long start; 99c2380338SWarner Losh } iospace[4]; /* XXX this could be as high as 16 */ 100c2380338SWarner Losh u_int16_t irqmask; 101c2380338SWarner Losh int num_memspace; 102c2380338SWarner Losh struct { 103c2380338SWarner Losh u_long length; 104c2380338SWarner Losh u_long cardaddr; 105c2380338SWarner Losh u_long hostaddr; 106c2380338SWarner Losh } memspace[2]; /* XXX this could be as high as 8 */ 107c2380338SWarner Losh int maxtwins; 1089344caafSWarner Losh struct resource *iores[4]; 1099344caafSWarner Losh int iorid[4]; 1109344caafSWarner Losh struct resource *irqres; 1119344caafSWarner Losh int irqrid; 1129344caafSWarner Losh struct resource *memres[2]; 1139344caafSWarner Losh int memrid[2]; 114e3975643SJake Burkholder STAILQ_ENTRY(pccard_config_entry) cfe_list; 115c2380338SWarner Losh }; 116c2380338SWarner Losh 117a8bc3167STakeshi Shibagaki struct pccard_funce_disk { 118a8bc3167STakeshi Shibagaki int pfd_interface; 119a8bc3167STakeshi Shibagaki }; 120a8bc3167STakeshi Shibagaki 121a8bc3167STakeshi Shibagaki struct pccard_funce_lan { 122a8bc3167STakeshi Shibagaki int pfl_nidlen; 123a8bc3167STakeshi Shibagaki u_int8_t pfl_nid[8]; 124a8bc3167STakeshi Shibagaki }; 125a8bc3167STakeshi Shibagaki 126a8bc3167STakeshi Shibagaki union pccard_funce { 127a8bc3167STakeshi Shibagaki struct pccard_funce_disk pfv_disk; 128a8bc3167STakeshi Shibagaki struct pccard_funce_lan pfv_lan; 129a8bc3167STakeshi Shibagaki }; 130a8bc3167STakeshi Shibagaki 131c2380338SWarner Losh struct pccard_function { 132c2380338SWarner Losh /* read off the card */ 133c2380338SWarner Losh int number; 134c2380338SWarner Losh int function; 135c2380338SWarner Losh int last_config_index; 136c2380338SWarner Losh u_long ccr_base; 137c2380338SWarner Losh u_long ccr_mask; 13878ae73b5SWarner Losh struct resource *ccr_res; 13978ae73b5SWarner Losh int ccr_rid; 140e3975643SJake Burkholder STAILQ_HEAD(, pccard_config_entry) cfe_head; 141e3975643SJake Burkholder STAILQ_ENTRY(pccard_function) pf_list; 142c2380338SWarner Losh /* run-time state */ 143c2380338SWarner Losh struct pccard_softc *sc; 144c2380338SWarner Losh struct pccard_config_entry *cfe; 145c2380338SWarner Losh struct pccard_mem_handle pf_pcmh; 146bd6dd21eSWarner Losh device_t dev; 147c2380338SWarner Losh #define pf_ccrt pf_pcmh.memt 148c2380338SWarner Losh #define pf_ccrh pf_pcmh.memh 149c2380338SWarner Losh #define pf_ccr_realsize pf_pcmh.realsize 150c2380338SWarner Losh bus_addr_t pf_ccr_offset; 151c2380338SWarner Losh int pf_ccr_window; 152c2380338SWarner Losh long pf_mfc_iobase; 153c2380338SWarner Losh long pf_mfc_iomax; 154c2380338SWarner Losh int pf_flags; 1550c95c705SJonathan Chen driver_intr_t *intr_handler; 1560c95c705SJonathan Chen void *intr_handler_arg; 1570c95c705SJonathan Chen void *intr_handler_cookie; 158a8bc3167STakeshi Shibagaki 159a8bc3167STakeshi Shibagaki union pccard_funce pf_funce; /* CISTPL_FUNCE */ 160a8bc3167STakeshi Shibagaki #define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface 161a8bc3167STakeshi Shibagaki #define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid 162a8bc3167STakeshi Shibagaki #define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen 163c2380338SWarner Losh }; 164c2380338SWarner Losh 165c2380338SWarner Losh /* pf_flags */ 166c2380338SWarner Losh #define PFF_ENABLED 0x0001 /* function is enabled */ 167c2380338SWarner Losh 168c2380338SWarner Losh struct pccard_card { 169c2380338SWarner Losh int cis1_major; 170c2380338SWarner Losh int cis1_minor; 171c2380338SWarner Losh /* XXX waste of space? */ 172c2380338SWarner Losh char cis1_info_buf[256]; 173c2380338SWarner Losh char *cis1_info[4]; 174c2380338SWarner Losh /* 175c2380338SWarner Losh * Use int32_t for manufacturer and product so that they can 176c2380338SWarner Losh * hold the id value found in card CIS and special value that 177c2380338SWarner Losh * indicates no id was found. 178c2380338SWarner Losh */ 179c2380338SWarner Losh int32_t manufacturer; 180fdacad4eSWarner Losh #define PCMCIA_VENDOR_INVALID -1 181c2380338SWarner Losh int32_t product; 182fdacad4eSWarner Losh #define PCMCIA_PRODUCT_INVALID -1 18357ffbd6eSTakeshi Shibagaki int16_t prodext; 184c2380338SWarner Losh u_int16_t error; 185fdacad4eSWarner Losh #define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } 186e3975643SJake Burkholder STAILQ_HEAD(, pccard_function) pf_head; 187c2380338SWarner Losh }; 188c2380338SWarner Losh 189d3d805e6SWarner Losh #define PCCARD_MEM_ATTR 1 190d3d805e6SWarner Losh #define PCCARD_MEM_COMMON 2 191d3d805e6SWarner Losh 192d3d805e6SWarner Losh #define PCCARD_WIDTH_AUTO 0 193d3d805e6SWarner Losh #define PCCARD_WIDTH_IO8 1 194d3d805e6SWarner Losh #define PCCARD_WIDTH_IO16 2 195d3d805e6SWarner Losh 19612bba6c2SWarner Losh /* More later? */ 19712bba6c2SWarner Losh struct pccard_ivar { 19812bba6c2SWarner Losh struct resource_list resources; 19945713b37SWarner Losh struct pccard_function *fcn; 200c2380338SWarner Losh }; 201c2380338SWarner Losh 202c2380338SWarner Losh struct pccard_softc { 203deae2aafSWarner Losh device_t dev; 20478ae73b5SWarner Losh /* this stuff is for the socket */ 205deae2aafSWarner Losh 206c2380338SWarner Losh /* this stuff is for the card */ 207c2380338SWarner Losh struct pccard_card card; 208deae2aafSWarner Losh int sc_enabled_count; /* num functions enabled */ 209c2380338SWarner Losh }; 210c2380338SWarner Losh 211c2380338SWarner Losh void 21281047394SWarner Losh pccardbus_if_setup(struct pccard_softc*); 213c2380338SWarner Losh 214c2380338SWarner Losh struct pccard_cis_quirk { 215c2380338SWarner Losh int32_t manufacturer; 216c2380338SWarner Losh int32_t product; 217c2380338SWarner Losh char *cis1_info[4]; 218c2380338SWarner Losh struct pccard_function *pf; 219c2380338SWarner Losh struct pccard_config_entry *cfe; 220c2380338SWarner Losh }; 221c2380338SWarner Losh 222c2380338SWarner Losh struct pccard_tuple { 223c2380338SWarner Losh unsigned int code; 224c2380338SWarner Losh unsigned int length; 225c2380338SWarner Losh u_long mult; 226c2380338SWarner Losh bus_addr_t ptr; 227c2380338SWarner Losh bus_space_tag_t memt; 228c2380338SWarner Losh bus_space_handle_t memh; 229c2380338SWarner Losh }; 230c2380338SWarner Losh 2318456e16eSWarner Losh struct pccard_product { 2328456e16eSWarner Losh const char *pp_name; /* NULL if end of table */ 2338456e16eSWarner Losh #define PCCARD_VENDOR_ANY ((u_int32_t) -1) 2348456e16eSWarner Losh u_int32_t pp_vendor; 2358456e16eSWarner Losh #define PCCARD_PRODUCT_ANY ((u_int32_t) -1) 2368456e16eSWarner Losh u_int32_t pp_product; 2378456e16eSWarner Losh int pp_expfunc; 238da15fcf1SWarner Losh const char *pp_cis[4]; 2398456e16eSWarner Losh }; 2408456e16eSWarner Losh 2418456e16eSWarner Losh typedef int (*pccard_product_match_fn) (device_t dev, 2428456e16eSWarner Losh const struct pccard_product *ent, int vpfmatch); 2438456e16eSWarner Losh 2448456e16eSWarner Losh const struct pccard_product 2458456e16eSWarner Losh *pccard_product_lookup(device_t dev, const struct pccard_product *tab, 2468456e16eSWarner Losh size_t ent_size, pccard_product_match_fn matchfn); 2478456e16eSWarner Losh 24881047394SWarner Losh void pccard_read_cis(struct pccard_softc *); 249c2380338SWarner Losh void pccard_check_cis_quirks(device_t); 250c2380338SWarner Losh void pccard_print_cis(device_t); 2513a6352bdSWarner Losh int pccard_scan_cis(device_t, 25281047394SWarner Losh int (*) (struct pccard_tuple *, void *), void *); 253c2380338SWarner Losh 254c2380338SWarner Losh #define pccard_cis_read_1(tuple, idx0) \ 255c2380338SWarner Losh (bus_space_read_1((tuple)->memt, (tuple)->memh, (tuple)->mult*(idx0))) 256c2380338SWarner Losh 257c2380338SWarner Losh #define pccard_tuple_read_1(tuple, idx1) \ 258c2380338SWarner Losh (pccard_cis_read_1((tuple), ((tuple)->ptr+(2+(idx1))))) 259c2380338SWarner Losh 260c2380338SWarner Losh #define pccard_tuple_read_2(tuple, idx2) \ 261c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx2)) | \ 262c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx2)+1)<<8)) 263c2380338SWarner Losh 264c2380338SWarner Losh #define pccard_tuple_read_3(tuple, idx3) \ 265c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)) | \ 266c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)+1)<<8) | \ 267c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)+2)<<16)) 268c2380338SWarner Losh 269c2380338SWarner Losh #define pccard_tuple_read_4(tuple, idx4) \ 270c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)) | \ 271c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+1)<<8) | \ 272c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+2)<<16) | \ 273c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+3)<<24)) 274c2380338SWarner Losh 275c2380338SWarner Losh #define pccard_tuple_read_n(tuple, n, idxn) \ 276c2380338SWarner Losh (((n)==1)?pccard_tuple_read_1((tuple), (idxn)) : \ 277c2380338SWarner Losh (((n)==2)?pccard_tuple_read_2((tuple), (idxn)) : \ 278c2380338SWarner Losh (((n)==3)?pccard_tuple_read_3((tuple), (idxn)) : \ 279c2380338SWarner Losh /* n == 4 */ pccard_tuple_read_4((tuple), (idxn))))) 280c2380338SWarner Losh 281c2380338SWarner Losh #define PCCARD_SPACE_MEMORY 1 282c2380338SWarner Losh #define PCCARD_SPACE_IO 2 283c2380338SWarner Losh 284c2380338SWarner Losh #define pccard_mfc(sc) (STAILQ_FIRST(&(sc)->card.pf_head) && \ 285c2380338SWarner Losh STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list)) 286c2380338SWarner Losh 287c2380338SWarner Losh #define pccard_io_alloc(pf, start, size, align, pciop) \ 288c2380338SWarner Losh (pccard_chip_io_alloc((pf)->sc->pct, pf->sc->pch, (start), \ 289c2380338SWarner Losh (size), (align), (pciop))) 290c2380338SWarner Losh 291c2380338SWarner Losh #define pccard_io_free(pf, pciohp) \ 292c2380338SWarner Losh (pccard_chip_io_free((pf)->sc->pct, (pf)->sc->pch, (pciohp))) 293c2380338SWarner Losh 29481047394SWarner Losh int pccard_io_map(struct pccard_function *, int, bus_addr_t, 29581047394SWarner Losh bus_size_t, struct pccard_io_handle *, int *); 29681047394SWarner Losh void pccard_io_unmap(struct pccard_function *, int); 297c2380338SWarner Losh 298c2380338SWarner Losh #define pccard_mem_alloc(pf, size, pcmhp) \ 299c2380338SWarner Losh (pccard_chip_mem_alloc((pf)->sc->pct, (pf)->sc->pch, (size), (pcmhp))) 300c2380338SWarner Losh #define pccard_mem_free(pf, pcmhp) \ 301c2380338SWarner Losh (pccard_chip_mem_free((pf)->sc->pct, (pf)->sc->pch, (pcmhp))) 302c2380338SWarner Losh #define pccard_mem_map(pf, kind, card_addr, size, pcmhp, offsetp, windowp) \ 303c2380338SWarner Losh (pccard_chip_mem_map((pf)->sc->pct, (pf)->sc->pch, (kind), \ 304c2380338SWarner Losh (card_addr), (size), (pcmhp), (offsetp), (windowp))) 305c2380338SWarner Losh #define pccard_mem_unmap(pf, window) \ 306c2380338SWarner Losh (pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window))) 30787ef0a0aSTatsumi Hosokawa 3082276cee5SWarner Losh /* compat layer */ 309c33c1284SWarner Losh static __inline int 310c33c1284SWarner Losh pccard_compat_probe(device_t dev) 311c33c1284SWarner Losh { 312c33c1284SWarner Losh return (CARD_COMPAT_DO_PROBE(device_get_parent(dev), dev)); 313c33c1284SWarner Losh } 314c33c1284SWarner Losh 315c33c1284SWarner Losh static __inline int 316c33c1284SWarner Losh pccard_compat_attach(device_t dev) 317c33c1284SWarner Losh { 318c33c1284SWarner Losh return (CARD_COMPAT_DO_ATTACH(device_get_parent(dev), dev)); 319c33c1284SWarner Losh } 3202276cee5SWarner Losh 32187ef0a0aSTatsumi Hosokawa /* ivar interface */ 32287ef0a0aSTatsumi Hosokawa enum { 32387ef0a0aSTatsumi Hosokawa PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */ 3248456e16eSWarner Losh PCCARD_IVAR_VENDOR, 3258456e16eSWarner Losh PCCARD_IVAR_PRODUCT, 32657ffbd6eSTakeshi Shibagaki PCCARD_IVAR_PRODEXT, 3278456e16eSWarner Losh PCCARD_IVAR_FUNCTION_NUMBER, 3288456e16eSWarner Losh PCCARD_IVAR_VENDOR_STR, /* CIS string for "Manufacturer" */ 3298456e16eSWarner Losh PCCARD_IVAR_PRODUCT_STR,/* CIS strnig for "Product" */ 330d62abc77SWarner Losh PCCARD_IVAR_CIS3_STR, 331dc8e185fSWarner Losh PCCARD_IVAR_CIS4_STR, 332dc8e185fSWarner Losh PCCARD_IVAR_FUNCTION 33387ef0a0aSTatsumi Hosokawa }; 33487ef0a0aSTatsumi Hosokawa 3358456e16eSWarner Losh #define PCCARD_ACCESSOR(A, B, T) \ 3368456e16eSWarner Losh __inline static int \ 3378456e16eSWarner Losh pccard_get_ ## A(device_t dev, T *t) \ 3388456e16eSWarner Losh { \ 3398456e16eSWarner Losh return BUS_READ_IVAR(device_get_parent(dev), dev, \ 3408456e16eSWarner Losh PCCARD_IVAR_ ## B, (uintptr_t *) t); \ 341e14c13daSWarner Losh } 342e14c13daSWarner Losh 3438456e16eSWarner Losh PCCARD_ACCESSOR(ether, ETHADDR, u_int8_t) 3448456e16eSWarner Losh PCCARD_ACCESSOR(vendor, VENDOR, u_int32_t) 3458456e16eSWarner Losh PCCARD_ACCESSOR(product, PRODUCT, u_int32_t) 34657ffbd6eSTakeshi Shibagaki PCCARD_ACCESSOR(prodext, PRODEXT, u_int16_t) 3478456e16eSWarner Losh PCCARD_ACCESSOR(function_number,FUNCTION_NUMBER, u_int32_t) 348dc8e185fSWarner Losh PCCARD_ACCESSOR(function, FUNCTION, u_int32_t) 3498456e16eSWarner Losh PCCARD_ACCESSOR(vendor_str, VENDOR_STR, char *) 3508456e16eSWarner Losh PCCARD_ACCESSOR(product_str, PRODUCT_STR, char *) 3518456e16eSWarner Losh PCCARD_ACCESSOR(cis3_str, CIS3_STR, char *) 3528456e16eSWarner Losh 3530a177c3dSDuncan Barclay /* shared memory flags */ 354e14c13daSWarner Losh enum { 3550a177c3dSDuncan Barclay PCCARD_A_MEM_COM, /* common */ 3560a177c3dSDuncan Barclay PCCARD_A_MEM_ATTR, /* attribute */ 3570a177c3dSDuncan Barclay PCCARD_A_MEM_8BIT, /* 8 bit */ 3580a177c3dSDuncan Barclay PCCARD_A_MEM_16BIT /* 16 bit */ 359e14c13daSWarner Losh }; 360e14c13daSWarner Losh 361c8ce264eSWarner Losh #define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) 3625f7e36d1SWarner Losh #define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) 36334e4437eSWarner Losh 36434e4437eSWarner Losh #define PCCARD_S(a, b) PCMCIA_STR_ ## a ## _ ## b 36534e4437eSWarner Losh #define PCCARD_P(a, b) PCMCIA_PRODUCT_ ## a ## _ ## b 36634e4437eSWarner Losh #define PCCARD_C(a, b) PCMCIA_CIS_ ## a ## _ ## b 36734e4437eSWarner Losh #define PCMCIA_CARD(v, p, f) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ 36834e4437eSWarner Losh PCCARD_P(v, p), f, PCCARD_C(v, p) } 36934e4437eSWarner Losh #define PCMCIA_CARD2(v1, p1, p2, f) \ 37034e4437eSWarner Losh { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ 37134e4437eSWarner Losh f, PCMCIA_CIS_ ## p2} 37234e4437eSWarner Losh 373