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