Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 1 | /* |
| 2 | * MIPS support for CONFIG_OF device tree support |
| 3 | * |
| 4 | * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/init.h> |
Paul Gortmaker | 73bc256 | 2011-07-23 16:30:40 -0400 | [diff] [blame] | 12 | #include <linux/export.h> |
Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 13 | #include <linux/errno.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/bootmem.h> |
| 16 | #include <linux/initrd.h> |
| 17 | #include <linux/debugfs.h> |
| 18 | #include <linux/of.h> |
| 19 | #include <linux/of_fdt.h> |
| 20 | #include <linux/of_irq.h> |
| 21 | #include <linux/of_platform.h> |
| 22 | |
| 23 | #include <asm/page.h> |
| 24 | #include <asm/prom.h> |
| 25 | |
| 26 | int __init early_init_dt_scan_memory_arch(unsigned long node, |
| 27 | const char *uname, int depth, |
| 28 | void *data) |
| 29 | { |
| 30 | return early_init_dt_scan_memory(node, uname, depth, data); |
| 31 | } |
| 32 | |
| 33 | void __init early_init_dt_add_memory_arch(u64 base, u64 size) |
| 34 | { |
| 35 | return add_memory_region(base, size, BOOT_MEM_RAM); |
| 36 | } |
| 37 | |
Grant Likely | 672c544 | 2011-01-13 15:36:09 -0700 | [diff] [blame] | 38 | void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) |
Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 39 | { |
Grant Likely | 672c544 | 2011-01-13 15:36:09 -0700 | [diff] [blame] | 40 | return __alloc_bootmem(size, align, __pa(MAX_DMA_ADDRESS)); |
Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | #ifdef CONFIG_BLK_DEV_INITRD |
| 44 | void __init early_init_dt_setup_initrd_arch(unsigned long start, |
| 45 | unsigned long end) |
| 46 | { |
| 47 | initrd_start = (unsigned long)__va(start); |
| 48 | initrd_end = (unsigned long)__va(end); |
| 49 | initrd_below_start_ok = 1; |
| 50 | } |
| 51 | #endif |
| 52 | |
Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 53 | void __init early_init_devtree(void *params) |
| 54 | { |
| 55 | /* Setup flat device-tree pointer */ |
| 56 | initial_boot_params = params; |
| 57 | |
| 58 | /* Retrieve various informations from the /chosen node of the |
| 59 | * device-tree, including the platform type, initrd location and |
| 60 | * size, and more ... |
| 61 | */ |
Grant Likely | 85f60ae | 2011-04-29 00:18:16 -0600 | [diff] [blame] | 62 | of_scan_flat_dt(early_init_dt_scan_chosen, arcs_cmdline); |
| 63 | |
Dezhong Diao | f2ffa5a | 2010-10-13 00:52:46 -0600 | [diff] [blame] | 64 | |
| 65 | /* Scan memory nodes */ |
| 66 | of_scan_flat_dt(early_init_dt_scan_root, NULL); |
| 67 | of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); |
| 68 | } |
| 69 | |
Ralf Baechle | 7d6168e | 2012-01-25 15:03:19 +0100 | [diff] [blame] | 70 | void __init __dt_setup_arch(struct boot_param_header *bph) |
| 71 | { |
| 72 | if (be32_to_cpu(bph->magic) != OF_DT_HEADER) { |
| 73 | pr_err("DTB has bad magic, ignoring builtin OF DTB\n"); |
| 74 | |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | initial_boot_params = bph; |
John Crispin | 40e91ae | 2012-05-02 12:27:35 +0200 | [diff] [blame] | 79 | |
| 80 | early_init_devtree(initial_boot_params); |
Ralf Baechle | 7d6168e | 2012-01-25 15:03:19 +0100 | [diff] [blame] | 81 | } |