pccardvarp.h revision 237692
1108768Strhodes/*- 2108768Strhodes * Copyright (c) 2005, M. Warner Losh 3108768Strhodes * All rights reserved. 4108768Strhodes * 5133338Ssimon * Redistribution and use in source and binary forms, with or without 6108768Strhodes * modification, are permitted provided that the following conditions 7108768Strhodes * are met: 8108768Strhodes * 1. Redistributions of source code must retain the above copyright 9108768Strhodes * notice unmodified, this list of conditions, and the following 10111447Sru * disclaimer. 11108768Strhodes * 2. Redistributions in binary form must reproduce the above copyright 12159719Sbrueffer * notice, this list of conditions and the following disclaimer in the 13159719Sbrueffer * documentation and/or other materials provided with the distribution. 14159719Sbrueffer * 15159719Sbrueffer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16159719Sbrueffer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17111447Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18111447Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19159719Sbrueffer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20159719Sbrueffer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21159719Sbrueffer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22159719Sbrueffer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23159719Sbrueffer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24159719Sbrueffer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25159719Sbrueffer * SUCH DAMAGE. 26159719Sbrueffer * 27108768Strhodes * $FreeBSD: head/sys/dev/pccard/pccardvarp.h 237692 2012-06-28 07:26:44Z imp $ 28108768Strhodes */ 29108768Strhodes 30108768Strhodes#ifndef _PCCARD_PCCARDVARP_H 31111447Sru#define _PCCARD_PCCARDVARP_H 32108768Strhodes 33133336Ssimon/* pccard itself */ 34133336Ssimon 35133336Ssimon#define PCCARD_MEM_PAGE_SIZE 1024 36133336Ssimon 37108768Strhodes#define PCCARD_CFE_MWAIT_REQUIRED 0x0001 38133336Ssimon#define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 39111447Sru#define PCCARD_CFE_WP_ACTIVE 0x0004 40111447Sru#define PCCARD_CFE_BVD_ACTIVE 0x0008 41111447Sru#define PCCARD_CFE_IO8 0x0010 42111447Sru#define PCCARD_CFE_IO16 0x0020 43111447Sru#define PCCARD_CFE_IRQSHARE 0x0040 44111447Sru#define PCCARD_CFE_IRQPULSE 0x0080 45111447Sru#define PCCARD_CFE_IRQLEVEL 0x0100 46111447Sru#define PCCARD_CFE_POWERDOWN 0x0200 47111447Sru#define PCCARD_CFE_READONLY 0x0400 48111447Sru#define PCCARD_CFE_AUDIO 0x0800 49108768Strhodes 50108768Strhodesstruct pccard_ce_iospace { 51133336Ssimon u_long length; 52111447Sru u_long start; 53111447Sru}; 54111447Sru 55111447Srustruct pccard_ce_memspace { 56111447Sru u_long length; 57111447Sru u_long cardaddr; 58108768Strhodes u_long hostaddr; 59108768Strhodes}; 60108768Strhodes 61108768Strhodesstruct pccard_config_entry { 62108768Strhodes int number; 63108768Strhodes uint32_t flags; 64108768Strhodes int iftype; 65108768Strhodes int num_iospace; 66111447Sru /* 67108768Strhodes * The card will only decode this mask in any case, so we can 68108768Strhodes * do dynamic allocation with this in mind, in case the suggestions 69108768Strhodes * below are no good. 70108768Strhodes */ 71111447Sru u_long iomask; 72159773Sbrueffer struct pccard_ce_iospace iospace[4]; /* XXX up to 16 */ 73111447Sru uint16_t irqmask; 74108768Strhodes int num_memspace; 75108768Strhodes struct pccard_ce_memspace memspace[2]; /* XXX up to 8 */ 76108768Strhodes int maxtwins; 77112626Strhodes STAILQ_ENTRY(pccard_config_entry) cfe_list; 78}; 79 80struct pccard_funce_disk { 81 uint8_t pfd_interface; 82 uint8_t pfd_power; 83}; 84 85struct pccard_funce_lan { 86 int pfl_nidlen; 87 uint8_t pfl_nid[8]; 88}; 89 90union pccard_funce { 91 struct pccard_funce_disk pfv_disk; 92 struct pccard_funce_lan pfv_lan; 93}; 94 95struct pccard_function { 96 /* read off the card */ 97 int number; 98 int function; 99 int last_config_index; 100 uint32_t ccr_base; /* Offset with card's memory */ 101 uint32_t ccr_mask; 102 struct resource *ccr_res; 103 int ccr_rid; 104 STAILQ_HEAD(, pccard_config_entry) cfe_head; 105 STAILQ_ENTRY(pccard_function) pf_list; 106 /* run-time state */ 107 struct pccard_softc *sc; 108 struct pccard_config_entry *cfe; 109 struct pccard_mem_handle pf_pcmh; 110 device_t dev; 111#define pf_ccrt pf_pcmh.memt 112#define pf_ccrh pf_pcmh.memh 113#define pf_ccr_realsize pf_pcmh.realsize 114 uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ 115 int pf_ccr_window; 116 bus_addr_t pf_mfc_iobase; 117 bus_addr_t pf_mfc_iomax; 118 int pf_flags; 119 driver_filter_t *intr_filter; 120 driver_intr_t *intr_handler; 121 void *intr_handler_arg; 122 void *intr_handler_cookie; 123 124 union pccard_funce pf_funce; /* CISTPL_FUNCE */ 125#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface 126#define pf_funce_disk_power pf_funce.pfv_disk.pfd_power 127#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid 128#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen 129}; 130 131/* pf_flags */ 132#define PFF_ENABLED 0x0001 /* function is enabled */ 133 134struct pccard_card { 135 int cis1_major; 136 int cis1_minor; 137 /* XXX waste of space? */ 138 char cis1_info_buf[256]; 139 char *cis1_info[4]; 140 /* 141 * Use int32_t for manufacturer and product so that they can 142 * hold the id value found in card CIS and special value that 143 * indicates no id was found. 144 */ 145 int32_t manufacturer; 146#define PCMCIA_VENDOR_INVALID -1 147 int32_t product; 148#define PCMCIA_PRODUCT_INVALID -1 149 int16_t prodext; 150 uint16_t error; 151#define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } 152 STAILQ_HEAD(, pccard_function) pf_head; 153}; 154 155/* More later? */ 156struct pccard_ivar { 157 struct resource_list resources; 158 struct pccard_function *pf; 159}; 160 161struct cis_buffer 162{ 163 size_t len; /* Actual length of the CIS */ 164 uint8_t buffer[2040]; /* small enough to be 2k */ 165}; 166 167struct pccard_softc { 168 device_t dev; 169 /* this stuff is for the socket */ 170 171 /* this stuff is for the card */ 172 struct pccard_card card; 173 int sc_enabled_count; /* num functions enabled */ 174 struct cdev *cisdev; 175 int cis_open; 176 struct cis_buffer *cis; 177}; 178 179struct pccard_cis_quirk { 180 int32_t manufacturer; 181 int32_t product; 182 char *cis1_info[4]; 183 struct pccard_function *pf; 184 struct pccard_config_entry *cfe; 185}; 186 187void pccard_read_cis(struct pccard_softc *); 188void pccard_check_cis_quirks(device_t); 189void pccard_print_cis(device_t); 190int pccard_scan_cis(device_t, device_t, pccard_scan_t, void *); 191 192int pccard_device_create(struct pccard_softc *); 193int pccard_device_destroy(struct pccard_softc *); 194 195#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) 196#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) 197 198#endif /* _PCCARD_PCCARDVARP_H */ 199