1 /* $NetBSD: xbox.c,v 1.19 2009/05/12 14:43:59 cegger Exp $ */
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: xbox.c,v 1.19 2009/05/12 14:43:59 cegger Exp $");
39 #include <sys/param.h>
40 #include <sys/malloc.h>
41 #include <sys/systm.h>
42 #include <sys/device.h>
45 #include <dev/sbus/sbusvar.h>
46 #include <dev/sbus/xboxvar.h>
47 #include <machine/autoconf.h>
50 * Xbox registers definitions.
52 * The xbox device can operate in two mode: "opaque" and "transparent".
53 * In opaque mode, all accesses to the xbox address space are directed
54 * to the xbox itself. In transparent mode, all accesses are mapped to
55 * the SBus cards in the expansion box.
57 * To access the xbox registers in transparent mode, you must write
58 * to the "write0" register. The layout of this register appears to
61 * bit 31-24: xbox key (identifies device when you cascade them)
62 * bit 23-12: offset of register to access
63 * bit 11-0: value to write
65 * For instance, to switch to opaque mode:
66 * (*sc->write0_reg) = (sc->sc_key << 24) | XAC_CTL1_OFFSET;
68 * (note we're not currently using any of this)
70 #define WRITE0_OFFSET 0
72 #define XAC_ERR_OFFSET 0x2000
73 #define XAC_CTL0_OFFSET 0x10000
74 #define XAC_CTL1_OFFSET 0x11000
75 #define XAC_ELUA_OFFSET 0x12000
76 #define XAC_ELLA_OFFSET 0x13000
77 #define XAC_ELE_OFFSET 0x14000
79 #define XBC_ERR_OFFSET 0x42000
80 #define XBC_CTL0_OFFSET 0x50000
81 #define XBC_CTL1_OFFSET 0x51000
82 #define XBC_ELUA_OFFSET 0x52000
83 #define XBC_ELLA_OFFSET 0x53000
84 #define XBC_ELE_OFFSET 0x54000
89 struct device sc_dev
; /* base device */
90 int sc_key
; /* this xbox's unique key */
93 /* autoconfiguration driver */
94 int xbox_match(device_t
, cfdata_t
, void *);
95 void xbox_attach(device_t
, device_t
, void *);
96 int xbox_print( void *, const char *);
98 CFATTACH_DECL(xbox
, sizeof(struct xbox_softc
),
99 xbox_match
, xbox_attach
, NULL
, NULL
);
102 xbox_print(void *args
, const char *busname
)
104 struct xbox_attach_args
*xa
= args
;
107 aprint_normal("%s at %s", xa
->xa_name
, busname
);
112 xbox_match(device_t parent
, cfdata_t cf
, void *aux
)
114 struct sbus_attach_args
*sa
= aux
;
116 return (strcmp("SUNW,xbox", sa
->sa_name
) == 0);
123 xbox_attach(device_t parent
, device_t self
, void *aux
)
125 struct xbox_softc
*sc
= device_private(self
);
126 struct sbus_attach_args
*sa
= aux
;
127 int node
= sa
->sa_node
;
128 struct xbox_attach_args xa
;
131 sc
->sc_key
= prom_getpropint(node
, "write0-key", -1);
133 cp
= prom_getpropstring(node
, "model");
134 printf(": model %s", cp
);
136 cp
= prom_getpropstring(node
, "child-present");
137 if (strcmp(cp
, "true") != 0) {
138 printf(": no sbus devices\n");
145 * Now pretend to be another Sbus.
147 memset(&xa
, 0, sizeof xa
);
150 xa
.xa_bustag
= sa
->sa_bustag
;
151 xa
.xa_dmatag
= sa
->sa_dmatag
;
153 (void) config_found(self
, (void *)&xa
, xbox_print
);