FreeBSD/Linux Kernel Cross Reference
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, 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 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * 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 16
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 uint32_t rval[4];
74 uint32_t rmask[4];
75 struct {
76 int type;
77 int bar;
78 int offset;
79 u_int serialfreq;
80 u_int flags;
81 int regshft;
82 } ports[PUC_MAX_PORTS];
83 uint32_t ilr_type;
84 uint32_t ilr_offset[2];
85 puc_init_t *init;
86 };
87
88 #define PUC_REG_VEND 0
89 #define PUC_REG_PROD 1
90 #define PUC_REG_SVEND 2
91 #define PUC_REG_SPROD 3
92
93 #define PUC_PORT_TYPE_NONE 0
94 #define PUC_PORT_TYPE_COM 1
95 #define PUC_PORT_TYPE_LPT 2
96 #define PUC_PORT_TYPE_UART 3
97
98 /* UART subtypes. */
99 #define PUC_PORT_SUBTYPE_MASK (~0xff)
100 #define PUC_PORT_UART_NS8250 (0<<8)
101 #define PUC_PORT_UART_SAB82532 (1<<8)
102 #define PUC_PORT_UART_Z8530 (2<<8)
103
104 /* Interrupt Latch Register (ILR) types */
105 #define PUC_ILR_TYPE_NONE 0
106 #define PUC_ILR_TYPE_DIGI 1
107
108 #define PUC_FLAGS_MEMORY 0x0001 /* Use memory mapped I/O. */
109 #define PUC_FLAGS_ALTRES 0x0002 /* Use alternate I/O type. */
110
111 #define PUC_PORT_VALID(desc, port) \
112 ((port) < PUC_MAX_PORTS && (desc).ports[(port)].type != PUC_PORT_TYPE_NONE)
113
114 #define PUC_MAX_BAR 6
115
116 enum puc_device_ivars {
117 PUC_IVAR_FREQ,
118 PUC_IVAR_SUBTYPE,
119 PUC_IVAR_REGSHFT,
120 PUC_IVAR_PORT
121 };
122
123 #ifdef PUC_ENTRAILS
124 int puc_attach(device_t dev, const struct puc_device_description *desc);
125 extern devclass_t puc_devclass;
126 struct resource *puc_alloc_resource(device_t, device_t, int, int *,
127 u_long, u_long, u_long, u_int);
128 int puc_release_resource(device_t, device_t, int, int, struct resource *);
129 int puc_get_resource(device_t, device_t, int, int, u_long *, u_long *);
130 int puc_read_ivar(device_t, device_t, int, uintptr_t *);
131 int puc_setup_intr(device_t, device_t, struct resource *, int,
132 void (*)(void *), void *, void **);
133 int puc_teardown_intr(device_t, device_t, struct resource *,
134 void *);
135
136 struct puc_softc {
137 struct puc_device_description sc_desc;
138
139 /* card-global dynamic data */
140 int fastintr;
141 int barmuxed;
142 int irqrid;
143 struct resource *irqres;
144 void *intr_cookie;
145 int ilr_enabled;
146 bus_space_tag_t ilr_st;
147 bus_space_handle_t ilr_sh;
148
149 struct {
150 int used;
151 int bar;
152 int type; /* SYS_RES_IOPORT or SYS_RES_MEMORY. */
153 struct resource *res;
154 } sc_bar_mappings[PUC_MAX_BAR];
155
156 /* per-port dynamic data */
157 struct {
158 struct device *dev;
159 /* filled in by bus_setup_intr() */
160 void (*ihand)(void *);
161 void *ihandarg;
162 } sc_ports[PUC_MAX_PORTS];
163 };
164
165 #endif /* PUC_ENTRAILS */
Cache object: 12e74e8cba677e5a4aeb4e4f7cdc61af
|