aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc/platforms/chrp_setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/ppc/platforms/chrp_setup.c')
-rw-r--r--arch/ppc/platforms/chrp_setup.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/arch/ppc/platforms/chrp_setup.c b/arch/ppc/platforms/chrp_setup.c
index 056ac2a7b5c1..48996b787378 100644
--- a/arch/ppc/platforms/chrp_setup.c
+++ b/arch/ppc/platforms/chrp_setup.c
@@ -53,6 +53,7 @@
53#include <asm/i8259.h> 53#include <asm/i8259.h>
54#include <asm/open_pic.h> 54#include <asm/open_pic.h>
55#include <asm/xmon.h> 55#include <asm/xmon.h>
56#include "mem_pieces.h"
56 57
57unsigned long chrp_get_rtc_time(void); 58unsigned long chrp_get_rtc_time(void);
58int chrp_set_rtc_time(unsigned long nowtime); 59int chrp_set_rtc_time(unsigned long nowtime);
@@ -65,7 +66,6 @@ void rtas_display_progress(char *, unsigned short);
65void rtas_indicator_progress(char *, unsigned short); 66void rtas_indicator_progress(char *, unsigned short);
66void btext_progress(char *, unsigned short); 67void btext_progress(char *, unsigned short);
67 68
68extern unsigned long pmac_find_end_of_memory(void);
69extern int of_show_percpuinfo(struct seq_file *, int); 69extern int of_show_percpuinfo(struct seq_file *, int);
70 70
71int _chrp_type; 71int _chrp_type;
@@ -467,6 +467,75 @@ chrp_init2(void)
467 ppc_md.progress(" Have fun! ", 0x7777); 467 ppc_md.progress(" Have fun! ", 0x7777);
468} 468}
469 469
470static struct device_node *memory_node;
471
472static int __init get_mem_prop(char *name, struct mem_pieces *mp)
473{
474 struct reg_property *rp;
475 int i, s;
476 unsigned int *ip;
477 int nac = prom_n_addr_cells(memory_node);
478 int nsc = prom_n_size_cells(memory_node);
479
480 ip = (unsigned int *) get_property(memory_node, name, &s);
481 if (ip == NULL) {
482 printk(KERN_ERR "error: couldn't get %s property on /memory\n",
483 name);
484 return 0;
485 }
486 s /= (nsc + nac) * 4;
487 rp = mp->regions;
488 for (i = 0; i < s; ++i, ip += nac+nsc) {
489 if (nac >= 2 && ip[nac-2] != 0)
490 continue;
491 rp->address = ip[nac-1];
492 if (nsc >= 2 && ip[nac+nsc-2] != 0)
493 rp->size = ~0U;
494 else
495 rp->size = ip[nac+nsc-1];
496 ++rp;
497 }
498 mp->n_regions = rp - mp->regions;
499
500 /* Make sure the pieces are sorted. */
501 mem_pieces_sort(mp);
502 mem_pieces_coalesce(mp);
503 return 1;
504}
505
506static unsigned long __init chrp_find_end_of_memory(void)
507{
508 unsigned long a, total;
509 struct mem_pieces phys_mem;
510
511 /*
512 * Find out where physical memory is, and check that it
513 * starts at 0 and is contiguous. It seems that RAM is
514 * always physically contiguous on Power Macintoshes.
515 *
516 * Supporting discontiguous physical memory isn't hard,
517 * it just makes the virtual <-> physical mapping functions
518 * more complicated (or else you end up wasting space
519 * in mem_map).
520 */
521 memory_node = find_devices("memory");
522 if (memory_node == NULL || !get_mem_prop("reg", &phys_mem)
523 || phys_mem.n_regions == 0)
524 panic("No RAM??");
525 a = phys_mem.regions[0].address;
526 if (a != 0)
527 panic("RAM doesn't start at physical address 0");
528 total = phys_mem.regions[0].size;
529
530 if (phys_mem.n_regions > 1) {
531 printk("RAM starting at 0x%x is not contiguous\n",
532 phys_mem.regions[1].address);
533 printk("Using RAM from 0 to 0x%lx\n", total-1);
534 }
535
536 return total;
537}
538
470void __init 539void __init
471chrp_init(unsigned long r3, unsigned long r4, unsigned long r5, 540chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
472 unsigned long r6, unsigned long r7) 541 unsigned long r6, unsigned long r7)
@@ -525,7 +594,7 @@ chrp_init(unsigned long r3, unsigned long r4, unsigned long r5,
525 ppc_md.get_rtc_time = chrp_get_rtc_time; 594 ppc_md.get_rtc_time = chrp_get_rtc_time;
526 ppc_md.calibrate_decr = chrp_calibrate_decr; 595 ppc_md.calibrate_decr = chrp_calibrate_decr;
527 596
528 ppc_md.find_end_of_memory = pmac_find_end_of_memory; 597 ppc_md.find_end_of_memory = chrp_find_end_of_memory;
529 598
530 if (rtas_data) { 599 if (rtas_data) {
531 struct device_node *rtas; 600 struct device_node *rtas;