More FB2 stuff
[coreboot.git] / src / pmc / altimus / mpc7410 / mpc7410.c
1 /* $Id$ */
2 /* Copyright 2000  AG Electronics Ltd. */
3 /* This code is distributed without warranty under the GPL v2 (see COPYING) */
4
5 #include <ppc.h>
6 #include <ppcreg.h>
7 #include <string.h>
8 #include <console/console.h>
9
10 #define ONEMEG  0x00100000
11 #define HALFMEG 0x00080000
12
13 unsigned long memory_base = 0;
14 unsigned long memory_top = 0;
15 unsigned long memory_size = 0;
16
17 //extern char __heap_end[];
18 extern unsigned mpc107_config_memory(void);
19
20 unsigned config_memory(unsigned offset)
21 {
22     //extern char __start[];
23     //extern char __bss_start[];
24     //unsigned rom_image = (unsigned) __start & 0xfff00000;
25     //unsigned physical = rom_image + offset;
26     //unsigned codesize = (unsigned) __bss_start - rom_image;
27
28 #if 0    
29     /* At this point, DBAT 0 is memory, 1 is variable, 2 is the rom image,
30        and 3 is IO. */
31     ppc_set_io_dbat_reloc(2, rom_image, physical, ONEMEG);
32     ppc_set_io_dbat (3, 0xf0000000, 0x10000000);
33     if ( rom_image != physical )
34             ppc_set_ibats_reloc(rom_image, physical, ONEMEG);
35     else
36             ppc_set_ibats(physical, ONEMEG);
37
38     printk_debug("bsp_init_memory...\n");
39 #endif
40
41     ppc_setup_cpu(1); /* icache enable = 1 */
42     //ppc_enable_mmu();
43
44     memory_size = mpc107_config_memory();
45         
46     /* If we have some working RAM, we copy the code and rodata into it.
47      * This allows us to reprogram the flash later. */
48 #if 0
49     if (memory_size)
50     {
51         unsigned onemeg = memory_size - ONEMEG;
52         ppc_set_mem_dbat_reloc(1, onemeg, onemeg, ONEMEG);
53         memcpy((void *)onemeg, (void *)rom_image, codesize);
54         memset((void *)(onemeg + codesize), 0, ONEMEG - codesize);
55         ppc_set_ibats_reloc2(rom_image, physical, onemeg, ONEMEG);
56         ppc_set_mem_dbat_reloc(2, rom_image, onemeg, ONEMEG);
57         make_coherent((void *)onemeg, ONEMEG);
58     }
59
60     ppc_set_memory_dbat (memory_size);
61 #endif
62
63     //ppc_enable_dcache ();
64
65     return memory_size;
66 }