bootm-fdt.c 1.4 KB

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