diff options
author | David Daney <david.daney@cavium.com> | 2012-07-05 12:12:38 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2012-07-23 08:54:52 -0400 |
commit | 7ed1815296498e9d1bfa1f13e94b743364b14caf (patch) | |
tree | f8988180f1827f9a0f9e251ae79afc80745ec7f6 /arch/mips/cavium-octeon/setup.c | |
parent | b01da9f130adbf69cfbad2a65f1327f1382bf4ae (diff) |
MIPS: Octeon: Initialize and fixup device tree.
If a compiled in device tree template is used, trim out unwanted parts
based on legacy platform probing.
Signed-off-by: David Daney <david.daney@cavium.com>
Cc: linux-mips@linux-mips.org
Cc: devicetree-discuss@lists.ozlabs.org
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: linux-kernel@vger.kernel.org
Cc: David Daney <david.daney@cavium.com>
Patchwork: https://patchwork.linux-mips.org/patch/3935/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/cavium-octeon/setup.c')
-rw-r--r-- | arch/mips/cavium-octeon/setup.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/mips/cavium-octeon/setup.c b/arch/mips/cavium-octeon/setup.c index 260dc247c05..919b0fb7bb1 100644 --- a/arch/mips/cavium-octeon/setup.c +++ b/arch/mips/cavium-octeon/setup.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/serial_core.h> | 22 | #include <linux/serial_core.h> |
23 | #include <linux/serial_8250.h> | 23 | #include <linux/serial_8250.h> |
24 | #include <linux/of_fdt.h> | ||
25 | #include <linux/libfdt.h> | ||
24 | 26 | ||
25 | #include <asm/processor.h> | 27 | #include <asm/processor.h> |
26 | #include <asm/reboot.h> | 28 | #include <asm/reboot.h> |
@@ -775,3 +777,46 @@ void prom_free_prom_memory(void) | |||
775 | } | 777 | } |
776 | #endif | 778 | #endif |
777 | } | 779 | } |
780 | |||
781 | int octeon_prune_device_tree(void); | ||
782 | |||
783 | extern const char __dtb_octeon_3xxx_begin; | ||
784 | extern const char __dtb_octeon_3xxx_end; | ||
785 | extern const char __dtb_octeon_68xx_begin; | ||
786 | extern const char __dtb_octeon_68xx_end; | ||
787 | void __init device_tree_init(void) | ||
788 | { | ||
789 | int dt_size; | ||
790 | struct boot_param_header *fdt; | ||
791 | bool do_prune; | ||
792 | |||
793 | if (octeon_bootinfo->minor_version >= 3 && octeon_bootinfo->fdt_addr) { | ||
794 | fdt = phys_to_virt(octeon_bootinfo->fdt_addr); | ||
795 | if (fdt_check_header(fdt)) | ||
796 | panic("Corrupt Device Tree passed to kernel."); | ||
797 | dt_size = be32_to_cpu(fdt->totalsize); | ||
798 | do_prune = false; | ||
799 | } else if (OCTEON_IS_MODEL(OCTEON_CN68XX)) { | ||
800 | fdt = (struct boot_param_header *)&__dtb_octeon_68xx_begin; | ||
801 | dt_size = &__dtb_octeon_68xx_end - &__dtb_octeon_68xx_begin; | ||
802 | do_prune = true; | ||
803 | } else { | ||
804 | fdt = (struct boot_param_header *)&__dtb_octeon_3xxx_begin; | ||
805 | dt_size = &__dtb_octeon_3xxx_end - &__dtb_octeon_3xxx_begin; | ||
806 | do_prune = true; | ||
807 | } | ||
808 | |||
809 | /* Copy the default tree from init memory. */ | ||
810 | initial_boot_params = early_init_dt_alloc_memory_arch(dt_size, 8); | ||
811 | if (initial_boot_params == NULL) | ||
812 | panic("Could not allocate initial_boot_params\n"); | ||
813 | memcpy(initial_boot_params, fdt, dt_size); | ||
814 | |||
815 | if (do_prune) { | ||
816 | octeon_prune_device_tree(); | ||
817 | pr_info("Using internal Device Tree.\n"); | ||
818 | } else { | ||
819 | pr_info("Using passed Device Tree.\n"); | ||
820 | } | ||
821 | unflatten_device_tree(); | ||
822 | } | ||