Fri Jul 29 08:37:37 2011 UTC ()
port the openbsd central and fhc drivers, and the clock/zs attachments.
doesn't quite work yet, crashes when central_attach() calls
config_attach() (faulting address is 0xf8000000.)
(mrg)
diff -r1.141 -r1.142 src/sys/arch/sparc64/conf/GENERIC
diff -r1.133 -r1.134 src/sys/arch/sparc64/conf/files.sparc64
diff -r0 -r1.1 src/sys/arch/sparc64/dev/central.c
diff -r0 -r1.1 src/sys/arch/sparc64/dev/centralvar.h
diff -r0 -r1.1 src/sys/arch/sparc64/dev/fhc.c
diff -r0 -r1.1 src/sys/arch/sparc64/dev/fhc_central.c
diff -r0 -r1.1 src/sys/arch/sparc64/dev/fhc_mainbus.c
diff -r0 -r1.1 src/sys/arch/sparc64/dev/fhcreg.h
diff -r0 -r1.1 src/sys/arch/sparc64/dev/fhcvar.h
diff -r1.8 -r1.9 src/sys/arch/sparc64/dev/mkclock.c
diff -r1.89 -r1.90 src/sys/arch/sparc64/dev/sbus.c
diff -r1.70 -r1.71 src/sys/arch/sparc64/dev/zs.c
--- src/sys/arch/sparc64/conf/GENERIC 2011/07/23 21:12:58 1.141
+++ src/sys/arch/sparc64/conf/GENERIC 2011/07/29 08:37:37 1.142
| @@ -1,38 +1,38 @@ | | | @@ -1,38 +1,38 @@ |
1 | # $NetBSD: GENERIC,v 1.141 2011/07/23 21:12:58 jakllsch Exp $ | | 1 | # $NetBSD: GENERIC,v 1.142 2011/07/29 08:37:37 mrg Exp $ |
2 | # | | 2 | # |
3 | # GENERIC machine description file | | 3 | # GENERIC machine description file |
4 | # | | 4 | # |
5 | # This machine description file is used to generate the default NetBSD | | 5 | # This machine description file is used to generate the default NetBSD |
6 | # kernel. The generic kernel does not include all options, subsystems | | 6 | # kernel. The generic kernel does not include all options, subsystems |
7 | # and device drivers, but should be useful for most applications. | | 7 | # and device drivers, but should be useful for most applications. |
8 | # | | 8 | # |
9 | # The machine description file can be customised for your specific | | 9 | # The machine description file can be customised for your specific |
10 | # machine to reduce the kernel size and improve its performance. | | 10 | # machine to reduce the kernel size and improve its performance. |
11 | # | | 11 | # |
12 | # For further information on compiling NetBSD kernels, see the config(8) | | 12 | # For further information on compiling NetBSD kernels, see the config(8) |
13 | # man page. | | 13 | # man page. |
14 | # | | 14 | # |
15 | # For further information on hardware support for this architecture, see | | 15 | # For further information on hardware support for this architecture, see |
16 | # the intro(4) man page. For further information about kernel options | | 16 | # the intro(4) man page. For further information about kernel options |
17 | # for this architecture, see the options(4) man page. For an explanation | | 17 | # for this architecture, see the options(4) man page. For an explanation |
18 | # of each device driver in this file see the section 4 man page for the | | 18 | # of each device driver in this file see the section 4 man page for the |
19 | # device. | | 19 | # device. |
20 | | | 20 | |
21 | include "arch/sparc64/conf/std.sparc64" | | 21 | include "arch/sparc64/conf/std.sparc64" |
22 | | | 22 | |
23 | options INCLUDE_CONFIG_FILE # embed config file in kernel binary | | 23 | options INCLUDE_CONFIG_FILE # embed config file in kernel binary |
24 | | | 24 | |
25 | #ident "GENERIC-$Revision: 1.141 $" | | 25 | #ident "GENERIC-$Revision: 1.142 $" |
26 | | | 26 | |
27 | maxusers 64 | | 27 | maxusers 64 |
28 | | | 28 | |
29 | ## System kernel configuration. See options(4) for more detail. | | 29 | ## System kernel configuration. See options(4) for more detail. |
30 | | | 30 | |
31 | | | 31 | |
32 | # Options for variants of the Sun SPARC architecure. | | 32 | # Options for variants of the Sun SPARC architecure. |
33 | options SUN4U # sun4u - UltraSPARC | | 33 | options SUN4U # sun4u - UltraSPARC |
34 | #options BLINK # blink the system LED | | 34 | #options BLINK # blink the system LED |
35 | | | 35 | |
36 | #### System options that are the same for all ports | | 36 | #### System options that are the same for all ports |
37 | | | 37 | |
38 | ## Root device configuration: change the ?'s if you are going to use a | | 38 | ## Root device configuration: change the ?'s if you are going to use a |
| @@ -230,66 +230,71 @@ options PPP_FILTER # Add active filters | | | @@ -230,66 +230,71 @@ options PPP_FILTER # Add active filters |
230 | | | 230 | |
231 | | | 231 | |
232 | #### Main bus and CPUs .. all systems. | | 232 | #### Main bus and CPUs .. all systems. |
233 | mainbus0 at root | | 233 | mainbus0 at root |
234 | options MULTIPROCESSOR # include multiprocessor support | | 234 | options MULTIPROCESSOR # include multiprocessor support |
235 | cpu* at mainbus0 # declare additional CPUs | | 235 | cpu* at mainbus0 # declare additional CPUs |
236 | | | 236 | |
237 | #### Bus types found on SPARC systems. | | 237 | #### Bus types found on SPARC systems. |
238 | | | 238 | |
239 | sbus* at mainbus0 # SBus-based systems | | 239 | sbus* at mainbus0 # SBus-based systems |
240 | psycho* at mainbus0 # PCI-based systems | | 240 | psycho* at mainbus0 # PCI-based systems |
241 | schizo* at mainbus? | | 241 | schizo* at mainbus? |
242 | pyro* at mainbus? | | 242 | pyro* at mainbus? |
| | | 243 | central* at mainbus? |
| | | 244 | fhc* at mainbus? |
243 | pci* at psycho? | | 245 | pci* at psycho? |
244 | pci* at schizo? | | 246 | pci* at schizo? |
245 | pci* at pyro? | | 247 | pci* at pyro? |
246 | pci* at ppb? | | 248 | pci* at ppb? |
247 | ppb* at pci? # `APB' support. | | 249 | ppb* at pci? |
| | | 250 | fhc* at central? |
248 | ebus* at mainbus0 # ebus devices | | 251 | ebus* at mainbus0 # ebus devices |
249 | ebus* at pci? # ebus devices | | 252 | ebus* at pci? # ebus devices |
250 | # XXX 'puc's aren't really bridges, but there's no better place for them here | | 253 | # XXX 'puc's aren't really bridges, but there's no better place for them here |
251 | puc* at pci? dev ? function ? # PCI "universal" comm. cards | | 254 | puc* at pci? dev ? function ? # PCI "universal" comm. cards |
252 | | | 255 | |
253 | #### Standard system devices -- all required for a given architecture | | 256 | #### Standard system devices -- all required for a given architecture |
254 | | | 257 | |
255 | ## PROM console driver -- if all else fails | | 258 | ## PROM console driver -- if all else fails |
256 | pcons0 at mainbus0 # PROM console | | 259 | pcons0 at mainbus0 # PROM console |
257 | | | 260 | |
258 | ## Auxiliary system registers -- We use the OBP for power management | | 261 | ## Auxiliary system registers -- We use the OBP for power management |
259 | auxio* at ebus? # auxio registers | | 262 | auxio* at ebus? # auxio registers |
260 | auxio* at sbus? slot ? offset ? # auxio registers | | 263 | auxio* at sbus? slot ? offset ? # auxio registers |
261 | | | 264 | |
262 | # We also need: | | 265 | # We also need: |
263 | bpp* at sbus? slot ? offset ? # parallel port | | 266 | bpp* at sbus? slot ? offset ? # parallel port |
264 | lpt* at ebus? # parallel port | | 267 | lpt* at ebus? # parallel port |
265 | | | 268 | |
266 | ## Mostek clock found on sbus on Ultra-1,2 systems | | 269 | ## Mostek clock found on sbus on Ultra-1,2 systems |
267 | ## and found on ebus on Ultra-5 and other systems. | | 270 | ## and found on ebus on Ultra-5 and other systems. |
268 | clock* at sbus? slot ? offset ? | | 271 | clock* at sbus? slot ? offset ? |
| | | 272 | clock* at fhc? |
269 | clock* at ebus? | | 273 | clock* at ebus? |
270 | | | 274 | |
271 | ## DS1287 compatible clock found on ebus on Netra X1 and other systems. | | 275 | ## DS1287 compatible clock found on ebus on Netra X1 and other systems. |
272 | rtc* at ebus? | | 276 | rtc* at ebus? |
273 | | | 277 | |
274 | ## Timer chip found on 4/300, sun4c, sun4m and (some) sun4u systems. | | 278 | ## Timer chip found on 4/300, sun4c, sun4m and (some) sun4u systems. |
275 | timer* at mainbus0 # sun4c | | 279 | timer* at mainbus0 # sun4c |
276 | | | 280 | |
277 | #### Serial port configuration | | 281 | #### Serial port configuration |
278 | | | 282 | |
279 | ## Zilog 8530 serial chips. Each has two-channels. | | 283 | ## Zilog 8530 serial chips. Each has two-channels. |
280 | ## zs0 is ttya and ttyb. zs1 is the keyboard and mouse. | | 284 | ## zs0 is ttya and ttyb. zs1 is the keyboard and mouse. |
281 | zs* at sbus? slot ? offset ? | | 285 | zs* at sbus? slot ? offset ? |
282 | zstty* at zs? channel ? # ttya | | 286 | zs* at fhc? |
| | | 287 | zstty* at zs? channel ? # ttys |
283 | kbd0 at zstty? | | 288 | kbd0 at zstty? |
284 | ms0 at zstty? | | 289 | ms0 at zstty? |
285 | | | 290 | |
286 | ## PCI machines have serial ports: | | 291 | ## PCI machines have serial ports: |
287 | ## Siemens SAB82532 controller: ttya and ttyb (`su'; sab) | | 292 | ## Siemens SAB82532 controller: ttya and ttyb (`su'; sab) |
288 | ## Part of NS PC87332VLJ Super I/O controller: kbd/mouse (`se'; com) | | 293 | ## Part of NS PC87332VLJ Super I/O controller: kbd/mouse (`se'; com) |
289 | | | 294 | |
290 | ## The SAB82532 controller has two serial ports | | 295 | ## The SAB82532 controller has two serial ports |
291 | sab* at ebus? # ttya/ttyb | | 296 | sab* at ebus? # ttya/ttyb |
292 | sabtty* at sab? channel ? | | 297 | sabtty* at sab? channel ? |
293 | | | 298 | |
294 | ## Part of a PC87332VLJ | | 299 | ## Part of a PC87332VLJ |
295 | com* at ebus? # `com' driver for `su' | | 300 | com* at ebus? # `com' driver for `su' |
--- src/sys/arch/sparc64/conf/files.sparc64 2011/06/12 03:35:47 1.133
+++ src/sys/arch/sparc64/conf/files.sparc64 2011/07/29 08:37:37 1.134
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: files.sparc64,v 1.133 2011/06/12 03:35:47 rmind Exp $ | | 1 | # $NetBSD: files.sparc64,v 1.134 2011/07/29 08:37:37 mrg Exp $ |
2 | | | 2 | |
3 | # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 | | 3 | # @(#)files.sparc64 8.1 (Berkeley) 7/19/93 |
4 | # sparc64-specific configuration info | | 4 | # sparc64-specific configuration info |
5 | | | 5 | |
6 | # maxpartitions must be first item in files.${ARCH} | | 6 | # maxpartitions must be first item in files.${ARCH} |
7 | maxpartitions 8 | | 7 | maxpartitions 8 |
8 | | | 8 | |
9 | maxusers 2 8 1024 | | 9 | maxusers 2 8 1024 |
10 | | | 10 | |
11 | defflag opt_sparc_arch.h SUN4U | | 11 | defflag opt_sparc_arch.h SUN4U |
12 | | | 12 | |
13 | define mainbus {} | | 13 | define mainbus {} |
14 | device mainbus: mainbus | | 14 | device mainbus: mainbus |
| @@ -32,40 +32,54 @@ file arch/sparc64/dev/sbus.c sbus | | | @@ -32,40 +32,54 @@ file arch/sparc64/dev/sbus.c sbus |
32 | | | 32 | |
33 | device psycho: pcibus, sysmon_power, sysmon_taskq | | 33 | device psycho: pcibus, sysmon_power, sysmon_taskq |
34 | attach psycho at mainbus | | 34 | attach psycho at mainbus |
35 | device schizo: pcibus, sysmon_power, sysmon_taskq | | 35 | device schizo: pcibus, sysmon_power, sysmon_taskq |
36 | attach schizo at mainbus | | 36 | attach schizo at mainbus |
37 | device pyro: pcibus, sysmon_power, sysmon_taskq | | 37 | device pyro: pcibus, sysmon_power, sysmon_taskq |
38 | attach pyro at mainbus | | 38 | attach pyro at mainbus |
39 | include "dev/pci/files.pci" | | 39 | include "dev/pci/files.pci" |
40 | file arch/sparc64/dev/psycho.c psycho | | 40 | file arch/sparc64/dev/psycho.c psycho |
41 | file arch/sparc64/dev/schizo.c schizo | | 41 | file arch/sparc64/dev/schizo.c schizo |
42 | file arch/sparc64/dev/pyro.c pyro | | 42 | file arch/sparc64/dev/pyro.c pyro |
43 | file arch/sparc64/dev/pci_machdep.c psycho | schizo | pyro | | 43 | file arch/sparc64/dev/pci_machdep.c psycho | schizo | pyro |
44 | | | 44 | |
| | | 45 | define central {} |
| | | 46 | device central: central |
| | | 47 | attach central at mainbus |
| | | 48 | file arch/sparc64/dev/central.c central |
| | | 49 | |
| | | 50 | define fhc {} |
| | | 51 | device fhc: fhc |
| | | 52 | attach fhc at mainbus with fhc_mainbus |
| | | 53 | attach fhc at central with fhc_central |
| | | 54 | file arch/sparc64/dev/fhc.c fhc |
| | | 55 | file arch/sparc64/dev/fhc_central.c fhc_central |
| | | 56 | file arch/sparc64/dev/fhc_mainbus.c fhc_mainbus |
| | | 57 | |
45 | # IOMMU is for both | | 58 | # IOMMU is for both |
46 | file arch/sparc64/dev/iommu.c sbus | psycho | schizo | pyro | | 59 | file arch/sparc64/dev/iommu.c sbus | psycho | schizo | pyro |
47 | | | 60 | |
48 | include "dev/ata/files.ata" | | 61 | include "dev/ata/files.ata" |
49 | | | 62 | |
50 | device ebus {[addr = -1]}: pcibus | | 63 | device ebus {[addr = -1]}: pcibus |
51 | attach ebus at pci | | 64 | attach ebus at pci |
52 | file arch/sparc64/dev/ebus.c ebus | | 65 | file arch/sparc64/dev/ebus.c ebus |
53 | attach ebus at mainbus with ebus_mainbus | | 66 | attach ebus at mainbus with ebus_mainbus |
54 | file arch/sparc64/dev/ebus_mainbus.c ebus_mainbus | | 67 | file arch/sparc64/dev/ebus_mainbus.c ebus_mainbus |
55 | | | 68 | |
56 | device clock: mk48txx | | 69 | device clock: mk48txx |
57 | attach clock at sbus with mkclock_sbus | | 70 | attach clock at sbus with mkclock_sbus |
58 | attach clock at ebus with mkclock_ebus | | 71 | attach clock at ebus with mkclock_ebus |
| | | 72 | attach clock at fhc with mkclock_fhc |
59 | file arch/sparc64/dev/mkclock.c clock | | 73 | file arch/sparc64/dev/mkclock.c clock |
60 | | | 74 | |
61 | device rtc: mc146818 | | 75 | device rtc: mc146818 |
62 | attach rtc at ebus with rtc_ebus | | 76 | attach rtc at ebus with rtc_ebus |
63 | file arch/sparc64/dev/rtc.c rtc | | 77 | file arch/sparc64/dev/rtc.c rtc |
64 | | | 78 | |
65 | device psm: sysmon_envsys, sysmon_power | | 79 | device psm: sysmon_envsys, sysmon_power |
66 | attach psm at ebus | | 80 | attach psm at ebus |
67 | file arch/sparc64/dev/psm.c psm | | 81 | file arch/sparc64/dev/psm.c psm |
68 | | | 82 | |
69 | device timer | | 83 | device timer |
70 | attach timer at mainbus, sbus | | 84 | attach timer at mainbus, sbus |
71 | | | 85 | |
| @@ -115,27 +129,27 @@ file dev/ebus/cs4231_ebus.c audiocs_eb | | | @@ -115,27 +129,27 @@ file dev/ebus/cs4231_ebus.c audiocs_eb |
115 | | | 129 | |
116 | # PCMCIA bus (references fdc) | | 130 | # PCMCIA bus (references fdc) |
117 | include "dev/pcmcia/files.pcmcia" | | 131 | include "dev/pcmcia/files.pcmcia" |
118 | | | 132 | |
119 | # CardBus Support | | 133 | # CardBus Support |
120 | include "dev/cardbus/files.cardbus" | | 134 | include "dev/cardbus/files.cardbus" |
121 | file arch/sparc64/sparc64/rbus_machdep.c cardbus | | 135 | file arch/sparc64/sparc64/rbus_machdep.c cardbus |
122 | | | 136 | |
123 | # | | 137 | # |
124 | # Console related stuff | | 138 | # Console related stuff |
125 | # | | 139 | # |
126 | | | 140 | |
127 | device zs {channel = -1} | | 141 | device zs {channel = -1} |
128 | attach zs at sbus | | 142 | attach zs at sbus, fhc |
129 | file arch/sparc64/dev/zs.c zs needs-flag | | 143 | file arch/sparc64/dev/zs.c zs needs-flag |
130 | file dev/ic/z8530sc.c zs | | 144 | file dev/ic/z8530sc.c zs |
131 | | | 145 | |
132 | # siemens SAB82532; found on U5/U10/... for tty ports. | | 146 | # siemens SAB82532; found on U5/U10/... for tty ports. |
133 | device sab {channel = -1} | | 147 | device sab {channel = -1} |
134 | attach sab at ebus | | 148 | attach sab at ebus |
135 | file arch/sparc64/dev/sab.c sab | sabtty needs-flag | | 149 | file arch/sparc64/dev/sab.c sab | sabtty needs-flag |
136 | | | 150 | |
137 | # "com" attachments for the kbd/mouse of the U5/U10/... | | 151 | # "com" attachments for the kbd/mouse of the U5/U10/... |
138 | attach com at ebus with com_ebus | | 152 | attach com at ebus with com_ebus |
139 | file arch/sparc64/dev/com_ebus.c com_ebus | | 153 | file arch/sparc64/dev/com_ebus.c com_ebus |
140 | | | 154 | |
141 | device zstty {}: tty | | 155 | device zstty {}: tty |
/* $NetBSD: central.c,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: central.c,v 1.7 2010/11/11 17:58:23 miod Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <sparc64/dev/centralvar.h>
struct central_softc {
bus_space_tag_t sc_bt;
bus_space_tag_t sc_cbt;
int sc_node;
int sc_nrange;
struct central_range *sc_range;
};
static int central_match(device_t, cfdata_t, void *);
static void central_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(central, sizeof(struct central_softc),
central_match, central_attach, NULL, NULL);
static int central_print(void *, const char *);
static int central_get_string(int, const char *, char **);
static bus_space_tag_t central_alloc_bus_tag(struct central_softc *);
static int _central_bus_map(
bus_space_tag_t,
bus_addr_t, /*offset*/
bus_size_t, /*size*/
int, /*flags*/
vaddr_t, /* XXX unused -- compat w/sparc */
bus_space_handle_t *);
static int
central_match(device_t parent, cfdata_t match, void *aux)
{
struct mainbus_attach_args *ma = aux;
if (strcmp(ma->ma_name, "central") == 0)
return (1);
return (0);
}
static void
central_attach(device_t parent, device_t self, void *aux)
{
struct central_softc *sc = (struct central_softc *)self;
struct mainbus_attach_args *ma = aux;
int node0, node;
sc->sc_bt = ma->ma_bustag;
sc->sc_node = ma->ma_node;
sc->sc_cbt = central_alloc_bus_tag(sc);
prom_getprop(sc->sc_node, "ranges", sizeof(struct central_range),
&sc->sc_nrange, (void **)&sc->sc_range);
printf("\n");
node0 = firstchild(sc->sc_node);
for (node = node0; node; node = nextsibling(node)) {
struct central_attach_args ca;
bzero(&ca, sizeof(ca));
ca.ca_node = node;
ca.ca_bustag = sc->sc_cbt;
if (central_get_string(ca.ca_node, "name", &ca.ca_name)) {
printf("can't fetch name for node 0x%x\n", node);
continue;
}
prom_getprop(node, "reg", sizeof(struct central_reg),
&ca.ca_nreg, (void **)&ca.ca_reg);
(void)config_found(self, (void *)&ca, central_print);
if (ca.ca_name != NULL)
free(ca.ca_name, M_DEVBUF);
}
}
static int
central_get_string(int node, const char *name, char **buf)
{
int len;
len = prom_getproplen(node, name);
if (len < 0)
return (len);
*buf = (char *)malloc(len + 1, M_DEVBUF, M_NOWAIT);
if (*buf == NULL)
return (-1);
if (len != 0)
prom_getpropstringA(node, name, *buf, len + 1);
(*buf)[len] = '\0';
return (0);
}
static int
central_print(void *args, const char *busname)
{
struct central_attach_args *ca = args;
char *class;
if (busname != NULL) {
printf("\"%s\" at %s", ca->ca_name, busname);
class = prom_getpropstring(ca->ca_node, "device_type");
if (*class != '\0')
printf(" class %s", class);
}
return (UNCONF);
}
static bus_space_tag_t
central_alloc_bus_tag(struct central_softc *sc)
{
struct sparc_bus_space_tag *bt;
bt = malloc(sizeof(*bt), M_DEVBUF, M_NOWAIT | M_ZERO);
if (bt == NULL)
panic("central: couldn't alloc bus tag");
bt->cookie = sc;
bt->parent = sc->sc_bt;
#if 0
bt->asi = bt->parent->asi;
bt->sasi = bt->parent->sasi;
#endif
bt->sparc_bus_map = _central_bus_map;
/* XXX bt->sparc_bus_mmap = central_bus_mmap; */
/* XXX bt->sparc_intr_establish = upa_intr_establish; */
return (bt);
}
static int
_central_bus_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size, int flags,
vaddr_t v, bus_space_handle_t *hp)
{
struct central_softc *sc = t->cookie;
int64_t slot = BUS_ADDR_IOSPACE(addr);
int64_t offset = BUS_ADDR_PADDR(addr);
int i;
if (t->parent == NULL || t->parent->sparc_bus_map == NULL) {
printf("\ncentral_bus_map: invalid parent");
return (EINVAL);
}
for (i = 0; i < sc->sc_nrange; i++) {
bus_addr_t paddr;
if (sc->sc_range[i].cspace != slot)
continue;
paddr = offset - sc->sc_range[i].coffset;
paddr += sc->sc_range[i].poffset;
paddr |= ((bus_addr_t)sc->sc_range[i].pspace << 32);
return bus_space_map(t->parent, paddr, size, flags, hp);
}
return (EINVAL);
}
/* $NetBSD: centralvar.h,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: centralvar.h,v 1.1 2004/09/22 21:31:51 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
struct central_reg {
u_int32_t cbr_slot;
u_int32_t cbr_offset;
u_int32_t cbr_size;
};
struct central_attach_args {
char *ca_name;
bus_space_tag_t ca_bustag;
struct central_reg *ca_reg;
int ca_node;
int ca_nreg;
};
struct central_range {
u_int32_t cspace; /* Client space */
u_int32_t coffset; /* Client offset */
u_int32_t pspace; /* Parent space */
u_int32_t poffset; /* Parent offset */
u_int32_t size; /* Size in bytes of this range */
};
#define central_bus_map(t, slot, offset, sz, flags, hp) \
bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp)
/* $NetBSD: fhc.c,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: fhc.c,v 1.17 2010/11/11 17:58:23 miod Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/malloc.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <sparc64/dev/fhcreg.h>
#include <sparc64/dev/fhcvar.h>
#include <sparc64/dev/iommureg.h>
int fhc_print(void *, const char *);
bus_space_tag_t fhc_alloc_bus_tag(struct fhc_softc *);
int _fhc_bus_map(bus_space_tag_t, bus_addr_t, bus_size_t, int, vaddr_t,
bus_space_handle_t *);
void *fhc_intr_establish(bus_space_tag_t, int, int,
int (*)(void *), void *, void (*)(void));
bus_space_handle_t *fhc_find_intr_handle(struct fhc_softc *, int);
void
fhc_attach(struct fhc_softc *sc)
{
int node0, node;
u_int32_t ctrl;
printf(" board %d: %s\n", sc->sc_board,
prom_getpropstring(sc->sc_node, "board-model"));
sc->sc_cbt = fhc_alloc_bus_tag(sc);
sc->sc_ign = sc->sc_board << 1;
bus_space_write_4(sc->sc_bt, sc->sc_ireg, FHC_I_IGN, sc->sc_ign);
sc->sc_ign = bus_space_read_4(sc->sc_bt, sc->sc_ireg, FHC_I_IGN);
ctrl = bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL);
if (!sc->sc_is_central)
ctrl |= FHC_P_CTRL_IXIST;
ctrl &= ~(FHC_P_CTRL_AOFF | FHC_P_CTRL_BOFF | FHC_P_CTRL_SLINE);
bus_space_write_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL, ctrl);
bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_CTRL);
/* clear interrupts */
bus_space_write_4(sc->sc_bt, sc->sc_freg, FHC_F_ICLR, 0);
bus_space_read_4(sc->sc_bt, sc->sc_freg, FHC_F_ICLR);
bus_space_write_4(sc->sc_bt, sc->sc_sreg, FHC_S_ICLR, 0);
bus_space_read_4(sc->sc_bt, sc->sc_sreg, FHC_S_ICLR);
bus_space_write_4(sc->sc_bt, sc->sc_ureg, FHC_U_ICLR, 0);
bus_space_read_4(sc->sc_bt, sc->sc_ureg, FHC_U_ICLR);
bus_space_write_4(sc->sc_bt, sc->sc_treg, FHC_T_ICLR, 0);
bus_space_read_4(sc->sc_bt, sc->sc_treg, FHC_T_ICLR);
prom_getprop(sc->sc_node, "ranges", sizeof(struct fhc_range),
&sc->sc_nrange, (void **)&sc->sc_range);
node0 = firstchild(sc->sc_node);
for (node = node0; node; node = nextsibling(node)) {
struct fhc_attach_args fa;
#if 0
if (!checkstatus(node))
continue;
#endif
bzero(&fa, sizeof(fa));
fa.fa_node = node;
fa.fa_bustag = sc->sc_cbt;
if (fhc_get_string(fa.fa_node, "name", &fa.fa_name)) {
printf("can't fetch name for node 0x%x\n", node);
continue;
}
prom_getprop(node, "reg", sizeof(struct fhc_reg),
&fa.fa_nreg, (void **)&fa.fa_reg);
prom_getprop(node, "interrupts", sizeof(int),
&fa.fa_nintr, (void **)&fa.fa_intr);
prom_getprop(node, "address", sizeof(*fa.fa_promvaddrs),
&fa.fa_npromvaddrs, (void **)&fa.fa_promvaddrs);
(void)config_found(sc->sc_dev, (void *)&fa, fhc_print);
if (fa.fa_name != NULL)
free(fa.fa_name, M_DEVBUF);
if (fa.fa_reg != NULL)
free(fa.fa_reg, M_DEVBUF);
if (fa.fa_intr != NULL)
free(fa.fa_intr, M_DEVBUF);
if (fa.fa_promvaddrs != NULL)
free(fa.fa_promvaddrs, M_DEVBUF);
}
}
int
fhc_print(void *args, const char *busname)
{
struct fhc_attach_args *fa = args;
char *class;
if (busname != NULL) {
printf("\"%s\" at %s", fa->fa_name, busname);
class = prom_getpropstring(fa->fa_node, "device_type");
if (*class != '\0')
printf(" class %s", class);
}
return (UNCONF);
}
int
fhc_get_string(int node, const char *name, char **buf)
{
int len;
len = prom_getproplen(node, name);
if (len < 0)
return (len);
*buf = (char *)malloc(len + 1, M_DEVBUF, M_NOWAIT);
if (*buf == NULL)
return (-1);
if (len != 0)
prom_getpropstringA(node, name, *buf, len + 1);
(*buf)[len] = '\0';
return (0);
}
bus_space_tag_t
fhc_alloc_bus_tag(struct fhc_softc *sc)
{
struct sparc_bus_space_tag *bt;
bt = malloc(sizeof(*bt), M_DEVBUF, M_NOWAIT | M_ZERO);
if (bt == NULL)
panic("fhc: couldn't alloc bus tag");
bt->cookie = sc;
bt->parent = sc->sc_bt;
bt->type = 0; /* XXX asi? */
bt->sparc_bus_map = _fhc_bus_map;
/* XXX bt->sparc_bus_mmap = fhc_bus_mmap; */
bt->sparc_intr_establish = fhc_intr_establish;
return (bt);
}
int
_fhc_bus_map(bus_space_tag_t t, bus_addr_t addr, bus_size_t size,
int flags, vaddr_t unused, bus_space_handle_t *hp)
{
struct fhc_softc *sc = t->cookie;
int64_t slot = BUS_ADDR_IOSPACE(addr);
int64_t offset = BUS_ADDR_PADDR(addr);
int i;
if (t->parent == NULL || t->parent->sparc_bus_map == NULL) {
printf("\n_fhc_bus_map: invalid parent");
return (EINVAL);
}
for (i = 0; i < sc->sc_nrange; i++) {
bus_addr_t paddr;
if (sc->sc_range[i].cspace != slot)
continue;
paddr = offset - sc->sc_range[i].coffset;
paddr += sc->sc_range[i].poffset;
paddr |= ((bus_addr_t)sc->sc_range[i].pspace << 32);
return bus_space_map(t->parent, paddr, size, flags, hp);
}
return (EINVAL);
}
bus_space_handle_t *
fhc_find_intr_handle(struct fhc_softc *sc, int ino)
{
switch (FHC_INO(ino)) {
case FHC_F_INO:
return &sc->sc_freg;
case FHC_S_INO:
return &sc->sc_sreg;
case FHC_U_INO:
return &sc->sc_ureg;
case FHC_T_INO:
return &sc->sc_treg;
default:
break;
}
return (NULL);
}
void *
fhc_intr_establish(bus_space_tag_t t, int ihandle, int level,
int (*handler)(void *), void *arg, void (*fastvec)(void) /* ignored */)
{
struct fhc_softc *sc = t->cookie;
volatile u_int64_t *intrmapptr = NULL, *intrclrptr = NULL;
struct intrhand *ih;
long vec;
bus_space_handle_t *hp;
struct fhc_intr_reg *intrregs;
hp = fhc_find_intr_handle(sc, ihandle);
if (hp == NULL) {
printf(": can't find intr handle\n");
return (NULL);
}
intrregs = bus_space_vaddr(sc->sc_bt, *hp);
intrmapptr = &intrregs->imap;
intrclrptr = &intrregs->iclr;
vec = ((sc->sc_ign << INTMAP_IGN_SHIFT) & INTMAP_IGN) |
INTINO(ihandle);
ih = (struct intrhand *)
malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
if (ih == NULL)
return (NULL);
ih->ih_ivec = ihandle;
/* Register the map and clear intr registers */
ih->ih_map = intrmapptr;
ih->ih_clr = intrclrptr;
ih->ih_fun = handler;
ih->ih_arg = arg;
ih->ih_pil = level;
ih->ih_number = vec;
intr_establish(ih->ih_pil, level != IPL_VM, ih);
/*
* XXXX --- we really should use bus_space for this.
*/
if (intrmapptr != NULL) {
u_int64_t r;
r = *intrmapptr;
r |= INTMAP_V;
*intrmapptr = r;
r = *intrmapptr;
ih->ih_number |= r & INTMAP_INR;
}
return (ih);
}
/* $NetBSD: fhc_central.c,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: fhc_central.c,v 1.5 2004/09/27 18:32:35 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <sparc64/dev/centralvar.h>
#include <sparc64/dev/fhcreg.h>
#include <sparc64/dev/fhcvar.h>
int fhc_central_match(device_t, cfdata_t, void *);
void fhc_central_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(fhc_central, sizeof(struct fhc_softc),
fhc_central_match, fhc_central_attach, NULL, NULL);
int
fhc_central_match(device_t parent, cfdata_t match, void *aux)
{
struct central_attach_args *ca = aux;
if (strcmp(ca->ca_name, "fhc") == 0)
return (1);
return (0);
}
void
fhc_central_attach(device_t parent, device_t self, void *aux)
{
struct fhc_softc *sc = (struct fhc_softc *)self;
struct central_attach_args *ca = aux;
u_int32_t board;
sc->sc_node = ca->ca_node;
sc->sc_bt = ca->ca_bustag;
sc->sc_is_central = 1;
if (central_bus_map(sc->sc_bt, ca->ca_reg[0].cbr_slot,
ca->ca_reg[0].cbr_offset, ca->ca_reg[0].cbr_size, 0,
&sc->sc_preg)) {
printf(": failed to map preg\n");
return;
}
if (central_bus_map(sc->sc_bt, ca->ca_reg[1].cbr_slot,
ca->ca_reg[1].cbr_offset, ca->ca_reg[1].cbr_size, 0,
&sc->sc_ireg)) {
printf(": failed to map ireg\n");
return;
}
if (central_bus_map(sc->sc_bt, ca->ca_reg[2].cbr_slot,
ca->ca_reg[2].cbr_offset, ca->ca_reg[2].cbr_size,
BUS_SPACE_MAP_LINEAR, &sc->sc_freg)) {
printf(": failed to map freg\n");
return;
}
if (central_bus_map(sc->sc_bt, ca->ca_reg[3].cbr_slot,
ca->ca_reg[3].cbr_offset, ca->ca_reg[3].cbr_size,
BUS_SPACE_MAP_LINEAR, &sc->sc_sreg)) {
printf(": failed to map sreg\n");
return;
}
if (central_bus_map(sc->sc_bt, ca->ca_reg[4].cbr_slot,
ca->ca_reg[4].cbr_offset, ca->ca_reg[4].cbr_size,
BUS_SPACE_MAP_LINEAR, &sc->sc_ureg)) {
printf(": failed to map ureg\n");
return;
}
if (central_bus_map(sc->sc_bt, ca->ca_reg[5].cbr_slot,
ca->ca_reg[5].cbr_offset, ca->ca_reg[5].cbr_size,
BUS_SPACE_MAP_LINEAR, &sc->sc_treg)) {
printf(": failed to map treg\n");
return;
}
board = bus_space_read_4(sc->sc_bt, sc->sc_preg, FHC_P_BSR);
sc->sc_board = ((board >> 16) & 0x1) | ((board >> 12) & 0xe);
sc->sc_dev = self;
fhc_attach(sc);
return;
}
/* $NetBSD: fhc_mainbus.c,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: fhc_mainbus.c,v 1.4 2004/09/27 18:32:35 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <sys/conf.h>
#include <sys/bus.h>
#include <machine/autoconf.h>
#include <machine/openfirm.h>
#include <sparc64/dev/fhcvar.h>
int fhc_mainbus_match(device_t, cfdata_t, void *);
void fhc_mainbus_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(fhc_mainbus, sizeof(struct fhc_softc),
fhc_mainbus_match, fhc_mainbus_attach, NULL, NULL);
int
fhc_mainbus_match(device_t parent, cfdata_t match, void *aux)
{
struct mainbus_attach_args *ma = aux;
if (strcmp(ma->ma_name, "fhc") == 0)
return (1);
return (0);
}
void
fhc_mainbus_attach(device_t parent, device_t self, void *aux)
{
struct fhc_softc *sc = (struct fhc_softc *)self;
struct mainbus_attach_args *ma = aux;
sc->sc_node = ma->ma_node;
sc->sc_bt = ma->ma_bustag;
sc->sc_is_central = 0;
if (bus_space_map(sc->sc_bt, ma->ma_reg[0].ur_paddr,
ma->ma_reg[0].ur_len, 0, &sc->sc_preg)) {
printf(": failed to map preg\n");
return;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[1].ur_paddr,
ma->ma_reg[1].ur_len, 0, &sc->sc_ireg)) {
printf(": failed to map ireg\n");
return;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[2].ur_paddr,
ma->ma_reg[2].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_freg)) {
printf(": failed to map freg\n");
return;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[3].ur_paddr,
ma->ma_reg[3].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_sreg)) {
printf(": failed to map sreg\n");
return;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[4].ur_paddr,
ma->ma_reg[4].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_ureg)) {
printf(": failed to map ureg\n");
return;
}
if (bus_space_map(sc->sc_bt, ma->ma_reg[5].ur_paddr,
ma->ma_reg[5].ur_len, BUS_SPACE_MAP_LINEAR, &sc->sc_treg)) {
printf(": failed to map treg\n");
return;
}
sc->sc_board = prom_getpropint(sc->sc_node, "board#", -1);
sc->sc_dev = self;
fhc_attach(sc);
return;
}
/* $NetBSD: fhcreg.h,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: fhcreg.h,v 1.4 2007/05/01 19:44:56 kettenis Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#define FHC_P_ID 0x00000000 /* ID */
#define FHC_P_RCS 0x00000010 /* reset ctrl/status */
#define FHC_P_CTRL 0x00000020 /* control */
#define FHC_P_BSR 0x00000030 /* board status */
#define FHC_P_ECC 0x00000040 /* ECC control */
#define FHC_P_JCTRL 0x000000f0 /* JTAG control */
#define FHC_P_CTRL_ICS 0x00100000 /* ignore centerplane sigs */
#define FHC_P_CTRL_FRST 0x00080000 /* fatal error reset enable */
#define FHC_P_CTRL_LFAT 0x00080000 /* AC/DC local error */
#define FHC_P_CTRL_SLINE 0x00010000 /* firmware sync line */
#define FHC_P_CTRL_DCD 0x00008000 /* DC/DC converter disable */
#define FHC_P_CTRL_POFF 0x00004000 /* AC/DC ctlr PLL disable */
#define FHC_P_CTRL_FOFF 0x00002000 /* FHC ctlr PLL disable */
#define FHC_P_CTRL_AOFF 0x00001000 /* cpu a sram low pwr mode */
#define FHC_P_CTRL_BOFF 0x00000800 /* cpu b sram low pwr mode */
#define FHC_P_CTRL_PSOFF 0x00000400 /* disable fhc power supply */
#define FHC_P_CTRL_IXIST 0x00000200 /* fhc notifies clock-board */
#define FHC_P_CTRL_XMSTR 0x00000100 /* xir master enable */
#define FHC_P_CTRL_LLED 0x00000040 /* left led (reversed) */
#define FHC_P_CTRL_MLED 0x00000020 /* middle led */
#define FHC_P_CTRL_RLED 0x00000010 /* right led */
#define FHC_P_CTRL_BPINS 0x00000003 /* spare bidir pins */
#define FHC_I_IGN 0x00000000 /* IGN register */
#define FHC_F_IMAP 0x00000000 /* fanfail intr map */
#define FHC_F_ICLR 0x00000010 /* fanfail intr clr */
#define FHC_S_IMAP 0x00000000 /* system intr map */
#define FHC_S_ICLR 0x00000010 /* system intr clr */
#define FHC_U_IMAP 0x00000000 /* uart intr map */
#define FHC_U_ICLR 0x00000010 /* uart intr clr */
#define FHC_T_IMAP 0x00000000 /* tod intr map */
#define FHC_T_ICLR 0x00000010 /* tod intr clr */
struct fhc_intr_reg {
u_int64_t imap;
u_int64_t unused_0;
u_int64_t iclr;
u_int64_t unused_1;
};
#define FHC_INO(ino) ((ino) & 0x7)
#define FHC_S_INO 0
#define FHC_U_INO 1
#define FHC_T_INO 2
#define FHC_F_INO 3
/* $NetBSD: fhcvar.h,v 1.1 2011/07/29 08:37:36 mrg Exp $ */
/* $OpenBSD: fhcvar.h,v 1.8 2004/10/01 18:18:49 jason Exp $ */
/*
* Copyright (c) 2004 Jason L. Wright (jason@thought.net).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
struct fhc_reg {
u_int32_t fbr_slot;
u_int32_t fbr_offset;
u_int32_t fbr_size;
};
struct fhc_range {
u_int32_t cspace; /* Client space */
u_int32_t coffset; /* Client offset */
u_int32_t pspace; /* Parent space */
u_int32_t poffset; /* Parent offset */
u_int32_t size; /* Size in bytes of this range */
};
struct fhc_softc {
device_t sc_dev;
int sc_node;
int sc_is_central; /* parent is central */
int sc_board;
u_int32_t sc_ign;
bus_space_tag_t sc_bt;
bus_space_tag_t sc_cbt;
int sc_nrange;
struct fhc_range *sc_range;
bus_space_handle_t sc_preg; /* internal regs */
bus_space_handle_t sc_ireg; /* ign regs */
bus_space_handle_t sc_freg; /* fanfail regs */
bus_space_handle_t sc_sreg; /* system regs */
bus_space_handle_t sc_ureg; /* uart regs */
bus_space_handle_t sc_treg; /* tod regs */
};
void fhc_attach(struct fhc_softc *);
int fhc_get_string(int, const char *, char **);
struct fhc_attach_args {
bus_space_tag_t fa_bustag;
char *fa_name;
int *fa_intr;
struct fhc_reg *fa_reg;
u_int32_t *fa_promvaddrs;
int fa_node;
int fa_nreg;
int fa_nintr;
int fa_npromvaddrs;
};
#define fhc_bus_map(t, slot, offset, sz, flags, hp) \
bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp)
--- src/sys/arch/sparc64/dev/mkclock.c 2011/07/01 18:48:36 1.8
+++ src/sys/arch/sparc64/dev/mkclock.c 2011/07/29 08:37:36 1.9
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: mkclock.c,v 1.8 2011/07/01 18:48:36 dyoung Exp $ */ | | 1 | /* $NetBSD: mkclock.c,v 1.9 2011/07/29 08:37:36 mrg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1992, 1993 | | 4 | * Copyright (c) 1992, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * Copyright (c) 1994 Gordon W. Ross | | 6 | * Copyright (c) 1994 Gordon W. Ross |
7 | * Copyright (c) 1993 Adam Glass | | 7 | * Copyright (c) 1993 Adam Glass |
8 | * Copyright (c) 1996 Paul Kranenburg | | 8 | * Copyright (c) 1996 Paul Kranenburg |
9 | * Copyright (c) 1996 | | 9 | * Copyright (c) 1996 |
10 | * The President and Fellows of Harvard College. All rights reserved. | | 10 | * The President and Fellows of Harvard College. All rights reserved. |
11 | * | | 11 | * |
12 | * This software was developed by the Computer Systems Engineering group | | 12 | * This software was developed by the Computer Systems Engineering group |
13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and | | 13 | * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and |
14 | * contributed to Berkeley. | | 14 | * contributed to Berkeley. |
| @@ -45,27 +45,27 @@ | | | @@ -45,27 +45,27 @@ |
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 | * SUCH DAMAGE. | | 51 | * SUCH DAMAGE. |
52 | * | | 52 | * |
53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 | | 53 | * @(#)clock.c 8.1 (Berkeley) 6/11/93 |
54 | * | | 54 | * |
55 | */ | | 55 | */ |
56 | | | 56 | |
57 | #include <sys/cdefs.h> | | 57 | #include <sys/cdefs.h> |
58 | __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.8 2011/07/01 18:48:36 dyoung Exp $"); | | 58 | __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v 1.9 2011/07/29 08:37:36 mrg Exp $"); |
59 | | | 59 | |
60 | /* | | 60 | /* |
61 | * Clock driver for 'mkclock' - Mostek MK48Txx TOD clock. | | 61 | * Clock driver for 'mkclock' - Mostek MK48Txx TOD clock. |
62 | */ | | 62 | */ |
63 | | | 63 | |
64 | #include <sys/param.h> | | 64 | #include <sys/param.h> |
65 | #include <sys/kernel.h> | | 65 | #include <sys/kernel.h> |
66 | #include <sys/device.h> | | 66 | #include <sys/device.h> |
67 | #include <sys/proc.h> | | 67 | #include <sys/proc.h> |
68 | #include <sys/resourcevar.h> | | 68 | #include <sys/resourcevar.h> |
69 | #include <sys/malloc.h> | | 69 | #include <sys/malloc.h> |
70 | #include <sys/systm.h> | | 70 | #include <sys/systm.h> |
71 | | | 71 | |
| @@ -74,66 +74,82 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v | | | @@ -74,66 +74,82 @@ __KERNEL_RCSID(0, "$NetBSD: mkclock.c,v |
74 | #include <sys/bus.h> | | 74 | #include <sys/bus.h> |
75 | #include <machine/autoconf.h> | | 75 | #include <machine/autoconf.h> |
76 | #include <machine/eeprom.h> | | 76 | #include <machine/eeprom.h> |
77 | #include <machine/cpu.h> | | 77 | #include <machine/cpu.h> |
78 | | | 78 | |
79 | #include <dev/clock_subr.h> | | 79 | #include <dev/clock_subr.h> |
80 | #include <dev/ic/mk48txxreg.h> | | 80 | #include <dev/ic/mk48txxreg.h> |
81 | #include <dev/ic/mk48txxvar.h> | | 81 | #include <dev/ic/mk48txxvar.h> |
82 | | | 82 | |
83 | #include <dev/sbus/sbusvar.h> | | 83 | #include <dev/sbus/sbusvar.h> |
84 | #include <dev/ebus/ebusreg.h> | | 84 | #include <dev/ebus/ebusreg.h> |
85 | #include <dev/ebus/ebusvar.h> | | 85 | #include <dev/ebus/ebusvar.h> |
86 | | | 86 | |
| | | 87 | #include <sparc64/dev/fhcvar.h> |
| | | 88 | |
87 | /* | | 89 | /* |
88 | * clock (eeprom) attaches at the sbus or the ebus (PCI) | | 90 | * clock (eeprom) attaches at the sbus or the ebus (PCI) |
89 | */ | | 91 | */ |
90 | static int mkclock_sbus_match(device_t, cfdata_t, void *); | | 92 | static int mkclock_sbus_match(device_t, cfdata_t, void *); |
91 | static void mkclock_sbus_attach(device_t, device_t, void *); | | 93 | static void mkclock_sbus_attach(device_t, device_t, void *); |
92 | | | 94 | |
93 | static int mkclock_ebus_match(device_t, cfdata_t, void *); | | 95 | static int mkclock_ebus_match(device_t, cfdata_t, void *); |
94 | static void mkclock_ebus_attach(device_t, device_t, void *); | | 96 | static void mkclock_ebus_attach(device_t, device_t, void *); |
95 | | | 97 | |
| | | 98 | static int mkclock_fhc_match(device_t, cfdata_t, void *); |
| | | 99 | static void mkclock_fhc_attach(device_t, device_t, void *); |
| | | 100 | |
96 | static void mkclock_attach(struct mk48txx_softc *, int); | | 101 | static void mkclock_attach(struct mk48txx_softc *, int); |
97 | | | 102 | |
98 | static int mkclock_wenable(struct todr_chip_handle *, int); | | 103 | static int mkclock_wenable(struct todr_chip_handle *, int); |
99 | | | 104 | |
100 | | | 105 | |
101 | CFATTACH_DECL_NEW(mkclock_sbus, sizeof(struct mk48txx_softc), | | 106 | CFATTACH_DECL_NEW(mkclock_sbus, sizeof(struct mk48txx_softc), |
102 | mkclock_sbus_match, mkclock_sbus_attach, NULL, NULL); | | 107 | mkclock_sbus_match, mkclock_sbus_attach, NULL, NULL); |
103 | | | 108 | |
104 | CFATTACH_DECL_NEW(mkclock_ebus, sizeof(struct mk48txx_softc), | | 109 | CFATTACH_DECL_NEW(mkclock_ebus, sizeof(struct mk48txx_softc), |
105 | mkclock_ebus_match, mkclock_ebus_attach, NULL, NULL); | | 110 | mkclock_ebus_match, mkclock_ebus_attach, NULL, NULL); |
106 | | | 111 | |
| | | 112 | CFATTACH_DECL_NEW(mkclock_fhc, sizeof(struct mk48txx_softc), |
| | | 113 | mkclock_fhc_match, mkclock_fhc_attach, NULL, NULL); |
| | | 114 | |
107 | /* | | 115 | /* |
108 | * The OPENPROM calls the clock the "eeprom", so we have to have our | | 116 | * The OPENPROM calls the clock the "eeprom", so we have to have our |
109 | * own special match function to call it the "clock". | | 117 | * own special match function to call it the "clock". |
110 | */ | | 118 | */ |
111 | static int | | 119 | static int |
112 | mkclock_sbus_match(device_t parent, cfdata_t cf, void *aux) | | 120 | mkclock_sbus_match(device_t parent, cfdata_t cf, void *aux) |
113 | { | | 121 | { |
114 | struct sbus_attach_args *sa = aux; | | 122 | struct sbus_attach_args *sa = aux; |
115 | | | 123 | |
116 | return (strcmp("eeprom", sa->sa_name) == 0); | | 124 | return (strcmp("eeprom", sa->sa_name) == 0); |
117 | } | | 125 | } |
118 | | | 126 | |
119 | static int | | 127 | static int |
120 | mkclock_ebus_match(device_t parent, cfdata_t cf, void *aux) | | 128 | mkclock_ebus_match(device_t parent, cfdata_t cf, void *aux) |
121 | { | | 129 | { |
122 | struct ebus_attach_args *ea = aux; | | 130 | struct ebus_attach_args *ea = aux; |
123 | | | 131 | |
124 | return (strcmp("eeprom", ea->ea_name) == 0); | | 132 | return (strcmp("eeprom", ea->ea_name) == 0); |
125 | } | | 133 | } |
126 | | | 134 | |
| | | 135 | static int |
| | | 136 | mkclock_fhc_match(device_t parent, cfdata_t cf, void *aux) |
| | | 137 | { |
| | | 138 | struct fhc_attach_args *fa = aux; |
| | | 139 | |
| | | 140 | return (strcmp("eeprom", fa->fa_name) == 0); |
| | | 141 | } |
| | | 142 | |
127 | /* | | 143 | /* |
128 | * Attach a clock (really `eeprom') to the sbus or ebus. | | 144 | * Attach a clock (really `eeprom') to the sbus or ebus. |
129 | * | | 145 | * |
130 | * We ignore any existing virtual address as we need to map | | 146 | * We ignore any existing virtual address as we need to map |
131 | * this read-only and make it read-write only temporarily, | | 147 | * this read-only and make it read-write only temporarily, |
132 | * whenever we read or write the clock chip. The clock also | | 148 | * whenever we read or write the clock chip. The clock also |
133 | * contains the ID ``PROM'', and I have already had the pleasure | | 149 | * contains the ID ``PROM'', and I have already had the pleasure |
134 | * of reloading the CPU type, Ethernet address, etc, by hand from | | 150 | * of reloading the CPU type, Ethernet address, etc, by hand from |
135 | * the console FORTH interpreter. I intend not to enjoy it again. | | 151 | * the console FORTH interpreter. I intend not to enjoy it again. |
136 | * | | 152 | * |
137 | * the MK48T02 is 2K. the MK48T08 is 8K, and the MK48T59 is | | 153 | * the MK48T02 is 2K. the MK48T08 is 8K, and the MK48T59 is |
138 | * supposed to be identical to it. | | 154 | * supposed to be identical to it. |
139 | * | | 155 | * |
| @@ -189,26 +205,48 @@ mkclock_ebus_attach(struct device *paren | | | @@ -189,26 +205,48 @@ mkclock_ebus_attach(struct device *paren |
189 | sz = ea->ea_reg[0].size; | | 205 | sz = ea->ea_reg[0].size; |
190 | | | 206 | |
191 | if (bus_space_map(sc->sc_bst, | | 207 | if (bus_space_map(sc->sc_bst, |
192 | EBUS_ADDR_FROM_REG(&ea->ea_reg[0]), | | 208 | EBUS_ADDR_FROM_REG(&ea->ea_reg[0]), |
193 | sz, | | 209 | sz, |
194 | BUS_SPACE_MAP_LINEAR, | | 210 | BUS_SPACE_MAP_LINEAR, |
195 | &sc->sc_bsh) != 0) { | | 211 | &sc->sc_bsh) != 0) { |
196 | aprint_error(": can't map register\n"); | | 212 | aprint_error(": can't map register\n"); |
197 | return; | | 213 | return; |
198 | } | | 214 | } |
199 | mkclock_attach(sc, ea->ea_node); | | 215 | mkclock_attach(sc, ea->ea_node); |
200 | } | | 216 | } |
201 | | | 217 | |
| | | 218 | /* ARGSUSED */ |
| | | 219 | static void |
| | | 220 | mkclock_fhc_attach(struct device *parent, struct device *self, void *aux) |
| | | 221 | { |
| | | 222 | struct mk48txx_softc *sc = device_private(self); |
| | | 223 | struct fhc_attach_args *fa = aux; |
| | | 224 | |
| | | 225 | sc->sc_dev = self; |
| | | 226 | sc->sc_bst = fa->fa_bustag; |
| | | 227 | |
| | | 228 | if (fhc_bus_map(sc->sc_bst, |
| | | 229 | fa->fa_reg[0].fbr_slot, |
| | | 230 | (fa->fa_reg[0].fbr_offset & ~NBPG), |
| | | 231 | fa->fa_reg[0].fbr_size, |
| | | 232 | BUS_SPACE_MAP_LINEAR, |
| | | 233 | &sc->sc_bsh) != 0) { |
| | | 234 | aprint_error(": can't map register\n"); |
| | | 235 | return; |
| | | 236 | } |
| | | 237 | mkclock_attach(sc, fa->fa_node); |
| | | 238 | } |
| | | 239 | |
202 | | | 240 | |
203 | static void | | 241 | static void |
204 | mkclock_attach(struct mk48txx_softc *sc, int node) | | 242 | mkclock_attach(struct mk48txx_softc *sc, int node) |
205 | { | | 243 | { |
206 | | | 244 | |
207 | sc->sc_model = prom_getpropstring(node, "model"); | | 245 | sc->sc_model = prom_getpropstring(node, "model"); |
208 | | | 246 | |
209 | #ifdef DIAGNOSTIC | | 247 | #ifdef DIAGNOSTIC |
210 | if (sc->sc_model == NULL) | | 248 | if (sc->sc_model == NULL) |
211 | panic("clockattach: no model property"); | | 249 | panic("clockattach: no model property"); |
212 | #endif | | 250 | #endif |
213 | | | 251 | |
214 | /* Our TOD clock year 0 is 1968 */ | | 252 | /* Our TOD clock year 0 is 1968 */ |
--- src/sys/arch/sparc64/dev/sbus.c 2011/07/20 12:06:00 1.89
+++ src/sys/arch/sparc64/dev/sbus.c 2011/07/29 08:37:36 1.90
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sbus.c,v 1.89 2011/07/20 12:06:00 macallan Exp $ */ | | 1 | /* $NetBSD: sbus.c,v 1.90 2011/07/29 08:37:36 mrg Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1999-2002 Eduardo Horvath | | 4 | * Copyright (c) 1999-2002 Eduardo Horvath |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | | 24 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | | 25 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | * SUCH DAMAGE. | | 28 | * SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Sbus stuff. | | 33 | * Sbus stuff. |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.89 2011/07/20 12:06:00 macallan Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.90 2011/07/29 08:37:36 mrg Exp $"); |
38 | | | 38 | |
39 | #include "opt_ddb.h" | | 39 | #include "opt_ddb.h" |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/extent.h> | | 42 | #include <sys/extent.h> |
43 | #include <sys/malloc.h> | | 43 | #include <sys/malloc.h> |
44 | #include <sys/systm.h> | | 44 | #include <sys/systm.h> |
45 | #include <sys/device.h> | | 45 | #include <sys/device.h> |
46 | #include <sys/reboot.h> | | 46 | #include <sys/reboot.h> |
47 | | | 47 | |
48 | #include <sys/bus.h> | | 48 | #include <sys/bus.h> |
49 | #include <machine/openfirm.h> | | 49 | #include <machine/openfirm.h> |
50 | | | 50 | |
| @@ -69,27 +69,27 @@ int sbus_debug = 0; | | | @@ -69,27 +69,27 @@ int sbus_debug = 0; |
69 | #endif | | 69 | #endif |
70 | | | 70 | |
71 | void sbusreset(int); | | 71 | void sbusreset(int); |
72 | | | 72 | |
73 | static bus_dma_tag_t sbus_alloc_dmatag(struct sbus_softc *); | | 73 | static bus_dma_tag_t sbus_alloc_dmatag(struct sbus_softc *); |
74 | static int sbus_get_intr(struct sbus_softc *, int, struct openprom_intr **, | | 74 | static int sbus_get_intr(struct sbus_softc *, int, struct openprom_intr **, |
75 | int *, int); | | 75 | int *, int); |
76 | static int sbus_overtemp(void *); | | 76 | static int sbus_overtemp(void *); |
77 | static int _sbus_bus_map( | | 77 | static int _sbus_bus_map( |
78 | bus_space_tag_t, | | 78 | bus_space_tag_t, |
79 | bus_addr_t, /*offset*/ | | 79 | bus_addr_t, /*offset*/ |
80 | bus_size_t, /*size*/ | | 80 | bus_size_t, /*size*/ |
81 | int, /*flags*/ | | 81 | int, /*flags*/ |
82 | vaddr_t, /* XXX unused -- compat w/sparc */ | | 82 | vaddr_t, /* XXX unused -- compat w/sparc */ |
83 | bus_space_handle_t *); | | 83 | bus_space_handle_t *); |
84 | static void *sbus_intr_establish( | | 84 | static void *sbus_intr_establish( |
85 | bus_space_tag_t, | | 85 | bus_space_tag_t, |
86 | int, /*`device class' priority*/ | | 86 | int, /*`device class' priority*/ |
87 | int, /*Sbus interrupt level*/ | | 87 | int, /*Sbus interrupt level*/ |
88 | int (*)(void *), /*handler*/ | | 88 | int (*)(void *), /*handler*/ |
89 | void *, /*handler arg*/ | | 89 | void *, /*handler arg*/ |
90 | void (*)(void)); /*optional fast trap*/ | | 90 | void (*)(void)); /*optional fast trap*/ |
91 | | | 91 | |
92 | | | 92 | |
93 | /* autoconfiguration driver */ | | 93 | /* autoconfiguration driver */ |
94 | int sbus_match(device_t, cfdata_t, void *); | | 94 | int sbus_match(device_t, cfdata_t, void *); |
95 | void sbus_attach(device_t, device_t, void *); | | 95 | void sbus_attach(device_t, device_t, void *); |
--- src/sys/arch/sparc64/dev/zs.c 2011/03/12 11:43:38 1.70
+++ src/sys/arch/sparc64/dev/zs.c 2011/07/29 08:37:36 1.71
| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: zs.c,v 1.70 2011/03/12 11:43:38 nakayama Exp $ */ | | 1 | /* $NetBSD: zs.c,v 1.71 2011/07/29 08:37:36 mrg Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1996 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1996 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Gordon W. Ross. | | 8 | * by Gordon W. Ross. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -28,27 +28,27 @@ | | | @@ -28,27 +28,27 @@ |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * Zilog Z8530 Dual UART driver (machine-dependent part) | | 33 | * Zilog Z8530 Dual UART driver (machine-dependent part) |
34 | * | | 34 | * |
35 | * Runs two serial lines per chip using slave drivers. | | 35 | * Runs two serial lines per chip using slave drivers. |
36 | * Plain tty/async lines use the zs_async slave. | | 36 | * Plain tty/async lines use the zs_async slave. |
37 | * Sun keyboard/mouse uses the zs_kbd/zs_ms slaves. | | 37 | * Sun keyboard/mouse uses the zs_kbd/zs_ms slaves. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #include <sys/cdefs.h> | | 40 | #include <sys/cdefs.h> |
41 | __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.70 2011/03/12 11:43:38 nakayama Exp $"); | | 41 | __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.71 2011/07/29 08:37:36 mrg Exp $"); |
42 | | | 42 | |
43 | #include "opt_ddb.h" | | 43 | #include "opt_ddb.h" |
44 | #include "opt_kgdb.h" | | 44 | #include "opt_kgdb.h" |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/systm.h> | | 47 | #include <sys/systm.h> |
48 | #include <sys/conf.h> | | 48 | #include <sys/conf.h> |
49 | #include <sys/device.h> | | 49 | #include <sys/device.h> |
50 | #include <sys/file.h> | | 50 | #include <sys/file.h> |
51 | #include <sys/ioctl.h> | | 51 | #include <sys/ioctl.h> |
52 | #include <sys/kernel.h> | | 52 | #include <sys/kernel.h> |
53 | #include <sys/proc.h> | | 53 | #include <sys/proc.h> |
54 | #include <sys/tty.h> | | 54 | #include <sys/tty.h> |
| @@ -59,26 +59,27 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.70 | | | @@ -59,26 +59,27 @@ __KERNEL_RCSID(0, "$NetBSD: zs.c,v 1.70 |
59 | #include <machine/autoconf.h> | | 59 | #include <machine/autoconf.h> |
60 | #include <machine/openfirm.h> | | 60 | #include <machine/openfirm.h> |
61 | #include <machine/cpu.h> | | 61 | #include <machine/cpu.h> |
62 | #include <machine/eeprom.h> | | 62 | #include <machine/eeprom.h> |
63 | #include <machine/psl.h> | | 63 | #include <machine/psl.h> |
64 | #include <machine/z8530var.h> | | 64 | #include <machine/z8530var.h> |
65 | | | 65 | |
66 | #include <dev/cons.h> | | 66 | #include <dev/cons.h> |
67 | #include <dev/ic/z8530reg.h> | | 67 | #include <dev/ic/z8530reg.h> |
68 | #include <dev/sun/kbd_ms_ttyvar.h> | | 68 | #include <dev/sun/kbd_ms_ttyvar.h> |
69 | #include <ddb/db_output.h> | | 69 | #include <ddb/db_output.h> |
70 | | | 70 | |
71 | #include <dev/sbus/sbusvar.h> | | 71 | #include <dev/sbus/sbusvar.h> |
| | | 72 | #include <sparc64/dev/fhcvar.h> |
72 | #include <sparc64/dev/cons.h> | | 73 | #include <sparc64/dev/cons.h> |
73 | | | 74 | |
74 | #include "ioconf.h" | | 75 | #include "ioconf.h" |
75 | #include "kbd.h" /* NKBD */ | | 76 | #include "kbd.h" /* NKBD */ |
76 | #include "ms.h" /* NMS */ | | 77 | #include "ms.h" /* NMS */ |
77 | #include "zs.h" /* NZS */ | | 78 | #include "zs.h" /* NZS */ |
78 | | | 79 | |
79 | /* Make life easier for the initialized arrays here. */ | | 80 | /* Make life easier for the initialized arrays here. */ |
80 | #if NZS < 3 | | 81 | #if NZS < 3 |
81 | #undef NZS | | 82 | #undef NZS |
82 | #define NZS 3 | | 83 | #define NZS 3 |
83 | #endif | | 84 | #endif |
84 | | | 85 | |
| @@ -144,32 +145,38 @@ struct consdev zs_consdev = { | | | @@ -144,32 +145,38 @@ struct consdev zs_consdev = { |
144 | .cn_putc = zscnputc, | | 145 | .cn_putc = zscnputc, |
145 | .cn_pollc = zscnpollc, | | 146 | .cn_pollc = zscnpollc, |
146 | }; | | 147 | }; |
147 | | | 148 | |
148 | | | 149 | |
149 | /**************************************************************** | | 150 | /**************************************************************** |
150 | * Autoconfig | | 151 | * Autoconfig |
151 | ****************************************************************/ | | 152 | ****************************************************************/ |
152 | | | 153 | |
153 | /* Definition of the driver for autoconfig. */ | | 154 | /* Definition of the driver for autoconfig. */ |
154 | static int zs_match_sbus(device_t, cfdata_t, void *); | | 155 | static int zs_match_sbus(device_t, cfdata_t, void *); |
155 | static void zs_attach_sbus(device_t, device_t, void *); | | 156 | static void zs_attach_sbus(device_t, device_t, void *); |
156 | | | 157 | |
| | | 158 | static int zs_match_fhc(device_t, cfdata_t, void *); |
| | | 159 | static void zs_attach_fhc(device_t, device_t, void *); |
| | | 160 | |
157 | static void zs_attach(struct zsc_softc *, struct zsdevice *, int); | | 161 | static void zs_attach(struct zsc_softc *, struct zsdevice *, int); |
158 | static int zs_print(void *, const char *); | | 162 | static int zs_print(void *, const char *); |
159 | | | 163 | |
160 | CFATTACH_DECL_NEW(zs, sizeof(struct zsc_softc), | | 164 | CFATTACH_DECL_NEW(zs, sizeof(struct zsc_softc), |
161 | zs_match_sbus, zs_attach_sbus, NULL, NULL); | | 165 | zs_match_sbus, zs_attach_sbus, NULL, NULL); |
162 | | | 166 | |
| | | 167 | CFATTACH_DECL_NEW(zs_fhc, sizeof(struct zsc_softc), |
| | | 168 | zs_match_fhc, zs_attach_fhc, NULL, NULL); |
| | | 169 | |
163 | /* Interrupt handlers. */ | | 170 | /* Interrupt handlers. */ |
164 | int zscheckintr(void *); | | 171 | int zscheckintr(void *); |
165 | static int zshard(void *); | | 172 | static int zshard(void *); |
166 | static void zssoft(void *); | | 173 | static void zssoft(void *); |
167 | | | 174 | |
168 | static int zs_get_speed(struct zs_chanstate *); | | 175 | static int zs_get_speed(struct zs_chanstate *); |
169 | | | 176 | |
170 | /* Console device support */ | | 177 | /* Console device support */ |
171 | static int zs_console_flags(int, int, int); | | 178 | static int zs_console_flags(int, int, int); |
172 | | | 179 | |
173 | /* Power management hooks */ | | 180 | /* Power management hooks */ |
174 | int zs_enable(struct zs_chanstate *); | | 181 | int zs_enable(struct zs_chanstate *); |
175 | void zs_disable(struct zs_chanstate *); | | 182 | void zs_disable(struct zs_chanstate *); |
| @@ -181,26 +188,37 @@ struct tty *zstty_get_tty_from_dev(struc | | | @@ -181,26 +188,37 @@ struct tty *zstty_get_tty_from_dev(struc |
181 | * Is the zs chip present? | | 188 | * Is the zs chip present? |
182 | */ | | 189 | */ |
183 | static int | | 190 | static int |
184 | zs_match_sbus(device_t parent, cfdata_t cf, void *aux) | | 191 | zs_match_sbus(device_t parent, cfdata_t cf, void *aux) |
185 | { | | 192 | { |
186 | struct sbus_attach_args *sa = aux; | | 193 | struct sbus_attach_args *sa = aux; |
187 | | | 194 | |
188 | if (strcmp(cf->cf_name, sa->sa_name) != 0) | | 195 | if (strcmp(cf->cf_name, sa->sa_name) != 0) |
189 | return (0); | | 196 | return (0); |
190 | | | 197 | |
191 | return (1); | | 198 | return (1); |
192 | } | | 199 | } |
193 | | | 200 | |
| | | 201 | static int |
| | | 202 | zs_match_fhc(device_t parent, cfdata_t cf, void *aux) |
| | | 203 | { |
| | | 204 | struct fhc_attach_args *fa = aux; |
| | | 205 | |
| | | 206 | if (strcmp(cf->cf_name, fa->fa_name) != 0) |
| | | 207 | return (0); |
| | | 208 | |
| | | 209 | return (1); |
| | | 210 | } |
| | | 211 | |
194 | static void | | 212 | static void |
195 | zs_attach_sbus(device_t parent, device_t self, void *aux) | | 213 | zs_attach_sbus(device_t parent, device_t self, void *aux) |
196 | { | | 214 | { |
197 | struct zsc_softc *zsc = device_private(self); | | 215 | struct zsc_softc *zsc = device_private(self); |
198 | struct sbus_attach_args *sa = aux; | | 216 | struct sbus_attach_args *sa = aux; |
199 | bus_space_handle_t bh; | | 217 | bus_space_handle_t bh; |
200 | int zs_unit; | | 218 | int zs_unit; |
201 | | | 219 | |
202 | zsc->zsc_dev = self; | | 220 | zsc->zsc_dev = self; |
203 | zs_unit = device_unit(self); | | 221 | zs_unit = device_unit(self); |
204 | | | 222 | |
205 | if (sa->sa_nintr == 0) { | | 223 | if (sa->sa_nintr == 0) { |
206 | aprint_error(": no interrupt lines\n"); | | 224 | aprint_error(": no interrupt lines\n"); |
| @@ -234,26 +252,85 @@ zs_attach_sbus(device_t parent, device_t | | | @@ -234,26 +252,85 @@ zs_attach_sbus(device_t parent, device_t |
234 | aprint_error(": cannot map registers\n"); | | 252 | aprint_error(": cannot map registers\n"); |
235 | return; | | 253 | return; |
236 | } | | 254 | } |
237 | } | | 255 | } |
238 | zsaddr[zs_unit] = bus_space_vaddr(sa->sa_bustag, bh); | | 256 | zsaddr[zs_unit] = bus_space_vaddr(sa->sa_bustag, bh); |
239 | } | | 257 | } |
240 | zsc->zsc_bustag = sa->sa_bustag; | | 258 | zsc->zsc_bustag = sa->sa_bustag; |
241 | zsc->zsc_dmatag = sa->sa_dmatag; | | 259 | zsc->zsc_dmatag = sa->sa_dmatag; |
242 | zsc->zsc_promunit = prom_getpropint(sa->sa_node, "slave", -2); | | 260 | zsc->zsc_promunit = prom_getpropint(sa->sa_node, "slave", -2); |
243 | zsc->zsc_node = sa->sa_node; | | 261 | zsc->zsc_node = sa->sa_node; |
244 | zs_attach(zsc, zsaddr[zs_unit], sa->sa_pri); | | 262 | zs_attach(zsc, zsaddr[zs_unit], sa->sa_pri); |
245 | } | | 263 | } |
246 | | | 264 | |
| | | 265 | static void |
| | | 266 | zs_attach_fhc(device_t parent, device_t self, void *aux) |
| | | 267 | { |
| | | 268 | struct zsc_softc *zsc = device_private(self); |
| | | 269 | struct fhc_attach_args *fa = aux; |
| | | 270 | bus_space_handle_t bh; |
| | | 271 | int zs_unit; |
| | | 272 | |
| | | 273 | zsc->zsc_dev = self; |
| | | 274 | zs_unit = device_unit(self); |
| | | 275 | |
| | | 276 | if (fa->fa_nreg < 1 && fa->fa_npromvaddrs < 1) { |
| | | 277 | printf(": no registers\n"); |
| | | 278 | return; |
| | | 279 | } |
| | | 280 | |
| | | 281 | if (fa->fa_nintr == 0) { |
| | | 282 | aprint_error(": no interrupt lines\n"); |
| | | 283 | return; |
| | | 284 | } |
| | | 285 | |
| | | 286 | /* Use the mapping setup by the Sun PROM if possible. */ |
| | | 287 | if (zsaddr[zs_unit] == NULL) { |
| | | 288 | /* Only map registers once. */ |
| | | 289 | if (fa->fa_npromvaddrs) { |
| | | 290 | /* |
| | | 291 | * We're converting from a 32-bit pointer to a 64-bit |
| | | 292 | * pointer. Since the 32-bit entity is negative, but |
| | | 293 | * the kernel is still mapped into the lower 4GB |
| | | 294 | * range, this needs to be zero-extended. |
| | | 295 | * |
| | | 296 | * XXXXX If we map the kernel and devices into the |
| | | 297 | * high 4GB range, this needs to be changed to |
| | | 298 | * sign-extend the address. |
| | | 299 | */ |
| | | 300 | sparc_promaddr_to_handle(fa->fa_bustag, |
| | | 301 | fa->fa_promvaddrs[0], &bh); |
| | | 302 | |
| | | 303 | } else { |
| | | 304 | |
| | | 305 | if (fhc_bus_map(fa->fa_bustag, |
| | | 306 | fa->fa_reg[0].fbr_slot, |
| | | 307 | fa->fa_reg[0].fbr_offset, |
| | | 308 | fa->fa_reg[0].fbr_size, |
| | | 309 | BUS_SPACE_MAP_LINEAR, |
| | | 310 | &bh) != 0) { |
| | | 311 | aprint_error(": cannot map registers\n"); |
| | | 312 | return; |
| | | 313 | } |
| | | 314 | } |
| | | 315 | zsaddr[zs_unit] = bus_space_vaddr(fa->fa_bustag, bh); |
| | | 316 | } |
| | | 317 | zsc->zsc_bustag = fa->fa_bustag; |
| | | 318 | zsc->zsc_dmatag = NULL; |
| | | 319 | zsc->zsc_promunit = prom_getpropint(fa->fa_node, "slave", -2); |
| | | 320 | zsc->zsc_node = fa->fa_node; |
| | | 321 | zs_attach(zsc, zsaddr[zs_unit], fa->fa_intr[0]); |
| | | 322 | } |
| | | 323 | |
247 | /* | | 324 | /* |
248 | * Attach a found zs. | | 325 | * Attach a found zs. |
249 | * | | 326 | * |
250 | * USE ROM PROPERTIES port-a-ignore-cd AND port-b-ignore-cd FOR | | 327 | * USE ROM PROPERTIES port-a-ignore-cd AND port-b-ignore-cd FOR |
251 | * SOFT CARRIER, AND keyboard PROPERTY FOR KEYBOARD/MOUSE? | | 328 | * SOFT CARRIER, AND keyboard PROPERTY FOR KEYBOARD/MOUSE? |
252 | */ | | 329 | */ |
253 | static void | | 330 | static void |
254 | zs_attach(struct zsc_softc *zsc, struct zsdevice *zsd, int pri) | | 331 | zs_attach(struct zsc_softc *zsc, struct zsdevice *zsd, int pri) |
255 | { | | 332 | { |
256 | struct zsc_attach_args zsc_args; | | 333 | struct zsc_attach_args zsc_args; |
257 | struct zs_chanstate *cs; | | 334 | struct zs_chanstate *cs; |
258 | int channel; | | 335 | int channel; |
259 | | | 336 | |