1 /* $NetBSD: rsbus.c,v 1.6 2009/03/14 15:35:58 dsl Exp $ */
5 * Ichiro FUKUHARA <ichiro@ichiro.org>.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``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 ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: rsbus.c,v 1.6 2009/03/14 15:35:58 dsl Exp $");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/device.h>
38 #include <machine/bus.h>
40 #include <acorn32/eb7500atx/rsbus.h>
44 extern struct bus_space rsbus_bs_tag
;
46 /* Declare prototypes */
48 static int rsbus_match(struct device
*, struct cfdata
*, void *);
49 static void rsbus_attach(struct device
*, struct device
*, void *);
50 static int rsbus_print(void *, const char *);
51 static int rsbus_search(struct device
*, struct cfdata
*,
54 CFATTACH_DECL(rsbus
, sizeof(struct rsbus_softc
),
55 rsbus_match
, rsbus_attach
, NULL
, NULL
);
58 rsbus_match(struct device
*parent
, struct cfdata
*cf
, void *aux
)
64 rsbus_attach(struct device
*parent
, struct device
*self
, void *aux
)
66 struct rsbus_softc
*sc
= (void *) self
;
67 sc
->sc_iot
= &rsbus_bs_tag
;
74 config_search_ia(rsbus_search
, self
, "rsbus", NULL
);
78 rsbus_search(struct device
*parent
, struct cfdata
*cf
, const int *ldesc
, void *aux
)
80 struct rsbus_softc
*sc
= (struct rsbus_softc
*)parent
;
81 struct rsbus_attach_args sa
;
83 sa
.sa_iot
= sc
->sc_iot
;
84 sa
.sa_addr
= cf
->cf_loc
[RSBUSCF_ADDR
];
85 sa
.sa_size
= cf
->cf_loc
[RSBUSCF_SIZE
];
86 sa
.sa_intr
= cf
->cf_loc
[RSBUSCF_IRQ
];
88 if (config_match(parent
, cf
, &sa
) > 0)
89 config_attach(parent
, cf
, &sa
, rsbus_print
);
95 rsbus_print(void *aux
, const char *name
)
97 struct rsbus_attach_args
*sa
= (struct rsbus_attach_args
*)aux
;
100 aprint_normal(" addr 0x%lx", sa
->sa_addr
);
102 aprint_normal("-0x%lx", sa
->sa_addr
+ sa
->sa_size
- 1);
104 aprint_normal(" irq %d", sa
->sa_intr
);