bootm-fdt.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. int arch_fixup_fdt(void *blob)
  26. {
  27. bd_t *bd = gd->bd;
  28. int bank, ret;
  29. u64 start[CONFIG_NR_DRAM_BANKS];
  30. u64 size[CONFIG_NR_DRAM_BANKS];
  31. for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
  32. start[bank] = bd->bi_dram[bank].start;
  33. size[bank] = bd->bi_dram[bank].size;
  34. #ifdef CONFIG_ARMV7_NONSEC
  35. ret = armv7_apply_memory_carveout(&start[bank], &size[bank]);
  36. if (ret)
  37. return ret;
  38. #endif
  39. }
  40. ret = fdt_fixup_memory_banks(blob, start, size, CONFIG_NR_DRAM_BANKS);
  41. if (ret)
  42. return ret;
  43. #ifdef CONFIG_ARMV8_SPIN_TABLE
  44. ret = spin_table_update_dt(blob);
  45. if (ret)
  46. return ret;
  47. #endif
  48. #if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI)
  49. ret = psci_update_dt(blob);
  50. if (ret)
  51. return ret;
  52. #endif
  53. return 0;
  54. }