1 /* $NetBSD: kbc.c,v 1.11 2008/03/28 18:19:56 tsutsui Exp $ */
4 * Copyright (C) 2001 Izumi Tsutsui. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __KERNEL_RCSID(0, "$NetBSD: kbc.c,v 1.11 2008/03/28 18:19:56 tsutsui Exp $");
30 #include <sys/param.h>
31 #include <sys/systm.h>
33 #include <sys/device.h>
36 #include <machine/bus.h>
37 #include <machine/cpu.h>
41 #include <news68k/dev/hbvar.h>
42 #include <news68k/dev/kbcvar.h>
46 #define KBC_SIZE 0x10 /* XXX */
48 /* Definition of the driver for autoconfig. */
49 static int kbc_match(device_t
, cfdata_t
, void *);
50 static void kbc_attach(device_t
, device_t
, void *);
51 static int kbc_print(void *, const char *name
);
53 CFATTACH_DECL_NEW(kbc
, 0,
54 kbc_match
, kbc_attach
, NULL
, NULL
);
56 static int kbc_match(device_t parent
, cfdata_t cf
, void *aux
)
58 struct hb_attach_args
*ha
= aux
;
61 if (strcmp(ha
->ha_name
, "kbc"))
64 /* XXX no default address */
65 if (ha
->ha_address
== (u_int
)-1)
68 addr
= IIOV(ha
->ha_address
); /* XXX */
70 if (badaddr((void *)addr
, 1))
77 kbc_attach(device_t parent
, device_t self
, void *aux
)
79 struct hb_attach_args
*ha
= aux
;
80 struct kbc_attach_args ka
;
81 bus_space_tag_t bt
= ha
->ha_bust
;
82 bus_space_handle_t bh
;
84 if (bus_space_map(bt
, ha
->ha_address
, KBC_SIZE
, 0, &bh
) != 0) {
85 aprint_error(": can't map device space\n");
93 ka
.ka_ipl
= ha
->ha_ipl
;
99 config_found(self
, (void *)&ka
, kbc_print
);
102 config_found(self
, (void *)&ka
, kbc_print
);
106 kbc_print(void *aux
, const char *name
)
110 aprint_normal("%s: ", name
);