ioasic_subr.c revision 1.9 1 /* $NetBSD: ioasic_subr.c,v 1.9 2005/08/25 18:35:40 drochner Exp $ */
2
3 /*
4 * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Keith Bostic, Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: ioasic_subr.c,v 1.9 2005/08/25 18:35:40 drochner Exp $");
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
37 #include <dev/tc/tcvar.h>
38 #include <dev/tc/ioasicvar.h>
39
40 #include "locators.h"
41
42 int ioasicprint(void *, const char *);
43 int ioasicsubmatch(struct device *, struct cfdata *,
44 const locdesc_t *, void *);
45
46 int
47 ioasicprint(aux, pnp)
48 void *aux;
49 const char *pnp;
50 {
51 struct ioasicdev_attach_args *d = aux;
52
53 if (pnp)
54 aprint_normal("%s at %s", d->iada_modname, pnp);
55 aprint_normal(" offset 0x%x", d->iada_offset);
56 return (UNCONF);
57 }
58
59 int
60 ioasicsubmatch(struct device *parent, struct cfdata *cf,
61 const locdesc_t *locs, void *aux)
62 {
63
64 if ((cf->cf_loc[IOASICCF_OFFSET] != IOASICCF_OFFSET_DEFAULT) &&
65 (cf->cf_loc[IOASICCF_OFFSET] != locs[IOASICCF_OFFSET]))
66 return (0);
67
68 return (config_match(parent, cf, aux));
69 }
70
71 void
72 ioasic_attach_devs(sc, ioasic_devs, ioasic_ndevs)
73 struct ioasic_softc *sc;
74 struct ioasic_dev *ioasic_devs;
75 int ioasic_ndevs;
76 {
77 struct ioasicdev_attach_args idev;
78 int i;
79 int locs[IOASICCF_NLOCS];
80
81 /*
82 * Try to configure each device.
83 */
84 for (i = 0; i < ioasic_ndevs; i++) {
85 strlcpy(idev.iada_modname, ioasic_devs[i].iad_modname,
86 sizeof(idev.iada_modname));
87 idev.iada_offset = ioasic_devs[i].iad_offset;
88 idev.iada_addr = sc->sc_base + ioasic_devs[i].iad_offset;
89 idev.iada_cookie = ioasic_devs[i].iad_cookie;
90
91 /* Tell the autoconfig machinery we've found the hardware. */
92 locs[IOASICCF_OFFSET] = ioasic_devs[i].iad_offset;
93 config_found_sm_loc(&sc->sc_dv, "ioasic", locs, &idev,
94 ioasicprint, ioasicsubmatch);
95 }
96 }
97