Annotation of sys/arch/sparc64/dev/fhc_central.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: fhc_central.c,v 1.5 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/centralvar.h>
42: #include <sparc64/dev/fhcreg.h>
43: #include <sparc64/dev/fhcvar.h>
44:
45: int fhc_central_match(struct device *, void *, void *);
46: void fhc_central_attach(struct device *, struct device *, void *);
47:
48: struct cfattach fhc_central_ca = {
49: sizeof(struct fhc_softc), fhc_central_match, fhc_central_attach
50: };
51:
52: int
53: fhc_central_match(parent, match, aux)
54: struct device *parent;
55: void *match, *aux;
56: {
57: struct central_attach_args *ca = aux;
58:
59: if (strcmp(ca->ca_name, "fhc") == 0)
60: return (1);
61: return (0);
62: }
63:
64: void
65: fhc_central_attach(parent, self, aux)
66: struct device *parent, *self;
67: void *aux;
68: {
69: struct fhc_softc *sc = (struct fhc_softc *)self;
70: struct central_attach_args *ca = aux;
71: u_int32_t board;
72:
73: sc->sc_node = ca->ca_node;
74: sc->sc_bt = ca->ca_bustag;
75: sc->sc_is_central = 1;
76:
77: if (central_bus_map(sc->sc_bt, ca->ca_reg[0].cbr_slot,
78: ca->ca_reg[0].cbr_offset, ca->ca_reg[0].cbr_size, 0,
79: &sc->sc_preg)) {
80: printf(": failed to map preg\n");
81: return;
82: }
83:
84: if (central_bus_map(sc->sc_bt, ca->ca_reg[1].cbr_slot,
85: ca->ca_reg[1].cbr_offset, ca->ca_reg[1].cbr_size, 0,
86: &sc->sc_ireg)) {
87: printf(": failed to map ireg\n");
88: return;
89: }
90:
91: if (central_bus_map(sc->sc_bt, ca->ca_reg[2].cbr_slot,
92: ca->ca_reg[2].cbr_offset, ca->ca_reg[2].cbr_size,
93: BUS_SPACE_MAP_LINEAR, &sc->sc_freg)) {
94: printf(": failed to map freg\n");
95: return;
96: }
97:
98: if (central_bus_map(sc->sc_bt, ca->ca_reg[3].cbr_slot,
99: ca->ca_reg[3].cbr_offset, ca->ca_reg[3].cbr_size,
100: BUS_SPACE_MAP_LINEAR, &sc->sc_sreg)) {
101: printf(": failed to map sreg\n");
102: return;
103: }
104:
105: if (central_bus_map(sc->sc_bt, ca->ca_reg[4].cbr_slot,
106: ca->ca_reg[4].cbr_offset, ca->ca_reg[4].cbr_size,
107: BUS_SPACE_MAP_LINEAR, &sc->sc_ureg)) {
108: printf(": failed to map ureg\n");
109: return;
110: }
111:
112: if (central_bus_map(sc->sc_bt, ca->ca_reg[5].cbr_slot,
113: ca->ca_reg[5].cbr_offset, ca->ca_reg[5].cbr_size,
114: BUS_SPACE_MAP_LINEAR, &sc->sc_treg)) {
115: printf(": failed to map treg\n");
116: return;
117: }
118:
119: board = bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_BSR);
120: sc->sc_board = ((board >> 16) & 0x1) | ((board >> 12) & 0xe);
121:
122: fhc_attach(sc);
123: return;
124: }
CVSweb