prom.c 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Device tree support
  4. *
  5. * Copyright (C) 2013, 2015 Altera Corporation
  6. * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
  7. *
  8. * Based on MIPS support for CONFIG_OF device tree support
  9. *
  10. * Copyright (C) 2010 Cisco Systems Inc. <dediao@cisco.com>
  11. */
  12. #include <linux/init.h>
  13. #include <linux/types.h>
  14. #include <linux/memblock.h>
  15. #include <linux/of.h>
  16. #include <linux/of_fdt.h>
  17. #include <linux/io.h>
  18. #include <asm/sections.h>
  19. void __init early_init_devtree(void *params)
  20. {
  21. __be32 *dtb = (u32 *)__dtb_start;
  22. #if defined(CONFIG_NIOS2_DTB_AT_PHYS_ADDR)
  23. if (be32_to_cpup((__be32 *)CONFIG_NIOS2_DTB_PHYS_ADDR) ==
  24. OF_DT_HEADER) {
  25. params = (void *)CONFIG_NIOS2_DTB_PHYS_ADDR;
  26. early_init_dt_scan(params);
  27. return;
  28. }
  29. #endif
  30. if (be32_to_cpu((__be32) *dtb) == OF_DT_HEADER)
  31. params = (void *)__dtb_start;
  32. early_init_dt_scan(params);
  33. }