xref: /netbsd/sys/arch/prep/prep/platform.c (revision c4a72b64)
1 /*	$NetBSD: platform.c,v 1.8 2002/05/30 16:10:09 nonaka Exp $	*/
2 
3 /*-
4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by NONAKA Kimihiro.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
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.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *	This product includes software developed by the NetBSD
21  *	Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 
42 #include <dev/pci/pcivar.h>
43 
44 #include <machine/intr.h>
45 #include <machine/platform.h>
46 #include <machine/residual.h>
47 
48 static struct platform platform_unknown = {
49 	"",					/* model */
50 	platform_generic_match,			/* match */
51 	prep_pci_get_chipset_tag_indirect,	/* pci_setup */
52 	pci_intr_nofixup,			/* pci_intr_fixup */
53 	init_intr,				/* init_intr */
54 	cpu_setup_unknown,			/* cpu_setup */
55 	reset_unknown,				/* reset */
56 	obiodevs_nodev,				/* obiodevs */
57 };
58 
59 static struct plattab plattab_unknown = {
60 	NULL,	0
61 };
62 
63 const char *obiodevs_nodev[] = {
64 	NULL
65 };
66 
67 struct platform *platform = &platform_unknown;
68 
69 int
70 ident_platform(void)
71 {
72 	struct plattab *p = &plattab_unknown;
73 	int matched = -1, match = 0;
74 	int i, rv;
75 
76 	if (res == NULL)
77 		return 0;
78 
79 	if (strncmp(res->VitalProductData.PrintableModel,
80 	    "IBM", 3) == 0)
81 		p = &plattab_ibm;
82 	else if (strncmp(res->VitalProductData.PrintableModel,
83 	    "MOT", 3) == 0)
84 		p = &plattab_mot;
85 	else if (strncmp(res->VitalProductData.PrintableModel,
86 	    "BULL ESTRELLA (e0)         (e0)", 31) == 0) /* XXX */
87 		p = &plattab_mot;
88 
89 	for (i = 0; i < p->num; i++) {
90 		rv = (*p->platform[i]->match)(p->platform[i]);
91 		if (rv > match) {
92 			match = rv;
93 			matched = i;
94 		}
95 	}
96 	if (match)
97 		platform = p->platform[matched];
98 	return match;
99 }
100 
101 int
102 platform_generic_match(struct platform *p)
103 {
104 
105 	if (p == NULL || p->model == NULL)
106 		return 0;
107 	if (strcmp(res->VitalProductData.PrintableModel, p->model) != 0)
108     		return 0;
109 	return 1;
110 }
111 
112 /* ARGUSED */
113 void
114 pci_intr_nofixup(int busno, int device, int *intr)
115 {
116 }
117 
118 /* ARGUSED */
119 void
120 cpu_setup_unknown(struct device *dev)
121 {
122 }
123 
124 void
125 reset_unknown(void)
126 {
127 }
128 
129 void
130 reset_prep_generic(void)
131 {
132 	int msr;
133 	u_char reg;
134 
135 	asm volatile("mfmsr %0" : "=r"(msr));
136 	msr |= PSL_IP;
137 	asm volatile("mtmsr %0" :: "r"(msr));
138 
139 	reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
140 	reg &= ~1UL;
141 	*(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
142 	reg = *(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92);
143 	reg |= 1;
144 	*(volatile u_char *)(PREP_BUS_SPACE_IO + 0x92) = reg;
145 }
146