1 |
1275 |
phoenix |
/*
|
2 |
|
|
* arch/mips/ddb5476/setup.c -- NEC DDB Vrc-5476 setup routines
|
3 |
|
|
*
|
4 |
|
|
* Copyright (C) 2000 Geert Uytterhoeven <geert@sonycom.com>
|
5 |
|
|
* Sony Software Development Center Europe (SDCE), Brussels
|
6 |
|
|
*/
|
7 |
|
|
#include <linux/config.h>
|
8 |
|
|
#include <linux/init.h>
|
9 |
|
|
#include <linux/kbd_ll.h>
|
10 |
|
|
#include <linux/kernel.h>
|
11 |
|
|
#include <linux/kdev_t.h>
|
12 |
|
|
#include <linux/types.h>
|
13 |
|
|
#include <linux/console.h>
|
14 |
|
|
#include <linux/sched.h>
|
15 |
|
|
#include <linux/mc146818rtc.h>
|
16 |
|
|
#include <linux/pc_keyb.h>
|
17 |
|
|
#include <linux/pci.h>
|
18 |
|
|
#include <linux/ide.h>
|
19 |
|
|
|
20 |
|
|
#include <asm/addrspace.h>
|
21 |
|
|
#include <asm/bcache.h>
|
22 |
|
|
#include <asm/keyboard.h>
|
23 |
|
|
#include <asm/irq.h>
|
24 |
|
|
#include <asm/reboot.h>
|
25 |
|
|
#include <asm/gdb-stub.h>
|
26 |
|
|
#include <asm/time.h>
|
27 |
|
|
#include <asm/debug.h>
|
28 |
|
|
#include <asm/traps.h>
|
29 |
|
|
|
30 |
|
|
#include <asm/ddb5xxx/ddb5xxx.h>
|
31 |
|
|
|
32 |
|
|
// #define USE_CPU_COUNTER_TIMER /* whether we use cpu counter */
|
33 |
|
|
|
34 |
|
|
#ifdef USE_CPU_COUNTER_TIMER
|
35 |
|
|
|
36 |
|
|
#define CPU_COUNTER_FREQUENCY 83000000
|
37 |
|
|
#else
|
38 |
|
|
/* otherwise we use general purpose timer */
|
39 |
|
|
#define TIMER_FREQUENCY 83000000
|
40 |
|
|
#define TIMER_BASE DDB_T2CTRL
|
41 |
|
|
#define TIMER_IRQ (VRC5476_IRQ_BASE + VRC5476_IRQ_GPT)
|
42 |
|
|
#endif
|
43 |
|
|
|
44 |
|
|
#ifdef CONFIG_KGDB
|
45 |
|
|
extern void breakpoint(void);
|
46 |
|
|
#endif
|
47 |
|
|
|
48 |
|
|
extern struct ide_ops std_ide_ops;
|
49 |
|
|
extern struct kbd_ops std_kbd_ops;
|
50 |
|
|
|
51 |
|
|
static void (*back_to_prom) (void) = (void (*)(void)) 0xbfc00000;
|
52 |
|
|
|
53 |
|
|
static void ddb_machine_restart(char *command)
|
54 |
|
|
{
|
55 |
|
|
u32 t;
|
56 |
|
|
|
57 |
|
|
/* PCI cold reset */
|
58 |
|
|
t = ddb_in32(DDB_PCICTRL + 4);
|
59 |
|
|
t |= 0x40000000;
|
60 |
|
|
ddb_out32(DDB_PCICTRL + 4, t);
|
61 |
|
|
/* CPU cold reset */
|
62 |
|
|
t = ddb_in32(DDB_CPUSTAT);
|
63 |
|
|
t |= 1;
|
64 |
|
|
ddb_out32(DDB_CPUSTAT, t);
|
65 |
|
|
/* Call the PROM */
|
66 |
|
|
back_to_prom();
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
static void ddb_machine_halt(void)
|
70 |
|
|
{
|
71 |
|
|
printk(KERN_NOTICE "DDB Vrc-5476 halted.\n");
|
72 |
|
|
while (1);
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
static void ddb_machine_power_off(void)
|
76 |
|
|
{
|
77 |
|
|
printk(KERN_NOTICE "DDB Vrc-5476 halted. Please turn off the power.\n");
|
78 |
|
|
while (1);
|
79 |
|
|
}
|
80 |
|
|
|
81 |
|
|
extern void ddb_irq_setup(void);
|
82 |
|
|
extern void rtc_ds1386_init(unsigned long base);
|
83 |
|
|
|
84 |
|
|
static void __init ddb_time_init(void)
|
85 |
|
|
{
|
86 |
|
|
#if defined(USE_CPU_COUNTER_TIMER)
|
87 |
|
|
mips_hpt_frequency = CPU_COUNTER_FREQUENCY;
|
88 |
|
|
#endif
|
89 |
|
|
|
90 |
|
|
/* we have ds1396 RTC chip */
|
91 |
|
|
rtc_ds1386_init(KSEG1ADDR(DDB_PCI_MEM_BASE));
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
extern int setup_irq(unsigned int irq, struct irqaction *irqaction);
|
96 |
|
|
static void __init ddb_timer_setup(struct irqaction *irq)
|
97 |
|
|
{
|
98 |
|
|
#if defined(USE_CPU_COUNTER_TIMER)
|
99 |
|
|
|
100 |
|
|
unsigned int count;
|
101 |
|
|
|
102 |
|
|
/* we are using the cpu counter for timer interrupts */
|
103 |
|
|
setup_irq(CPU_IRQ_BASE + 7, irq);
|
104 |
|
|
|
105 |
|
|
/* to generate the first timer interrupt */
|
106 |
|
|
count = read_c0_count();
|
107 |
|
|
write_c0_compare(count + 1000);
|
108 |
|
|
|
109 |
|
|
#else
|
110 |
|
|
|
111 |
|
|
ddb_out32(TIMER_BASE, TIMER_FREQUENCY/HZ);
|
112 |
|
|
ddb_out32(TIMER_BASE+4, 0x1); /* enable timer */
|
113 |
|
|
setup_irq(TIMER_IRQ, irq);
|
114 |
|
|
#endif
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
static struct {
|
118 |
|
|
struct resource dma1;
|
119 |
|
|
struct resource pic1;
|
120 |
|
|
struct resource timer;
|
121 |
|
|
struct resource rtc;
|
122 |
|
|
struct resource dma_page_reg;
|
123 |
|
|
struct resource pic2;
|
124 |
|
|
struct resource dma2;
|
125 |
|
|
} ddb5476_ioport = {
|
126 |
|
|
{
|
127 |
|
|
"dma1", 0x00, 0x1f, IORESOURCE_BUSY}, {
|
128 |
|
|
"pic1", 0x20, 0x3f, IORESOURCE_BUSY}, {
|
129 |
|
|
"timer", 0x40, 0x5f, IORESOURCE_BUSY}, {
|
130 |
|
|
"rtc", 0x70, 0x7f, IORESOURCE_BUSY}, {
|
131 |
|
|
"dma page reg", 0x80, 0x8f, IORESOURCE_BUSY}, {
|
132 |
|
|
"pic2", 0xa0, 0xbf, IORESOURCE_BUSY}, {
|
133 |
|
|
"dma2", 0xc0, 0xdf, IORESOURCE_BUSY}
|
134 |
|
|
};
|
135 |
|
|
|
136 |
|
|
static struct {
|
137 |
|
|
struct resource nile4;
|
138 |
|
|
} ddb5476_iomem = {
|
139 |
|
|
{ "Nile 4", DDB_BASE, DDB_BASE + DDB_SIZE - 1, IORESOURCE_BUSY}
|
140 |
|
|
};
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
static void ddb5476_board_init(void);
|
144 |
|
|
extern void ddb5476_irq_setup(void);
|
145 |
|
|
extern void (*irq_setup)(void);
|
146 |
|
|
|
147 |
|
|
void __init
|
148 |
|
|
ddb_setup(void)
|
149 |
|
|
{
|
150 |
|
|
extern int panic_timeout;
|
151 |
|
|
|
152 |
|
|
irq_setup = ddb5476_irq_setup;
|
153 |
|
|
set_io_port_base(KSEG1ADDR(DDB_PCI_IO_BASE));
|
154 |
|
|
|
155 |
|
|
board_time_init = ddb_time_init;
|
156 |
|
|
board_timer_setup = ddb_timer_setup;
|
157 |
|
|
|
158 |
|
|
_machine_restart = ddb_machine_restart;
|
159 |
|
|
_machine_halt = ddb_machine_halt;
|
160 |
|
|
_machine_power_off = ddb_machine_power_off;
|
161 |
|
|
|
162 |
|
|
/* request io port/mem resources */
|
163 |
|
|
if (request_resource(&ioport_resource, &ddb5476_ioport.dma1) ||
|
164 |
|
|
request_resource(&ioport_resource, &ddb5476_ioport.pic1) ||
|
165 |
|
|
request_resource(&ioport_resource, &ddb5476_ioport.timer) ||
|
166 |
|
|
request_resource(&ioport_resource, &ddb5476_ioport.rtc) ||
|
167 |
|
|
request_resource(&ioport_resource,
|
168 |
|
|
&ddb5476_ioport.dma_page_reg)
|
169 |
|
|
|| request_resource(&ioport_resource, &ddb5476_ioport.pic2)
|
170 |
|
|
|| request_resource(&ioport_resource, &ddb5476_ioport.dma2)
|
171 |
|
|
|| request_resource(&iomem_resource, &ddb5476_iomem.nile4)) {
|
172 |
|
|
printk
|
173 |
|
|
("ddb_setup - requesting oo port resources failed.\n");
|
174 |
|
|
for (;;);
|
175 |
|
|
}
|
176 |
|
|
#ifdef CONFIG_BLK_DEV_IDE
|
177 |
|
|
ide_ops = &std_ide_ops;
|
178 |
|
|
#endif
|
179 |
|
|
|
180 |
|
|
#ifdef CONFIG_PC_KEYB
|
181 |
|
|
kbd_ops = &std_kbd_ops;
|
182 |
|
|
#endif
|
183 |
|
|
|
184 |
|
|
/* Reboot on panic */
|
185 |
|
|
panic_timeout = 180;
|
186 |
|
|
|
187 |
|
|
/* [jsun] we need to set BAR0 so that SDRAM 0 appears at 0x0 in PCI */
|
188 |
|
|
/* *(long*)0xbfa00218 = 0x8; */
|
189 |
|
|
|
190 |
|
|
#ifdef CONFIG_FB
|
191 |
|
|
conswitchp = &dummy_con;
|
192 |
|
|
#endif
|
193 |
|
|
|
194 |
|
|
/* board initialization stuff */
|
195 |
|
|
ddb5476_board_init();
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
/*
|
199 |
|
|
* We don't trust bios. We essentially does hardware re-initialization
|
200 |
|
|
* as complete as possible, as far as we know we can safely do.
|
201 |
|
|
*/
|
202 |
|
|
static void
|
203 |
|
|
ddb5476_board_init(void)
|
204 |
|
|
{
|
205 |
|
|
/* ----------- setup PDARs ------------ */
|
206 |
|
|
/* check SDRAM0, whether we are on MEM bus does not matter */
|
207 |
|
|
db_assert((ddb_in32(DDB_SDRAM0) & 0xffffffef) ==
|
208 |
|
|
ddb_calc_pdar(DDB_SDRAM_BASE, DDB_SDRAM_SIZE, 32, 0, 1));
|
209 |
|
|
|
210 |
|
|
/* SDRAM1 should be turned off. What is this for anyway ? */
|
211 |
|
|
db_assert( (ddb_in32(DDB_SDRAM1) & 0xf) == 0);
|
212 |
|
|
|
213 |
|
|
/* flash 1&2, DDB status, DDB control */
|
214 |
|
|
ddb_set_pdar(DDB_DCS2, DDB_DCS2_BASE, DDB_DCS2_SIZE, 16, 0, 0);
|
215 |
|
|
ddb_set_pdar(DDB_DCS3, DDB_DCS3_BASE, DDB_DCS3_SIZE, 16, 0, 0);
|
216 |
|
|
ddb_set_pdar(DDB_DCS4, DDB_DCS4_BASE, DDB_DCS4_SIZE, 8, 0, 0);
|
217 |
|
|
ddb_set_pdar(DDB_DCS5, DDB_DCS5_BASE, DDB_DCS5_SIZE, 8, 0, 0);
|
218 |
|
|
|
219 |
|
|
/* shut off other pdar so they don't accidentally get into the way */
|
220 |
|
|
ddb_set_pdar(DDB_DCS6, 0xffffffff, 0, 32, 0, 0);
|
221 |
|
|
ddb_set_pdar(DDB_DCS7, 0xffffffff, 0, 32, 0, 0);
|
222 |
|
|
ddb_set_pdar(DDB_DCS8, 0xffffffff, 0, 32, 0, 0);
|
223 |
|
|
|
224 |
|
|
/* verify VRC5477 base addr */
|
225 |
|
|
/* don't care about some details */
|
226 |
|
|
db_assert((ddb_in32(DDB_INTCS) & 0xffffff0f) ==
|
227 |
|
|
ddb_calc_pdar(DDB_INTCS_BASE, DDB_INTCS_SIZE, 8, 0, 0));
|
228 |
|
|
|
229 |
|
|
/* verify BOOT ROM addr */
|
230 |
|
|
/* don't care about some details */
|
231 |
|
|
db_assert((ddb_in32(DDB_BOOTCS) & 0xffffff0f) ==
|
232 |
|
|
ddb_calc_pdar(DDB_BOOTCS_BASE, DDB_BOOTCS_SIZE, 8, 0, 0));
|
233 |
|
|
|
234 |
|
|
/* setup PCI windows - window1 for MEM/config, window0 for IO */
|
235 |
|
|
ddb_set_pdar(DDB_PCIW0, DDB_PCI_IO_BASE, DDB_PCI_IO_SIZE, 32, 0, 1);
|
236 |
|
|
ddb_set_pmr(DDB_PCIINIT0, DDB_PCICMD_IO, 0, DDB_PCI_ACCESS_32);
|
237 |
|
|
|
238 |
|
|
ddb_set_pdar(DDB_PCIW1, DDB_PCI_MEM_BASE, DDB_PCI_MEM_SIZE, 32, 0, 1);
|
239 |
|
|
ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE, DDB_PCI_ACCESS_32);
|
240 |
|
|
|
241 |
|
|
/* ----------- setup PDARs ------------ */
|
242 |
|
|
/* this is problematic - it will reset Aladin which cause we loose
|
243 |
|
|
* serial port, and we don't know how to set up Aladin chip again.
|
244 |
|
|
*/
|
245 |
|
|
// ddb_pci_reset_bus();
|
246 |
|
|
|
247 |
|
|
ddb_out32(DDB_BAR0, 0x00000008);
|
248 |
|
|
|
249 |
|
|
ddb_out32(DDB_BARC, 0xffffffff);
|
250 |
|
|
ddb_out32(DDB_BARB, 0xffffffff);
|
251 |
|
|
ddb_out32(DDB_BAR1, 0xffffffff);
|
252 |
|
|
ddb_out32(DDB_BAR2, 0xffffffff);
|
253 |
|
|
ddb_out32(DDB_BAR3, 0xffffffff);
|
254 |
|
|
ddb_out32(DDB_BAR4, 0xffffffff);
|
255 |
|
|
ddb_out32(DDB_BAR5, 0xffffffff);
|
256 |
|
|
ddb_out32(DDB_BAR6, 0xffffffff);
|
257 |
|
|
ddb_out32(DDB_BAR7, 0xffffffff);
|
258 |
|
|
ddb_out32(DDB_BAR8, 0xffffffff);
|
259 |
|
|
|
260 |
|
|
/* ----------- switch PCI1 to PCI CONFIG space ------------ */
|
261 |
|
|
ddb_set_pdar(DDB_PCIW1, DDB_PCI_CONFIG_BASE, DDB_PCI_CONFIG_SIZE, 32, 0, 1);
|
262 |
|
|
ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_CFG, 0x0, DDB_PCI_ACCESS_32);
|
263 |
|
|
|
264 |
|
|
/* ----- M1543 PCI setup ------ */
|
265 |
|
|
|
266 |
|
|
/* we know M1543 PCI-ISA controller is at addr:18 */
|
267 |
|
|
/* xxxx1010 makes USB at addr:13 and PMU at addr:14 */
|
268 |
|
|
*(volatile unsigned char *) 0xa8040072 &= 0xf0;
|
269 |
|
|
*(volatile unsigned char *) 0xa8040072 |= 0xa;
|
270 |
|
|
|
271 |
|
|
/* setup USB interrupt to IRQ 9, (bit 0:3 - 0001)
|
272 |
|
|
* no IOCHRDY signal, (bit 7 - 1)
|
273 |
|
|
* M1543C & M7101 VID and Subsys Device ID are read-only (bit 6 - 1)
|
274 |
|
|
* Make USB Master INTAJ level to edge conversion (bit 4 - 1)
|
275 |
|
|
*/
|
276 |
|
|
*(unsigned char *) 0xa8040074 = 0xd1;
|
277 |
|
|
|
278 |
|
|
/* setup PMU(SCI to IRQ 10 (bit 0:3 - 0011)
|
279 |
|
|
* SCI routing to IRQ 13 disabled (bit 7 - 1)
|
280 |
|
|
* SCI interrupt level to edge conversion bypassed (bit 4 - 0)
|
281 |
|
|
*/
|
282 |
|
|
*(unsigned char *) 0xa8040076 = 0x83;
|
283 |
|
|
|
284 |
|
|
/* setup IDE controller
|
285 |
|
|
* enable IDE controller (bit 6 - 1)
|
286 |
|
|
* IDE IDSEL to be addr:24 (bit 4:5 - 11)
|
287 |
|
|
* no IDE ATA Secondary Bus Signal Pad Control (bit 3 - 0)
|
288 |
|
|
* no IDE ATA Primary Bus Signal Pad Control (bit 2 - 0)
|
289 |
|
|
* primary IRQ is 14, secondary is 15 (bit 1:0 - 01
|
290 |
|
|
*/
|
291 |
|
|
// *(unsigned char*)0xa8040058 = 0x71;
|
292 |
|
|
// *(unsigned char*)0xa8040058 = 0x79;
|
293 |
|
|
// *(unsigned char*)0xa8040058 = 0x74; // use SIRQ, primary tri-state
|
294 |
|
|
*(unsigned char *) 0xa8040058 = 0x75; // primary tri-state
|
295 |
|
|
|
296 |
|
|
#if 0
|
297 |
|
|
/* this is not necessary if M5229 does not use SIRQ */
|
298 |
|
|
*(unsigned char *) 0xa8040044 = 0x0d; // primary to IRQ 14
|
299 |
|
|
*(unsigned char *) 0xa8040075 = 0x0d; // secondary to IRQ 14
|
300 |
|
|
#endif
|
301 |
|
|
|
302 |
|
|
/* enable IDE in the M5229 config register 0x50 (bit 0 - 1) */
|
303 |
|
|
/* M5229 IDSEL is addr:24; see above setting */
|
304 |
|
|
*(unsigned char *) 0xa9000050 |= 0x1;
|
305 |
|
|
|
306 |
|
|
/* enable bus master (bit 2) and IO decoding (bit 0) */
|
307 |
|
|
*(unsigned char *) 0xa9000004 |= 0x5;
|
308 |
|
|
|
309 |
|
|
/* enable native, copied from arch/ppc/k2boot/head.S */
|
310 |
|
|
/* TODO - need volatile, need to be portable */
|
311 |
|
|
*(unsigned char *) 0xa9000009 = 0xff;
|
312 |
|
|
|
313 |
|
|
/* ----- end of M1543 PCI setup ------ */
|
314 |
|
|
|
315 |
|
|
/* ----- reset on-board ether chip ------ */
|
316 |
|
|
*((volatile u32 *) 0xa8020004) |= 1; /* decode I/O */
|
317 |
|
|
*((volatile u32 *) 0xa8020010) = 0; /* set BAR address */
|
318 |
|
|
|
319 |
|
|
/* send reset command */
|
320 |
|
|
*((volatile u32 *) 0xa6000000) = 1; /* do a soft reset */
|
321 |
|
|
|
322 |
|
|
/* disable ether chip */
|
323 |
|
|
*((volatile u32 *) 0xa8020004) = 0; /* disable any decoding */
|
324 |
|
|
|
325 |
|
|
/* put it into sleep */
|
326 |
|
|
*((volatile u32 *) 0xa8020040) = 0x80000000;
|
327 |
|
|
|
328 |
|
|
/* ----- end of reset on-board ether chip ------ */
|
329 |
|
|
|
330 |
|
|
/* ----------- switch PCI1 back to PCI MEM space ------------ */
|
331 |
|
|
ddb_set_pdar(DDB_PCIW1, DDB_PCI_MEM_BASE, DDB_PCI_MEM_SIZE, 32, 0, 1);
|
332 |
|
|
ddb_set_pmr(DDB_PCIINIT1, DDB_PCICMD_MEM, DDB_PCI_MEM_BASE, DDB_PCI_ACCESS_32);
|
333 |
|
|
}
|