Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / amiga / dev / drsupio.c
blobe84a4f03b9de2e6a4ffc388ed4d22cbeb1df9172
1 /* $NetBSD: drsupio.c,v 1.17 2005/12/11 12:16:28 christos Exp $ */
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: drsupio.c,v 1.17 2005/12/11 12:16:28 christos Exp $");
36 * DraCo multi-io chip bus space stuff
39 #include <sys/types.h>
41 #include <sys/conf.h>
42 #include <sys/device.h>
43 #include <sys/systm.h>
44 #include <sys/param.h>
46 #include <uvm/uvm_extern.h>
48 #include <machine/bus.h>
50 #include <amiga/include/cpu.h>
52 #include <amiga/amiga/device.h>
53 #include <amiga/amiga/drcustom.h>
55 #include <amiga/dev/supio.h>
57 struct drsupio_softc {
58 struct device sc_dev;
59 struct bus_space_tag sc_bst;
62 int drsupiomatch(struct device *, struct cfdata *, void *);
63 void drsupioattach(struct device *, struct device *, void *);
64 int drsupprint(void *auxp, const char *);
65 void drlptintack(void *);
67 CFATTACH_DECL(drsupio, sizeof(struct drsupio_softc),
68 drsupiomatch, drsupioattach, NULL, NULL);
70 int
71 drsupiomatch(struct device *parent, struct cfdata *cfp, void *auxp)
73 static int drsupio_matched = 0;
75 /* Exactly one of us lives on the DraCo */
76 if (!is_draco() || !matchname(auxp, "drsupio") || drsupio_matched)
77 return 0;
79 drsupio_matched = 1;
80 return 1;
83 struct drsupio_devs {
84 const char *name;
85 int off;
86 int arg;
87 } drsupiodevs[] = {
88 { "com", 0x3f8, 115200 * 16 },
89 { "com", 0x2f8, 115200 * 16 },
90 { "lpt", 0x278, (int)drlptintack },
91 { "fdc", 0x3f0, 0 },
92 /* WD port? */
93 { 0 }
96 void
97 drsupioattach(struct device *parent, struct device *self, void *auxp)
99 struct drsupio_softc *drsc;
100 struct drsupio_devs *drsd;
101 struct drioct *ioct;
102 struct supio_attach_args supa;
104 drsc = (struct drsupio_softc *)self;
105 drsd = drsupiodevs;
107 if (parent)
108 printf("\n");
110 drsc->sc_bst.base = DRCCADDR + PAGE_SIZE * DRSUPIOPG + 1;
111 drsc->sc_bst.absm = &amiga_bus_stride_4;
113 supa.supio_iot = &drsc->sc_bst;
114 supa.supio_ipl = 5;
116 while (drsd->name) {
117 supa.supio_name = drsd->name;
118 supa.supio_iobase = drsd->off;
119 supa.supio_arg = drsd->arg;
120 config_found(self, &supa, drsupprint); /* XXX */
121 ++drsd;
124 drlptintack(0);
125 ioct = (struct drioct *)(DRCCADDR + PAGE_SIZE * DRIOCTLPG);
126 ioct->io_status2 |= DRSTAT2_PARIRQENA;
129 void
130 drlptintack(void *p)
132 struct drioct *ioct;
134 (void)p;
135 ioct = (struct drioct *)(DRCCADDR + PAGE_SIZE * DRIOCTLPG);
137 ioct->io_parrst = 0; /* any value works */
141 drsupprint(void *auxp, const char *pnp)
143 struct supio_attach_args *supa;
144 supa = auxp;
146 if (pnp == NULL)
147 return(QUIET);
149 aprint_normal("%s at %s port 0x%02x",
150 supa->supio_name, pnp, supa->supio_iobase);
152 return(UNCONF);