ioplanar.c revision 1.3 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.3 matt __KERNEL_RCSID(0, "$NetBSD: ioplanar.c,v 1.3 2011/06/18 08:08:30 matt 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.3 matt static int ioplanar_match(device_t, cfdata_t, void *);
45 1.3 matt static void ioplanar_attach(device_t, device_t, void *);
46 1.1 garbled static int ioplanar_print(void *, const char *);
47 1.3 matt static int ioplanar_search(device_t, cfdata_t, const int *, void *);
48 1.1 garbled
49 1.3 matt CFATTACH_DECL_NEW(ioplanar, sizeof(struct ioplanar_softc),
50 1.1 garbled ioplanar_match, ioplanar_attach, NULL, NULL);
51 1.1 garbled
52 1.1 garbled struct ioplanar_softc *ioplanar_softc;
53 1.1 garbled extern struct cfdriver ioplanar_cd;
54 1.1 garbled
55 1.1 garbled #define RAINBOW_DEVS 7
56 1.1 garbled int rainbow_map[RAINBOW_DEVS] =
57 1.1 garbled { IOP_COM0, IOP_COM1, IOP_LPD, IOP_KBD_2,
58 1.1 garbled IOP_TABLET_2, IOP_MOUSE, IOP_FDC_2 };
59 1.1 garbled
60 1.1 garbled static int
61 1.3 matt ioplanar_match(device_t parent, cfdata_t cf, void *aux)
62 1.1 garbled {
63 1.1 garbled struct mca_attach_args *ma = aux;
64 1.1 garbled
65 1.1 garbled switch (ma->ma_id) {
66 1.1 garbled case MCA_PRODUCT_IBM_SIO_RAINBOW:
67 1.1 garbled return 1;
68 1.1 garbled }
69 1.1 garbled
70 1.1 garbled return 0;
71 1.1 garbled }
72 1.1 garbled
73 1.1 garbled static void
74 1.3 matt ioplanar_attach(device_t parent, device_t self, void *aux)
75 1.1 garbled {
76 1.3 matt struct ioplanar_softc *sc = device_private(self);
77 1.1 garbled struct mca_attach_args *ma = aux;
78 1.1 garbled
79 1.3 matt aprint_normal("\n");
80 1.1 garbled
81 1.1 garbled ioplanar_softc = sc;
82 1.3 matt sc->sc_dev = self;
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.3 matt ioplanar_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
94 1.1 garbled {
95 1.1 garbled struct ioplanar_dev_attach_args idaa;
96 1.1 garbled struct mca_attach_args *ma = aux;
97 1.1 garbled int i;
98 1.1 garbled
99 1.1 garbled idaa.idaa_mc = ma->ma_mc;
100 1.1 garbled idaa.idaa_iot = ma->ma_iot;
101 1.1 garbled idaa.idaa_memt = ma->ma_memt;
102 1.1 garbled idaa.idaa_dmat = ma->ma_dmat;
103 1.1 garbled idaa.idaa_devid = ma->ma_id;
104 1.1 garbled
105 1.1 garbled switch (ma->ma_id) {
106 1.1 garbled case MCA_PRODUCT_IBM_SIO_RAINBOW:
107 1.1 garbled for (i=0; i < RAINBOW_DEVS; i++) {
108 1.1 garbled idaa.idaa_device = rainbow_map[i];
109 1.1 garbled if (config_match(parent, cf, &idaa) > 0)
110 1.1 garbled config_attach(parent, cf, &idaa,
111 1.1 garbled ioplanar_print);
112 1.1 garbled }
113 1.1 garbled break;
114 1.1 garbled default:
115 1.1 garbled return 0;
116 1.1 garbled }
117 1.1 garbled return 0;
118 1.1 garbled }
119 1.1 garbled
120 1.1 garbled static int
121 1.1 garbled ioplanar_print(void *args, const char *name)
122 1.1 garbled {
123 1.1 garbled /*struct ioplanar_dev_attach_args *idaa = args;*/
124 1.1 garbled
125 1.1 garbled aprint_normal(": ");
126 1.1 garbled return (UNCONF);
127 1.1 garbled }
128