xref: /rk3399_ARM-atf/drivers/renesas/rcar_gen4/ptp/ptp.c (revision e47c7a163cb9ddd18a83b7cff37fe76a040d0f80)
1 /*
2  * Copyright (c) 2015-2025, Renesas Electronics Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <lib/mmio.h>
8 #include <lib/utils_def.h>
9 
10 #define	RCAR_CPG_BASE		0xE6150000U
11 #define	RCAR_CPG_CPGWPR		(RCAR_CPG_BASE + 0x0000U)
12 #define	RCAR_CPG_CPGWPCR	(RCAR_CPG_BASE + 0x0004U)
13 
14 #define	RCAR_CPG_MSTPCR27	(RCAR_CPG_BASE + 0x2D6CU)
15 #define	RCAR_CPG_MSTPSR27	(RCAR_CPG_BASE + 0x2E6CU)
16 
17 #define	RCAR_PTPRO_BASE		0xE6449000U
18 #define	RCAR_PTPSCR0		(RCAR_PTPRO_BASE + 0x780U)
19 #define	RCAR_PTPSCR1		(RCAR_PTPRO_BASE + 0x784U)
20 
rcar_ptp_setup(void)21 void rcar_ptp_setup(void)
22 {
23 #if PTP_NONSECURE_ACCESS
24 	mmio_clrbits_32(RCAR_CPG_MSTPCR27, BIT(23));
25 	while ((mmio_read_32(RCAR_CPG_MSTPSR27) & BIT(23)) != 0)
26 		;
27 
28 	mmio_write_32(RCAR_PTPSCR0, 0x30003); /* PTPSCR0 */
29 	mmio_write_32(RCAR_PTPSCR1, 0x30003); /* PTPSCR1 */
30 #endif /* PTP_NONSECURE_ACCESS */
31 }
32