Annotation of sys/arch/sparc64/dev/fhc_mainbus.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: fhc_mainbus.c,v 1.4 2004/09/27 18:32:35 jason Exp $ */
2:
3: /*
4: * Copyright (c) 2004 Jason L. Wright (jason@thought.net).
5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26: * POSSIBILITY OF SUCH DAMAGE.
27: */
28:
29: #include <sys/types.h>
30: #include <sys/param.h>
31: #include <sys/systm.h>
32: #include <sys/kernel.h>
33: #include <sys/device.h>
34: #include <sys/conf.h>
35: #include <sys/timeout.h>
36:
37: #include <machine/bus.h>
38: #include <machine/autoconf.h>
39: #include <machine/openfirm.h>
40:
41: #include <sparc64/dev/fhcvar.h>
42:
43: int fhc_mainbus_match(struct device *, void *, void *);
44: void fhc_mainbus_attach(struct device *, struct device *, void *);
45:
46: struct cfattach fhc_mainbus_ca = {
47: sizeof(struct fhc_softc), fhc_mainbus_match, fhc_mainbus_attach
48: };
49:
50: int
51: fhc_mainbus_match(parent, match, aux)
52: struct device *parent;
53: void *match, *aux;
54: {
55: struct mainbus_attach_args *ma = aux;
56:
57: if (strcmp(ma->ma_name, "fhc") == 0)
58: return (1);
59: return (0);
60: }
61:
62: void
63: fhc_mainbus_attach(parent, self, aux)
64: struct device *parent, *self;
65: void *aux;
66: {
67: struct fhc_softc *sc = (struct fhc_softc *)self;
68: struct mainbus_attach_args *ma = aux;
69:
70: sc->sc_node = ma->ma_node;
71: sc->sc_bt = ma->ma_bustag;
72: sc->sc_is_central = 0;
73:
74: if (bus_space_map(sc->sc_bt, ma->ma_reg[0].ur_paddr,
75: ma->ma_reg[0].ur_len, 0, &sc->sc_preg)) {
76: printf(": failed to map preg\n");
77: return;
78: }
79:
80: if (bus_space_map(sc->sc_bt, ma->ma_reg[1].ur_paddr,
81: ma->ma_reg[1].ur_len, 0, &sc->sc_ireg)) {
82: printf(": failed to map ireg\n");
83: return;
84: }
85:
86: if (bus_space_map(sc->sc_bt, ma->ma_reg[2].ur_paddr,
87: ma->ma_reg[2].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_freg)) {
88: printf(": failed to map freg\n");
89: return;
90: }
91:
92: if (bus_space_map(sc->sc_bt, ma->ma_reg[3].ur_paddr,
93: ma->ma_reg[3].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_sreg)) {
94: printf(": failed to map sreg\n");
95: return;
96: }
97:
98: if (bus_space_map(sc->sc_bt, ma->ma_reg[4].ur_paddr,
99: ma->ma_reg[4].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_ureg)) {
100: printf(": failed to map ureg\n");
101: return;
102: }
103:
104: if (bus_space_map(sc->sc_bt, ma->ma_reg[5].ur_paddr,
105: ma->ma_reg[5].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_treg)) {
106: printf(": failed to map treg\n");
107: return;
108: }
109:
110: sc->sc_board = getpropint(sc->sc_node, "board#", -1);
111:
112: fhc_attach(sc);
113:
114: return;
115: }
CVSweb