1/* 2 * linux/arch/metag/kernel/devtree.c 3 * 4 * Copyright (C) 2012 Imagination Technologies Ltd. 5 * 6 * Based on ARM version: 7 * Copyright (C) 2009 Canonical Ltd. <jeremy.kerr@canonical.com> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License version 2 as 11 * published by the Free Software Foundation. 12 */ 13 14#include <linux/init.h> 15#include <linux/export.h> 16#include <linux/types.h> 17#include <linux/bootmem.h> 18#include <linux/memblock.h> 19#include <linux/of.h> 20#include <linux/of_fdt.h> 21 22#include <asm/setup.h> 23#include <asm/page.h> 24#include <asm/mach/arch.h> 25 26void __init early_init_dt_add_memory_arch(u64 base, u64 size) 27{ 28 pr_err("%s(%llx, %llx)\n", 29 __func__, base, size); 30} 31 32void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align) 33{ 34 return alloc_bootmem_align(size, align); 35} 36 37static const void * __init arch_get_next_mach(const char *const **match) 38{ 39 static const struct machine_desc *mdesc = __arch_info_begin; 40 const struct machine_desc *m = mdesc; 41 42 if (m >= __arch_info_end) 43 return NULL; 44 45 mdesc++; 46 *match = m->dt_compat; 47 return m; 48} 49 50/** 51 * setup_machine_fdt - Machine setup when an dtb was passed to the kernel 52 * @dt: virtual address pointer to dt blob 53 * 54 * If a dtb was passed to the kernel, then use it to choose the correct 55 * machine_desc and to setup the system. 56 */ 57const struct machine_desc * __init setup_machine_fdt(void *dt) 58{ 59 const struct machine_desc *mdesc; 60 61 /* check device tree validity */ 62 if (!early_init_dt_scan(dt)) 63 return NULL; 64 65 mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach); 66 if (!mdesc) 67 dump_machine_table(); /* does not return */ 68 pr_info("Machine name: %s\n", mdesc->name); 69 70 return mdesc; 71} 72