pamu_table.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2012-2016 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <log.h>
  7. #include <asm/fsl_pamu.h>
  8. DECLARE_GLOBAL_DATA_PTR;
  9. void construct_pamu_addr_table(struct pamu_addr_tbl *tbl, int *num_entries)
  10. {
  11. int i = 0;
  12. int j;
  13. tbl->start_addr[i] =
  14. (uint64_t)virt_to_phys((void *)CONFIG_SYS_SDRAM_BASE);
  15. tbl->size[i] = (phys_size_t)(min(gd->ram_size, CONFIG_MAX_MEM_MAPPED));
  16. tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
  17. i++;
  18. #ifdef CONFIG_SYS_FLASH_BASE_PHYS
  19. tbl->start_addr[i] =
  20. (uint64_t)virt_to_phys((void *)CONFIG_SYS_FLASH_BASE_PHYS);
  21. tbl->size[i] = 256 * 1024 * 1024; /* 256MB flash */
  22. tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
  23. i++;
  24. #endif
  25. #if (defined(CONFIG_SPL_BUILD) && (CONFIG_SYS_INIT_L3_VADDR))
  26. tbl->start_addr[i] =
  27. (uint64_t)virt_to_phys((void *)CONFIG_SYS_INIT_L3_VADDR);
  28. tbl->size[i] = 256 * 1024; /* 256K CPC flash */
  29. tbl->end_addr[i] = tbl->start_addr[i] + tbl->size[i] - 1;
  30. i++;
  31. #endif
  32. debug("PAMU address\t\t\tsize\n");
  33. for (j = 0; j < i ; j++)
  34. debug("%llx \t\t\t%llx\n", tbl->start_addr[j], tbl->size[j]);
  35. *num_entries = i;
  36. }
  37. int sec_config_pamu_table(uint32_t liodn_ns, uint32_t liodn_s)
  38. {
  39. struct pamu_addr_tbl tbl;
  40. int num_entries = 0;
  41. int ret = 0;
  42. construct_pamu_addr_table(&tbl, &num_entries);
  43. ret = config_pamu(&tbl, num_entries, liodn_ns);
  44. if (ret)
  45. return ret;
  46. ret = config_pamu(&tbl, num_entries, liodn_s);
  47. if (ret)
  48. return ret;
  49. return ret;
  50. }