Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / news68k / dev / kbc.c
blob14fc69d18678a327cca0e5d909b07ab13062ddc5
1 /* $NetBSD: kbc.c,v 1.11 2008/03/28 18:19:56 tsutsui Exp $ */
3 /*-
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
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.
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>
32 #include <sys/conf.h>
33 #include <sys/device.h>
34 #include <sys/tty.h>
36 #include <machine/bus.h>
37 #include <machine/cpu.h>
39 #include <dev/cons.h>
41 #include <news68k/dev/hbvar.h>
42 #include <news68k/dev/kbcvar.h>
44 #include "ioconf.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;
59 u_int addr;
61 if (strcmp(ha->ha_name, "kbc"))
62 return 0;
64 /* XXX no default address */
65 if (ha->ha_address == (u_int)-1)
66 return 0;
68 addr = IIOV(ha->ha_address); /* XXX */
70 if (badaddr((void *)addr, 1))
71 return 0;
73 return 1;
76 static void
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");
86 return;
89 aprint_normal("\n");
91 ka.ka_bt = bt;
92 ka.ka_bh = bh;
93 ka.ka_ipl = ha->ha_ipl;
95 if (ka.ka_ipl == -1)
96 ka.ka_ipl = KBC_PRI;
98 ka.ka_name = "kb";
99 config_found(self, (void *)&ka, kbc_print);
101 ka.ka_name = "ms";
102 config_found(self, (void *)&ka, kbc_print);
105 static int
106 kbc_print(void *aux, const char *name)
109 if (name != NULL)
110 aprint_normal("%s: ", name);
112 return UNCONF;