bootm-fdt.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/global_data.h>
  22. #include <asm/psci.h>
  23. #include <asm/spin_table.h>
  24. DECLARE_GLOBAL_DATA_PTR;
  25. #ifdef CONFIG_FMAN_ENET
  26. __weak int fdt_update_ethernet_dt(void *blob)
  27. {
  28. return 0;
  29. }
  30. #endif
  31. int arch_fixup_fdt(void *blob)
  32. {
  33. __maybe_unused int ret = 0;
  34. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_OF_LIBFDT)
  35. struct bd_info *bd = gd->bd;
  36. int bank;
  37. u64 start[CONFIG_NR_DRAM_BANKS];
  38. u64 size[CONFIG_NR_DRAM_BANKS];
  39. for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
  40. start[bank] = bd->bi_dram[bank].start;
  41. size[bank] = bd->bi_dram[bank].size;
  42. #ifdef CONFIG_ARMV7_NONSEC
  43. ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
  44. if (ret)
  45. return ret;
  46. #endif
  47. }
  48. #ifdef CONFIG_OF_LIBFDT
  49. ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
  50. if (ret)
  51. return ret;
  52. #endif
  53. #ifdef CONFIG_ARMV8_SPIN_TABLE
  54. ret = spin_table_update_dt(blob);
  55. if (ret)
  56. return ret;
  57. #endif
  58. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
  59. CONFIG_IS_ENABLED(SEC_FIRMWARE_ARMV8_PSCI)
  60. ret = psci_update_dt(blob);
  61. if (ret)
  62. return ret;
  63. #endif
  64. #endif
  65. #ifdef CONFIG_FMAN_ENET
  66. ret = fdt_update_ethernet_dt(blob);
  67. if (ret)
  68. return ret;
  69. #endif
  70. return 0;
  71. }