pccardvar.h (fe364ce96338f9bc6cb7930ee6b05562633a7eed) | pccardvar.h (73cac3387f31b913d1c8eeb21104c2eb09152f2b) |
---|---|
1/* $NetBSD: pcmciavar.h,v 1.12 2000/02/08 12:51:31 enami Exp $ */ 2/* $FreeBSD$ */ 3 4/*- 5 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 | 1/* $NetBSD: pcmciavar.h,v 1.12 2000/02/08 12:51:31 enami Exp $ */ 2/* $FreeBSD$ */ 3 4/*- 5 * Copyright (c) 1997 Marc Horowitz. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 16 unchanged lines hidden (view full) --- 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 |
33extern int pccard_verbose; 34 | |
35/* 36 * PCCARD_API_LEVEL. When set to 5, we provide a 5.x compatable API 37 * for driver writers that have to share their code between 5.x and 6.x. 38 * The 5.x compatibility interfaces will be unsupported in 7.0, at which 39 * point we'll only support 6 and newer, etc. 40 */ 41#ifndef PCCARD_API_LEVEL 42#define PCCARD_API_LEVEL 6 --- 23 unchanged lines hidden (view full) --- 66 bus_space_handle_t memh; /* mapped space handle */ 67 bus_addr_t addr; /* resulting address in bus space */ 68 bus_size_t size; /* size of mem space */ 69 bus_size_t realsize; /* how much we really allocated */ 70 bus_addr_t cardaddr; /* Absolute address on card */ 71 int kind; 72}; 73 | 33/* 34 * PCCARD_API_LEVEL. When set to 5, we provide a 5.x compatable API 35 * for driver writers that have to share their code between 5.x and 6.x. 36 * The 5.x compatibility interfaces will be unsupported in 7.0, at which 37 * point we'll only support 6 and newer, etc. 38 */ 39#ifndef PCCARD_API_LEVEL 40#define PCCARD_API_LEVEL 6 --- 23 unchanged lines hidden (view full) --- 64 bus_space_handle_t memh; /* mapped space handle */ 65 bus_addr_t addr; /* resulting address in bus space */ 66 bus_size_t size; /* size of mem space */ 67 bus_size_t realsize; /* how much we really allocated */ 68 bus_addr_t cardaddr; /* Absolute address on card */ 69 int kind; 70}; 71 |
74/* pccard itself */ 75 76#define PCCARD_MEM_PAGE_SIZE 4096 77 78#define PCCARD_CFE_MWAIT_REQUIRED 0x0001 79#define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 80#define PCCARD_CFE_WP_ACTIVE 0x0004 81#define PCCARD_CFE_BVD_ACTIVE 0x0008 82#define PCCARD_CFE_IO8 0x0010 83#define PCCARD_CFE_IO16 0x0020 84#define PCCARD_CFE_IRQSHARE 0x0040 85#define PCCARD_CFE_IRQPULSE 0x0080 86#define PCCARD_CFE_IRQLEVEL 0x0100 87#define PCCARD_CFE_POWERDOWN 0x0200 88#define PCCARD_CFE_READONLY 0x0400 89#define PCCARD_CFE_AUDIO 0x0800 90 91struct pccard_config_entry { 92 int number; 93 uint32_t flags; 94 int iftype; 95 int num_iospace; 96 97 /* 98 * The card will only decode this mask in any case, so we can 99 * do dynamic allocation with this in mind, in case the suggestions 100 * below are no good. 101 */ 102 u_long iomask; 103 struct { 104 u_long length; 105 u_long start; 106 } iospace[4]; /* XXX this could be as high as 16 */ 107 uint16_t irqmask; 108 int num_memspace; 109 struct { 110 u_long length; 111 u_long cardaddr; 112 u_long hostaddr; 113 } memspace[2]; /* XXX this could be as high as 8 */ 114 int maxtwins; 115 STAILQ_ENTRY(pccard_config_entry) cfe_list; 116}; 117 118struct pccard_funce_disk { 119 int pfd_interface; 120}; 121 122struct pccard_funce_lan { 123 int pfl_nidlen; 124 uint8_t pfl_nid[8]; 125}; 126 127union pccard_funce { 128 struct pccard_funce_disk pfv_disk; 129 struct pccard_funce_lan pfv_lan; 130}; 131 132struct pccard_function { 133 /* read off the card */ 134 int number; 135 int function; 136 int last_config_index; 137 uint32_t ccr_base; /* Offset with card's memory */ 138 uint32_t ccr_mask; 139 struct resource *ccr_res; 140 int ccr_rid; 141 STAILQ_HEAD(, pccard_config_entry) cfe_head; 142 STAILQ_ENTRY(pccard_function) pf_list; 143 /* run-time state */ 144 struct pccard_softc *sc; 145 struct pccard_config_entry *cfe; 146 struct pccard_mem_handle pf_pcmh; 147 device_t dev; 148#define pf_ccrt pf_pcmh.memt 149#define pf_ccrh pf_pcmh.memh 150#define pf_ccr_realsize pf_pcmh.realsize 151 uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ 152 int pf_ccr_window; 153 bus_addr_t pf_mfc_iobase; 154 bus_addr_t pf_mfc_iomax; 155 int pf_flags; 156 driver_intr_t *intr_handler; 157 void *intr_handler_arg; 158 void *intr_handler_cookie; 159 160 union pccard_funce pf_funce; /* CISTPL_FUNCE */ 161#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface 162#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid 163#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen 164}; 165 166/* pf_flags */ 167#define PFF_ENABLED 0x0001 /* function is enabled */ 168 169struct pccard_card { 170 int cis1_major; 171 int cis1_minor; 172 /* XXX waste of space? */ 173 char cis1_info_buf[256]; 174 char *cis1_info[4]; 175 /* 176 * Use int32_t for manufacturer and product so that they can 177 * hold the id value found in card CIS and special value that 178 * indicates no id was found. 179 */ 180 int32_t manufacturer; 181#define PCMCIA_VENDOR_INVALID -1 182 int32_t product; 183#define PCMCIA_PRODUCT_INVALID -1 184 int16_t prodext; 185 uint16_t error; 186#define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } 187 STAILQ_HEAD(, pccard_function) pf_head; 188}; 189 | |
190#define PCCARD_WIDTH_AUTO 0 191#define PCCARD_WIDTH_IO8 1 192#define PCCARD_WIDTH_IO16 2 193 | 72#define PCCARD_WIDTH_AUTO 0 73#define PCCARD_WIDTH_IO8 1 74#define PCCARD_WIDTH_IO16 2 75 |
194/* More later? */ 195struct pccard_ivar { 196 struct resource_list resources; 197 struct pccard_function *pf; 198}; 199 200struct pccard_softc { 201 device_t dev; 202 /* this stuff is for the socket */ 203 204 /* this stuff is for the card */ 205 struct pccard_card card; 206 int sc_enabled_count; /* num functions enabled */ 207}; 208 209struct pccard_cis_quirk { 210 int32_t manufacturer; 211 int32_t product; 212 char *cis1_info[4]; 213 struct pccard_function *pf; 214 struct pccard_config_entry *cfe; 215}; 216 | |
217struct pccard_tuple { 218 unsigned int code; 219 unsigned int length; | 76struct pccard_tuple { 77 unsigned int code; 78 unsigned int length; |
220 u_long mult; | 79 u_long mult; /* dist btn successive bytes */ |
221 bus_addr_t ptr; 222 bus_space_tag_t memt; 223 bus_space_handle_t memh; 224}; 225 226typedef int (*pccard_scan_t)(const struct pccard_tuple *, void *); 227 228struct pccard_product { --- 17 unchanged lines hidden (view full) --- 246static __inline const struct pccard_product * 247pccard_product_lookup(device_t dev, const struct pccard_product *tab, 248 size_t ent_size, pccard_product_match_fn matchfn) 249{ 250 return CARD_DO_PRODUCT_LOOKUP(device_get_parent(dev), dev, 251 tab, ent_size, matchfn); 252} 253 | 80 bus_addr_t ptr; 81 bus_space_tag_t memt; 82 bus_space_handle_t memh; 83}; 84 85typedef int (*pccard_scan_t)(const struct pccard_tuple *, void *); 86 87struct pccard_product { --- 17 unchanged lines hidden (view full) --- 105static __inline const struct pccard_product * 106pccard_product_lookup(device_t dev, const struct pccard_product *tab, 107 size_t ent_size, pccard_product_match_fn matchfn) 108{ 109 return CARD_DO_PRODUCT_LOOKUP(device_get_parent(dev), dev, 110 tab, ent_size, matchfn); 111} 112 |
254void pccard_read_cis(struct pccard_softc *); 255void pccard_check_cis_quirks(device_t); 256void pccard_print_cis(device_t); 257int pccard_scan_cis(device_t, device_t, pccard_scan_t, void *); 258 | |
259#define pccard_cis_read_1(tuple, idx0) \ 260 (bus_space_read_1((tuple)->memt, (tuple)->memh, (tuple)->mult*(idx0))) 261 262#define pccard_tuple_read_1(tuple, idx1) \ 263 (pccard_cis_read_1((tuple), ((tuple)->ptr+(2+(idx1))))) 264 265#define pccard_tuple_read_2(tuple, idx2) \ 266 (pccard_tuple_read_1((tuple), (idx2)) | \ --- 18 unchanged lines hidden (view full) --- 285 286#define PCCARD_SPACE_MEMORY 1 287#define PCCARD_SPACE_IO 2 288 289#define pccard_mfc(sc) \ 290 (STAILQ_FIRST(&(sc)->card.pf_head) && \ 291 STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list)) 292 | 113#define pccard_cis_read_1(tuple, idx0) \ 114 (bus_space_read_1((tuple)->memt, (tuple)->memh, (tuple)->mult*(idx0))) 115 116#define pccard_tuple_read_1(tuple, idx1) \ 117 (pccard_cis_read_1((tuple), ((tuple)->ptr+(2+(idx1))))) 118 119#define pccard_tuple_read_2(tuple, idx2) \ 120 (pccard_tuple_read_1((tuple), (idx2)) | \ --- 18 unchanged lines hidden (view full) --- 139 140#define PCCARD_SPACE_MEMORY 1 141#define PCCARD_SPACE_IO 2 142 143#define pccard_mfc(sc) \ 144 (STAILQ_FIRST(&(sc)->card.pf_head) && \ 145 STAILQ_NEXT(STAILQ_FIRST(&(sc)->card.pf_head),pf_list)) 146 |
293/* compat layer */ 294static __inline int 295pccard_compat_probe(device_t dev) 296{ 297 return (CARD_COMPAT_DO_PROBE(device_get_parent(dev), dev)); 298} 299 300static __inline int 301pccard_compat_attach(device_t dev) 302{ 303 return (CARD_COMPAT_DO_ATTACH(device_get_parent(dev), dev)); 304} 305 | |
306/* Convenience functions */ 307 308static __inline int 309pccard_cis_scan(device_t dev, pccard_scan_t fct, void *arg) 310{ 311 return (CARD_CIS_SCAN(device_get_parent(dev), dev, fct, arg)); 312} 313 --- 57 unchanged lines hidden (view full) --- 371/* shared memory flags */ 372enum { 373 PCCARD_A_MEM_COM, /* common */ 374 PCCARD_A_MEM_ATTR, /* attribute */ 375 PCCARD_A_MEM_8BIT, /* 8 bit */ 376 PCCARD_A_MEM_16BIT /* 16 bit */ 377}; 378 | 147/* Convenience functions */ 148 149static __inline int 150pccard_cis_scan(device_t dev, pccard_scan_t fct, void *arg) 151{ 152 return (CARD_CIS_SCAN(device_get_parent(dev), dev, fct, arg)); 153} 154 --- 57 unchanged lines hidden (view full) --- 212/* shared memory flags */ 213enum { 214 PCCARD_A_MEM_COM, /* common */ 215 PCCARD_A_MEM_ATTR, /* attribute */ 216 PCCARD_A_MEM_8BIT, /* 8 bit */ 217 PCCARD_A_MEM_16BIT /* 16 bit */ 218}; 219 |
379#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) 380#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) 381 | |
382#define PCCARD_S(a, b) PCMCIA_STR_ ## a ## _ ## b 383#define PCCARD_P(a, b) PCMCIA_PRODUCT_ ## a ## _ ## b 384#define PCCARD_C(a, b) PCMCIA_CIS_ ## a ## _ ## b 385#if PCCARD_API_LEVEL >= 6 386#define PCMCIA_CARD_D(v, p) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ 387 PCCARD_P(v, p), PCCARD_C(v, p) } 388#define PCMCIA_CARD2_D(v1, p1, p2) \ 389 { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ --- 18 unchanged lines hidden --- | 220#define PCCARD_S(a, b) PCMCIA_STR_ ## a ## _ ## b 221#define PCCARD_P(a, b) PCMCIA_PRODUCT_ ## a ## _ ## b 222#define PCCARD_C(a, b) PCMCIA_CIS_ ## a ## _ ## b 223#if PCCARD_API_LEVEL >= 6 224#define PCMCIA_CARD_D(v, p) { PCCARD_S(v, p), PCMCIA_VENDOR_ ## v, \ 225 PCCARD_P(v, p), PCCARD_C(v, p) } 226#define PCMCIA_CARD2_D(v1, p1, p2) \ 227 { PCMCIA_STR_ ## p2, PCMCIA_VENDOR_ ## v1, PCCARD_P(v1, p1), \ --- 18 unchanged lines hidden --- |