pamu_table.c 1.5 KB

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