ioplanar.c revision 1.2 1 1.1 garbled /*-
2 1.1 garbled * Copyright (c) 2007 The NetBSD Foundation, Inc.
3 1.1 garbled * All rights reserved.
4 1.1 garbled *
5 1.1 garbled * This code is derived from software contributed to The NetBSD Foundation
6 1.1 garbled * by Tim Rightnour
7 1.1 garbled *
8 1.1 garbled * Redistribution and use in source and binary forms, with or without
9 1.1 garbled * modification, are permitted provided that the following conditions
10 1.1 garbled * are met:
11 1.1 garbled * 1. Redistributions of source code must retain the above copyright
12 1.1 garbled * notice, this list of conditions and the following disclaimer.
13 1.1 garbled * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 garbled * notice, this list of conditions and the following disclaimer in the
15 1.1 garbled * documentation and/or other materials provided with the distribution.
16 1.1 garbled *
17 1.1 garbled * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18 1.1 garbled * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 1.1 garbled * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 1.1 garbled * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21 1.1 garbled * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 1.1 garbled * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 1.1 garbled * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 1.1 garbled * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 1.1 garbled * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 1.1 garbled * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 1.1 garbled * POSSIBILITY OF SUCH DAMAGE.
28 1.1 garbled */
29 1.1 garbled
30 1.1 garbled #include <sys/cdefs.h>
31 1.2 martin __KERNEL_RCSID(0, "$NetBSD: ioplanar.c,v 1.2 2008/04/28 20:23:34 martin Exp $");
32 1.1 garbled
33 1.1 garbled #include <sys/param.h>
34 1.1 garbled #include <sys/device.h>
35 1.1 garbled
36 1.1 garbled #include <machine/intr.h>
37 1.1 garbled #include <machine/bus.h>
38 1.1 garbled
39 1.1 garbled #include <dev/mca/mcavar.h>
40 1.1 garbled #include <dev/mca/mcadevs.h>
41 1.1 garbled
42 1.1 garbled #include <rs6000/ioplanar/ioplanarvar.h>
43 1.1 garbled
44 1.1 garbled static int ioplanar_match(struct device *, struct cfdata *, void *);
45 1.1 garbled static void ioplanar_attach(struct device *, struct device *, void *);
46 1.1 garbled static int ioplanar_print(void *, const char *);
47 1.1 garbled static int ioplanar_search(struct device *, struct cfdata *,
48 1.1 garbled const int *, void *);
49 1.1 garbled
50 1.1 garbled CFATTACH_DECL(ioplanar, sizeof(struct ioplanar_softc),
51 1.1 garbled ioplanar_match, ioplanar_attach, NULL, NULL);
52 1.1 garbled
53 1.1 garbled struct ioplanar_softc *ioplanar_softc;
54 1.1 garbled extern struct cfdriver ioplanar_cd;
55 1.1 garbled
56 1.1 garbled #define RAINBOW_DEVS 7
57 1.1 garbled int rainbow_map[RAINBOW_DEVS] =
58 1.1 garbled { IOP_COM0, IOP_COM1, IOP_LPD, IOP_KBD_2,
59 1.1 garbled IOP_TABLET_2, IOP_MOUSE, IOP_FDC_2 };
60 1.1 garbled
61 1.1 garbled static int
62 1.1 garbled ioplanar_match(struct device *parent, struct cfdata *cf, void *aux)
63 1.1 garbled {
64 1.1 garbled struct mca_attach_args *ma = aux;
65 1.1 garbled
66 1.1 garbled switch (ma->ma_id) {
67 1.1 garbled case MCA_PRODUCT_IBM_SIO_RAINBOW:
68 1.1 garbled return 1;
69 1.1 garbled }
70 1.1 garbled
71 1.1 garbled return 0;
72 1.1 garbled }
73 1.1 garbled
74 1.1 garbled static void
75 1.1 garbled ioplanar_attach(struct device *parent, struct device *self, void *aux)
76 1.1 garbled {
77 1.1 garbled struct ioplanar_softc *sc = (struct ioplanar_softc *)self;
78 1.1 garbled struct mca_attach_args *ma = aux;
79 1.1 garbled
80 1.1 garbled printf("\n");
81 1.1 garbled
82 1.1 garbled ioplanar_softc = sc;
83 1.1 garbled sc->sc_ic = ma->ma_mc;
84 1.1 garbled sc->sc_iot = ma->ma_iot;
85 1.1 garbled sc->sc_memt = ma->ma_memt;
86 1.1 garbled sc->sc_dmat = ma->ma_dmat;
87 1.1 garbled sc->sc_devid = ma->ma_id;
88 1.1 garbled
89 1.1 garbled (void)config_search_ia(ioplanar_search, self, "ioplanar", aux);
90 1.1 garbled }
91 1.1 garbled
92 1.1 garbled static int
93 1.1 garbled ioplanar_search(struct device *parent, struct cfdata *cf,
94 1.1 garbled const int *ldesc, void *aux)
95 1.1 garbled {
96 1.1 garbled struct ioplanar_dev_attach_args idaa;
97 1.1 garbled struct mca_attach_args *ma = aux;
98 1.1 garbled int i;
99 1.1 garbled
100 1.1 garbled idaa.idaa_mc = ma->ma_mc;
101 1.1 garbled idaa.idaa_iot = ma->ma_iot;
102 1.1 garbled idaa.idaa_memt = ma->ma_memt;
103 1.1 garbled idaa.idaa_dmat = ma->ma_dmat;
104 1.1 garbled idaa.idaa_devid = ma->ma_id;
105 1.1 garbled
106 1.1 garbled switch (ma->ma_id) {
107 1.1 garbled case MCA_PRODUCT_IBM_SIO_RAINBOW:
108 1.1 garbled for (i=0; i < RAINBOW_DEVS; i++) {
109 1.1 garbled idaa.idaa_device = rainbow_map[i];
110 1.1 garbled if (config_match(parent, cf, &idaa) > 0)
111 1.1 garbled config_attach(parent, cf, &idaa,
112 1.1 garbled ioplanar_print);
113 1.1 garbled }
114 1.1 garbled break;
115 1.1 garbled default:
116 1.1 garbled return 0;
117 1.1 garbled }
118 1.1 garbled return 0;
119 1.1 garbled }
120 1.1 garbled
121 1.1 garbled static int
122 1.1 garbled ioplanar_print(void *args, const char *name)
123 1.1 garbled {
124 1.1 garbled /*struct ioplanar_dev_attach_args *idaa = args;*/
125 1.1 garbled
126 1.1 garbled aprint_normal(": ");
127 1.1 garbled return (UNCONF);
128 1.1 garbled }
129