aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/platforms/cpci690.c
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@mvista.com>2005-09-03 18:55:57 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:01 -0400
commitf54bef9e9c84c8dc656c55dc96c1da7b6d1c53d8 (patch)
treede93df49c67ebf63aeca64941a201365440e9551 /arch/ppc/platforms/cpci690.c
parentf4c6cc8d1e2305796f7fdad52d83b88cea4d2276 (diff)
[PATCH] ppc32: cpci690 updates
Update the cpci690 platform code: - pass mem size in from bootwrapper via bi_rec - some minor fixups Signed-off-by: Mark A. Greer <mgreer@mvista.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/ppc/platforms/cpci690.c')
-rw-r--r--arch/ppc/platforms/cpci690.c177
1 files changed, 71 insertions, 106 deletions
diff --git a/arch/ppc/platforms/cpci690.c b/arch/ppc/platforms/cpci690.c
index 507870c9a97a..f64ac2acb603 100644
--- a/arch/ppc/platforms/cpci690.c
+++ b/arch/ppc/platforms/cpci690.c
@@ -35,11 +35,7 @@
35#define SET_PCI_IDE_NATIVE 35#define SET_PCI_IDE_NATIVE
36 36
37static struct mv64x60_handle bh; 37static struct mv64x60_handle bh;
38static u32 cpci690_br_base; 38static void __iomem *cpci690_br_base;
39
40static const unsigned int cpu_7xx[16] = { /* 7xx & 74xx (but not 745x) */
41 18, 15, 14, 2, 4, 13, 5, 9, 6, 11, 8, 10, 16, 12, 7, 0
42};
43 39
44TODC_ALLOC(); 40TODC_ALLOC();
45 41
@@ -55,7 +51,7 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
55 * A B C D 51 * A B C D
56 */ 52 */
57 { 53 {
58 { 90, 91, 88, 89}, /* IDSEL 30/20 - Sentinel */ 54 { 90, 91, 88, 89 }, /* IDSEL 30/20 - Sentinel */
59 }; 55 };
60 56
61 const long min_idsel = 20, max_idsel = 20, irqs_per_slot = 4; 57 const long min_idsel = 20, max_idsel = 20, irqs_per_slot = 4;
@@ -67,9 +63,9 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
67 * A B C D 63 * A B C D
68 */ 64 */
69 { 65 {
70 { 93, 94, 95, 92}, /* IDSEL 28/18 - PMC slot 2 */ 66 { 93, 94, 95, 92 }, /* IDSEL 28/18 - PMC slot 2 */
71 { 0, 0, 0, 0}, /* IDSEL 29/19 - Not used */ 67 { 0, 0, 0, 0 }, /* IDSEL 29/19 - Not used */
72 { 94, 95, 92, 93}, /* IDSEL 30/20 - PMC slot 1 */ 68 { 94, 95, 92, 93 }, /* IDSEL 30/20 - PMC slot 1 */
73 }; 69 };
74 70
75 const long min_idsel = 18, max_idsel = 20, irqs_per_slot = 4; 71 const long min_idsel = 18, max_idsel = 20, irqs_per_slot = 4;
@@ -77,68 +73,29 @@ cpci690_map_irq(struct pci_dev *dev, unsigned char idsel, unsigned char pin)
77 } 73 }
78} 74}
79 75
80static int 76#define GB (1024UL * 1024UL * 1024UL)
81cpci690_get_cpu_speed(void)
82{
83 unsigned long hid1;
84 77
85 hid1 = mfspr(SPRN_HID1) >> 28; 78static u32
86 return CPCI690_BUS_FREQ * cpu_7xx[hid1]/2; 79cpci690_get_bus_freq(void)
80{
81 if (boot_mem_size >= (1*GB)) /* bus speed based on mem size */
82 return 100000000;
83 else
84 return 133333333;
87} 85}
88 86
89#define KB (1024UL) 87static const unsigned int cpu_750xx[32] = { /* 750FX & 750GX */
90#define MB (1024UL * KB) 88 0, 0, 2, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,/* 0-15*/
91#define GB (1024UL * MB) 89 16, 17, 18, 19, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 0 /*16-31*/
90};
92 91
93unsigned long __init 92static int
94cpci690_find_end_of_memory(void) 93cpci690_get_cpu_freq(void)
95{ 94{
96 u32 mem_ctlr_size; 95 unsigned long pll_cfg;
97 static u32 board_size; 96
98 static u8 first_time = 1; 97 pll_cfg = (mfspr(SPRN_HID1) & 0xf8000000) >> 27;
99 98 return cpci690_get_bus_freq() * cpu_750xx[pll_cfg]/2;
100 if (first_time) {
101 /* Using cpci690_set_bat() mapping ==> virt addr == phys addr */
102 switch (in_8((u8 *) (cpci690_br_base +
103 CPCI690_BR_MEM_CTLR)) & 0x07) {
104 case 0x01:
105 board_size = 256*MB;
106 break;
107 case 0x02:
108 board_size = 512*MB;
109 break;
110 case 0x03:
111 board_size = 768*MB;
112 break;
113 case 0x04:
114 board_size = 1*GB;
115 break;
116 case 0x05:
117 board_size = 1*GB + 512*MB;
118 break;
119 case 0x06:
120 board_size = 2*GB;
121 break;
122 default:
123 board_size = 0xffffffff; /* use mem ctlr size */
124 } /* switch */
125
126 mem_ctlr_size = mv64x60_get_mem_size(CONFIG_MV64X60_NEW_BASE,
127 MV64x60_TYPE_GT64260A);
128
129 /* Check that mem ctlr & board reg agree. If not, pick MIN. */
130 if (board_size != mem_ctlr_size) {
131 printk(KERN_WARNING "Board register & memory controller"
132 "mem size disagree (board reg: 0x%lx, "
133 "mem ctlr: 0x%lx)\n",
134 (ulong)board_size, (ulong)mem_ctlr_size);
135 board_size = min(board_size, mem_ctlr_size);
136 }
137
138 first_time = 0;
139 } /* if */
140
141 return board_size;
142} 99}
143 100
144static void __init 101static void __init
@@ -228,7 +185,7 @@ cpci690_setup_peripherals(void)
228 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, CPCI690_BR_BASE, 185 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_0_WIN, CPCI690_BR_BASE,
229 CPCI690_BR_SIZE, 0); 186 CPCI690_BR_SIZE, 0);
230 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN); 187 bh.ci->enable_window_32bit(&bh, MV64x60_CPU2DEV_0_WIN);
231 cpci690_br_base = (u32)ioremap(CPCI690_BR_BASE, CPCI690_BR_SIZE); 188 cpci690_br_base = ioremap(CPCI690_BR_BASE, CPCI690_BR_SIZE);
232 189
233 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, CPCI690_TODC_BASE, 190 mv64x60_set_32bit_window(&bh, MV64x60_CPU2DEV_1_WIN, CPCI690_TODC_BASE,
234 CPCI690_TODC_SIZE, 0); 191 CPCI690_TODC_SIZE, 0);
@@ -329,7 +286,7 @@ cpci690_fixup_mpsc_pdata(struct platform_device *pdev)
329 pdata->max_idle = 40; 286 pdata->max_idle = 40;
330 pdata->default_baud = CPCI690_MPSC_BAUD; 287 pdata->default_baud = CPCI690_MPSC_BAUD;
331 pdata->brg_clk_src = CPCI690_MPSC_CLK_SRC; 288 pdata->brg_clk_src = CPCI690_MPSC_CLK_SRC;
332 pdata->brg_clk_freq = CPCI690_BUS_FREQ; 289 pdata->brg_clk_freq = cpci690_get_bus_freq();
333} 290}
334 291
335static int __init 292static int __init
@@ -365,7 +322,7 @@ cpci690_reset_board(void)
365 u32 i = 10000; 322 u32 i = 10000;
366 323
367 local_irq_disable(); 324 local_irq_disable();
368 out_8((u8 *)(cpci690_br_base + CPCI690_BR_SW_RESET), 0x11); 325 out_8((cpci690_br_base + CPCI690_BR_SW_RESET), 0x11);
369 326
370 while (i != 0) i++; 327 while (i != 0) i++;
371 panic("restart failed\n"); 328 panic("restart failed\n");
@@ -394,10 +351,40 @@ cpci690_power_off(void)
394static int 351static int
395cpci690_show_cpuinfo(struct seq_file *m) 352cpci690_show_cpuinfo(struct seq_file *m)
396{ 353{
354 char *s;
355
356 seq_printf(m, "cpu MHz\t\t: %d\n",
357 (cpci690_get_cpu_freq() + 500000) / 1000000);
358 seq_printf(m, "bus MHz\t\t: %d\n",
359 (cpci690_get_bus_freq() + 500000) / 1000000);
397 seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n"); 360 seq_printf(m, "vendor\t\t: " BOARD_VENDOR "\n");
398 seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n"); 361 seq_printf(m, "machine\t\t: " BOARD_MACHINE "\n");
399 seq_printf(m, "cpu MHz\t\t: %d\n", cpci690_get_cpu_speed()/1000/1000); 362 seq_printf(m, "FPGA Revision\t: %d\n",
400 seq_printf(m, "bus MHz\t\t: %d\n", CPCI690_BUS_FREQ/1000/1000); 363 in_8(cpci690_br_base + CPCI690_BR_MEM_CTLR) >> 5);
364
365 switch(bh.type) {
366 case MV64x60_TYPE_GT64260A:
367 s = "gt64260a";
368 break;
369 case MV64x60_TYPE_GT64260B:
370 s = "gt64260b";
371 break;
372 case MV64x60_TYPE_MV64360:
373 s = "mv64360";
374 break;
375 case MV64x60_TYPE_MV64460:
376 s = "mv64460";
377 break;
378 default:
379 s = "Unknown";
380 }
381 seq_printf(m, "bridge type\t: %s\n", s);
382 seq_printf(m, "bridge rev\t: 0x%x\n", bh.rev);
383#if defined(CONFIG_NOT_COHERENT_CACHE)
384 seq_printf(m, "coherency\t: %s\n", "off");
385#else
386 seq_printf(m, "coherency\t: %s\n", "on");
387#endif
401 388
402 return 0; 389 return 0;
403} 390}
@@ -407,7 +394,7 @@ cpci690_calibrate_decr(void)
407{ 394{
408 ulong freq; 395 ulong freq;
409 396
410 freq = CPCI690_BUS_FREQ / 4; 397 freq = cpci690_get_bus_freq() / 4;
411 398
412 printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n", 399 printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n",
413 freq/1000000, freq%1000000); 400 freq/1000000, freq%1000000);
@@ -416,25 +403,12 @@ cpci690_calibrate_decr(void)
416 tb_to_us = mulhwu_scale_factor(freq, 1000000); 403 tb_to_us = mulhwu_scale_factor(freq, 1000000);
417} 404}
418 405
419static __inline__ void 406#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC)
420cpci690_set_bat(u32 addr, u32 size)
421{
422 addr &= 0xfffe0000;
423 size &= 0x1ffe0000;
424 size = ((size >> 17) - 1) << 2;
425
426 mb();
427 mtspr(SPRN_DBAT1U, addr | size | 0x2); /* Vs == 1; Vp == 0 */
428 mtspr(SPRN_DBAT1L, addr | 0x2a); /* WIMG bits == 0101; PP == r/w access */
429 mb();
430}
431
432#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB)
433static void __init 407static void __init
434cpci690_map_io(void) 408cpci690_map_io(void)
435{ 409{
436 io_block_mapping(CONFIG_MV64X60_NEW_BASE, CONFIG_MV64X60_NEW_BASE, 410 io_block_mapping(CONFIG_MV64X60_NEW_BASE, CONFIG_MV64X60_NEW_BASE,
437 128 * KB, _PAGE_IO); 411 128 * 1024, _PAGE_IO);
438} 412}
439#endif 413#endif
440 414
@@ -442,14 +416,15 @@ void __init
442platform_init(unsigned long r3, unsigned long r4, unsigned long r5, 416platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
443 unsigned long r6, unsigned long r7) 417 unsigned long r6, unsigned long r7)
444{ 418{
445#ifdef CONFIG_BLK_DEV_INITRD
446 initrd_start=initrd_end=0;
447 initrd_below_start_ok=0;
448#endif /* CONFIG_BLK_DEV_INITRD */
449
450 parse_bootinfo(find_bootinfo()); 419 parse_bootinfo(find_bootinfo());
451 420
452 loops_per_jiffy = cpci690_get_cpu_speed() / HZ; 421#ifdef CONFIG_BLK_DEV_INITRD
422 /* take care of initrd if we have one */
423 if (r4) {
424 initrd_start = r4 + KERNELBASE;
425 initrd_end = r5 + KERNELBASE;
426 }
427#endif /* CONFIG_BLK_DEV_INITRD */
453 428
454 isa_mem_base = 0; 429 isa_mem_base = 0;
455 430
@@ -460,7 +435,6 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
460 ppc_md.restart = cpci690_restart; 435 ppc_md.restart = cpci690_restart;
461 ppc_md.power_off = cpci690_power_off; 436 ppc_md.power_off = cpci690_power_off;
462 ppc_md.halt = cpci690_halt; 437 ppc_md.halt = cpci690_halt;
463 ppc_md.find_end_of_memory = cpci690_find_end_of_memory;
464 ppc_md.time_init = todc_time_init; 438 ppc_md.time_init = todc_time_init;
465 ppc_md.set_rtc_time = todc_set_rtc_time; 439 ppc_md.set_rtc_time = todc_set_rtc_time;
466 ppc_md.get_rtc_time = todc_get_rtc_time; 440 ppc_md.get_rtc_time = todc_get_rtc_time;
@@ -468,22 +442,13 @@ platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
468 ppc_md.nvram_write_val = todc_direct_write_val; 442 ppc_md.nvram_write_val = todc_direct_write_val;
469 ppc_md.calibrate_decr = cpci690_calibrate_decr; 443 ppc_md.calibrate_decr = cpci690_calibrate_decr;
470 444
471 /* 445#if defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC)
472 * Need to map in board regs (used by cpci690_find_end_of_memory())
473 * and the bridge's regs (used by progress);
474 */
475 cpci690_set_bat(CPCI690_BR_BASE, 32 * MB);
476 cpci690_br_base = CPCI690_BR_BASE;
477
478#ifdef CONFIG_SERIAL_TEXT_DEBUG
479 ppc_md.setup_io_mappings = cpci690_map_io; 446 ppc_md.setup_io_mappings = cpci690_map_io;
447#ifdef CONFIG_SERIAL_TEXT_DEBUG
480 ppc_md.progress = mv64x60_mpsc_progress; 448 ppc_md.progress = mv64x60_mpsc_progress;
481 mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE); 449 mv64x60_progress_init(CONFIG_MV64X60_NEW_BASE);
482#endif /* CONFIG_SERIAL_TEXT_DEBUG */ 450#endif /* CONFIG_SERIAL_TEXT_DEBUG */
483#ifdef CONFIG_KGDB 451#endif /* defined(CONFIG_SERIAL_TEXT_DEBUG) || defined(CONFIG_KGDB_MPSC) */
484 ppc_md.setup_io_mappings = cpci690_map_io;
485 ppc_md.early_serial_map = cpci690_early_serial_map;
486#endif /* CONFIG_KGDB */
487 452
488#if defined(CONFIG_SERIAL_MPSC) 453#if defined(CONFIG_SERIAL_MPSC)
489 platform_notify = cpci690_platform_notify; 454 platform_notify = cpci690_platform_notify;