1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/config.h>
17#include <linux/stddef.h>
18#include <linux/kernel.h>
19#include <linux/init.h>
20#include <linux/errno.h>
21#include <linux/reboot.h>
22#include <linux/pci.h>
23#include <linux/kdev_t.h>
24#include <linux/types.h>
25#include <linux/major.h>
26#include <linux/initrd.h>
27#include <linux/console.h>
28#include <linux/delay.h>
29#include <linux/irq.h>
30#include <linux/slab.h>
31#include <linux/seq_file.h>
32#include <linux/ide.h>
33#include <linux/root_dev.h>
34
35#include <asm/byteorder.h>
36#include <asm/system.h>
37#include <asm/pgtable.h>
38#include <asm/page.h>
39#include <asm/dma.h>
40#include <asm/io.h>
41#include <asm/irq.h>
42#include <asm/machdep.h>
43#include <asm/time.h>
44#include <platforms/powerpmc250.h>
45#include <asm/open_pic.h>
46#include <asm/pci-bridge.h>
47#include <asm/mpc10x.h>
48#include <asm/uaccess.h>
49#include <asm/bootinfo.h>
50
51extern void powerpmc250_find_bridges(void);
52extern unsigned long loops_per_jiffy;
53
54static u_char powerpmc250_openpic_initsenses[] __initdata =
55{
56 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
57 1,
58 1,
59 1,
60 1,
61 0,
62};
63
64static int
65powerpmc250_show_cpuinfo(struct seq_file *m)
66{
67 seq_printf(m,"machine\t\t: Force PowerPMC250\n");
68
69 return 0;
70}
71
72static void __init
73powerpmc250_setup_arch(void)
74{
75
76 loops_per_jiffy = 50000000/HZ;
77
78
79 powerpmc250_find_bridges();
80
81#ifdef CONFIG_BLK_DEV_INITRD
82 if (initrd_start)
83 ROOT_DEV = Root_RAM0;
84 else
85#endif
86#ifdef CONFIG_ROOT_NFS
87 ROOT_DEV = Root_NFS;
88#else
89 ROOT_DEV = Root_SDA2;
90#endif
91
92 printk("Force PowerPMC250 port (C) 2001 MontaVista Software, Inc. (source@mvista.com)\n");
93}
94
95#if 0
96
97
98
99
100unsigned long __init powerpmc250_get_bus_speed(void)
101{
102 unsigned long tbl_start, tbl_end;
103 unsigned long current_state, old_state, bus_speed;
104 unsigned char lcr, dll, dlm;
105 int baud_divisor, count;
106
107
108 lcr = readb(PRPMC750_SERIAL_0_LCR);
109 writeb(lcr | UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
110 dll = readb(PRPMC750_SERIAL_0_DLL);
111 dlm = readb(PRPMC750_SERIAL_0_DLM);
112 writeb(lcr & ~UART_LCR_DLAB, PRPMC750_SERIAL_0_LCR);
113 baud_divisor = (dlm << 8) | dll;
114
115
116
117
118
119
120
121
122 count = PRPMC750_BASE_BAUD / (baud_divisor * 16);
123
124
125 old_state = readb(PRPMC750_STATUS_REG) & PRPMC750_BAUDOUT_MASK;
126 do {
127 current_state = readb(PRPMC750_STATUS_REG) &
128 PRPMC750_BAUDOUT_MASK;
129 } while(old_state == current_state);
130
131 old_state = current_state;
132
133
134 tbl_start = get_tbl();
135
136
137
138
139
140 do {
141 do {
142 current_state = readb(PRPMC750_STATUS_REG) &
143 PRPMC750_BAUDOUT_MASK;
144 } while(old_state == current_state);
145 old_state = current_state;
146 } while (--count);
147
148
149 tbl_end = get_tbl();
150
151
152 bus_speed = (tbl_end-tbl_start)*128;
153
154 return bus_speed;
155}
156#endif
157
158static void __init
159powerpmc250_calibrate_decr(void)
160{
161 unsigned long freq;
162 int divisor = 4;
163
164
165#warning hardcoded bus freq
166 freq = 100000000;
167
168 tb_ticks_per_jiffy = freq / (HZ * divisor);
169 tb_to_us = mulhwu_scale_factor(freq/divisor, 1000000);
170}
171
172static void
173powerpmc250_restart(char *cmd)
174{
175 local_irq_disable();
176
177 writeb(0x11, 0xfe000332);
178 while(1);
179}
180
181static void
182powerpmc250_halt(void)
183{
184 local_irq_disable();
185 while (1);
186}
187
188static void
189powerpmc250_power_off(void)
190{
191 powerpmc250_halt();
192}
193
194static void __init
195powerpmc250_init_IRQ(void)
196{
197
198 OpenPIC_InitSenses = powerpmc250_openpic_initsenses;
199 OpenPIC_NumInitSenses = sizeof(powerpmc250_openpic_initsenses);
200 mpc10x_set_openpic();
201}
202
203
204
205
206static __inline__ void
207powerpmc250_set_bat(void)
208{
209 unsigned long bat3u, bat3l;
210 static int mapping_set = 0;
211
212 if (!mapping_set)
213 {
214 __asm__ __volatile__(
215 " lis %0,0xf000\n \
216 ori %1,%0,0x002a\n \
217 ori %0,%0,0x1ffe\n \
218 mtspr 0x21e,%0\n \
219 mtspr 0x21f,%1\n \
220 isync\n \
221 sync "
222 : "=r" (bat3u), "=r" (bat3l));
223
224 mapping_set = 1;
225 }
226 return;
227}
228
229static unsigned long __init
230powerpmc250_find_end_of_memory(void)
231{
232
233
234 powerpmc250_set_bat();
235
236 return mpc10x_get_mem_size(MPC10X_MEM_MAP_B);
237}
238
239static void __init
240powerpmc250_map_io(void)
241{
242 io_block_mapping(0xfe000000, 0xfe000000, 0x02000000, _PAGE_IO);
243}
244
245void __init
246platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
247 unsigned long r6, unsigned long r7)
248{
249 parse_bootinfo(find_bootinfo());
250
251#ifdef CONFIG_BLK_DEV_INITRD
252 if ( r4 )
253 {
254 initrd_start = r4 + KERNELBASE;
255 initrd_end = r5 + KERNELBASE;
256 }
257#endif
258
259
260 if ( r6)
261 {
262 *(char *)(r7 + KERNELBASE) = 0;
263 strcpy(cmd_line, (char *)(r6 + KERNELBASE));
264 }
265
266 isa_io_base = MPC10X_MAPB_ISA_IO_BASE;
267 isa_mem_base = MPC10X_MAPB_ISA_MEM_BASE;
268 pci_dram_offset = MPC10X_MAPB_DRAM_OFFSET;
269
270 ppc_md.setup_arch = powerpmc250_setup_arch;
271 ppc_md.show_cpuinfo = powerpmc250_show_cpuinfo;
272 ppc_md.init_IRQ = powerpmc250_init_IRQ;
273 ppc_md.get_irq = openpic_get_irq;
274
275 ppc_md.find_end_of_memory = powerpmc250_find_end_of_memory;
276 ppc_md.setup_io_mappings = powerpmc250_map_io;
277
278 ppc_md.restart = powerpmc250_restart;
279 ppc_md.power_off = powerpmc250_power_off;
280 ppc_md.halt = powerpmc250_halt;
281
282
283 ppc_md.time_init = NULL;
284 ppc_md.get_rtc_time = NULL;
285 ppc_md.set_rtc_time = NULL;
286 ppc_md.calibrate_decr = powerpmc250_calibrate_decr;
287}
288
289
290
291
292
293
294
295
296
297#undef DEBUG
298#ifdef DEBUG
299#define DBG(x...) printk(x)
300#else
301#define DBG(x...)
302#endif
303
304static inline int __init
305powerpmc250_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
306{
307 static char pci_irq_table[][4] =
308
309
310
311
312 {
313 {17, 0, 0, 0},
314 {0, 0, 0, 0},
315 {0, 0, 0, 0},
316 {0, 0, 0, 0},
317 {0, 0, 0, 0},
318 {16, 17, 18, 19},
319 };
320 const long min_idsel = 11, max_idsel = 16, irqs_per_slot = 4;
321 return PCI_IRQ_TABLE_LOOKUP;
322};
323
324static int
325powerpmc250_exclude_device(u_char bus, u_char devfn)
326{
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341 if ((bus == 0) && (PCI_SLOT(devfn) == 13 || PCI_SLOT(devfn) == 14)) {
342 return PCIBIOS_DEVICE_NOT_FOUND;
343 }
344 else {
345 return PCIBIOS_SUCCESSFUL;
346 }
347}
348
349void __init
350powerpmc250_find_bridges(void)
351{
352 struct pci_controller* hose;
353
354 hose = pcibios_alloc_controller();
355 if (!hose){
356 printk("Can't allocate PCI 'hose' structure!!!\n");
357 return;
358 }
359
360 hose->first_busno = 0;
361 hose->last_busno = 0xff;
362
363 if (mpc10x_bridge_init(hose,
364 MPC10X_MEM_MAP_B,
365 MPC10X_MEM_MAP_B,
366 MPC10X_MAPB_EUMB_BASE) == 0) {
367
368 hose->mem_resources[0].end = 0xffffffff;
369
370 hose->last_busno = pciauto_bus_scan(hose, hose->first_busno);
371
372
373 ppc_md.pci_swizzle = common_swizzle;
374
375 ppc_md.pci_exclude_device = powerpmc250_exclude_device;
376 ppc_md.pci_map_irq = powerpmc250_map_irq;
377 } else {
378 if (ppc_md.progress)
379 ppc_md.progress("Bridge init failed", 0x100);
380 printk("Host bridge init failed\n");
381 }
382
383}
384