diff options
| author | Ley Foon Tan <lftan@altera.com> | 2014-11-06 02:20:03 -0500 |
|---|---|---|
| committer | Ley Foon Tan <lftan@altera.com> | 2014-12-07 23:56:01 -0500 |
| commit | 95acd4c7b69c9b250d901d154390ec4c8b7b51c1 (patch) | |
| tree | 2232613144f317f21ccbd3684cd31ee11eb9c2b5 /arch/nios2/kernel | |
| parent | eea9507a69d637d52705de8703b168bf6bfe5643 (diff) | |
nios2: Device tree support
Add device tree support to arch/nios2.
Signed-off-by: Ley Foon Tan <lftan@altera.com>
Diffstat (limited to 'arch/nios2/kernel')
| -rw-r--r-- | arch/nios2/kernel/prom.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/nios2/kernel/prom.c b/arch/nios2/kernel/prom.c new file mode 100644 index 000000000000..0522d3378e3f --- /dev/null +++ b/arch/nios2/kernel/prom.c | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | /* | ||
| 2 | * Device tree support | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Altera Corporation | ||
| 5 | * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw> | ||
| 6 | * | ||
| 7 | * Based on MIPS support for CONFIG_OF device tree support | ||
| 8 | * | ||
| 9 | * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify | ||
| 12 | * it under the terms of the GNU General Public License as published by | ||
| 13 | * the Free Software Foundation; either version 2 of the License, or | ||
| 14 | * (at your option) any later version. | ||
| 15 | * | ||
| 16 | * This program is distributed in the hope that it will be useful, | ||
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 19 | * GNU General Public License for more details. | ||
| 20 | * | ||
| 21 | * You should have received a copy of the GNU General Public License | ||
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 23 | * | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/init.h> | ||
| 27 | #include <linux/types.h> | ||
| 28 | #include <linux/bootmem.h> | ||
| 29 | #include <linux/of.h> | ||
| 30 | #include <linux/of_fdt.h> | ||
| 31 | #include <linux/io.h> | ||
| 32 | |||
| 33 | #include <asm/sections.h> | ||
| 34 | |||
| 35 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) | ||
| 36 | { | ||
| 37 | u64 kernel_start = (u64)virt_to_phys(_text); | ||
| 38 | |||
| 39 | if (!memory_size && | ||
| 40 | (kernel_start >= base) && (kernel_start < (base + size))) | ||
| 41 | memory_size = size; | ||
| 42 | |||
| 43 | } | ||
| 44 | |||
| 45 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) | ||
| 46 | { | ||
| 47 | return alloc_bootmem_align(size, align); | ||
| 48 | } | ||
| 49 | |||
| 50 | void __init early_init_devtree(void *params) | ||
| 51 | { | ||
| 52 | __be32 *dtb = (u32 *)__dtb_start; | ||
| 53 | #if defined(CONFIG_NIOS2_DTB_AT_PHYS_ADDR) | ||
| 54 | if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) == | ||
| 55 | OF_DT_HEADER) { | ||
| 56 | params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR; | ||
| 57 | early_init_dt_scan(params); | ||
| 58 | return; | ||
| 59 | } | ||
| 60 | #endif | ||
| 61 | if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER) | ||
| 62 | params = (void *)__dtb_start; | ||
| 63 | |||
| 64 | early_init_dt_scan(params); | ||
| 65 | } | ||
