devtree.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include <linux/init.h>
  14. #include <linux/export.h>
  15. #include <linux/types.h>
  16. #include <linux/bootmem.h>
  17. #include <linux/memblock.h>
  18. #include <linux/of.h>
  19. #include <linux/of_fdt.h>
  20. #include <asm/setup.h>
  21. #include <asm/page.h>
  22. #include <asm/mach/arch.h>
  23. void __init early_init_dt_add_memory_arch(u64 base, u64 size)
  24. {
  25. pr_err("%s(%llx, %llx)\n",
  26. __func__, base, size);
  27. }
  28. void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
  29. {
  30. return alloc_bootmem_align(size, align);
  31. }
  32. static const void * __init arch_get_next_mach(const char *const **match)
  33. {
  34. static const struct machine_desc *mdesc = __arch_info_begin;
  35. const struct machine_desc *m = mdesc;
  36. if (m >= __arch_info_end)
  37. return NULL;
  38. mdesc++;
  39. *match = m->dt_compat;
  40. return m;
  41. }
  42. /**
  43. * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
  44. * @dt: virtual address pointer to dt blob
  45. *
  46. * If a dtb was passed to the kernel, then use it to choose the correct
  47. * machine_desc and to setup the system.
  48. */
  49. const struct machine_desc * __init setup_machine_fdt(void *dt)
  50. {
  51. const struct machine_desc *mdesc;
  52. /* check device tree validity */
  53. if (!early_init_dt_scan(dt))
  54. return NULL;
  55. mdesc = of_flat_dt_match_machine(NULL, arch_get_next_mach);
  56. if (!mdesc)
  57. dump_machine_table(); /* does not return */
  58. pr_info("Machine name: %s\n", mdesc->name);
  59. return mdesc;
  60. }