18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Renesas RZ/G2E System Controller
48c2ecf20Sopenharmony_ci * Copyright (C) 2018 Renesas Electronics Corp.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Based on Renesas R-Car E3 System Controller
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#include <linux/bits.h>
108c2ecf20Sopenharmony_ci#include <linux/kernel.h>
118c2ecf20Sopenharmony_ci#include <linux/sys_soc.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <dt-bindings/power/r8a774c0-sysc.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "rcar-sysc.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_cistatic struct rcar_sysc_area r8a774c0_areas[] __initdata = {
188c2ecf20Sopenharmony_ci	{ "always-on",	    0, 0, R8A774C0_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
198c2ecf20Sopenharmony_ci	{ "ca53-scu",	0x140, 0, R8A774C0_PD_CA53_SCU,  R8A774C0_PD_ALWAYS_ON,
208c2ecf20Sopenharmony_ci	  PD_SCU },
218c2ecf20Sopenharmony_ci	{ "ca53-cpu0",	0x200, 0, R8A774C0_PD_CA53_CPU0, R8A774C0_PD_CA53_SCU,
228c2ecf20Sopenharmony_ci	  PD_CPU_NOCR },
238c2ecf20Sopenharmony_ci	{ "ca53-cpu1",	0x200, 1, R8A774C0_PD_CA53_CPU1, R8A774C0_PD_CA53_SCU,
248c2ecf20Sopenharmony_ci	  PD_CPU_NOCR },
258c2ecf20Sopenharmony_ci	{ "a3vc",	0x380, 0, R8A774C0_PD_A3VC,	R8A774C0_PD_ALWAYS_ON },
268c2ecf20Sopenharmony_ci	{ "a2vc1",	0x3c0, 1, R8A774C0_PD_A2VC1,	R8A774C0_PD_A3VC },
278c2ecf20Sopenharmony_ci	{ "3dg-a",	0x100, 0, R8A774C0_PD_3DG_A,	R8A774C0_PD_ALWAYS_ON },
288c2ecf20Sopenharmony_ci	{ "3dg-b",	0x100, 1, R8A774C0_PD_3DG_B,	R8A774C0_PD_3DG_A },
298c2ecf20Sopenharmony_ci};
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci/* Fixups for RZ/G2E ES1.0 revision */
328c2ecf20Sopenharmony_cistatic const struct soc_device_attribute r8a774c0[] __initconst = {
338c2ecf20Sopenharmony_ci	{ .soc_id = "r8a774c0", .revision = "ES1.0" },
348c2ecf20Sopenharmony_ci	{ /* sentinel */ }
358c2ecf20Sopenharmony_ci};
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cistatic int __init r8a774c0_sysc_init(void)
388c2ecf20Sopenharmony_ci{
398c2ecf20Sopenharmony_ci	if (soc_device_match(r8a774c0)) {
408c2ecf20Sopenharmony_ci		/* Fix incorrect 3DG hierarchy */
418c2ecf20Sopenharmony_ci		swap(r8a774c0_areas[6], r8a774c0_areas[7]);
428c2ecf20Sopenharmony_ci		r8a774c0_areas[6].parent = R8A774C0_PD_ALWAYS_ON;
438c2ecf20Sopenharmony_ci		r8a774c0_areas[7].parent = R8A774C0_PD_3DG_B;
448c2ecf20Sopenharmony_ci	}
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	return 0;
478c2ecf20Sopenharmony_ci}
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciconst struct rcar_sysc_info r8a774c0_sysc_info __initconst = {
508c2ecf20Sopenharmony_ci	.init = r8a774c0_sysc_init,
518c2ecf20Sopenharmony_ci	.areas = r8a774c0_areas,
528c2ecf20Sopenharmony_ci	.num_areas = ARRAY_SIZE(r8a774c0_areas),
538c2ecf20Sopenharmony_ci	.extmask_offs = 0x2f8,
548c2ecf20Sopenharmony_ci	.extmask_val = BIT(0),
558c2ecf20Sopenharmony_ci};
56