| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * OpenRISC setup.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 8 | 9 | * Modifications for the OpenRISC architecture: |
|---|
| 9 | 10 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
|---|
| 10 | 11 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> |
|---|
| 11 | | - * |
|---|
| 12 | | - * This program is free software; you can redistribute it and/or |
|---|
| 13 | | - * modify it under the terms of the GNU General Public License |
|---|
| 14 | | - * as published by the Free Software Foundation; either version |
|---|
| 15 | | - * 2 of the License, or (at your option) any later version. |
|---|
| 16 | 12 | * |
|---|
| 17 | 13 | * This file handles the architecture-dependent parts of initialization |
|---|
| 18 | 14 | */ |
|---|
| .. | .. |
|---|
| 30 | 26 | #include <linux/delay.h> |
|---|
| 31 | 27 | #include <linux/console.h> |
|---|
| 32 | 28 | #include <linux/init.h> |
|---|
| 33 | | -#include <linux/bootmem.h> |
|---|
| 29 | +#include <linux/memblock.h> |
|---|
| 34 | 30 | #include <linux/seq_file.h> |
|---|
| 35 | 31 | #include <linux/serial.h> |
|---|
| 36 | 32 | #include <linux/initrd.h> |
|---|
| 37 | 33 | #include <linux/of_fdt.h> |
|---|
| 38 | 34 | #include <linux/of.h> |
|---|
| 39 | | -#include <linux/memblock.h> |
|---|
| 40 | 35 | #include <linux/device.h> |
|---|
| 41 | 36 | |
|---|
| 42 | 37 | #include <asm/sections.h> |
|---|
| 43 | | -#include <asm/segment.h> |
|---|
| 44 | | -#include <asm/pgtable.h> |
|---|
| 45 | 38 | #include <asm/types.h> |
|---|
| 46 | 39 | #include <asm/setup.h> |
|---|
| 47 | 40 | #include <asm/io.h> |
|---|
| .. | .. |
|---|
| 55 | 48 | unsigned long ram_start_pfn; |
|---|
| 56 | 49 | unsigned long ram_end_pfn; |
|---|
| 57 | 50 | phys_addr_t memory_start, memory_end; |
|---|
| 58 | | - struct memblock_region *region; |
|---|
| 59 | 51 | |
|---|
| 60 | 52 | memory_end = memory_start = 0; |
|---|
| 61 | 53 | |
|---|
| 62 | 54 | /* Find main memory where is the kernel, we assume its the only one */ |
|---|
| 63 | | - for_each_memblock(memory, region) { |
|---|
| 64 | | - memory_start = region->base; |
|---|
| 65 | | - memory_end = region->base + region->size; |
|---|
| 66 | | - printk(KERN_INFO "%s: Memory: 0x%x-0x%x\n", __func__, |
|---|
| 67 | | - memory_start, memory_end); |
|---|
| 68 | | - } |
|---|
| 55 | + memory_start = memblock_start_of_DRAM(); |
|---|
| 56 | + memory_end = memblock_end_of_DRAM(); |
|---|
| 69 | 57 | |
|---|
| 70 | 58 | if (!memory_end) { |
|---|
| 71 | 59 | panic("No memory!"); |
|---|
| .. | .. |
|---|
| 86 | 74 | * RAM usable. |
|---|
| 87 | 75 | */ |
|---|
| 88 | 76 | memblock_reserve(__pa(_stext), _end - _stext); |
|---|
| 77 | + |
|---|
| 78 | +#ifdef CONFIG_BLK_DEV_INITRD |
|---|
| 79 | + /* Then reserve the initrd, if any */ |
|---|
| 80 | + if (initrd_start && (initrd_end > initrd_start)) { |
|---|
| 81 | + unsigned long aligned_start = ALIGN_DOWN(initrd_start, PAGE_SIZE); |
|---|
| 82 | + unsigned long aligned_end = ALIGN(initrd_end, PAGE_SIZE); |
|---|
| 83 | + |
|---|
| 84 | + memblock_reserve(__pa(aligned_start), aligned_end - aligned_start); |
|---|
| 85 | + } |
|---|
| 86 | +#endif /* CONFIG_BLK_DEV_INITRD */ |
|---|
| 89 | 87 | |
|---|
| 90 | 88 | early_init_fdt_reserve_self(); |
|---|
| 91 | 89 | early_init_fdt_scan_reserved_mem(); |
|---|
| .. | .. |
|---|
| 158 | 156 | { |
|---|
| 159 | 157 | u32 hwid; |
|---|
| 160 | 158 | struct device_node *cpun; |
|---|
| 161 | | - struct device_node *cpus = of_find_node_by_path("/cpus"); |
|---|
| 162 | 159 | |
|---|
| 163 | | - for_each_available_child_of_node(cpus, cpun) { |
|---|
| 160 | + for_each_of_cpu_node(cpun) { |
|---|
| 164 | 161 | if (of_property_read_u32(cpun, "reg", &hwid)) |
|---|
| 165 | 162 | continue; |
|---|
| 166 | 163 | if (hwid == cpu) |
|---|
| .. | .. |
|---|
| 302 | 299 | init_mm.brk = (unsigned long)_end; |
|---|
| 303 | 300 | |
|---|
| 304 | 301 | #ifdef CONFIG_BLK_DEV_INITRD |
|---|
| 305 | | - initrd_start = (unsigned long)&__initrd_start; |
|---|
| 306 | | - initrd_end = (unsigned long)&__initrd_end; |
|---|
| 307 | 302 | if (initrd_start == initrd_end) { |
|---|
| 303 | + printk(KERN_INFO "Initial ramdisk not found\n"); |
|---|
| 308 | 304 | initrd_start = 0; |
|---|
| 309 | 305 | initrd_end = 0; |
|---|
| 306 | + } else { |
|---|
| 307 | + printk(KERN_INFO "Initial ramdisk at: 0x%p (%lu bytes)\n", |
|---|
| 308 | + (void *)(initrd_start), initrd_end - initrd_start); |
|---|
| 309 | + initrd_below_start_ok = 1; |
|---|
| 310 | 310 | } |
|---|
| 311 | | - initrd_below_start_ok = 1; |
|---|
| 312 | 311 | #endif |
|---|
| 313 | 312 | |
|---|
| 314 | 313 | /* setup memblock allocator */ |
|---|
| .. | .. |
|---|
| 316 | 315 | |
|---|
| 317 | 316 | /* paging_init() sets up the MMU and marks all pages as reserved */ |
|---|
| 318 | 317 | paging_init(); |
|---|
| 319 | | - |
|---|
| 320 | | -#if defined(CONFIG_VT) && defined(CONFIG_DUMMY_CONSOLE) |
|---|
| 321 | | - if (!conswitchp) |
|---|
| 322 | | - conswitchp = &dummy_con; |
|---|
| 323 | | -#endif |
|---|
| 324 | 318 | |
|---|
| 325 | 319 | *cmdline_p = boot_command_line; |
|---|
| 326 | 320 | |
|---|