Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/mips/sni/setup.c
26442 views
1
/*
2
* Setup pointers to hardware-dependent routines.
3
*
4
* This file is subject to the terms and conditions of the GNU General Public
5
* License. See the file "COPYING" in the main directory of this archive
6
* for more details.
7
*
8
* Copyright (C) 1996, 97, 98, 2000, 03, 04, 06 Ralf Baechle ([email protected])
9
* Copyright (C) 2006,2007 Thomas Bogendoerfer ([email protected])
10
*/
11
#include <linux/eisa.h>
12
#include <linux/init.h>
13
#include <linux/export.h>
14
#include <linux/console.h>
15
#include <linux/screen_info.h>
16
17
#ifdef CONFIG_FW_ARC
18
#include <asm/fw/arc/types.h>
19
#include <asm/sgialib.h>
20
#endif
21
22
#ifdef CONFIG_FW_SNIPROM
23
#include <asm/mipsprom.h>
24
#endif
25
26
#include <asm/bootinfo.h>
27
#include <asm/cpu.h>
28
#include <asm/io.h>
29
#include <asm/reboot.h>
30
#include <asm/sni.h>
31
32
unsigned int sni_brd_type;
33
EXPORT_SYMBOL(sni_brd_type);
34
35
extern void sni_machine_restart(char *command);
36
extern void sni_machine_power_off(void);
37
38
static void __init sni_display_setup(void)
39
{
40
#if defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_FW_ARC)
41
static struct screen_info si;
42
DISPLAY_STATUS *di;
43
44
di = ArcGetDisplayStatus(1);
45
46
if (di) {
47
si.orig_x = di->CursorXPosition;
48
si.orig_y = di->CursorYPosition;
49
si.orig_video_cols = di->CursorMaxXPosition;
50
si.orig_video_lines = di->CursorMaxYPosition;
51
si.orig_video_isVGA = VIDEO_TYPE_VGAC;
52
si.orig_video_points = 16;
53
54
vgacon_register_screen(&si);
55
}
56
#endif
57
}
58
59
static void __init sni_console_setup(void)
60
{
61
#ifndef CONFIG_FW_ARC
62
char *ctype;
63
char *cdev;
64
char *baud;
65
int port;
66
static char options[8] __initdata;
67
68
cdev = prom_getenv("console_dev");
69
if (strncmp(cdev, "tty", 3) == 0) {
70
ctype = prom_getenv("console");
71
switch (*ctype) {
72
default:
73
case 'l':
74
port = 0;
75
baud = prom_getenv("lbaud");
76
break;
77
case 'r':
78
port = 1;
79
baud = prom_getenv("rbaud");
80
break;
81
}
82
if (baud)
83
strcpy(options, baud);
84
if (strncmp(cdev, "tty552", 6) == 0)
85
add_preferred_console("ttyS", port,
86
baud ? options : NULL);
87
else
88
add_preferred_console("ttySC", port,
89
baud ? options : NULL);
90
}
91
#endif
92
}
93
94
#ifdef DEBUG
95
static void __init sni_idprom_dump(void)
96
{
97
int i;
98
99
pr_debug("SNI IDProm dump:\n");
100
for (i = 0; i < 256; i++) {
101
if (i%16 == 0)
102
pr_debug("%04x ", i);
103
104
printk("%02x ", *(unsigned char *) (SNI_IDPROM_BASE + i));
105
106
if (i % 16 == 15)
107
printk("\n");
108
}
109
}
110
#endif
111
112
void __init plat_mem_setup(void)
113
{
114
int cputype;
115
116
set_io_port_base(SNI_PORT_BASE);
117
// ioport_resource.end = sni_io_resource.end;
118
119
/*
120
* Setup (E)ISA I/O memory access stuff
121
*/
122
#ifdef CONFIG_EISA
123
EISA_bus = 1;
124
#endif
125
126
sni_brd_type = *(unsigned char *)SNI_IDPROM_BRDTYPE;
127
cputype = *(unsigned char *)SNI_IDPROM_CPUTYPE;
128
switch (sni_brd_type) {
129
case SNI_BRD_TOWER_OASIC:
130
switch (cputype) {
131
case SNI_CPU_M8030:
132
system_type = "RM400-330";
133
break;
134
case SNI_CPU_M8031:
135
system_type = "RM400-430";
136
break;
137
case SNI_CPU_M8037:
138
system_type = "RM400-530";
139
break;
140
case SNI_CPU_M8034:
141
system_type = "RM400-730";
142
break;
143
default:
144
system_type = "RM400-xxx";
145
break;
146
}
147
break;
148
case SNI_BRD_MINITOWER:
149
switch (cputype) {
150
case SNI_CPU_M8021:
151
case SNI_CPU_M8043:
152
system_type = "RM400-120";
153
break;
154
case SNI_CPU_M8040:
155
system_type = "RM400-220";
156
break;
157
case SNI_CPU_M8053:
158
system_type = "RM400-225";
159
break;
160
case SNI_CPU_M8050:
161
system_type = "RM400-420";
162
break;
163
default:
164
system_type = "RM400-xxx";
165
break;
166
}
167
break;
168
case SNI_BRD_PCI_TOWER:
169
system_type = "RM400-Cxx";
170
break;
171
case SNI_BRD_RM200:
172
system_type = "RM200-xxx";
173
break;
174
case SNI_BRD_PCI_MTOWER:
175
system_type = "RM300-Cxx";
176
break;
177
case SNI_BRD_PCI_DESKTOP:
178
switch (read_c0_prid() & PRID_IMP_MASK) {
179
case PRID_IMP_R4600:
180
case PRID_IMP_R4700:
181
system_type = "RM200-C20";
182
break;
183
case PRID_IMP_R5000:
184
system_type = "RM200-C40";
185
break;
186
default:
187
system_type = "RM200-Cxx";
188
break;
189
}
190
break;
191
case SNI_BRD_PCI_TOWER_CPLUS:
192
system_type = "RM400-Exx";
193
break;
194
case SNI_BRD_PCI_MTOWER_CPLUS:
195
system_type = "RM300-Exx";
196
break;
197
}
198
pr_debug("Found SNI brdtype %02x name %s\n", sni_brd_type, system_type);
199
200
#ifdef DEBUG
201
sni_idprom_dump();
202
#endif
203
204
switch (sni_brd_type) {
205
case SNI_BRD_10:
206
case SNI_BRD_10NEW:
207
case SNI_BRD_TOWER_OASIC:
208
case SNI_BRD_MINITOWER:
209
sni_a20r_init();
210
break;
211
212
case SNI_BRD_PCI_TOWER:
213
case SNI_BRD_PCI_TOWER_CPLUS:
214
sni_pcit_init();
215
break;
216
217
case SNI_BRD_RM200:
218
sni_rm200_init();
219
break;
220
221
case SNI_BRD_PCI_MTOWER:
222
case SNI_BRD_PCI_DESKTOP:
223
case SNI_BRD_PCI_MTOWER_CPLUS:
224
sni_pcimt_init();
225
break;
226
}
227
228
_machine_restart = sni_machine_restart;
229
pm_power_off = sni_machine_power_off;
230
231
sni_display_setup();
232
sni_console_setup();
233
}
234
235
#ifdef CONFIG_PCI
236
237
#include <linux/pci.h>
238
#include <video/vga.h>
239
#include <video/cirrus.h>
240
241
static void quirk_cirrus_ram_size(struct pci_dev *dev)
242
{
243
u16 cmd;
244
245
/*
246
* firmware doesn't set the ram size correct, so we
247
* need to do it here, otherwise we get screen corruption
248
* on older Cirrus chips
249
*/
250
pci_read_config_word(dev, PCI_COMMAND, &cmd);
251
if ((cmd & (PCI_COMMAND_IO|PCI_COMMAND_MEMORY))
252
== (PCI_COMMAND_IO|PCI_COMMAND_MEMORY)) {
253
vga_wseq(NULL, CL_SEQR6, 0x12); /* unlock all extension registers */
254
vga_wseq(NULL, CL_SEQRF, 0x18);
255
}
256
}
257
258
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5434_8,
259
quirk_cirrus_ram_size);
260
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5436,
261
quirk_cirrus_ram_size);
262
DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CIRRUS, PCI_DEVICE_ID_CIRRUS_5446,
263
quirk_cirrus_ram_size);
264
#endif
265
266