7d22c436a3627537b9f68bd3507e9793a6800d92
[coreboot.git] / src / pmc / altimus / mpc7410 / mpc7410.c
1 /*
2  * This file is part of the LinuxBIOS project.
3  *
4  * Copyright (C) 2000 AG Electronics Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include <ppc.h>
21 #include <ppcreg.h>
22 #include <string.h>
23 #include <console/console.h>
24
25 #define ONEMEG  0x00100000
26 #define HALFMEG 0x00080000
27
28 unsigned long memory_base = 0;
29 unsigned long memory_top = 0;
30 unsigned long memory_size = 0;
31
32 //extern char __heap_end[];
33 extern unsigned mpc107_config_memory(void);
34
35 unsigned config_memory(unsigned offset)
36 {
37     //extern char __start[];
38     //extern char __bss_start[];
39     //unsigned rom_image = (unsigned) __start & 0xfff00000;
40     //unsigned physical = rom_image + offset;
41     //unsigned codesize = (unsigned) __bss_start - rom_image;
42
43 #if 0    
44     /* At this point, DBAT 0 is memory, 1 is variable, 2 is the rom image,
45        and 3 is IO. */
46     ppc_set_io_dbat_reloc(2, rom_image, physical, ONEMEG);
47     ppc_set_io_dbat (3, 0xf0000000, 0x10000000);
48     if ( rom_image != physical )
49             ppc_set_ibats_reloc(rom_image, physical, ONEMEG);
50     else
51             ppc_set_ibats(physical, ONEMEG);
52
53     printk_debug("bsp_init_memory...\n");
54 #endif
55
56     ppc_setup_cpu(1); /* icache enable = 1 */
57     //ppc_enable_mmu();
58
59     memory_size = mpc107_config_memory();
60         
61     /* If we have some working RAM, we copy the code and rodata into it.
62      * This allows us to reprogram the flash later. */
63 #if 0
64     if (memory_size)
65     {
66         unsigned onemeg = memory_size - ONEMEG;
67         ppc_set_mem_dbat_reloc(1, onemeg, onemeg, ONEMEG);
68         memcpy((void *)onemeg, (void *)rom_image, codesize);
69         memset((void *)(onemeg + codesize), 0, ONEMEG - codesize);
70         ppc_set_ibats_reloc2(rom_image, physical, onemeg, ONEMEG);
71         ppc_set_mem_dbat_reloc(2, rom_image, onemeg, ONEMEG);
72         make_coherent((void *)onemeg, ONEMEG);
73     }
74
75     ppc_set_memory_dbat (memory_size);
76 #endif
77
78     //ppc_enable_dcache ();
79
80     return memory_size;
81 }