1 /* $OpenBSD: pucvar.h,v 1.5 2006/07/31 11:06:33 mickey Exp $ */
2 /* $NetBSD: pucvar.h,v 1.2 1999/02/06 06:29:54 cgd Exp $ */
3
4 /*
5 * Copyright (c) 1998, 1999 Christopher G. Demetriou. 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 Christopher G. Demetriou
18 * for the NetBSD Project.
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
21 *
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.
32 */
33
34 /*
35 * Exported (or conveniently located) PCI "universal" communications card
36 * software structures.
37 *
38 * Author: Christopher G. Demetriou, May 14, 1998.
39 */
40
41 #define PUC_MAX_PORTS 8
42
43 struct puc_device_description {
44 u_long rval[4];
45 u_long rmask[4];
46 struct {
47 u_char type;
48 u_char bar;
49 u_short offset;
50 int flags;
51 } ports[PUC_MAX_PORTS];
52 };
53
54 #define PUC_REG_VEND 0
55 #define PUC_REG_PROD 1
56 #define PUC_REG_SVEND 2
57 #define PUC_REG_SPROD 3
58
59 #define PUC_PORT_TYPE_NONE 0
60 #define PUC_PORT_TYPE_COM 1
61 #define PUC_PORT_TYPE_LPT 2
62
63 #define PUC_PORT_VALID(desc, port) \
64 ((port) < PUC_MAX_PORTS && (desc)->ports[(port)].type != PUC_PORT_TYPE_NONE)
65 #define PUC_PORT_BAR_INDEX(bar) (((bar) - PCI_MAPREG_START) / 4)
66
67 /* Flags for PUC_PORT_TYPE_COM */
68 /* * assume all clock rates have 8 lower bits to 0 - this leaves us 8 flags */
69 #define PUC_COM_CLOCKMASK 0xffffff00
70
71 struct puc_attach_args {
72 int port;
73 int type;
74 int hwtype;
75 void *puc;
76
77 bus_addr_t a;
78 bus_space_tag_t t;
79 bus_space_handle_t h;
80 int flags;
81
82 const char *(*intr_string)(struct puc_attach_args *);
83 void *(*intr_establish)(struct puc_attach_args *, int, int (*)(void *),
84 void *, char *);
85 };
86
87 extern const struct puc_device_description puc_devices[];
88
89 #define PUC_NBARS 6
90 struct puc_softc {
91 struct device sc_dev;
92
93 /* static configuration data */
94 const struct puc_device_description *sc_desc;
95
96 /* card-global dynamic data */
97 struct {
98 int mapped;
99 u_long type;
100 bus_addr_t a;
101 bus_size_t s;
102 bus_space_tag_t t;
103 bus_space_handle_t h;
104 } sc_bar_mappings[PUC_NBARS];
105
106 /* per-port dynamic data */
107 struct {
108 struct device *dev;
109 /* filled in by port attachments */
110 int (*ihand)(void *);
111 void *ihandarg;
112 } sc_ports[PUC_MAX_PORTS];
113 };
114
115 const struct puc_device_description *
116 puc_find_description(u_long, u_long, u_long, u_long);
117 void puc_print_ports(const struct puc_device_description *);
118 void puc_common_attach(struct puc_softc *, struct puc_attach_args *);
119 int puc_print(void *, const char *);
120 int puc_submatch(struct device *, void *, void *);