1 /* $NetBSD: pcmciachip.h,v 1.4 1999/10/15 06:07:32 haya Exp $ */
2 /* $FreeBSD: src/sys/dev/pccard/pccardchip.h,v 1.6 2000/01/10 06:58:17 imp Exp $ */
3 /* $DragonFly: src/sys/dev/misc/pccard/Attic/pccardchip.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 #ifndef _PCCARD_PCCARDCHIP_H_
35 #define _PCCARD_PCCARDCHIP_H_
38 #include <machine/bus.h>
40 struct pccard_function;
41 struct pccard_mem_handle;
42 struct pccard_io_handle;
44 /* interfaces for pccard to call the chipset */
46 typedef struct pccard_chip_functions *pccard_chipset_tag_t;
47 typedef void *pccard_chipset_handle_t;
49 typedef int pccard_mem_handle_t;
51 #define PCCARD_MEM_ATTR 1
52 #define PCCARD_MEM_COMMON 2
54 #define PCCARD_WIDTH_AUTO 0
55 #define PCCARD_WIDTH_IO8 1
56 #define PCCARD_WIDTH_IO16 2
59 struct pccard_chip_functions {
60 /* memory space allocation */
61 int (*mem_alloc)(pccard_chipset_handle_t, bus_size_t,
62 struct pccard_mem_handle *);
63 void (*mem_free)(pccard_chipset_handle_t,
64 struct pccard_mem_handle *);
66 /* memory space window mapping */
67 int (*mem_map)(pccard_chipset_handle_t, int, bus_addr_t,
68 bus_size_t, struct pccard_mem_handle *,
70 void (*mem_unmap)(pccard_chipset_handle_t, int);
72 /* I/O space allocation */
73 int (*io_alloc) (pccard_chipset_handle_t, bus_addr_t,
74 bus_size_t, bus_size_t, struct pccard_io_handle *);
75 void (*io_free) (pccard_chipset_handle_t,
76 struct pccard_io_handle *);
78 /* I/O space window mapping */
79 int (*io_map) (pccard_chipset_handle_t, int, bus_addr_t,
80 bus_size_t, struct pccard_io_handle *, int *);
81 void (*io_unmap) (pccard_chipset_handle_t, int);
84 void *(*intr_establish) (pccard_chipset_handle_t,
85 struct pccard_function *, int, int (*)(void *), void *);
86 void (*intr_disestablish) (pccard_chipset_handle_t, void *);
88 /* card enable/disable */
89 void (*socket_enable) (pccard_chipset_handle_t);
90 void (*socket_disable) (pccard_chipset_handle_t);
93 int (*card_detect)(pccard_chipset_handle_t);
96 /* Memory space functions. */
97 #define pccard_chip_mem_alloc(tag, handle, size, pcmhp) \
98 ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
100 #define pccard_chip_mem_free(tag, handle, pcmhp) \
101 ((*(tag)->mem_free)((handle), (pcmhp)))
103 #define pccard_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp, \
105 ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
106 (offsetp), (windowp)))
108 #define pccard_chip_mem_unmap(tag, handle, window) \
109 ((*(tag)->mem_unmap)((handle), (window)))
111 /* I/O space functions. */
112 #define pccard_chip_io_alloc(tag, handle, start, size, align, pcihp) \
113 ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
115 #define pccard_chip_io_free(tag, handle, pcihp) \
116 ((*(tag)->io_free)((handle), (pcihp)))
118 #define pccard_chip_io_map(tag, handle, width, card_addr, size, pcihp, \
120 ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
123 #define pccard_chip_io_unmap(tag, handle, window) \
124 ((*(tag)->io_unmap)((handle), (window)))
126 /* Interrupt functions. */
127 #define pccard_chip_intr_establish(tag, handle, pf, ipl, fct, arg) \
128 ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg)))
130 #define pccard_chip_intr_disestablish(tag, handle, ih) \
131 ((*(tag)->intr_disestablish)((handle), (ih)))
133 /* Socket functions. */
134 #define pccard_chip_socket_enable(tag, handle) \
135 ((*(tag)->socket_enable)((handle)))
136 #define pccard_chip_socket_disable(tag, handle) \
137 ((*(tag)->socket_disable)((handle)))
139 struct pccardbus_attach_args {
140 char *paa_busname; /* Bus name */
141 pccard_chipset_tag_t pct;
142 pccard_chipset_handle_t pch;
143 bus_addr_t iobase; /* start i/o space allocation here */
144 bus_size_t iosize; /* size of the i/o space range */
149 #endif /* _PCCARD_PCCARDCHIP_H_ */