ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / ppc / platforms / mvme5100_setup.c
1 /*
2  * arch/ppc/platforms/mvme5100_setup.c
3  *
4  * Board setup routines for the Motorola MVME5100.
5  *
6  * Author: Matt Porter <mporter@mvista.com>
7  *
8  * 2001 (c) MontaVista, Software, Inc.  This file is licensed under
9  * the terms of the GNU General Public License version 2.  This program
10  * is licensed "as is" without any warranty of any kind, whether express
11  * or implied.
12  */
13
14 #include <linux/config.h>
15 #include <linux/stddef.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/errno.h>
19 #include <linux/reboot.h>
20 #include <linux/pci.h>
21 #include <linux/kdev_t.h>
22 #include <linux/major.h>
23 #include <linux/initrd.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/irq.h>
27 #include <linux/ide.h>
28 #include <linux/seq_file.h>
29 #include <linux/root_dev.h>
30
31 #include <asm/system.h>
32 #include <asm/pgtable.h>
33 #include <asm/page.h>
34 #include <asm/time.h>
35 #include <asm/dma.h>
36 #include <asm/io.h>
37 #include <asm/machdep.h>
38 #include <asm/prom.h>
39 #include <asm/smp.h>
40 #include <asm/open_pic.h>
41 #include <asm/i8259.h>
42 #include <platforms/mvme5100.h>
43 #include <asm/todc.h>
44 #include <asm/pci-bridge.h>
45 #include <asm/bootinfo.h>
46 #include <asm/pplus.h>
47
48 extern char cmd_line[];
49
50 static u_char mvme5100_openpic_initsenses[] __initdata = {
51         0,      /* 16: i8259 cascade (active high) */
52         1,      /* 17: TL16C550 UART 1,2 */
53         1,      /* 18: Enet 1 (front panel or P2) */
54         1,      /* 19: Hawk Watchdog 1,2 */
55         1,      /* 20: DS1621 thermal alarm */
56         1,      /* 21: Universe II LINT0# */
57         1,      /* 22: Universe II LINT1# */
58         1,      /* 23: Universe II LINT2# */
59         1,      /* 24: Universe II LINT3# */
60         1,      /* 25: PMC1 INTA#, PMC2 INTB# */
61         1,      /* 26: PMC1 INTB#, PMC2 INTC# */
62         1,      /* 27: PMC1 INTC#, PMC2 INTD# */
63         1,      /* 28: PMC1 INTD#, PMC2 INTA# */
64         1,      /* 29: Enet 2 (front panel) */
65         1,      /* 30: Abort Switch */
66         1,      /* 31: RTC Alarm */
67 };
68
69 static void __init
70 mvme5100_setup_arch(void)
71 {
72         if ( ppc_md.progress )
73                 ppc_md.progress("mvme5100_setup_arch: enter", 0);
74
75         loops_per_jiffy = 50000000 / HZ;
76
77 #ifdef CONFIG_BLK_DEV_INITRD
78         if (initrd_start)
79                 ROOT_DEV = Root_RAM0;
80         else
81 #endif
82 #ifdef  CONFIG_ROOT_NFS
83                 ROOT_DEV = Root_NFS;
84 #else
85                 ROOT_DEV = Root_SDA2;
86 #endif
87
88 #ifdef CONFIG_DUMMY_CONSOLE
89         conswitchp = &dummy_con;
90 #endif
91
92         if ( ppc_md.progress )
93                 ppc_md.progress("mvme5100_setup_arch: find_bridges", 0);
94
95         /* Setup PCI host bridge */
96         mvme5100_setup_bridge();
97
98         /* Find and map our OpenPIC */
99         pplus_mpic_init(MVME5100_PCI_MEM_OFFSET);
100         OpenPIC_InitSenses = mvme5100_openpic_initsenses;
101         OpenPIC_NumInitSenses = sizeof(mvme5100_openpic_initsenses);
102
103         printk("MVME5100 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
104
105         if ( ppc_md.progress )
106                 ppc_md.progress("mvme5100_setup_arch: exit", 0);
107
108         return;
109 }
110
111 static void __init
112 mvme5100_init2(void)
113 {
114 #ifdef CONFIG_MVME5100_IPMC761_PRESENT
115                 request_region(0x00,0x20,"dma1");
116                 request_region(0x20,0x20,"pic1");
117                 request_region(0x40,0x20,"timer");
118                 request_region(0x80,0x10,"dma page reg");
119                 request_region(0xa0,0x20,"pic2");
120                 request_region(0xc0,0x20,"dma2");
121 #endif
122         return;
123 }
124
125 /*
126  * Interrupt setup and service.
127  * Have MPIC on HAWK and cascaded 8259s on Winbond cascaded to MPIC.
128  */
129 static void __init
130 mvme5100_init_IRQ(void)
131 {
132 #ifdef CONFIG_MVME5100_IPMC761_PRESENT
133         int i;
134 #endif
135
136         if ( ppc_md.progress )
137                 ppc_md.progress("init_irq: enter", 0);
138
139 #ifdef CONFIG_MVME5100_IPMC761_PRESENT
140         openpic_init(1, NUM_8259_INTERRUPTS, NULL, -1);
141         openpic_hookup_cascade(NUM_8259_INTERRUPTS,"82c59 cascade",&i8259_irq);
142
143         for(i=0; i < NUM_8259_INTERRUPTS; i++)
144                 irq_desc[i].handler = &i8259_pic;
145
146         i8259_init(NULL);
147 #else
148         openpic_init(1, 0, NULL, -1);
149 #endif
150
151         if ( ppc_md.progress )
152                 ppc_md.progress("init_irq: exit", 0);
153
154         return;
155 }
156
157 /*
158  * Set BAT 3 to map 0xf0000000 to end of physical memory space.
159  */
160 static __inline__ void
161 mvme5100_set_bat(void)
162 {
163         unsigned long bat3u, bat3l;
164         static int mapping_set = 0;
165
166         if (!mapping_set) {
167
168                 __asm__ __volatile__(
169                 " lis %0,0xf000\n \
170                   ori %1,%0,0x002a\n \
171                   ori %0,%0,0x1ffe\n \
172                   mtspr 0x21e,%0\n \
173                   mtspr 0x21f,%1\n \
174                   isync\n \
175                   sync "
176                 : "=r" (bat3u), "=r" (bat3l));
177
178                 mapping_set = 1;
179         }
180
181         return;
182 }
183
184 static unsigned long __init
185 mvme5100_find_end_of_memory(void)
186 {
187         mvme5100_set_bat();
188         return pplus_get_mem_size(MVME5100_HAWK_SMC_BASE);
189 }
190
191 static void __init
192 mvme5100_map_io(void)
193 {
194         io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
195         ioremap_base = 0xfe000000;
196 }
197
198 static void
199 mvme5100_reset_board(void)
200 {
201         local_irq_disable();
202
203         /* Set exception prefix high - to the firmware */
204         _nmask_and_or_msr(0, MSR_IP);
205
206         out_8((u_char *)MVME5100_BOARD_MODRST_REG, 0x01);
207
208         return;
209 }
210
211 static void
212 mvme5100_restart(char *cmd)
213 {
214         volatile ulong i = 10000000;
215
216         mvme5100_reset_board();
217
218         while (i-- > 0);
219         panic("restart failed\n");
220 }
221
222 static void
223 mvme5100_halt(void)
224 {
225         local_irq_disable();
226         while (1);
227 }
228
229 static void
230 mvme5100_power_off(void)
231 {
232         mvme5100_halt();
233 }
234
235 static int
236 mvme5100_show_cpuinfo(struct seq_file *m)
237 {
238         seq_printf(m, "vendor\t\t: Motorola\n");
239         seq_printf(m, "machine\t\t: MVME5100\n");
240
241         return 0;
242 }
243
244 TODC_ALLOC();
245
246 void __init
247 platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
248               unsigned long r6, unsigned long r7)
249 {
250         parse_bootinfo(find_bootinfo());
251
252         isa_io_base = MVME5100_ISA_IO_BASE;
253         isa_mem_base = MVME5100_ISA_MEM_BASE;
254         pci_dram_offset = MVME5100_PCI_DRAM_OFFSET;
255
256         ppc_md.setup_arch = mvme5100_setup_arch;
257         ppc_md.show_cpuinfo = mvme5100_show_cpuinfo;
258         ppc_md.init_IRQ = mvme5100_init_IRQ;
259         ppc_md.get_irq = openpic_get_irq;
260         ppc_md.init = mvme5100_init2;
261
262         ppc_md.restart = mvme5100_restart;
263         ppc_md.power_off = mvme5100_power_off;
264         ppc_md.halt = mvme5100_halt;
265
266         ppc_md.find_end_of_memory = mvme5100_find_end_of_memory;
267         ppc_md.setup_io_mappings = mvme5100_map_io;
268
269         TODC_INIT(TODC_TYPE_MK48T37,
270                   MVME5100_NVRAM_AS0,
271                   MVME5100_NVRAM_AS1,
272                   MVME5100_NVRAM_DATA,
273                   8);
274
275         ppc_md.time_init = todc_time_init;
276         ppc_md.set_rtc_time = todc_set_rtc_time;
277         ppc_md.get_rtc_time = todc_get_rtc_time;
278         ppc_md.calibrate_decr = todc_calibrate_decr;
279
280         ppc_md.nvram_read_val = todc_m48txx_read_val;
281         ppc_md.nvram_write_val = todc_m48txx_write_val;
282
283         ppc_md.progress = NULL;
284 }