prom.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Device tree support
  3. *
  4. * Copyright (C) 2013, 2015 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. #include <linux/init.h>
  26. #include <linux/types.h>
  27. #include <linux/bootmem.h>
  28. #include <linux/of.h>
  29. #include <linux/of_fdt.h>
  30. #include <linux/io.h>
  31. #include <asm/sections.h>
  32. void __init early_init_dt_add_memory_arch(u64 base, u64 size)
  33. {
  34. u64 kernel_start = (u64)virt_to_phys(_text);
  35. if (!memory_size &&
  36. (kernel_start >= base) && (kernel_start < (base + size)))
  37. memory_size = size;
  38. }
  39. int __init early_init_dt_reserve_memory_arch(phys_addr_t base, phys_addr_t size,
  40. bool nomap)
  41. {
  42. reserve_bootmem(base, size, BOOTMEM_DEFAULT);
  43. return 0;
  44. }
  45. void __init early_init_devtree(void *params)
  46. {
  47. __be32 *dtb = (u32 *)__dtb_start;
  48. #if defined(CONFIG_NIOS2_DTB_AT_PHYS_ADDR)
  49. if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
  50. OF_DT_HEADER) {
  51. params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR;
  52. early_init_dt_scan(params);
  53. return;
  54. }
  55. #endif
  56. if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
  57. params = (void *)__dtb_start;
  58. early_init_dt_scan(params);
  59. }