// SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
/*
 * Device Tree Source for the r8a774a3 SoC
 *
 * Copyright (C) 2026 Renesas Electronics Corp.
 */

#include <dt-bindings/clock/renesas,r8a774a3-cpg-mssr.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/power/renesas,r8a774a3-sysc.h>

/ {
	compatible = "renesas,r8a774a3";
	#address-cells = <2>;
	#size-cells = <2>;
	interrupt-parent = <&gic>;

	cluster0_opp: opp-table-0 {
		compatible = "operating-points-v2";
		opp-shared;

		opp-500000000 {
			opp-hz = /bits/ 64 <500000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
		};
		opp-1000000000 {
			opp-hz = /bits/ 64 <1000000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
		};
		opp-1500000000 {
			opp-hz = /bits/ 64 <1500000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
			opp-suspend;
		};
	};

	cluster1_opp: opp-table-1 {
		compatible = "operating-points-v2";
		opp-shared;

		opp-800000000 {
			opp-hz = /bits/ 64 <800000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
		};
		opp-1000000000 {
			opp-hz = /bits/ 64 <1000000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
		};
		opp-1200000000 {
			opp-hz = /bits/ 64 <1200000000>;
			opp-microvolt = <820000>;
			clock-latency-ns = <300000>;
		};
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu-map {
			cluster0 {
				core0 {
					cpu = <&a57_0>;
				};
				core1 {
					cpu = <&a57_1>;
				};
			};

			cluster1 {
				core0 {
					cpu = <&a53_0>;
				};
				core1 {
					cpu = <&a53_1>;
				};
				core2 {
					cpu = <&a53_2>;
				};
				core3 {
					cpu = <&a53_3>;
				};
			};
		};

		a57_0: cpu@0 {
			compatible = "arm,cortex-a57";
			reg = <0x0>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA57_CPU0>;
			next-level-cache = <&L2_CA57>;
			enable-method = "psci";
			dynamic-power-coefficient = <854>;
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z>;
			operating-points-v2 = <&cluster0_opp>;
			capacity-dmips-mhz = <1024>;
		};

		a57_1: cpu@1 {
			compatible = "arm,cortex-a57";
			reg = <0x1>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA57_CPU1>;
			next-level-cache = <&L2_CA57>;
			enable-method = "psci";
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z>;
			operating-points-v2 = <&cluster0_opp>;
			capacity-dmips-mhz = <1024>;
		};

		a53_0: cpu@100 {
			compatible = "arm,cortex-a53";
			reg = <0x100>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA53_CPU0>;
			next-level-cache = <&L2_CA53>;
			enable-method = "psci";
			dynamic-power-coefficient = <277>;
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z2>;
			operating-points-v2 = <&cluster1_opp>;
			capacity-dmips-mhz = <560>;
		};

		a53_1: cpu@101 {
			compatible = "arm,cortex-a53";
			reg = <0x101>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA53_CPU1>;
			next-level-cache = <&L2_CA53>;
			enable-method = "psci";
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z2>;
			operating-points-v2 = <&cluster1_opp>;
			capacity-dmips-mhz = <560>;
		};

		a53_2: cpu@102 {
			compatible = "arm,cortex-a53";
			reg = <0x102>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA53_CPU2>;
			next-level-cache = <&L2_CA53>;
			enable-method = "psci";
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z2>;
			operating-points-v2 = <&cluster1_opp>;
			capacity-dmips-mhz = <560>;
		};

		a53_3: cpu@103 {
			compatible = "arm,cortex-a53";
			reg = <0x103>;
			device_type = "cpu";
			power-domains = <&sysc R8A774A3_PD_CA53_CPU3>;
			next-level-cache = <&L2_CA53>;
			enable-method = "psci";
			clocks = <&cpg CPG_CORE R8A774A3_CLK_Z2>;
			operating-points-v2 = <&cluster1_opp>;
			capacity-dmips-mhz = <560>;
		};

		L2_CA57: cache-controller-0 {
			compatible = "cache";
			power-domains = <&sysc R8A774A3_PD_CA57_SCU>;
			cache-unified;
			cache-level = <2>;
		};

		L2_CA53: cache-controller-1 {
			compatible = "cache";
			power-domains = <&sysc R8A774A3_PD_CA53_SCU>;
			cache-unified;
			cache-level = <2>;
		};
	};

	extal_clk: extal {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		/* This value must be overridden by the board */
		clock-frequency = <0>;
		bootph-all;
	};

	extalr_clk: extalr {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		/* This value must be overridden by the board */
		clock-frequency = <0>;
		bootph-all;
	};

	pmu-a53 {
		compatible = "arm,cortex-a53-pmu";
		interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>,
			     <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-affinity = <&a53_0>, <&a53_1>, <&a53_2>, <&a53_3>;
	};

	pmu-a57 {
		compatible = "arm,cortex-a57-pmu";
		interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
			    <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-affinity = <&a57_0>, <&a57_1>;
	};

	psci {
		compatible = "arm,psci-1.0", "arm,psci-0.2";
		method = "smc";
	};

	/* External SCIF clock - to be overridden by boards that provide it */
	scif_clk: scif {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <0>;
	};

	soc: soc {
		compatible = "simple-bus";
		bootph-all;

		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		cpg: clock-controller@e6150000 {
			compatible = "renesas,r8a774a3-cpg-mssr";
			reg = <0 0xe6150000 0 0x1000>;
			clocks = <&extal_clk>, <&extalr_clk>;
			clock-names = "extal", "extalr";
			#clock-cells = <2>;
			#power-domain-cells = <0>;
			#reset-cells = <1>;
			bootph-all;
		};

		rst: reset-controller@e6160000 {
			compatible = "renesas,r8a774a3-rst";
			reg = <0 0xe6160000 0 0x200>;
			bootph-all;
		};

		sysc: system-controller@e6180000 {
			compatible = "renesas,r8a774a3-sysc";
			reg = <0 0xe6180000 0 0x400>;
			#power-domain-cells = <1>;
		};

		scif2: serial@e6e88000 {
			compatible = "renesas,scif-r8a774a3",
				     "renesas,rcar-gen3-scif", "renesas,scif";
			reg = <0 0xe6e88000 0 0x40>;
			interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&cpg CPG_MOD 310>,
				 <&cpg CPG_CORE R8A774A3_CLK_S3D1>,
				 <&scif_clk>;
			clock-names = "fck", "brg_int", "scif_clk";
			power-domains = <&sysc R8A774A3_PD_ALWAYS_ON>;
			resets = <&cpg 310>;
			status = "disabled";
		};

		gic: interrupt-controller@f1010000 {
			compatible = "arm,gic-400";
			#interrupt-cells = <3>;
			#address-cells = <0>;
			interrupt-controller;
			reg = <0x0 0xf1010000 0 0x1000>,
			      <0x0 0xf1020000 0 0x20000>,
			      <0x0 0xf1040000 0 0x20000>,
			      <0x0 0xf1060000 0 0x20000>;
			interrupts = <GIC_PPI 9
					(GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_HIGH)>;
			clocks = <&cpg CPG_MOD 408>;
			clock-names = "clk";
			power-domains = <&sysc R8A774A3_PD_ALWAYS_ON>;
			resets = <&cpg 408>;
		};

		prr: chipid@fff00044 {
			compatible = "renesas,prr";
			reg = <0 0xfff00044 0 4>;
			bootph-all;
		};
	};

	timer {
		compatible = "arm,armv8-timer";
		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>;
		interrupt-names = "sec-phys", "phys", "virt", "hyp-phys";
	};
};