apusys_dapc_v1.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2023, MediaTek Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /* TF-A system header */
  7. #include <common/debug.h>
  8. #include <lib/utils_def.h>
  9. /* Vendor header */
  10. #include "apusys.h"
  11. #include "apusys_dapc_v1.h"
  12. #include <platform_def.h>
  13. enum apusys_apc_err_status set_apusys_dapc_v1(const struct apc_dom_16 *dapc,
  14. uint32_t size, dapc_cfg_func cfg)
  15. {
  16. enum apusys_apc_err_status ret = APUSYS_APC_OK;
  17. uint32_t i;
  18. if ((dapc == NULL) || (cfg == NULL)) {
  19. return APUSYS_APC_ERR_GENERIC;
  20. }
  21. for (i = 0; i < size; i++) {
  22. ret += cfg(i, DOMAIN_0, dapc[i].d0_permission);
  23. ret += cfg(i, DOMAIN_1, dapc[i].d1_permission);
  24. ret += cfg(i, DOMAIN_2, dapc[i].d2_permission);
  25. ret += cfg(i, DOMAIN_3, dapc[i].d3_permission);
  26. ret += cfg(i, DOMAIN_4, dapc[i].d4_permission);
  27. ret += cfg(i, DOMAIN_5, dapc[i].d5_permission);
  28. ret += cfg(i, DOMAIN_6, dapc[i].d6_permission);
  29. ret += cfg(i, DOMAIN_7, dapc[i].d7_permission);
  30. ret += cfg(i, DOMAIN_8, dapc[i].d8_permission);
  31. ret += cfg(i, DOMAIN_9, dapc[i].d9_permission);
  32. ret += cfg(i, DOMAIN_10, dapc[i].d10_permission);
  33. ret += cfg(i, DOMAIN_11, dapc[i].d11_permission);
  34. ret += cfg(i, DOMAIN_12, dapc[i].d12_permission);
  35. ret += cfg(i, DOMAIN_13, dapc[i].d13_permission);
  36. ret += cfg(i, DOMAIN_14, dapc[i].d14_permission);
  37. ret += cfg(i, DOMAIN_15, dapc[i].d15_permission);
  38. }
  39. if (ret != APUSYS_APC_OK) {
  40. ret = APUSYS_APC_ERR_GENERIC;
  41. }
  42. return ret;
  43. }
  44. void dump_apusys_dapc_v1(const char *name, uintptr_t base, uint32_t reg_num, uint32_t dom_num)
  45. {
  46. uint32_t d, i;
  47. if ((name == NULL) || (base == 0)) {
  48. return;
  49. }
  50. for (d = 0; d < dom_num; d++) {
  51. for (i = 0; i <= reg_num; i++) {
  52. INFO(MODULE_TAG "[%s] D%d_APC_%d: 0x%x\n", name, d, i,
  53. mmio_read_32(base + d * DEVAPC_DOM_SIZE + i * DEVAPC_REG_SIZE));
  54. }
  55. }
  56. INFO(MODULE_TAG "[%s] APC_CON: 0x%x\n", name, mmio_read_32(APUSYS_DAPC_CON(base)));
  57. }