kbc.c revision 1.6 1 /* $NetBSD: kbc.c,v 1.6 2003/01/11 16:00:48 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
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/conf.h>
33 #include <sys/device.h>
34 #include <sys/tty.h>
35
36 #include <machine/bus.h>
37 #include <machine/cpu.h>
38
39 #include <dev/cons.h>
40
41 #include <news68k/dev/hbvar.h>
42 #include <news68k/dev/kbcvar.h>
43
44 #define KBC_SIZE 0x10 /* XXX */
45
46 /* Definition of the driver for autoconfig. */
47 static int kbc_match(struct device *, struct cfdata *, void *);
48 static void kbc_attach(struct device *, struct device *, void *);
49 static int kbc_print(void *, const char *name);
50
51 CFATTACH_DECL(kbc, sizeof(struct device),
52 kbc_match, kbc_attach, NULL, NULL);
53
54 extern struct cfdriver kbc_cd;
55
56 static int kbc_match(parent, cf, aux)
57 struct device *parent;
58 struct cfdata *cf;
59 void *aux;
60 {
61 struct hb_attach_args *ha = aux;
62 u_int addr;
63
64 if (strcmp(ha->ha_name, "kbc"))
65 return 0;
66
67 /* XXX no default address */
68 if (ha->ha_address == (u_int)-1)
69 return 0;
70
71 addr = IIOV(ha->ha_address); /* XXX */
72
73 if (badaddr((void *)addr, 1))
74 return 0;
75
76 return 1;
77 }
78
79 static void
80 kbc_attach(parent, self, aux)
81 struct device *parent;
82 struct device *self;
83 void *aux;
84 {
85 struct hb_attach_args *ha = aux;
86 struct kbc_attach_args ka;
87 bus_space_tag_t bt = ha->ha_bust;
88 bus_space_handle_t bh;
89
90 if (bus_space_map(bt, ha->ha_address, KBC_SIZE, 0, &bh) != 0) {
91 printf("can't map device space\n");
92 return;
93 }
94
95 printf("\n");
96
97 ka.ka_bt = bt;
98 ka.ka_bh = bh;
99 ka.ka_ipl = ha->ha_ipl;
100
101 if (ka.ka_ipl == -1)
102 ka.ka_ipl = KBC_PRI;
103
104 ka.ka_name = "kb";
105 config_found(self, (void *)&ka, kbc_print);
106
107 ka.ka_name = "ms";
108 config_found(self, (void *)&ka, kbc_print);
109 }
110
111 static int
112 kbc_print(aux, name)
113 void *aux;
114 const char *name;
115 {
116
117 if (name != NULL)
118 aprint_normal("%s: ", name);
119
120 return UNCONF;
121 }
122