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