csu.c 691 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright 2020 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include <endian.h>
  8. #include <common/debug.h>
  9. #include <csu.h>
  10. #include <lib/mmio.h>
  11. void enable_layerscape_ns_access(struct csu_ns_dev_st *csu_ns_dev,
  12. uint32_t num, uintptr_t nxp_csu_addr)
  13. {
  14. uint32_t *base = (uint32_t *)nxp_csu_addr;
  15. uint32_t *reg;
  16. uint32_t val;
  17. int i;
  18. for (i = 0; i < num; i++) {
  19. reg = base + csu_ns_dev[i].ind / 2U;
  20. val = be32toh(mmio_read_32((uintptr_t)reg));
  21. if (csu_ns_dev[i].ind % 2U == 0U) {
  22. val &= 0x0000ffffU;
  23. val |= csu_ns_dev[i].val << 16U;
  24. } else {
  25. val &= 0xffff0000U;
  26. val |= csu_ns_dev[i].val;
  27. }
  28. mmio_write_32((uintptr_t)reg, htobe32(val));
  29. }
  30. }