crime.c revision 1.1.4.2 1 1.1.4.2 minoura /* $NetBSD: crime.c,v 1.1.4.2 2000/06/22 17:02:58 minoura Exp $ */
2 1.1.4.2 minoura
3 1.1.4.2 minoura /*
4 1.1.4.2 minoura * Copyright (c) 2000 Soren S. Jorvang
5 1.1.4.2 minoura * All rights reserved.
6 1.1.4.2 minoura *
7 1.1.4.2 minoura * Redistribution and use in source and binary forms, with or without
8 1.1.4.2 minoura * modification, are permitted provided that the following conditions
9 1.1.4.2 minoura * are met:
10 1.1.4.2 minoura * 1. Redistributions of source code must retain the above copyright
11 1.1.4.2 minoura * notice, this list of conditions and the following disclaimer.
12 1.1.4.2 minoura * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.4.2 minoura * notice, this list of conditions and the following disclaimer in the
14 1.1.4.2 minoura * documentation and/or other materials provided with the distribution.
15 1.1.4.2 minoura * 3. All advertising materials mentioning features or use of this software
16 1.1.4.2 minoura * must display the following acknowledgement:
17 1.1.4.2 minoura * This product includes software developed for the
18 1.1.4.2 minoura * NetBSD Project. See http://www.netbsd.org/ for
19 1.1.4.2 minoura * information about NetBSD.
20 1.1.4.2 minoura * 4. The name of the author may not be used to endorse or promote products
21 1.1.4.2 minoura * derived from this software without specific prior written permission.
22 1.1.4.2 minoura *
23 1.1.4.2 minoura * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1.4.2 minoura * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1.4.2 minoura * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1.4.2 minoura * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1.4.2 minoura * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1.4.2 minoura * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1.4.2 minoura * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1.4.2 minoura * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1.4.2 minoura * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1.4.2 minoura * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1.4.2 minoura */
34 1.1.4.2 minoura
35 1.1.4.2 minoura /*
36 1.1.4.2 minoura * O2 CRIME
37 1.1.4.2 minoura */
38 1.1.4.2 minoura
39 1.1.4.2 minoura #include <sys/param.h>
40 1.1.4.2 minoura #include <sys/device.h>
41 1.1.4.2 minoura #include <sys/systm.h>
42 1.1.4.2 minoura
43 1.1.4.2 minoura #include <machine/cpu.h>
44 1.1.4.2 minoura #include <machine/locore.h>
45 1.1.4.2 minoura #include <machine/autoconf.h>
46 1.1.4.2 minoura #include <machine/bus.h>
47 1.1.4.2 minoura
48 1.1.4.2 minoura #include <dev/pci/pcivar.h>
49 1.1.4.2 minoura
50 1.1.4.2 minoura #include <sgimips/dev/crimereg.h>
51 1.1.4.2 minoura
52 1.1.4.2 minoura #include "locators.h"
53 1.1.4.2 minoura
54 1.1.4.2 minoura static int crime_match(struct device *, struct cfdata *, void *);
55 1.1.4.2 minoura static void crime_attach(struct device *, struct device *, void *);
56 1.1.4.2 minoura
57 1.1.4.2 minoura struct cfattach crime_ca = {
58 1.1.4.2 minoura sizeof(struct device), crime_match, crime_attach
59 1.1.4.2 minoura };
60 1.1.4.2 minoura
61 1.1.4.2 minoura static int
62 1.1.4.2 minoura crime_match(parent, match, aux)
63 1.1.4.2 minoura struct device *parent;
64 1.1.4.2 minoura struct cfdata *match;
65 1.1.4.2 minoura void *aux;
66 1.1.4.2 minoura {
67 1.1.4.2 minoura struct mainbus_attach_args *ma = aux;
68 1.1.4.2 minoura
69 1.1.4.2 minoura /*
70 1.1.4.2 minoura * The CRIME is in the O2.
71 1.1.4.2 minoura */
72 1.1.4.2 minoura switch (ma->ma_arch) {
73 1.1.4.2 minoura case 32:
74 1.1.4.2 minoura return 1;
75 1.1.4.2 minoura default:
76 1.1.4.2 minoura return 0;
77 1.1.4.2 minoura }
78 1.1.4.2 minoura }
79 1.1.4.2 minoura
80 1.1.4.2 minoura static void
81 1.1.4.2 minoura crime_attach(parent, self, aux)
82 1.1.4.2 minoura struct device *parent;
83 1.1.4.2 minoura struct device *self;
84 1.1.4.2 minoura void *aux;
85 1.1.4.2 minoura {
86 1.1.4.2 minoura struct mainbus_attach_args *ma = aux;
87 1.1.4.2 minoura u_int32_t rev; /* really u_int64_t ! */
88 1.1.4.2 minoura int major, minor;
89 1.1.4.2 minoura
90 1.1.4.2 minoura rev = bus_space_read_4(ma->ma_iot, ma->ma_ioh, 4) & 0xff;
91 1.1.4.2 minoura
92 1.1.4.2 minoura major = rev > 4;
93 1.1.4.2 minoura minor = rev & 0x0f;
94 1.1.4.2 minoura
95 1.1.4.2 minoura if (major == 0 && minor == 0)
96 1.1.4.2 minoura printf(": petty\n");
97 1.1.4.2 minoura else
98 1.1.4.2 minoura printf(": rev %d.%d\n", major, minor);
99 1.1.4.2 minoura
100 1.1.4.2 minoura #if 0
101 1.1.4.2 minoura *(volatile u_int64_t *)0xb4000018 = 0xffffffffffffffff;
102 1.1.4.2 minoura #else
103 1.1.4.2 minoura /* enable all mace interrupts, but no crime devices */
104 1.1.4.2 minoura *(volatile u_int64_t *)0xb4000018 = 0x000000000000ffff;
105 1.1.4.2 minoura #endif
106 1.1.4.2 minoura }
107