bootm-fdt.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (c) 2013, Google Inc.
  4. *
  5. * Copyright (C) 2011
  6. * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
  7. * - Added prep subcommand support
  8. * - Reorganized source - modeled after powerpc version
  9. *
  10. * (C) Copyright 2002
  11. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  12. * Marius Groeger <mgroeger@sysgo.de>
  13. *
  14. * Copyright (C) 2001 Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
  15. */
  16. #include <common.h>
  17. #include <fdt_support.h>
  18. #ifdef CONFIG_ARMV7_NONSEC
  19. #include <asm/armv7.h>
  20. #endif
  21. #include <asm/psci.h>
  22. #include <asm/spin_table.h>
  23. DECLARE_GLOBAL_DATA_PTR;
  24. #ifdef CONFIG_FMAN_ENET
  25. __weak int fdt_update_ethernet_dt(void *blob)
  26. {
  27. return 0;
  28. }
  29. #endif
  30. int arch_fixup_fdt(void *blob)
  31. {
  32. __maybe_unused int ret = 0;
  33. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT)
  34. struct bd_info *bd = gd->bd;
  35. int bank;
  36. u64 start[CONFIG_NR_DRAM_BANKS];
  37. u64 size[CONFIG_NR_DRAM_BANKS];
  38. for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
  39. start[bank] = bd->bi_dram[bank].start;
  40. size[bank] = bd->bi_dram[bank].size;
  41. #ifdef CONFIG_ARMV7_NONSEC
  42. ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
  43. if (ret)
  44. return ret;
  45. #endif
  46. }
  47. #ifdef CONFIG_OF_LIBFDT
  48. ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
  49. if (ret)
  50. return ret;
  51. #endif
  52. #ifdef CONFIG_ARMV8_SPIN_TABLE
  53. ret = spin_table_update_dt(blob);
  54. if (ret)
  55. return ret;
  56. #endif
  57. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
  58. defined(CONFIG_SEC_FIRMWARE_ARMV8_PSCI)
  59. ret = psci_update_dt(blob);
  60. if (ret)
  61. return ret;
  62. #endif
  63. #endif
  64. #ifdef CONFIG_FMAN_ENET
  65. ret = fdt_update_ethernet_dt(blob);
  66. if (ret)
  67. return ret;
  68. #endif
  69. return 0;
  70. }