1 /* $NetBSD: i82365var.h,v 1.8 1999/10/15 06:07:27 haya Exp $ */
2 /* $FreeBSD: src/sys/dev/pcic/i82365var.h,v 1.15.2.1 2000/05/23 03:57:02 imp Exp $ */
3 /* $DragonFly: src/sys/dev/misc/pcic/Attic/i82365var.h,v 1.2 2003/06/17 04:28:29 dillon Exp $ */
6 * Copyright (c) 1997 Marc Horowitz. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Marc Horowitz.
19 * 4. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <dev/pccard/pccardreg.h>
36 #include <dev/pcic/i82365reg.h>
41 STAILQ_ENTRY(pcic_event) pe_q;
46 #define PCIC_EVENT_INSERTION 0
47 #define PCIC_EVENT_REMOVAL 1
50 struct pcic_softc *sc;
52 bus_space_tag_t ph_bus_t; /* I/O or MEM? I don't mind */
53 bus_space_handle_t ph_bus_h;
54 u_int8_t (* ph_read)(struct pcic_handle*, int);
55 void (* ph_write)(struct pcic_handle *, int, u_int8_t);
62 struct pccard_mem_handle mem[PCIC_MEM_WINS]; /* XXX BAD XXX */
64 struct pccard_io_handle io[PCIC_IO_WINS]; /* XXX BAD XXX */
68 struct proc *event_thread;
69 STAILQ_HEAD(, pcic_event) events;
72 #define PCIC_FLAG_SOCKETP 0x0001
73 #define PCIC_FLAG_CARDP 0x0002
75 #define PCIC_LASTSTATE_PRESENT 0x0002
76 #define PCIC_LASTSTATE_HALF 0x0001
77 #define PCIC_LASTSTATE_EMPTY 0x0000
79 #define C0SA PCIC_CHIP0_BASE+PCIC_SOCKETA_INDEX
80 #define C0SB PCIC_CHIP0_BASE+PCIC_SOCKETB_INDEX
81 #define C1SA PCIC_CHIP1_BASE+PCIC_SOCKETA_INDEX
82 #define C1SB PCIC_CHIP1_BASE+PCIC_SOCKETB_INDEX
85 * This is sort of arbitrary. It merely needs to be "enough". It can be
86 * overridden in the conf file, anyway.
89 #define PCIC_MEM_PAGES 4
90 #define PCIC_MEMSIZE PCIC_MEM_PAGES*PCIC_MEM_PAGESIZE
98 bus_space_handle_t memh;
100 bus_space_handle_t ioh;
103 struct resource *irq_res;
105 struct resource *mem_res;
107 struct resource *port_res;
110 #define PCIC_MAX_MEM_PAGES (8 * sizeof(int))
112 /* used by memory window mapping functions */
116 * used by io window mapping functions. These can actually overlap
117 * with another pcic, since the underlying extent mapper will deal
118 * with individual allocations. This is here to deal with the fact
119 * that different busses have different real widths (different pc
120 * hardware seems to use 10 or 12 bits for the I/O bus).
128 struct pcic_handle handle[PCIC_NSLOTS];
132 int pcic_ident_ok(int);
133 int pcic_vendor(struct pcic_handle *);
134 char *pcic_vendor_to_string(int);
136 int pcic_attach(device_t dev);
140 static __inline int pcic_read(struct pcic_handle *, int);
143 struct pcic_handle *h;
147 bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX,
149 return (bus_space_read_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA));
152 static __inline void pcic_write(struct pcic_handle *, int, int);
154 pcic_write(h, idx, data)
155 struct pcic_handle *h;
160 bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_INDEX,
162 bus_space_write_1(h->sc->iot, h->sc->ioh, PCIC_REG_DATA, (data));
165 #define pcic_read(h, idx) \
166 (*(h)->ph_read)((h), (idx))
168 #define pcic_write(h, idx, data) \
169 (*(h)->ph_write)((h), (idx), (data))
174 * bus/device/etc routines
176 int pcic_activate_resource(device_t dev, device_t child, int type, int rid,
178 struct resource *pcic_alloc_resource(device_t dev, device_t child, int type,
179 int *rid, u_long start, u_long end, u_long count, u_int flags);
180 int pcic_deactivate_resource(device_t dev, device_t child, int type, int rid,
182 int pcic_release_resource(device_t dev, device_t child, int type, int rid,
184 int pcic_setup_intr(device_t dev, device_t child, struct resource *irq,
185 int flags, driver_intr_t intr, void *arg, void **cookiep);
186 int pcic_teardown_intr(device_t dev, device_t child, struct resource *irq,
188 int pcic_suspend(device_t dev);
189 int pcic_resume(device_t dev);
190 int pcic_enable_socket(device_t dev, device_t child);
191 int pcic_disable_socket(device_t dev, device_t child);
192 int pcic_set_res_flags(device_t dev, device_t child, int type, int rid,
194 int pcic_set_memory_offset(device_t dev, device_t child, int rid,