blob: afeb7f13e5b50a2f290bce79f5209b901fb36bfc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Ralf Baechlefcdb27a2006-01-18 17:37:07 +00008 * Copyright (C) 1996, 97, 98, 2000, 03, 04, 06 Ralf Baechle (ralf@linux-mips.org)
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/eisa.h>
11#include <linux/hdreg.h>
12#include <linux/ioport.h>
13#include <linux/sched.h>
14#include <linux/init.h>
15#include <linux/interrupt.h>
16#include <linux/mc146818rtc.h>
Ralf Baechlefcdb27a2006-01-18 17:37:07 +000017#include <linux/pm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/pci.h>
19#include <linux/console.h>
20#include <linux/fb.h>
Jon Smirl894673e2006-07-10 04:44:13 -070021#include <linux/screen_info.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Thomas Bogendoerfer4a0312f2006-06-13 13:59:01 +020023#ifdef CONFIG_ARC
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/arc/types.h>
25#include <asm/sgialib.h>
Thomas Bogendoerfer4a0312f2006-06-13 13:59:01 +020026#endif
27
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/bcache.h>
29#include <asm/bootinfo.h>
30#include <asm/io.h>
31#include <asm/irq.h>
32#include <asm/mc146818-time.h>
33#include <asm/processor.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/reboot.h>
35#include <asm/sni.h>
36#include <asm/time.h>
37#include <asm/traps.h>
38
39extern void sni_machine_restart(char *command);
40extern void sni_machine_halt(void);
41extern void sni_machine_power_off(void);
42
Ralf Baechle54d0a212006-07-09 21:38:56 +010043void __init plat_timer_setup(struct irqaction *irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -070044{
45 /* set the clock to 100 Hz */
46 outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
47 outb_p(LATCH & 0xff , 0x40); /* LSB */
48 outb(LATCH >> 8 , 0x40); /* MSB */
49 setup_irq(0, irq);
50}
51
52/*
53 * A bit more gossip about the iron we're running on ...
54 */
55static inline void sni_pcimt_detect(void)
56{
57 char boardtype[80];
58 unsigned char csmsr;
59 char *p = boardtype;
60 unsigned int asic;
61
62 csmsr = *(volatile unsigned char *)PCIMT_CSMSR;
63
64 p += sprintf(p, "%s PCI", (csmsr & 0x80) ? "RM200" : "RM300");
65 if ((csmsr & 0x80) == 0)
66 p += sprintf(p, ", board revision %s",
67 (csmsr & 0x20) ? "D" : "C");
68 asic = csmsr & 0x80;
69 asic = (csmsr & 0x08) ? asic : !asic;
70 p += sprintf(p, ", ASIC PCI Rev %s", asic ? "1.0" : "1.1");
71 printk("%s.\n", boardtype);
72}
73
74static void __init sni_display_setup(void)
75{
Thomas Bogendoerfer4a0312f2006-06-13 13:59:01 +020076#if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) && defined(CONFIG_ARC)
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 struct screen_info *si = &screen_info;
78 DISPLAY_STATUS *di;
79
80 di = ArcGetDisplayStatus(1);
81
82 if (di) {
83 si->orig_x = di->CursorXPosition;
84 si->orig_y = di->CursorYPosition;
85 si->orig_video_cols = di->CursorMaxXPosition;
86 si->orig_video_lines = di->CursorMaxYPosition;
87 si->orig_video_isVGA = VIDEO_TYPE_VGAC;
88 si->orig_video_points = 16;
89 }
90#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070091}
92
93static struct resource sni_io_resource = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -070094 .start = 0x00001000UL,
95 .end = 0x03bfffffUL,
96 .name = "PCIMT IO MEM",
97 .flags = IORESOURCE_IO,
Linus Torvalds1da177e2005-04-16 15:20:36 -070098};
99
100static struct resource pcimt_io_resources[] = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -0700101 {
102 .start = 0x00,
103 .end = 0x1f,
104 .name = "dma1",
105 .flags = IORESOURCE_BUSY
106 }, {
107 .start = 0x40,
108 .end = 0x5f,
109 .name = "timer",
110 .flags = IORESOURCE_BUSY
111 }, {
112 .start = 0x60,
113 .end = 0x6f,
114 .name = "keyboard",
115 .flags = IORESOURCE_BUSY
116 }, {
117 .start = 0x80,
118 .end = 0x8f,
119 .name = "dma page reg",
120 .flags = IORESOURCE_BUSY
121 }, {
122 .start = 0xc0,
123 .end = 0xdf,
124 .name = "dma2",
125 .flags = IORESOURCE_BUSY
126 }, {
127 .start = 0xcfc,
128 .end = 0xcff,
129 .name = "PCI config data",
130 .flags = IORESOURCE_BUSY
131 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132};
133
134static struct resource sni_mem_resource = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -0700135 .start = 0x10000000UL,
136 .end = 0xffffffffUL,
137 .name = "PCIMT PCI MEM",
138 .flags = IORESOURCE_MEM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139};
140
141/*
142 * The RM200/RM300 has a few holes in it's PCI/EISA memory address space used
143 * for other purposes. Be paranoid and allocate all of the before the PCI
144 * code gets a chance to to map anything else there ...
Ralf Baechle42a3b4f2005-09-03 15:56:17 -0700145 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 * This leaves the following areas available:
147 *
148 * 0x10000000 - 0x1009ffff (640kB) PCI/EISA/ISA Bus Memory
149 * 0x10100000 - 0x13ffffff ( 15MB) PCI/EISA/ISA Bus Memory
150 * 0x18000000 - 0x1fbfffff (124MB) PCI/EISA Bus Memory
151 * 0x1ff08000 - 0x1ffeffff (816kB) PCI/EISA Bus Memory
152 * 0xa0000000 - 0xffffffff (1.5GB) PCI/EISA Bus Memory
153 */
154static struct resource pcimt_mem_resources[] = {
Ralf Baechle5e46c3a2006-06-04 15:14:05 -0700155 {
156 .start = 0x100a0000,
157 .end = 0x100bffff,
158 .name = "Video RAM area",
159 .flags = IORESOURCE_BUSY
160 }, {
161 .start = 0x100c0000,
162 .end = 0x100fffff,
163 .name = "ISA Reserved",
164 .flags = IORESOURCE_BUSY
165 }, {
166 .start = 0x14000000,
167 .end = 0x17bfffff,
168 .name = "PCI IO",
169 .flags = IORESOURCE_BUSY
170 }, {
171 .start = 0x17c00000,
172 .end = 0x17ffffff,
173 .name = "Cache Replacement Area",
174 .flags = IORESOURCE_BUSY
175 }, {
176 .start = 0x1a000000,
177 .end = 0x1a000003,
178 .name = "PCI INT Acknowledge",
179 .flags = IORESOURCE_BUSY
180 }, {
181 .start = 0x1fc00000,
182 .end = 0x1fc7ffff,
183 .name = "Boot PROM",
184 .flags = IORESOURCE_BUSY
185 }, {
186 .start = 0x1fc80000,
187 .end = 0x1fcfffff,
188 .name = "Diag PROM",
189 .flags = IORESOURCE_BUSY
190 }, {
191 .start = 0x1fd00000,
192 .end = 0x1fdfffff,
193 .name = "X-Bus",
194 .flags = IORESOURCE_BUSY
195 }, {
196 .start = 0x1fe00000,
197 .end = 0x1fefffff,
198 .name = "BIOS map",
199 .flags = IORESOURCE_BUSY
200 }, {
201 .start = 0x1ff00000,
202 .end = 0x1ff7ffff,
203 .name = "NVRAM / EEPROM",
204 .flags = IORESOURCE_BUSY
205 }, {
206 .start = 0x1fff0000,
207 .end = 0x1fffefff,
208 .name = "ASIC PCI",
209 .flags = IORESOURCE_BUSY
210 }, {
211 .start = 0x1ffff000,
212 .end = 0x1fffffff,
213 .name = "MP Agent",
214 .flags = IORESOURCE_BUSY
215 }, {
216 .start = 0x20000000,
217 .end = 0x9fffffff,
218 .name = "Main Memory",
219 .flags = IORESOURCE_BUSY
220 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221};
222
223static void __init sni_resource_init(void)
224{
225 int i;
226
227 /* request I/O space for devices used on all i[345]86 PCs */
228 for (i = 0; i < ARRAY_SIZE(pcimt_io_resources); i++)
229 request_resource(&ioport_resource, pcimt_io_resources + i);
230
231 /* request mem space for pcimt-specific devices */
232 for (i = 0; i < ARRAY_SIZE(pcimt_mem_resources); i++)
233 request_resource(&sni_mem_resource, pcimt_mem_resources + i);
234
235 ioport_resource.end = sni_io_resource.end;
236}
237
238extern struct pci_ops sni_pci_ops;
239
240static struct pci_controller sni_controller = {
241 .pci_ops = &sni_pci_ops,
242 .mem_resource = &sni_mem_resource,
243 .mem_offset = 0x10000000UL,
244 .io_resource = &sni_io_resource,
245 .io_offset = 0x00000000UL
246};
247
248static inline void sni_pcimt_time_init(void)
249{
Yoichi Yuasad23ee8f2006-03-27 01:16:33 -0800250 rtc_mips_get_time = mc146818_get_cmos_time;
251 rtc_mips_set_time = mc146818_set_rtc_mmss;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252}
253
Ralf Baechle2925aba2006-06-18 01:32:22 +0100254void __init plat_mem_setup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255{
256 sni_pcimt_detect();
257 sni_pcimt_sc_init();
258 sni_pcimt_time_init();
259
260 set_io_port_base(SNI_PORT_BASE);
261 ioport_resource.end = sni_io_resource.end;
262
263 /*
264 * Setup (E)ISA I/O memory access stuff
265 */
266 isa_slot_offset = 0xb0000000;
267#ifdef CONFIG_EISA
268 EISA_bus = 1;
269#endif
270
271 sni_resource_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 _machine_restart = sni_machine_restart;
274 _machine_halt = sni_machine_halt;
Ralf Baechlefcdb27a2006-01-18 17:37:07 +0000275 pm_power_off = sni_machine_power_off;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276
277 sni_display_setup();
278
279#ifdef CONFIG_PCI
280 register_pci_controller(&sni_controller);
281#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282}