]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/puc/pucvar.h
Synchronize perforce Id tags
[FreeBSD/FreeBSD.git] / sys / dev / puc / pucvar.h
1 /*      $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $   */
2 /*      $FreeBSD$ */
3
4 /*-
5  * Copyright (c) 2002 JF Hay.  All rights reserved.
6  * Copyright (c) 2000 M. Warner Losh.  All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice unmodified, this list of conditions, and the following
13  *    disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 /*
31  * Copyright (c) 1998, 1999 Christopher G. Demetriou.  All rights reserved.
32  *
33  * Redistribution and use in source and binary forms, with or without
34  * modification, are permitted provided that the following conditions
35  * are met:
36  * 1. Redistributions of source code must retain the above copyright
37  *    notice, this list of conditions and the following disclaimer.
38  * 2. Redistributions in binary form must reproduce the above copyright
39  *    notice, this list of conditions and the following disclaimer in the
40  *    documentation and/or other materials provided with the distribution.
41  * 3. All advertising materials mentioning features or use of this software
42  *    must display the following acknowledgement:
43  *      This product includes software developed by Christopher G. Demetriou
44  *      for the NetBSD Project.
45  * 4. The name of the author may not be used to endorse or promote products
46  *    derived from this software without specific prior written permission
47  *
48  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
49  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
50  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
51  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
52  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
53  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
54  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
55  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
57  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58  */
59
60 /*
61  * Exported (or conveniently located) PCI "universal" communications card
62  * software structures.
63  *
64  * Author: Christopher G. Demetriou, May 14, 1998.
65  */
66
67 #define PUC_MAX_PORTS           12
68
69 struct puc_softc;
70 typedef int puc_init_t(struct puc_softc *sc);
71 struct puc_device_description {
72         const char      *name;
73         puc_init_t      *init;
74         uint32_t        rval[4];
75         uint32_t        rmask[4];
76         struct {
77                 int     type;
78                 int     bar;
79                 int     offset;
80                 u_int   serialfreq;
81                 u_int   flags;
82         } ports[PUC_MAX_PORTS];
83 };
84
85 #define PUC_REG_VEND            0
86 #define PUC_REG_PROD            1
87 #define PUC_REG_SVEND           2
88 #define PUC_REG_SPROD           3
89
90 #define PUC_PORT_TYPE_NONE      0
91 #define PUC_PORT_TYPE_COM       1
92 #define PUC_PORT_TYPE_LPT       2
93
94 #define PUC_PORT_VALID(desc, port) \
95   ((port) < PUC_MAX_PORTS && (desc)->ports[(port)].type != PUC_PORT_TYPE_NONE)
96
97 #define PUC_MAX_BAR             6
98
99 enum puc_device_ivars {
100         PUC_IVAR_FREQ
101 };
102
103 #ifdef PUC_ENTRAILS
104 int puc_attach(device_t dev, const struct puc_device_description *desc);
105 extern devclass_t puc_devclass;
106 struct resource *puc_alloc_resource(device_t, device_t, int, int *,
107     u_long, u_long, u_long, u_int);
108 int puc_release_resource(device_t, device_t, int, int, struct resource *);
109 int puc_get_resource(device_t, device_t, int, int, u_long *, u_long *);
110 int puc_read_ivar(device_t, device_t, int, uintptr_t *);
111 int puc_setup_intr(device_t, device_t, struct resource *, int,
112     void (*)(void *), void *, void **);
113 int puc_teardown_intr(device_t, device_t, struct resource *,
114     void *);
115 const struct puc_device_description *puc_find_description(uint32_t,
116     uint32_t, uint32_t, uint32_t);
117
118 struct puc_softc {
119         const struct puc_device_description *sc_desc;
120
121         /* card-global dynamic data */
122         int                     fastintr;
123         int                     barmuxed;
124         int                     irqrid;
125         struct resource         *irqres;
126         void                    *intr_cookie;
127
128         struct {
129                 int             used;
130                 int             bar;
131                 struct resource *res;
132         } sc_bar_mappings[PUC_MAX_BAR];
133
134         /* per-port dynamic data */
135         struct {
136                 struct device   *dev;
137                 /* filled in by bus_setup_intr() */
138                 void            (*ihand)(void *);
139                 void            *ihandarg;
140         } sc_ports[PUC_MAX_PORTS];
141 };
142
143 #endif /* PUC_ENTRAILS */
144
145 int puc_config_win877(struct puc_softc *);
146 extern const struct puc_device_description puc_devices[];