Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / amiga / dev / ioblix_zbus.c
blob07ef71629db188aa84296e1f2ebea4205327ed66
1 /* $NetBSD: ioblix_zbus.c,v 1.13 2005/12/11 12:16:28 christos Exp $ */
3 /*-
4 * Copyright (c) 2000 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: ioblix_zbus.c,v 1.13 2005/12/11 12:16:28 christos Exp $");
35 /* IOBlix Zorro driver */
36 /* XXX to be done: we need to probe the com clock speed! */
38 #include <sys/types.h>
40 #include <sys/conf.h>
41 #include <sys/device.h>
42 #include <sys/systm.h>
43 #include <sys/param.h>
45 #include <machine/bus.h>
47 #include <amiga/include/cpu.h>
49 #include <amiga/amiga/device.h>
50 #include <amiga/amiga/drcustom.h>
52 #include <amiga/dev/supio.h>
53 #include <amiga/dev/zbusvar.h>
56 struct iobz_softc {
57 struct device sc_dev;
58 struct bus_space_tag sc_bst;
61 int iobzmatch(struct device *, struct cfdata *, void *);
62 void iobzattach(struct device *, struct device *, void *);
63 int iobzprint(void *auxp, const char *);
64 void iobz_shutdown(void *);
66 CFATTACH_DECL(iobl_zbus, sizeof(struct iobz_softc),
67 iobzmatch, iobzattach, NULL, NULL);
69 int
70 iobzmatch(struct device *parent, struct cfdata *cfp, void *auxp)
73 struct zbus_args *zap;
75 zap = auxp;
77 if (zap->manid != 4711)
78 return (0);
80 if (zap->prodid != 1)
81 return (0);
83 return (1);
86 struct iobz_devs {
87 const char *name;
88 unsigned off;
89 int arg;
90 } iobzdevices[] = {
91 { "com", 0x100, 24000000 }, /* XXX see below */
92 { "com", 0x108, 24000000 },
93 { "com", 0x110, 24000000 },
94 { "com", 0x118, 24000000 },
95 { "lpt", 0x200, 0 },
96 { "lpt", 0x300, 0 },
97 { 0, 0, 0}
100 #ifndef IOBZCLOCK
101 #define IOBZCLOCK 22118400;
102 #endif
103 int iobzclock = IOBZCLOCK; /* patchable! */
105 void
106 iobzattach(struct device *parent, struct device *self, void *auxp)
108 struct iobz_softc *iobzsc;
109 struct iobz_devs *iobzd;
110 struct zbus_args *zap;
111 struct supio_attach_args supa;
112 extern const struct amiga_bus_space_methods amiga_bus_stride_16;
113 volatile u_int8_t *p;
116 iobzsc = (struct iobz_softc *)self;
117 zap = auxp;
119 if (parent)
120 printf("\n");
122 iobzsc->sc_bst.base = (u_long)zap->va;
123 iobzsc->sc_bst.absm = &amiga_bus_stride_16;
125 supa.supio_iot = &iobzsc->sc_bst;
126 supa.supio_ipl = 6;
128 iobzd = iobzdevices;
130 while (iobzd->name) {
131 supa.supio_name = iobzd->name;
132 supa.supio_iobase = iobzd->off;
133 supa.supio_arg = iobzclock /* XXX iobzd->arg */;
134 config_found(self, &supa, iobzprint); /* XXX */
135 ++iobzd;
138 p = (volatile u_int8_t *)zap->va + 2;
139 (void)shutdownhook_establish(iobz_shutdown, __UNVOLATILE(p));
140 *p = ((*p) & 0x1F) | 0x80;
144 iobzprint(void *auxp, const char *pnp)
146 struct supio_attach_args *supa;
147 supa = auxp;
149 if (pnp == NULL)
150 return(QUIET);
152 aprint_normal("%s at %s port 0x%02x",
153 supa->supio_name, pnp, supa->supio_iobase);
155 return(UNCONF);
159 * Disable board interrupts at shutdown time.
162 void
163 iobz_shutdown(void *p) {
164 volatile int8_t *q;
166 q = p;
168 *q &= 0x1F;