18456e16eSWarner Losh /* $NetBSD: pcmciavar.h,v 1.12 2000/02/08 12:51:31 enami Exp $ */ 2c2380338SWarner Losh /* $FreeBSD$ */ 3c2380338SWarner Losh 4098ca2bdSWarner 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 extern int pccard_verbose; 34c2380338SWarner Losh 35c2380338SWarner Losh /* 36ab581af7SWarner Losh * PCCARD_API_LEVEL. When set to 5, we provide a 5.x compatable API 37ab581af7SWarner Losh * for driver writers that have to share their code between 5.x and 6.x. 38ab581af7SWarner Losh * The 5.x compatibility interfaces will be unsupported in 7.0, at which 39ab581af7SWarner Losh * point we'll only support 6 and newer, etc. 40ab581af7SWarner Losh */ 41ab581af7SWarner Losh #ifndef PCCARD_API_LEVEL 42ab581af7SWarner Losh #define PCCARD_API_LEVEL 6 43ab581af7SWarner Losh #elif PCCARD_API_LEVEL < 5 44ab581af7SWarner Losh #error "pccard API less than 5 unsupported" 45ab581af7SWarner Losh #endif 46ab581af7SWarner Losh 47ab581af7SWarner Losh /* 48c2380338SWarner Losh * Contains information about mapped/allocated i/o spaces. 49c2380338SWarner Losh */ 50c2380338SWarner Losh struct pccard_io_handle { 51c2380338SWarner Losh bus_space_tag_t iot; /* bus space tag (from chipset) */ 52c2380338SWarner Losh bus_space_handle_t ioh; /* mapped space handle */ 53c2380338SWarner Losh bus_addr_t addr; /* resulting address in bus space */ 54c2380338SWarner Losh bus_size_t size; /* size of i/o space */ 55c2380338SWarner Losh int flags; /* misc. information */ 5681047394SWarner Losh int width; 57c2380338SWarner Losh }; 58c2380338SWarner Losh 59c2380338SWarner Losh #define PCCARD_IO_ALLOCATED 0x01 /* i/o space was allocated */ 60c2380338SWarner Losh 61c2380338SWarner Losh /* 62c2380338SWarner Losh * Contains information about allocated memory space. 63c2380338SWarner Losh */ 64c2380338SWarner Losh struct pccard_mem_handle { 65c2380338SWarner Losh bus_space_tag_t memt; /* bus space tag (from chipset) */ 66c2380338SWarner Losh bus_space_handle_t memh; /* mapped space handle */ 67c2380338SWarner Losh bus_addr_t addr; /* resulting address in bus space */ 68c2380338SWarner Losh bus_size_t size; /* size of mem space */ 69c2380338SWarner Losh bus_size_t realsize; /* how much we really allocated */ 70a91e0069SWarner Losh bus_addr_t cardaddr; /* Absolute address on card */ 7181047394SWarner Losh int kind; 72c2380338SWarner Losh }; 73c2380338SWarner Losh 74c2380338SWarner Losh /* pccard itself */ 75c2380338SWarner Losh 76395fee23SWarner Losh #define PCCARD_MEM_PAGE_SIZE 4096 77395fee23SWarner Losh 78c2380338SWarner Losh #define PCCARD_CFE_MWAIT_REQUIRED 0x0001 79c2380338SWarner Losh #define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 80c2380338SWarner Losh #define PCCARD_CFE_WP_ACTIVE 0x0004 81c2380338SWarner Losh #define PCCARD_CFE_BVD_ACTIVE 0x0008 82c2380338SWarner Losh #define PCCARD_CFE_IO8 0x0010 83c2380338SWarner Losh #define PCCARD_CFE_IO16 0x0020 84c2380338SWarner Losh #define PCCARD_CFE_IRQSHARE 0x0040 85c2380338SWarner Losh #define PCCARD_CFE_IRQPULSE 0x0080 86c2380338SWarner Losh #define PCCARD_CFE_IRQLEVEL 0x0100 87c2380338SWarner Losh #define PCCARD_CFE_POWERDOWN 0x0200 88c2380338SWarner Losh #define PCCARD_CFE_READONLY 0x0400 89c2380338SWarner Losh #define PCCARD_CFE_AUDIO 0x0800 90c2380338SWarner Losh 91c2380338SWarner Losh struct pccard_config_entry { 92c2380338SWarner Losh int number; 930540e305SWarner Losh uint32_t flags; 94c2380338SWarner Losh int iftype; 95c2380338SWarner Losh int num_iospace; 96c2380338SWarner Losh 97c2380338SWarner Losh /* 98c2380338SWarner Losh * The card will only decode this mask in any case, so we can 99c2380338SWarner Losh * do dynamic allocation with this in mind, in case the suggestions 100c2380338SWarner Losh * below are no good. 101c2380338SWarner Losh */ 102c2380338SWarner Losh u_long iomask; 103c2380338SWarner Losh struct { 104c2380338SWarner Losh u_long length; 105c2380338SWarner Losh u_long start; 106c2380338SWarner Losh } iospace[4]; /* XXX this could be as high as 16 */ 1070540e305SWarner Losh uint16_t irqmask; 108c2380338SWarner Losh int num_memspace; 109c2380338SWarner Losh struct { 110c2380338SWarner Losh u_long length; 111c2380338SWarner Losh u_long cardaddr; 112c2380338SWarner Losh u_long hostaddr; 113c2380338SWarner Losh } memspace[2]; /* XXX this could be as high as 8 */ 114c2380338SWarner Losh int maxtwins; 115e3975643SJake Burkholder STAILQ_ENTRY(pccard_config_entry) cfe_list; 116c2380338SWarner Losh }; 117c2380338SWarner Losh 118a8bc3167STakeshi Shibagaki struct pccard_funce_disk { 119a8bc3167STakeshi Shibagaki int pfd_interface; 120a8bc3167STakeshi Shibagaki }; 121a8bc3167STakeshi Shibagaki 122a8bc3167STakeshi Shibagaki struct pccard_funce_lan { 123a8bc3167STakeshi Shibagaki int pfl_nidlen; 1240540e305SWarner Losh uint8_t pfl_nid[8]; 125a8bc3167STakeshi Shibagaki }; 126a8bc3167STakeshi Shibagaki 127a8bc3167STakeshi Shibagaki union pccard_funce { 128a8bc3167STakeshi Shibagaki struct pccard_funce_disk pfv_disk; 129a8bc3167STakeshi Shibagaki struct pccard_funce_lan pfv_lan; 130a8bc3167STakeshi Shibagaki }; 131a8bc3167STakeshi Shibagaki 132c2380338SWarner Losh struct pccard_function { 133c2380338SWarner Losh /* read off the card */ 134c2380338SWarner Losh int number; 135c2380338SWarner Losh int function; 136c2380338SWarner Losh int last_config_index; 137f0299355SWarner Losh uint32_t ccr_base; /* Offset with card's memory */ 138f0299355SWarner Losh uint32_t ccr_mask; 13978ae73b5SWarner Losh struct resource *ccr_res; 14078ae73b5SWarner Losh int ccr_rid; 141e3975643SJake Burkholder STAILQ_HEAD(, pccard_config_entry) cfe_head; 142e3975643SJake Burkholder STAILQ_ENTRY(pccard_function) pf_list; 143c2380338SWarner Losh /* run-time state */ 144c2380338SWarner Losh struct pccard_softc *sc; 145c2380338SWarner Losh struct pccard_config_entry *cfe; 146c2380338SWarner Losh struct pccard_mem_handle pf_pcmh; 147bd6dd21eSWarner Losh device_t dev; 148c2380338SWarner Losh #define pf_ccrt pf_pcmh.memt 149c2380338SWarner Losh #define pf_ccrh pf_pcmh.memh 150c2380338SWarner Losh #define pf_ccr_realsize pf_pcmh.realsize 151f0299355SWarner Losh uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ 152c2380338SWarner Losh int pf_ccr_window; 1534f9303c0SWarner Losh bus_addr_t pf_mfc_iobase; 1544f9303c0SWarner Losh bus_addr_t pf_mfc_iomax; 155c2380338SWarner Losh int pf_flags; 1560c95c705SJonathan Chen driver_intr_t *intr_handler; 1570c95c705SJonathan Chen void *intr_handler_arg; 1580c95c705SJonathan Chen void *intr_handler_cookie; 159a8bc3167STakeshi Shibagaki 160a8bc3167STakeshi Shibagaki union pccard_funce pf_funce; /* CISTPL_FUNCE */ 161a8bc3167STakeshi Shibagaki #define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface 162a8bc3167STakeshi Shibagaki #define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid 163a8bc3167STakeshi Shibagaki #define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen 164c2380338SWarner Losh }; 165c2380338SWarner Losh 166c2380338SWarner Losh /* pf_flags */ 167c2380338SWarner Losh #define PFF_ENABLED 0x0001 /* function is enabled */ 168c2380338SWarner Losh 169c2380338SWarner Losh struct pccard_card { 170c2380338SWarner Losh int cis1_major; 171c2380338SWarner Losh int cis1_minor; 172c2380338SWarner Losh /* XXX waste of space? */ 173c2380338SWarner Losh char cis1_info_buf[256]; 174c2380338SWarner Losh char *cis1_info[4]; 175c2380338SWarner Losh /* 176c2380338SWarner Losh * Use int32_t for manufacturer and product so that they can 177c2380338SWarner Losh * hold the id value found in card CIS and special value that 178c2380338SWarner Losh * indicates no id was found. 179c2380338SWarner Losh */ 180c2380338SWarner Losh int32_t manufacturer; 181fdacad4eSWarner Losh #define PCMCIA_VENDOR_INVALID -1 182c2380338SWarner Losh int32_t product; 183fdacad4eSWarner Losh #define PCMCIA_PRODUCT_INVALID -1 18457ffbd6eSTakeshi Shibagaki int16_t prodext; 1850540e305SWarner Losh uint16_t error; 186fdacad4eSWarner Losh #define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } 187e3975643SJake Burkholder STAILQ_HEAD(, pccard_function) pf_head; 188c2380338SWarner Losh }; 189c2380338SWarner Losh 190d3d805e6SWarner Losh #define PCCARD_WIDTH_AUTO 0 191d3d805e6SWarner Losh #define PCCARD_WIDTH_IO8 1 192d3d805e6SWarner Losh #define PCCARD_WIDTH_IO16 2 193d3d805e6SWarner Losh 19412bba6c2SWarner Losh /* More later? */ 19512bba6c2SWarner Losh struct pccard_ivar { 19612bba6c2SWarner Losh struct resource_list resources; 197e6e34c56SWarner Losh struct pccard_function *pf; 198c2380338SWarner Losh }; 199c2380338SWarner Losh 200c2380338SWarner Losh struct pccard_softc { 201deae2aafSWarner Losh device_t dev; 20278ae73b5SWarner Losh /* this stuff is for the socket */ 203deae2aafSWarner Losh 204c2380338SWarner Losh /* this stuff is for the card */ 205c2380338SWarner Losh struct pccard_card card; 206deae2aafSWarner Losh int sc_enabled_count; /* num functions enabled */ 207c2380338SWarner Losh }; 208c2380338SWarner Losh 209c2380338SWarner Losh struct pccard_cis_quirk { 210c2380338SWarner Losh int32_t manufacturer; 211c2380338SWarner Losh int32_t product; 212c2380338SWarner Losh char *cis1_info[4]; 213c2380338SWarner Losh struct pccard_function *pf; 214c2380338SWarner Losh struct pccard_config_entry *cfe; 215c2380338SWarner Losh }; 216c2380338SWarner Losh 217c2380338SWarner Losh struct pccard_tuple { 218c2380338SWarner Losh unsigned int code; 219c2380338SWarner Losh unsigned int length; 220c2380338SWarner Losh u_long mult; 221c2380338SWarner Losh bus_addr_t ptr; 222c2380338SWarner Losh bus_space_tag_t memt; 223c2380338SWarner Losh bus_space_handle_t memh; 224c2380338SWarner Losh }; 225c2380338SWarner Losh 2265af5f40cSWarner Losh typedef int (*pccard_scan_t)(const struct pccard_tuple *, void *); 22726db48b9SWarner Losh 2288456e16eSWarner Losh struct pccard_product { 2298456e16eSWarner Losh const char *pp_name; /* NULL if end of table */ 2300540e305SWarner Losh #define PCCARD_VENDOR_ANY (0xffffffff) 2310540e305SWarner Losh uint32_t pp_vendor; 2320540e305SWarner Losh #define PCCARD_PRODUCT_ANY (0xffffffff) 2330540e305SWarner Losh uint32_t pp_product; 234da15fcf1SWarner Losh const char *pp_cis[4]; 2358456e16eSWarner Losh }; 2368456e16eSWarner Losh 2378456e16eSWarner Losh typedef int (*pccard_product_match_fn) (device_t dev, 2388456e16eSWarner Losh const struct pccard_product *ent, int vpfmatch); 2398456e16eSWarner Losh 240c1bb793bSWarner Losh #include "card_if.h" 241c1bb793bSWarner Losh 242c1bb793bSWarner Losh /* 243c1bb793bSWarner Losh * make this inline so that we don't have to worry about dangling references 244c1bb793bSWarner Losh * to it in the modules or the code. 245c1bb793bSWarner Losh */ 246c1bb793bSWarner Losh static __inline const struct pccard_product * 247c1bb793bSWarner Losh pccard_product_lookup(device_t dev, const struct pccard_product *tab, 248c1bb793bSWarner Losh size_t ent_size, pccard_product_match_fn matchfn) 249c1bb793bSWarner Losh { 250c1bb793bSWarner Losh return CARD_DO_PRODUCT_LOOKUP(device_get_parent(dev), dev, 251c1bb793bSWarner Losh tab, ent_size, matchfn); 252c1bb793bSWarner Losh } 2538456e16eSWarner Losh 25481047394SWarner Losh void pccard_read_cis(struct pccard_softc *); 255c2380338SWarner Losh void pccard_check_cis_quirks(device_t); 256c2380338SWarner Losh void pccard_print_cis(device_t); 257fe364ce9SWarner Losh int pccard_scan_cis(device_t, device_t, pccard_scan_t, void *); 258c2380338SWarner Losh 259c2380338SWarner Losh #define pccard_cis_read_1(tuple, idx0) \ 260c2380338SWarner Losh (bus_space_read_1((tuple)->memt, (tuple)->memh, (tuple)->mult*(idx0))) 261c2380338SWarner Losh 262c2380338SWarner Losh #define pccard_tuple_read_1(tuple, idx1) \ 263c2380338SWarner Losh (pccard_cis_read_1((tuple), ((tuple)->ptr+(2+(idx1))))) 264c2380338SWarner Losh 265c2380338SWarner Losh #define pccard_tuple_read_2(tuple, idx2) \ 266c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx2)) | \ 267c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx2)+1)<<8)) 268c2380338SWarner Losh 269c2380338SWarner Losh #define pccard_tuple_read_3(tuple, idx3) \ 270c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)) | \ 271c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)+1)<<8) | \ 272c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx3)+2)<<16)) 273c2380338SWarner Losh 274c2380338SWarner Losh #define pccard_tuple_read_4(tuple, idx4) \ 275c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)) | \ 276c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+1)<<8) | \ 277c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+2)<<16) | \ 278c2380338SWarner Losh (pccard_tuple_read_1((tuple), (idx4)+3)<<24)) 279c2380338SWarner Losh 280c2380338SWarner Losh #define pccard_tuple_read_n(tuple, n, idxn) \ 281c2380338SWarner Losh (((n)==1)?pccard_tuple_read_1((tuple), (idxn)) : \ 282c2380338SWarner Losh (((n)==2)?pccard_tuple_read_2((tuple), (idxn)) : \ 283c2380338SWarner Losh (((n)==3)?pccard_tuple_read_3((tuple), (idxn)) : \ 284c2380338SWarner Losh /* n == 4 */ pccard_tuple_read_4((tuple), (idxn))))) 285c2380338SWarner Losh 286c2380338SWarner Losh #define PCCARD_SPACE_MEMORY 1 287c2380338SWarner Losh #define PCCARD_SPACE_IO 2 288c2380338SWarner Losh 289d266c2dbSWarner Losh #define pccard_mfc(sc) \ 290d266c2dbSWarner Losh (STAILQ_FIRST(&(sc)->card.pf_head) && \ 291c2380338SWarner Losh STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list)) 292c2380338SWarner Losh 2932276cee5SWarner Losh /* compat layer */ 294c33c1284SWarner Losh static __inline int 295c33c1284SWarner Losh pccard_compat_probe(device_t dev) 296c33c1284SWarner Losh { 297c33c1284SWarner Losh return (CARD_COMPAT_DO_PROBE(device_get_parent(dev), dev)); 298c33c1284SWarner Losh } 299c33c1284SWarner Losh 300c33c1284SWarner Losh static __inline int 301c33c1284SWarner Losh pccard_compat_attach(device_t dev) 302c33c1284SWarner Losh { 303c33c1284SWarner Losh return (CARD_COMPAT_DO_ATTACH(device_get_parent(dev), dev)); 304c33c1284SWarner Losh } 3052276cee5SWarner Losh 306fe364ce9SWarner Losh /* Convenience functions */ 307fe364ce9SWarner Losh 308fe364ce9SWarner Losh static __inline int 309fe364ce9SWarner Losh pccard_cis_scan(device_t dev, pccard_scan_t fct, void *arg) 310fe364ce9SWarner Losh { 311fe364ce9SWarner Losh return (CARD_CIS_SCAN(device_get_parent(dev), dev, fct, arg)); 312fe364ce9SWarner Losh } 313fe364ce9SWarner Losh 314fe364ce9SWarner Losh static __inline int 315fe364ce9SWarner Losh pccard_attr_read_1(device_t dev, uint32_t offset, uint8_t *val) 316fe364ce9SWarner Losh { 317fe364ce9SWarner Losh return (CARD_ATTR_READ(device_get_parent(dev), dev, offset, val)); 318fe364ce9SWarner Losh } 319fe364ce9SWarner Losh 320fe364ce9SWarner Losh static __inline int 321fe364ce9SWarner Losh pccard_attr_write_1(device_t dev, uint32_t offset, uint8_t val) 322fe364ce9SWarner Losh { 323fe364ce9SWarner Losh return (CARD_ATTR_WRITE(device_get_parent(dev), dev, offset, val)); 324fe364ce9SWarner Losh } 325fe364ce9SWarner Losh 326fe364ce9SWarner Losh static __inline int 327fe364ce9SWarner Losh pccard_ccr_read_1(device_t dev, uint32_t offset, uint8_t *val) 328fe364ce9SWarner Losh { 329fe364ce9SWarner Losh return (CARD_CCR_READ(device_get_parent(dev), dev, offset, val)); 330fe364ce9SWarner Losh } 331fe364ce9SWarner Losh 332fe364ce9SWarner Losh static __inline int 333fe364ce9SWarner Losh pccard_ccr_write_1(device_t dev, uint32_t offset, uint8_t val) 334fe364ce9SWarner Losh { 335fe364ce9SWarner Losh return (CARD_CCR_WRITE(device_get_parent(dev), dev, offset, val)); 336fe364ce9SWarner Losh } 337fe364ce9SWarner Losh 33887ef0a0aSTatsumi Hosokawa /* ivar interface */ 33987ef0a0aSTatsumi Hosokawa enum { 34087ef0a0aSTatsumi Hosokawa PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */ 3418456e16eSWarner Losh PCCARD_IVAR_VENDOR, 3428456e16eSWarner Losh PCCARD_IVAR_PRODUCT, 34357ffbd6eSTakeshi Shibagaki PCCARD_IVAR_PRODEXT, 3448456e16eSWarner Losh PCCARD_IVAR_FUNCTION_NUMBER, 3458456e16eSWarner Losh PCCARD_IVAR_VENDOR_STR, /* CIS string for "Manufacturer" */ 3468456e16eSWarner Losh PCCARD_IVAR_PRODUCT_STR,/* CIS strnig for "Product" */ 347d62abc77SWarner Losh PCCARD_IVAR_CIS3_STR, 348dc8e185fSWarner Losh PCCARD_IVAR_CIS4_STR, 349dc8e185fSWarner Losh PCCARD_IVAR_FUNCTION 35087ef0a0aSTatsumi Hosokawa }; 35187ef0a0aSTatsumi Hosokawa 3528456e16eSWarner Losh #define PCCARD_ACCESSOR(A, B, T) \ 3538456e16eSWarner Losh __inline static int \ 3548456e16eSWarner Losh pccard_get_ ## A(device_t dev, T *t) \ 3558456e16eSWarner Losh { \ 3568456e16eSWarner Losh return BUS_READ_IVAR(device_get_parent(dev), dev, \ 3578456e16eSWarner Losh PCCARD_IVAR_ ## B, (uintptr_t *) t); \ 358e14c13daSWarner Losh } 359e14c13daSWarner Losh 3600540e305SWarner Losh PCCARD_ACCESSOR(ether, ETHADDR, uint8_t) 3610540e305SWarner Losh PCCARD_ACCESSOR(vendor, VENDOR, uint32_t) 3620540e305SWarner Losh PCCARD_ACCESSOR(product, PRODUCT, uint32_t) 3630540e305SWarner Losh PCCARD_ACCESSOR(prodext, PRODEXT, uint16_t) 3640540e305SWarner Losh PCCARD_ACCESSOR(function_number,FUNCTION_NUMBER, uint32_t) 3650540e305SWarner Losh PCCARD_ACCESSOR(function, FUNCTION, uint32_t) 366595670d9SWarner Losh PCCARD_ACCESSOR(vendor_str, VENDOR_STR, const char *) 367595670d9SWarner Losh PCCARD_ACCESSOR(product_str, PRODUCT_STR, const char *) 368595670d9SWarner Losh PCCARD_ACCESSOR(cis3_str, CIS3_STR, const char *) 369595670d9SWarner Losh PCCARD_ACCESSOR(cis4_str, CIS4_STR, const char *) 3708456e16eSWarner Losh 3710a177c3dSDuncan Barclay /* shared memory flags */ 372e14c13daSWarner Losh enum { 3730a177c3dSDuncan Barclay PCCARD_A_MEM_COM, /* common */ 3740a177c3dSDuncan Barclay PCCARD_A_MEM_ATTR, /* attribute */ 3750a177c3dSDuncan Barclay PCCARD_A_MEM_8BIT, /* 8 bit */ 3760a177c3dSDuncan Barclay PCCARD_A_MEM_16BIT /* 16 bit */ 377e14c13daSWarner Losh }; 378e14c13daSWarner Losh 379c8ce264eSWarner Losh #define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) 3805f7e36d1SWarner Losh #define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) 38134e4437eSWarner Losh 38234e4437eSWarner Losh #define PCCARD_S(a, b) PCMCIA_STR_ ## a ## _ ## b 38334e4437eSWarner Losh #define PCCARD_P(a, b) PCMCIA_PRODUCT_ ## a ## _ ## b 38434e4437eSWarner Losh #define PCCARD_C(a, b) PCMCIA_CIS_ ## a ## _ ## b 385ab581af7SWarner Losh #if PCCARD_API_LEVEL >= 6 386ab581af7SWarner Losh #define PCMCIA_CARD_D(v, p) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ 387ab581af7SWarner Losh PCCARD_P(v, p), PCCARD_C(v, p) } 388ab581af7SWarner Losh #define PCMCIA_CARD2_D(v1, p1, p2) \ 389ab581af7SWarner Losh { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ 390ab581af7SWarner Losh PCMCIA_CIS_ ## p2} 391ab581af7SWarner Losh #define PCMCIA_CARD(v, p) { NULL, PCMCIA_VENDOR_ ## v, \ 392ab581af7SWarner Losh PCCARD_P(v, p), PCCARD_C(v, p) } 393ab581af7SWarner Losh #define PCMCIA_CARD2(v1, p1, p2) \ 394ab581af7SWarner Losh { NULL, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ 395ab581af7SWarner Losh PCMCIA_CIS_ ## p2} 396ab581af7SWarner Losh #else 39746d5f4e7SWarner Losh #define PCMCIA_CARD_D(v, p, f) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ 398ab581af7SWarner Losh PCCARD_P(v, p), PCCARD_C(v, p) } 39946d5f4e7SWarner Losh #define PCMCIA_CARD2_D(v1, p1, p2, f) \ 40068d25868SWarner Losh { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ 401ab581af7SWarner Losh PCMCIA_CIS_ ## p2} 40246d5f4e7SWarner Losh #define PCMCIA_CARD(v, p, f) { NULL, PCMCIA_VENDOR_ ## v, \ 403ab581af7SWarner Losh PCCARD_P(v, p), PCCARD_C(v, p) } 40446d5f4e7SWarner Losh #define PCMCIA_CARD2(v1, p1, p2, f) \ 405bf1f89d4SWarner Losh { NULL, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ 406ab581af7SWarner Losh PCMCIA_CIS_ ## p2} 407ab581af7SWarner Losh #endif 408