Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / acorn26 / iobus / upc_iobus.c
blob3282c96a449e3123949612d53045c50aee9dce5b
1 /* $NetBSD: upc_iobus.c,v 1.8 2005/12/11 12:16:04 christos Exp $ */
2 /*-
3 * Copyright (c) 2000 Ben Harris
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * upc_iobus.c - attachment of the 82C7xx to the Archimedes I/O bus
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: upc_iobus.c,v 1.8 2005/12/11 12:16:04 christos Exp $");
35 #include <sys/param.h>
36 #include <sys/device.h>
38 #include <arch/acorn26/iobus/iobusvar.h>
40 #include <arch/acorn26/iobus/iocreg.h>
41 #include <machine/irq.h>
43 #include <dev/ic/upcreg.h>
44 #include <dev/ic/upcvar.h>
46 #include "ioeb.h"
48 #if NIOEB > 0
49 #include <arch/acorn26/ioc/ioebvar.h>
50 #endif
52 static int upc_iobus_match(device_t , cfdata_t , void *);
53 static void upc_iobus_attach(device_t , device_t , void *);
55 struct upc_iobus_softc {
56 struct upc_softc sc_upc;
57 struct evcnt sc_intrcnt4;
58 struct evcnt sc_intrcntw;
59 struct evcnt sc_intrcntf;
60 struct evcnt sc_intrcntp;
63 CFATTACH_DECL(upc_iobus, sizeof(struct upc_iobus_softc),
64 upc_iobus_match, upc_iobus_attach, NULL, NULL);
66 static device_t the_upc_iobus;
68 static int
69 upc_iobus_match(device_t parent, cfdata_t cf, void *aux)
73 * As is traditional, probing for iobus devices is impossible
74 * (The machine hangs if there's nothing there). In this case,
75 * assume that if there's an IOEB, we've got a UPC too.
77 #if NIOEB > 0
78 if (the_ioeb != NULL && the_upc_iobus == NULL)
79 return 1;
80 #endif
81 return 0;
84 static void
85 upc_iobus_attach(device_t parent, device_t self, void *aux)
87 struct iobus_attach_args *ioa = aux;
88 struct upc_iobus_softc *sc = device_private(self);
89 struct upc_softc *upc = &sc->sc_upc;
91 upc->sc_iot = ioa->ioa_tag;
92 bus_space_map(ioa->ioa_tag, ioa->ioa_base, UPC_BUS_SIZE, 0,
93 &upc->sc_ioh);
94 upc_attach(upc);
96 if (upc->sc_irq4.uih_func != NULL) {
97 evcnt_attach_dynamic(&sc->sc_intrcnt4, EVCNT_TYPE_INTR, NULL,
98 device_xname(self), "irq4");
99 irq_establish(IOC_IRQ_IL2, upc->sc_irq4.uih_level,
100 upc->sc_irq4.uih_func, upc->sc_irq4.uih_arg,
101 &sc->sc_intrcnt4);
103 if (upc->sc_wintr.uih_func != NULL) {
104 evcnt_attach_dynamic(&sc->sc_intrcntw, EVCNT_TYPE_INTR, NULL,
105 device_xname(self), "wdc intr");
106 irq_establish(IOC_IRQ_IL3, upc->sc_wintr.uih_level,
107 upc->sc_wintr.uih_func, upc->sc_wintr.uih_arg,
108 &sc->sc_intrcntw);
110 if (upc->sc_fintr.uih_func != NULL) {
111 evcnt_attach_dynamic(&sc->sc_intrcntf, EVCNT_TYPE_INTR, NULL,
112 device_xname(self), "fdc intr");
113 irq_establish(IOC_IRQ_IL4, upc->sc_fintr.uih_level,
114 upc->sc_fintr.uih_func, upc->sc_fintr.uih_arg,
115 &sc->sc_intrcntf);
117 if (upc->sc_pintr.uih_func != NULL) {
118 evcnt_attach_dynamic(&sc->sc_intrcntp, EVCNT_TYPE_INTR, NULL,
119 device_xname(self), "lpt intr");
120 irq_establish(IOC_IRQ_IL6, upc->sc_pintr.uih_level,
121 upc->sc_pintr.uih_func, upc->sc_pintr.uih_arg,
122 &sc->sc_intrcntp);
124 /* IRQ3 on the 82C71x is not connected */