pccardvarp.h revision 151368
1150362Simp/*- 2150362Simp * Copyright (c) 2005, M. Warner Losh 3150362Simp * All rights reserved. 4150362Simp * 5150362Simp * Redistribution and use in source and binary forms, with or without 6150362Simp * modification, are permitted provided that the following conditions 7150362Simp * are met: 8150362Simp * 1. Redistributions of source code must retain the above copyright 9150362Simp * notice unmodified, this list of conditions, and the following 10150362Simp * disclaimer. 11150362Simp * 2. Redistributions in binary form must reproduce the above copyright 12150362Simp * notice, this list of conditions and the following disclaimer in the 13150362Simp * documentation and/or other materials provided with the distribution. 14150362Simp * 15150362Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16150362Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17150362Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18150362Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19150362Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20150362Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21150362Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22150362Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23150362Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24150362Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25150362Simp * SUCH DAMAGE. 26150362Simp * 27150362Simp * $FreeBSD: head/sys/dev/pccard/pccardvarp.h 151368 2005-10-16 03:58:06Z imp $ 28150362Simp */ 29150362Simp 30150362Simp#ifndef _PCCARD_PCCARDVARP_H 31150362Simp#define _PCCARD_PCCARDVARP_H 32150362Simp 33150362Simp/* pccard itself */ 34150362Simp 35151368Simp#define PCCARD_MEM_PAGE_SIZE 1024 36150362Simp 37150362Simp#define PCCARD_CFE_MWAIT_REQUIRED 0x0001 38150362Simp#define PCCARD_CFE_RDYBSY_ACTIVE 0x0002 39150362Simp#define PCCARD_CFE_WP_ACTIVE 0x0004 40150362Simp#define PCCARD_CFE_BVD_ACTIVE 0x0008 41150362Simp#define PCCARD_CFE_IO8 0x0010 42150362Simp#define PCCARD_CFE_IO16 0x0020 43150362Simp#define PCCARD_CFE_IRQSHARE 0x0040 44150362Simp#define PCCARD_CFE_IRQPULSE 0x0080 45150362Simp#define PCCARD_CFE_IRQLEVEL 0x0100 46150362Simp#define PCCARD_CFE_POWERDOWN 0x0200 47150362Simp#define PCCARD_CFE_READONLY 0x0400 48150362Simp#define PCCARD_CFE_AUDIO 0x0800 49150362Simp 50150362Simpstruct pccard_config_entry { 51150362Simp int number; 52150362Simp uint32_t flags; 53150362Simp int iftype; 54150362Simp int num_iospace; 55150362Simp 56150362Simp /* 57150362Simp * The card will only decode this mask in any case, so we can 58150362Simp * do dynamic allocation with this in mind, in case the suggestions 59150362Simp * below are no good. 60150362Simp */ 61150362Simp u_long iomask; 62150362Simp struct { 63150362Simp u_long length; 64150362Simp u_long start; 65150362Simp } iospace[4]; /* XXX this could be as high as 16 */ 66150362Simp uint16_t irqmask; 67150362Simp int num_memspace; 68150362Simp struct { 69150362Simp u_long length; 70150362Simp u_long cardaddr; 71150362Simp u_long hostaddr; 72150362Simp } memspace[2]; /* XXX this could be as high as 8 */ 73150362Simp int maxtwins; 74150362Simp STAILQ_ENTRY(pccard_config_entry) cfe_list; 75150362Simp}; 76150362Simp 77150362Simpstruct pccard_funce_disk { 78150362Simp int pfd_interface; 79150362Simp}; 80150362Simp 81150362Simpstruct pccard_funce_lan { 82150362Simp int pfl_nidlen; 83150362Simp uint8_t pfl_nid[8]; 84150362Simp}; 85150362Simp 86150362Simpunion pccard_funce { 87150362Simp struct pccard_funce_disk pfv_disk; 88150362Simp struct pccard_funce_lan pfv_lan; 89150362Simp}; 90150362Simp 91150362Simpstruct pccard_function { 92150362Simp /* read off the card */ 93150362Simp int number; 94150362Simp int function; 95150362Simp int last_config_index; 96150362Simp uint32_t ccr_base; /* Offset with card's memory */ 97150362Simp uint32_t ccr_mask; 98150362Simp struct resource *ccr_res; 99150362Simp int ccr_rid; 100150362Simp STAILQ_HEAD(, pccard_config_entry) cfe_head; 101150362Simp STAILQ_ENTRY(pccard_function) pf_list; 102150362Simp /* run-time state */ 103150362Simp struct pccard_softc *sc; 104150362Simp struct pccard_config_entry *cfe; 105150362Simp struct pccard_mem_handle pf_pcmh; 106150362Simp device_t dev; 107150362Simp#define pf_ccrt pf_pcmh.memt 108150362Simp#define pf_ccrh pf_pcmh.memh 109150362Simp#define pf_ccr_realsize pf_pcmh.realsize 110150362Simp uint32_t pf_ccr_offset; /* Offset from ccr_base of CIS */ 111150362Simp int pf_ccr_window; 112150362Simp bus_addr_t pf_mfc_iobase; 113150362Simp bus_addr_t pf_mfc_iomax; 114150362Simp int pf_flags; 115150362Simp driver_intr_t *intr_handler; 116150362Simp void *intr_handler_arg; 117150362Simp void *intr_handler_cookie; 118150362Simp 119150362Simp union pccard_funce pf_funce; /* CISTPL_FUNCE */ 120150362Simp#define pf_funce_disk_interface pf_funce.pfv_disk.pfd_interface 121150362Simp#define pf_funce_lan_nid pf_funce.pfv_lan.pfl_nid 122150362Simp#define pf_funce_lan_nidlen pf_funce.pfv_lan.pfl_nidlen 123150362Simp}; 124150362Simp 125150362Simp/* pf_flags */ 126150362Simp#define PFF_ENABLED 0x0001 /* function is enabled */ 127150362Simp 128150362Simpstruct pccard_card { 129150362Simp int cis1_major; 130150362Simp int cis1_minor; 131150362Simp /* XXX waste of space? */ 132150362Simp char cis1_info_buf[256]; 133150362Simp char *cis1_info[4]; 134150362Simp /* 135150362Simp * Use int32_t for manufacturer and product so that they can 136150362Simp * hold the id value found in card CIS and special value that 137150362Simp * indicates no id was found. 138150362Simp */ 139150362Simp int32_t manufacturer; 140150362Simp#define PCMCIA_VENDOR_INVALID -1 141150362Simp int32_t product; 142150362Simp#define PCMCIA_PRODUCT_INVALID -1 143150362Simp int16_t prodext; 144150362Simp uint16_t error; 145150362Simp#define PCMCIA_CIS_INVALID { NULL, NULL, NULL, NULL } 146150362Simp STAILQ_HEAD(, pccard_function) pf_head; 147150362Simp}; 148150362Simp 149150362Simp/* More later? */ 150150362Simpstruct pccard_ivar { 151150362Simp struct resource_list resources; 152150362Simp struct pccard_function *pf; 153150362Simp}; 154150362Simp 155150362Simpstruct cis_buffer 156150362Simp{ 157150362Simp size_t len; /* Actual length of the CIS */ 158150362Simp uint8_t buffer[2040]; /* small enough to be 2k */ 159150362Simp}; 160150362Simp 161150362Simpstruct pccard_softc { 162150362Simp device_t dev; 163150362Simp /* this stuff is for the socket */ 164150362Simp 165150362Simp /* this stuff is for the card */ 166150362Simp struct pccard_card card; 167150362Simp int sc_enabled_count; /* num functions enabled */ 168150362Simp struct cdev *cisdev; 169150362Simp int cis_open; 170150362Simp struct cis_buffer *cis; 171150362Simp}; 172150362Simp 173150362Simpstruct pccard_cis_quirk { 174150362Simp int32_t manufacturer; 175150362Simp int32_t product; 176150362Simp char *cis1_info[4]; 177150362Simp struct pccard_function *pf; 178150362Simp struct pccard_config_entry *cfe; 179150362Simp}; 180150362Simp 181150362Simpvoid pccard_read_cis(struct pccard_softc *); 182150362Simpvoid pccard_check_cis_quirks(device_t); 183150362Simpvoid pccard_print_cis(device_t); 184150362Simpint pccard_scan_cis(device_t, device_t, pccard_scan_t, void *); 185150362Simp 186150362Simpint pccard_device_create(struct pccard_softc *); 187150362Simpint pccard_device_destroy(struct pccard_softc *); 188150362Simp 189150362Simp#define PCCARD_SOFTC(d) (struct pccard_softc *) device_get_softc(d) 190150362Simp#define PCCARD_IVAR(d) (struct pccard_ivar *) device_get_ivars(d) 191150362Simp 192150362Simp#endif /* _PCCARD_PCCARDVARP_H */ 193