Sync usage with man page.
[netbsd-mini2440.git] / sys / arch / acorn26 / iobus / iobus.c
blob11622982624f01c43521a8f3ba937e5df4dc889b
1 /* $NetBSD: iobus.c,v 1.14 2006/09/30 16:30:10 bjh21 Exp $ */
2 /*-
3 * Copyright (c) 1998 Ben Harris
4 * 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.
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.
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 OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * iobus.c - when the IORQ* calls...
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: iobus.c,v 1.14 2006/09/30 16:30:10 bjh21 Exp $");
35 #include <sys/param.h>
36 #include <sys/device.h>
37 #include <sys/systm.h>
39 #include <machine/bus.h>
40 #include <machine/memcreg.h>
42 #include <arch/acorn26/iobus/iobusvar.h>
44 #include "locators.h"
46 static int iobus_match(device_t parent, cfdata_t cf, void *aux);
47 static void iobus_attach(device_t parent, device_t self, void *aux);
48 static int iobus_search_ioc(device_t parent, cfdata_t cf,
49 const int *ldesc, void *aux);
50 static int iobus_search(device_t parent, cfdata_t cf,
51 const int *ldesc, void *aux);
52 static int iobus_print(void *aux, const char *pnp);
54 CFATTACH_DECL_NEW(iobus, 0, iobus_match, iobus_attach, NULL, NULL);
56 device_t the_iobus;
58 static int
59 iobus_match(device_t parent, cfdata_t cf, void *aux)
62 /* There can be only one! */
63 if (the_iobus == NULL)
64 return 1;
65 return 0;
68 static void
69 iobus_attach(device_t parent, device_t self, void *aux)
72 the_iobus = self;
73 aprint_normal("\n");
76 * Always look for the IOC first, since stuff under there determines
77 * what else is present.
79 config_search_ia(iobus_search_ioc, self, "iobus", NULL);
80 config_search_ia(iobus_search, self, "iobus", NULL);
83 extern struct bus_space iobus_bs_tag;
85 static int
86 iobus_search_ioc(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
88 struct iobus_attach_args ioa;
90 ioa.ioa_tag = &iobus_bs_tag;
91 ioa.ioa_base = (bus_addr_t)MEMC_IO_BASE + cf->cf_loc[IOBUSCF_BASE];
92 if (strcmp(cf->cf_name, "ioc") == 0 &&
93 config_match(parent, cf, &ioa) > 0)
94 config_attach(parent, cf, &ioa, iobus_print);
96 return 0;
99 static int
100 iobus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
102 struct iobus_attach_args ioa;
104 ioa.ioa_tag = &iobus_bs_tag;
105 ioa.ioa_base = (bus_addr_t)MEMC_IO_BASE + cf->cf_loc[IOBUSCF_BASE];
106 if (config_match(parent, cf, &ioa) > 0)
107 config_attach(parent, cf, &ioa, iobus_print);
109 return 0;
112 static int
113 iobus_print(void *aux, const char *pnp)
115 struct iobus_attach_args *ioa = aux;
117 if (ioa->ioa_base != IOBUSCF_BASE_DEFAULT)
118 aprint_normal(" base 0x%06lx",
119 ioa->ioa_base - (bus_addr_t)MEMC_IO_BASE);
120 return UNCONF;