rsbus.c revision 1.8 1 1.8 matt /* $NetBSD: rsbus.c,v 1.8 2011/06/03 07:35:37 matt Exp $ */
2 1.1 chris
3 1.1 chris /*
4 1.1 chris * Copyright (c) 2002
5 1.1 chris * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
6 1.1 chris * All rights reserved.
7 1.1 chris *
8 1.1 chris * Redistribution and use in source and binary forms, with or without
9 1.1 chris * modification, are permitted provided that the following conditions
10 1.1 chris * are met:
11 1.1 chris * 1. Redistributions of source code must retain the above copyright
12 1.1 chris * notice, this list of conditions and the following disclaimer.
13 1.1 chris * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 chris * notice, this list of conditions and the following disclaimer in the
15 1.1 chris * documentation and/or other materials provided with the distribution.
16 1.1 chris *
17 1.1 chris * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
18 1.1 chris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 1.1 chris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 1.1 chris * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
21 1.1 chris * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1 chris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.1 chris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.1 chris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.1 chris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.1 chris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.1 chris * SUCH DAMAGE.
28 1.1 chris */
29 1.1 chris
30 1.5 hubertf #include <sys/cdefs.h>
31 1.1 chris
32 1.8 matt __KERNEL_RCSID(0, "$NetBSD: rsbus.c,v 1.8 2011/06/03 07:35:37 matt Exp $");
33 1.1 chris
34 1.1 chris #include <sys/param.h>
35 1.1 chris #include <sys/systm.h>
36 1.1 chris #include <sys/device.h>
37 1.1 chris
38 1.1 chris #include <machine/bus.h>
39 1.1 chris
40 1.1 chris #include <acorn32/eb7500atx/rsbus.h>
41 1.1 chris
42 1.1 chris #include "locators.h"
43 1.1 chris
44 1.1 chris extern struct bus_space rsbus_bs_tag;
45 1.1 chris
46 1.1 chris /* Declare prototypes */
47 1.1 chris
48 1.8 matt static int rsbus_match(device_t, cfdata_t, void *);
49 1.8 matt static void rsbus_attach(device_t, device_t, void *);
50 1.1 chris static int rsbus_print(void *, const char *);
51 1.8 matt static int rsbus_search(device_t, cfdata_t,
52 1.3 drochner const int *, void *);
53 1.1 chris
54 1.1 chris CFATTACH_DECL(rsbus, sizeof(struct rsbus_softc),
55 1.1 chris rsbus_match, rsbus_attach, NULL, NULL);
56 1.1 chris
57 1.1 chris static int
58 1.8 matt rsbus_match(device_t parent, cfdata_t cf, void *aux)
59 1.1 chris {
60 1.1 chris return(1);
61 1.1 chris }
62 1.1 chris
63 1.1 chris static void
64 1.8 matt rsbus_attach(device_t parent, device_t self, void *aux)
65 1.1 chris {
66 1.8 matt struct rsbus_softc *sc = device_private(self);
67 1.1 chris sc->sc_iot = &rsbus_bs_tag;
68 1.1 chris
69 1.1 chris printf("\n");
70 1.1 chris
71 1.1 chris /*
72 1.1 chris * Attach each devices
73 1.1 chris */
74 1.2 drochner config_search_ia(rsbus_search, self, "rsbus", NULL);
75 1.1 chris }
76 1.1 chris
77 1.1 chris static int
78 1.8 matt rsbus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
79 1.1 chris {
80 1.8 matt struct rsbus_softc *sc = device_private(parent);
81 1.1 chris struct rsbus_attach_args sa;
82 1.1 chris
83 1.1 chris sa.sa_iot = sc->sc_iot;
84 1.1 chris sa.sa_addr = cf->cf_loc[RSBUSCF_ADDR];
85 1.1 chris sa.sa_size = cf->cf_loc[RSBUSCF_SIZE];
86 1.1 chris sa.sa_intr = cf->cf_loc[RSBUSCF_IRQ];
87 1.1 chris
88 1.1 chris if (config_match(parent, cf, &sa) > 0)
89 1.1 chris config_attach(parent, cf, &sa, rsbus_print);
90 1.1 chris
91 1.1 chris return (0);
92 1.1 chris }
93 1.1 chris
94 1.1 chris static int
95 1.6 dsl rsbus_print(void *aux, const char *name)
96 1.1 chris {
97 1.8 matt struct rsbus_attach_args *sa = aux;
98 1.1 chris
99 1.1 chris if (sa->sa_size)
100 1.1 chris aprint_normal(" addr 0x%lx", sa->sa_addr);
101 1.1 chris if (sa->sa_size > 1)
102 1.1 chris aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
103 1.1 chris if (sa->sa_intr > 1)
104 1.1 chris aprint_normal(" irq %d", sa->sa_intr);
105 1.1 chris
106 1.1 chris return (UNCONF);
107 1.1 chris }
108