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