1b4e8c8ddSTorez Smith /* 2b4e8c8ddSTorez Smith * Copyright 2010 Ben. Herrenschmidt, IBM Corporation. 3b4e8c8ddSTorez Smith * 4b4e8c8ddSTorez Smith * Based on earlier code: 5b4e8c8ddSTorez Smith * Copyright (C) Paul Mackerras 1997. 6b4e8c8ddSTorez Smith * 7b4e8c8ddSTorez Smith * Matt Porter <mporter@kernel.crashing.org> 8b4e8c8ddSTorez Smith * Copyright 2002-2005 MontaVista Software Inc. 9b4e8c8ddSTorez Smith * 10b4e8c8ddSTorez Smith * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net> 11b4e8c8ddSTorez Smith * Copyright (c) 2003, 2004 Zultys Technologies 12b4e8c8ddSTorez Smith * 13b4e8c8ddSTorez Smith * Copyright 2007 David Gibson, IBM Corporation. 14b4e8c8ddSTorez Smith * 15b4e8c8ddSTorez Smith * This program is free software; you can redistribute it and/or 16b4e8c8ddSTorez Smith * modify it under the terms of the GNU General Public License 17b4e8c8ddSTorez Smith * as published by the Free Software Foundation; either version 18b4e8c8ddSTorez Smith * 2 of the License, or (at your option) any later version. 19b4e8c8ddSTorez Smith */ 20b4e8c8ddSTorez Smith #include <stdarg.h> 21b4e8c8ddSTorez Smith #include <stddef.h> 22b4e8c8ddSTorez Smith #include "types.h" 23b4e8c8ddSTorez Smith #include "elf.h" 24b4e8c8ddSTorez Smith #include "string.h" 25b4e8c8ddSTorez Smith #include "stdio.h" 26b4e8c8ddSTorez Smith #include "page.h" 27b4e8c8ddSTorez Smith #include "ops.h" 28b4e8c8ddSTorez Smith #include "reg.h" 29b4e8c8ddSTorez Smith #include "io.h" 30b4e8c8ddSTorez Smith #include "dcr.h" 31b4e8c8ddSTorez Smith #include "4xx.h" 32b4e8c8ddSTorez Smith #include "44x.h" 33b4e8c8ddSTorez Smith #include "libfdt.h" 34b4e8c8ddSTorez Smith 35b4e8c8ddSTorez Smith BSS_STACK(4096); 36b4e8c8ddSTorez Smith 37e817513bSDave Kleikamp static u32 ibm4xx_memstart; 38e817513bSDave Kleikamp 39b4e8c8ddSTorez Smith static void iss_4xx_fixups(void) 40b4e8c8ddSTorez Smith { 41e817513bSDave Kleikamp void *memory; 42e817513bSDave Kleikamp u32 reg[3]; 43e817513bSDave Kleikamp 44e817513bSDave Kleikamp memory = finddevice("/memory"); 45e817513bSDave Kleikamp if (!memory) 46e817513bSDave Kleikamp fatal("Can't find memory node\n"); 47e817513bSDave Kleikamp /* This assumes #address-cells = 2, #size-cells =1 and that */ 48e817513bSDave Kleikamp getprop(memory, "reg", reg, sizeof(reg)); 49e817513bSDave Kleikamp if (reg[2]) 50e817513bSDave Kleikamp /* If the device tree specifies the memory range, use it */ 51e817513bSDave Kleikamp ibm4xx_memstart = reg[1]; 52e817513bSDave Kleikamp else 53e817513bSDave Kleikamp /* othersize, read it from the SDRAM controller */ 54b4e8c8ddSTorez Smith ibm4xx_sdram_fixup_memsize(); 55b4e8c8ddSTorez Smith } 56b4e8c8ddSTorez Smith 57e817513bSDave Kleikamp static void *iss_4xx_vmlinux_alloc(unsigned long size) 58e817513bSDave Kleikamp { 59e817513bSDave Kleikamp return (void *)ibm4xx_memstart; 60e817513bSDave Kleikamp } 61e817513bSDave Kleikamp 62*446957baSAdam Buchbinder #define SPRN_PIR 0x11E /* Processor Identification Register */ 63b4e8c8ddSTorez Smith void platform_init(void) 64b4e8c8ddSTorez Smith { 65b4e8c8ddSTorez Smith unsigned long end_of_ram = 0x08000000; 66b4e8c8ddSTorez Smith unsigned long avail_ram = end_of_ram - (unsigned long)_end; 67b4e8c8ddSTorez Smith u32 pir_reg; 68b4e8c8ddSTorez Smith 69b4e8c8ddSTorez Smith simple_alloc_init(_end, avail_ram, 128, 64); 70b4e8c8ddSTorez Smith platform_ops.fixups = iss_4xx_fixups; 71e817513bSDave Kleikamp platform_ops.vmlinux_alloc = iss_4xx_vmlinux_alloc; 72b4e8c8ddSTorez Smith platform_ops.exit = ibm44x_dbcr_reset; 73b4e8c8ddSTorez Smith pir_reg = mfspr(SPRN_PIR); 74b4e8c8ddSTorez Smith fdt_set_boot_cpuid_phys(_dtb_start, pir_reg); 75b4e8c8ddSTorez Smith fdt_init(_dtb_start); 76b4e8c8ddSTorez Smith serial_console_init(); 77b4e8c8ddSTorez Smith } 78