Initial import from FreeBSD RELENG_4:
[dragonfly.git] / sys / dev / misc / pccard / pccardchip.h
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
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
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *      This product includes software developed by Marc Horowitz.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
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
33 #ifndef _PCCARD_PCCARDCHIP_H_
34 #define _PCCARD_PCCARDCHIP_H_
35
36 #if 0
37 #include <machine/bus.h>
38
39 struct pccard_function;
40 struct pccard_mem_handle;
41 struct pccard_io_handle;
42
43 /* interfaces for pccard to call the chipset */
44
45 typedef struct pccard_chip_functions *pccard_chipset_tag_t;
46 typedef void *pccard_chipset_handle_t;
47 #endif
48 typedef int pccard_mem_handle_t;
49
50 #define PCCARD_MEM_ATTR         1
51 #define PCCARD_MEM_COMMON       2
52
53 #define PCCARD_WIDTH_AUTO       0
54 #define PCCARD_WIDTH_IO8        1
55 #define PCCARD_WIDTH_IO16       2
56
57 #if 0
58 struct pccard_chip_functions {
59         /* memory space allocation */
60         int     (*mem_alloc)(pccard_chipset_handle_t, bus_size_t,
61                     struct pccard_mem_handle *);
62         void    (*mem_free)(pccard_chipset_handle_t,
63                     struct pccard_mem_handle *);
64
65         /* memory space window mapping */
66         int     (*mem_map)(pccard_chipset_handle_t, int, bus_addr_t,
67                     bus_size_t, struct pccard_mem_handle *,
68                     bus_addr_t *, int *);
69         void    (*mem_unmap)(pccard_chipset_handle_t, int);
70
71         /* I/O space allocation */
72         int     (*io_alloc) (pccard_chipset_handle_t, bus_addr_t,
73                     bus_size_t, bus_size_t, struct pccard_io_handle *);
74         void    (*io_free) (pccard_chipset_handle_t,
75                     struct pccard_io_handle *);
76
77         /* I/O space window mapping */
78         int     (*io_map) (pccard_chipset_handle_t, int, bus_addr_t,
79                     bus_size_t, struct pccard_io_handle *, int *);
80         void    (*io_unmap) (pccard_chipset_handle_t, int);
81
82         /* interrupt glue */
83         void    *(*intr_establish) (pccard_chipset_handle_t,
84                     struct pccard_function *, int, int (*)(void *), void *);
85         void    (*intr_disestablish) (pccard_chipset_handle_t, void *);
86
87         /* card enable/disable */
88         void    (*socket_enable) (pccard_chipset_handle_t);
89         void    (*socket_disable) (pccard_chipset_handle_t);
90
91         /* card detection */
92         int (*card_detect)(pccard_chipset_handle_t);  
93 };
94
95 /* Memory space functions. */
96 #define pccard_chip_mem_alloc(tag, handle, size, pcmhp)                 \
97         ((*(tag)->mem_alloc)((handle), (size), (pcmhp)))
98
99 #define pccard_chip_mem_free(tag, handle, pcmhp)                        \
100         ((*(tag)->mem_free)((handle), (pcmhp)))
101
102 #define pccard_chip_mem_map(tag, handle, kind, card_addr, size, pcmhp,  \
103             offsetp, windowp)                                           \
104         ((*(tag)->mem_map)((handle), (kind), (card_addr), (size), (pcmhp), \
105             (offsetp), (windowp)))
106
107 #define pccard_chip_mem_unmap(tag, handle, window)                      \
108         ((*(tag)->mem_unmap)((handle), (window)))
109
110 /* I/O space functions. */
111 #define pccard_chip_io_alloc(tag, handle, start, size, align, pcihp)    \
112         ((*(tag)->io_alloc)((handle), (start), (size), (align), (pcihp)))
113
114 #define pccard_chip_io_free(tag, handle, pcihp)                         \
115         ((*(tag)->io_free)((handle), (pcihp)))
116
117 #define pccard_chip_io_map(tag, handle, width, card_addr, size, pcihp,  \
118             windowp) \
119         ((*(tag)->io_map)((handle), (width), (card_addr), (size), (pcihp), \
120             (windowp)))
121
122 #define pccard_chip_io_unmap(tag, handle, window)                       \
123         ((*(tag)->io_unmap)((handle), (window)))
124
125 /* Interrupt functions. */
126 #define pccard_chip_intr_establish(tag, handle, pf, ipl, fct, arg)      \
127         ((*(tag)->intr_establish)((handle), (pf), (ipl), (fct), (arg)))
128
129 #define pccard_chip_intr_disestablish(tag, handle, ih)                  \
130         ((*(tag)->intr_disestablish)((handle), (ih)))
131
132 /* Socket functions. */
133 #define pccard_chip_socket_enable(tag, handle)                          \
134         ((*(tag)->socket_enable)((handle)))
135 #define pccard_chip_socket_disable(tag, handle)                         \
136         ((*(tag)->socket_disable)((handle)))
137
138 struct pccardbus_attach_args {
139         char *paa_busname;      /* Bus name */
140         pccard_chipset_tag_t pct;
141         pccard_chipset_handle_t pch;
142         bus_addr_t iobase;              /* start i/o space allocation here */
143         bus_size_t iosize;              /* size of the i/o space range */
144 };
145
146 #endif /* 0 */
147
148 #endif /* _PCCARD_PCCARDCHIP_H_ */