common.c 855 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2018-2021, Renesas Electronics Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <lib/mmio.h>
  7. #include "cpg_registers.h"
  8. #include "rcar_private.h"
  9. #if IMAGE_BL31
  10. void __attribute__ ((section(".system_ram"))) cpg_write(uintptr_t regadr, uint32_t regval)
  11. #else
  12. void cpg_write(uintptr_t regadr, uint32_t regval)
  13. #endif
  14. {
  15. uint32_t value = regval;
  16. mmio_write_32(CPG_CPGWPR, ~value);
  17. mmio_write_32(regadr, value);
  18. }
  19. #if IMAGE_BL31
  20. void __attribute__ ((section(".system_ram"))) mstpcr_write(uint32_t mstpcr, uint32_t mstpsr,
  21. uint32_t target_bit)
  22. #else
  23. void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit)
  24. #endif
  25. {
  26. uint32_t reg;
  27. reg = mmio_read_32(mstpcr);
  28. reg &= ~target_bit;
  29. cpg_write(mstpcr, reg);
  30. while ((mmio_read_32(mstpsr) & target_bit) != 0U) {
  31. }
  32. }