2 * Copyright © 2011 Tony Breeds IBM Corporation
4 * Based on earlier code:
5 * Copyright (C) Paul Mackerras 1997.
7 * Matt Porter <mporter@kernel.crashing.org>
8 * Copyright 2002-2005 MontaVista Software Inc.
10 * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
11 * Copyright (c) 2003, 2004 Zultys Technologies
13 * Copyright 2007 David Gibson, IBM Corporation.
14 * Copyright 2010 Ben. Herrenschmidt, IBM Corporation.
15 * Copyright © 2011 David Kleikamp IBM Corporation
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version
20 * 2 of the License, or (at your option) any later version.
40 #define DDR3_MR0CF 0x80010011U
42 static unsigned long long ibm_currituck_memsize;
43 static unsigned long long ibm_currituck_detect_memsize(void)
47 unsigned long long memsize = 0;
49 for(i = 0; i < MAX_RANKS; i++){
50 reg = mfdcrx(DDR3_MR0CF + i);
57 memsize += (0x800000ULL << reg);
63 static void ibm_currituck_fixups(void)
65 void *devp = finddevice("/");
68 dt_fixup_memory(0x0ULL, ibm_currituck_memsize);
70 while ((devp = find_node_by_devtype(devp, "pci"))) {
71 if (getprop(devp, "dma-ranges", dma_ranges, sizeof(dma_ranges)) < 0) {
72 printf("%s: Failed to get dma-ranges\r\n", __func__);
76 dma_ranges[5] = ibm_currituck_memsize >> 32;
77 dma_ranges[6] = ibm_currituck_memsize & 0xffffffffUL;
79 setprop(devp, "dma-ranges", dma_ranges, sizeof(dma_ranges));
83 #define SPRN_PIR 0x11E /* Processor Identification Register */
84 void platform_init(void)
86 unsigned long end_of_ram, avail_ram;
91 ibm_currituck_memsize = ibm_currituck_detect_memsize();
92 if (ibm_currituck_memsize >> 32)
95 end_of_ram = ibm_currituck_memsize;
96 avail_ram = end_of_ram - (unsigned long)_end;
98 simple_alloc_init(_end, avail_ram, 128, 64);
99 platform_ops.fixups = ibm_currituck_fixups;
100 platform_ops.exit = ibm44x_dbcr_reset;
101 pir_reg = mfspr(SPRN_PIR);
103 /* Make sure FDT blob is sane */
104 if (fdt_check_header(_dtb_start) != 0)
105 fatal("Invalid device tree blob\n");
107 node = fdt_node_offset_by_prop_value(_dtb_start, -1, "device_type",
108 "cpu", sizeof("cpu"));
110 fatal("Cannot find cpu node\n");
111 timebase = fdt_getprop(_dtb_start, node, "timebase-frequency", &size);
112 if (timebase && (size == 4))
113 timebase_period_ns = 1000000000 / *timebase;
115 fdt_set_boot_cpuid_phys(_dtb_start, pir_reg);
116 fdt_init(_dtb_start);
118 serial_console_init();