kbc.c revision 1.8 1 /* $NetBSD: kbc.c,v 1.8 2004/09/04 11:28:32 tsutsui Exp $ */
2
3 /*-
4 * Copyright (C) 2001 Izumi Tsutsui. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: kbc.c,v 1.8 2004/09/04 11:28:32 tsutsui Exp $");
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/conf.h>
35 #include <sys/device.h>
36 #include <sys/tty.h>
37
38 #include <machine/bus.h>
39 #include <machine/cpu.h>
40
41 #include <dev/cons.h>
42
43 #include <news68k/dev/hbvar.h>
44 #include <news68k/dev/kbcvar.h>
45
46 #include "ioconf.h"
47
48 #define KBC_SIZE 0x10 /* XXX */
49
50 /* Definition of the driver for autoconfig. */
51 static int kbc_match(struct device *, struct cfdata *, void *);
52 static void kbc_attach(struct device *, struct device *, void *);
53 static int kbc_print(void *, const char *name);
54
55 CFATTACH_DECL(kbc, sizeof(struct device),
56 kbc_match, kbc_attach, NULL, NULL);
57
58 static int kbc_match(parent, cf, aux)
59 struct device *parent;
60 struct cfdata *cf;
61 void *aux;
62 {
63 struct hb_attach_args *ha = aux;
64 u_int addr;
65
66 if (strcmp(ha->ha_name, "kbc"))
67 return 0;
68
69 /* XXX no default address */
70 if (ha->ha_address == (u_int)-1)
71 return 0;
72
73 addr = IIOV(ha->ha_address); /* XXX */
74
75 if (badaddr((void *)addr, 1))
76 return 0;
77
78 return 1;
79 }
80
81 static void
82 kbc_attach(parent, self, aux)
83 struct device *parent;
84 struct device *self;
85 void *aux;
86 {
87 struct hb_attach_args *ha = aux;
88 struct kbc_attach_args ka;
89 bus_space_tag_t bt = ha->ha_bust;
90 bus_space_handle_t bh;
91
92 if (bus_space_map(bt, ha->ha_address, KBC_SIZE, 0, &bh) != 0) {
93 printf("can't map device space\n");
94 return;
95 }
96
97 printf("\n");
98
99 ka.ka_bt = bt;
100 ka.ka_bh = bh;
101 ka.ka_ipl = ha->ha_ipl;
102
103 if (ka.ka_ipl == -1)
104 ka.ka_ipl = KBC_PRI;
105
106 ka.ka_name = "kb";
107 config_found(self, (void *)&ka, kbc_print);
108
109 ka.ka_name = "ms";
110 config_found(self, (void *)&ka, kbc_print);
111 }
112
113 static int
114 kbc_print(aux, name)
115 void *aux;
116 const char *name;
117 {
118
119 if (name != NULL)
120 aprint_normal("%s: ", name);
121
122 return UNCONF;
123 }
124