rsbus.c revision 1.6 1 1.6 dsl /* $NetBSD: rsbus.c,v 1.6 2009/03/14 15:35:58 dsl 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 * 3. All advertising materials mentioning features or use of this software
17 1.1 chris * must display the following acknowledgement:
18 1.1 chris * This product includes software developed by Ichiro FUKUHARA.
19 1.1 chris * 4. The name of the company nor the name of the author may be used to
20 1.1 chris * endorse or promote products derived from this software without specific
21 1.1 chris * prior written permission.
22 1.1 chris *
23 1.1 chris * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
24 1.1 chris * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1 chris * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1 chris * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
27 1.1 chris * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 chris * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 chris * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 chris * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 chris * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 chris * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 chris * SUCH DAMAGE.
34 1.1 chris */
35 1.1 chris
36 1.5 hubertf #include <sys/cdefs.h>
37 1.1 chris
38 1.6 dsl __KERNEL_RCSID(0, "$NetBSD: rsbus.c,v 1.6 2009/03/14 15:35:58 dsl Exp $");
39 1.1 chris
40 1.1 chris #include <sys/param.h>
41 1.1 chris #include <sys/systm.h>
42 1.1 chris #include <sys/device.h>
43 1.1 chris
44 1.1 chris #include <machine/bus.h>
45 1.1 chris
46 1.1 chris #include <acorn32/eb7500atx/rsbus.h>
47 1.1 chris
48 1.1 chris #include "locators.h"
49 1.1 chris
50 1.1 chris extern struct bus_space rsbus_bs_tag;
51 1.1 chris
52 1.1 chris /* Declare prototypes */
53 1.1 chris
54 1.1 chris static int rsbus_match(struct device *, struct cfdata *, void *);
55 1.1 chris static void rsbus_attach(struct device *, struct device *, void *);
56 1.1 chris static int rsbus_print(void *, const char *);
57 1.2 drochner static int rsbus_search(struct device *, struct cfdata *,
58 1.3 drochner const int *, void *);
59 1.1 chris
60 1.1 chris CFATTACH_DECL(rsbus, sizeof(struct rsbus_softc),
61 1.1 chris rsbus_match, rsbus_attach, NULL, NULL);
62 1.1 chris
63 1.1 chris static int
64 1.6 dsl rsbus_match(struct device *parent, struct cfdata *cf, void *aux)
65 1.1 chris {
66 1.1 chris return(1);
67 1.1 chris }
68 1.1 chris
69 1.1 chris static void
70 1.1 chris rsbus_attach(struct device *parent, struct device *self, void *aux)
71 1.1 chris {
72 1.1 chris struct rsbus_softc *sc = (void *) self;
73 1.1 chris sc->sc_iot = &rsbus_bs_tag;
74 1.1 chris
75 1.1 chris printf("\n");
76 1.1 chris
77 1.1 chris /*
78 1.1 chris * Attach each devices
79 1.1 chris */
80 1.2 drochner config_search_ia(rsbus_search, self, "rsbus", NULL);
81 1.1 chris }
82 1.1 chris
83 1.1 chris static int
84 1.6 dsl rsbus_search(struct device *parent, struct cfdata *cf, const int *ldesc, void *aux)
85 1.1 chris {
86 1.1 chris struct rsbus_softc *sc = (struct rsbus_softc *)parent;
87 1.1 chris struct rsbus_attach_args sa;
88 1.1 chris
89 1.1 chris sa.sa_iot = sc->sc_iot;
90 1.1 chris sa.sa_addr = cf->cf_loc[RSBUSCF_ADDR];
91 1.1 chris sa.sa_size = cf->cf_loc[RSBUSCF_SIZE];
92 1.1 chris sa.sa_intr = cf->cf_loc[RSBUSCF_IRQ];
93 1.1 chris
94 1.1 chris if (config_match(parent, cf, &sa) > 0)
95 1.1 chris config_attach(parent, cf, &sa, rsbus_print);
96 1.1 chris
97 1.1 chris return (0);
98 1.1 chris }
99 1.1 chris
100 1.1 chris static int
101 1.6 dsl rsbus_print(void *aux, const char *name)
102 1.1 chris {
103 1.1 chris struct rsbus_attach_args *sa = (struct rsbus_attach_args*)aux;
104 1.1 chris
105 1.1 chris if (sa->sa_size)
106 1.1 chris aprint_normal(" addr 0x%lx", sa->sa_addr);
107 1.1 chris if (sa->sa_size > 1)
108 1.1 chris aprint_normal("-0x%lx", sa->sa_addr + sa->sa_size - 1);
109 1.1 chris if (sa->sa_intr > 1)
110 1.1 chris aprint_normal(" irq %d", sa->sa_intr);
111 1.1 chris
112 1.1 chris return (UNCONF);
113 1.1 chris }
114 1.1 chris
115