// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
 * Apple T8132 "M4" SoC
 *
 * Copyright The Asahi Linux Contributors
 */

#include <dt-bindings/interrupt-controller/apple-aic.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/pinctrl/apple.h>

/ {
	compatible = "apple,t8132", "apple,arm-platform";

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

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

		cpu-map {
			cluster0 {
				core0 {
					cpu = <&cpu_e0>;
				};
				core1 {
					cpu = <&cpu_e1>;
				};
				core2 {
					cpu = <&cpu_e2>;
				};
				core3 {
					cpu = <&cpu_e3>;
				};
				core4 {
					cpu = <&cpu_e4>;
				};
				core5 {
					cpu = <&cpu_e5>;
				};
			};

			cluster1 {
				core0 {
					cpu = <&cpu_p0>;
				};
				core1 {
					cpu = <&cpu_p1>;
				};
				core2 {
					cpu = <&cpu_p2>;
				};
				core3 {
					cpu = <&cpu_p3>;
				};
			};
		};

		cpu_e0: cpu@0 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x0>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_e1: cpu@1 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x1>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_e2: cpu@2 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x2>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_e3: cpu@3 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x3>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_e4: cpu@4 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x4>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_e5: cpu@5 {
			compatible = "apple,donan-e";
			device_type = "cpu";
			reg = <0x0 0x5>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_0>;
			i-cache-size = <0x20000>;
			d-cache-size = <0x10000>;
		};

		cpu_p0: cpu@10100 {
			compatible = "apple,donan-p";
			device_type = "cpu";
			reg = <0x0 0x10100>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_1>;
			i-cache-size = <0x30000>;
			d-cache-size = <0x20000>;
		};

		cpu_p1: cpu@10101 {
			compatible = "apple,donan-p";
			device_type = "cpu";
			reg = <0x0 0x10101>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_1>;
			i-cache-size = <0x30000>;
			d-cache-size = <0x20000>;
		};

		cpu_p2: cpu@10102 {
			compatible = "apple,donan-p";
			device_type = "cpu";
			reg = <0x0 0x10102>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_1>;
			i-cache-size = <0x30000>;
			d-cache-size = <0x20000>;
		};

		cpu_p3: cpu@10103 {
			compatible = "apple,donan-p";
			device_type = "cpu";
			reg = <0x0 0x10103>;
			enable-method = "spin-table";
			cpu-release-addr = <0 0>;
			next-level-cache = <&l2_cache_1>;
			i-cache-size = <0x30000>;
			d-cache-size = <0x20000>;
		};

		l2_cache_0: l2-cache-0 {
			compatible = "cache";
			cache-level = <2>;
			cache-unified;
			cache-size = <0x400000>;
		};

		l2_cache_1: l2-cache-1 {
			compatible = "cache";
			cache-level = <2>;
			cache-unified;
			cache-size = <0x1000000>;
		};
	};

	clkref: clock-ref {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <24000000>;
		clock-output-names = "clkref";
	};

	soc: soc {
		compatible = "simple-bus";
		#address-cells = <2>;
		#size-cells = <2>;

		ranges;
		nonposted-mmio;

		pmgr: power-management@380700000 {
			compatible = "apple,t8132-pmgr", "apple,t8103-pmgr", "syscon", "simple-mfd";
			#address-cells = <1>;
			#size-cells = <1>;
			reg = <0x3 0x80700000 0 0x14000>;
			/* child nodes are added in t8132-pmgr.dtsi */
		};

		aic: interrupt-controller@381000000 {
			compatible = "apple,t8132-aic3", "apple,t8122-aic3";
			#interrupt-cells = <3>;
			interrupt-controller;
			reg = <0x3 0x81000000 0x0 0x1cc000>,
			      <0x3 0x81040000 0x0 0x4000>;
			reg-names = "core", "event";
			power-domains = <&ps_aic>;

			affinities {
				e-core-pmu-affinity {
					apple,fiq-index = <AIC_CPU_PMU_E>;
					cpus = <&cpu_e0 &cpu_e1 &cpu_e2 &cpu_e3 &cpu_e4 &cpu_e5>;
				};

				p-core-pmu-affinity {
					apple,fiq-index = <AIC_CPU_PMU_P>;
					cpus = <&cpu_p0 &cpu_p1 &cpu_p2 &cpu_p3>;
				};
			};
		};

		pinctrl_nub: pinctrl@3881f0000 {
			compatible = "apple,t8132-pinctrl", "apple,t8103-pinctrl";
			reg = <0x3 0x881f0000 0x0 0x4000>;
			power-domains = <&ps_nub_gpio>;

			gpio-controller;
			#gpio-cells = <2>;
			gpio-ranges = <&pinctrl_nub 0 0 32>;
			apple,npins = <32>;

			interrupt-controller;
			#interrupt-cells = <2>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 499 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 500 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 501 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 502 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 503 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 504 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 505 IRQ_TYPE_LEVEL_HIGH>;
		};

		pmgr_mini: power-management@388280000 {
			compatible = "apple,t8132-pmgr", "apple,t8103-pmgr", "syscon", "simple-mfd";
			#address-cells = <1>;
			#size-cells = <1>;
			reg = <0x3 0x88280000 0 0x4000>;
			/* child nodes are added in t8132-pmgr.dtsi */
		};

		wdt: watchdog@3882b0000 {
			compatible = "apple,t8132-wdt", "apple,t8103-wdt";
			reg = <0x3 0x882b0000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 507 IRQ_TYPE_LEVEL_HIGH>;
		};

		pinctrl_smc: pinctrl@38c820000 {
			compatible = "apple,t8132-pinctrl", "apple,t8103-pinctrl";
			reg = <0x3 0x8c820000 0x0 0x4000>;

			gpio-controller;
			#gpio-cells = <2>;
			gpio-ranges = <&pinctrl_smc 0 0 18>;
			apple,npins = <18>;

			interrupt-controller;
			#interrupt-cells = <2>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 552 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 553 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 554 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 555 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 556 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 557 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 558 IRQ_TYPE_LEVEL_HIGH>;
		};

		pinctrl_aop: pinctrl@390824000 {
			compatible = "apple,t8132-pinctrl", "apple,t8103-pinctrl";
			reg = <0x3 0x90824000 0x0 0x4000>;

			gpio-controller;
			#gpio-cells = <2>;
			gpio-ranges = <&pinctrl_aop 0 0 57>;
			apple,npins = <57>;

			interrupt-controller;
			#interrupt-cells = <2>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 423 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 424 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 425 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 426 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 427 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 428 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 429 IRQ_TYPE_LEVEL_HIGH>;
		};

		pinctrl_ap: pinctrl@39a000000 {
			compatible = "apple,t8132-pinctrl", "apple,t8103-pinctrl";
			reg = <0x3 0x9a000000 0x0 0x100000>;
			power-domains = <&ps_gpio>;

			gpio-controller;
			#gpio-cells = <2>;
			gpio-ranges = <&pinctrl_ap 0 0 224>;
			apple,npins = <224>;

			interrupt-controller;
			#interrupt-cells = <2>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 303 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 304 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 305 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 306 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 307 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 308 IRQ_TYPE_LEVEL_HIGH>,
			             <AIC_IRQ 309 IRQ_TYPE_LEVEL_HIGH>;

			i2c0_pins: i2c0-pins {
				pinmux = <APPLE_PINMUX(104, 1)>,
				         <APPLE_PINMUX(103, 1)>;
			};

			i2c1_pins: i2c1-pins {
				pinmux = <APPLE_PINMUX(106, 1)>,
				         <APPLE_PINMUX(105, 1)>;
			};

			i2c2_pins: i2c2-pins {
				pinmux = <APPLE_PINMUX(44, 1)>,
				         <APPLE_PINMUX(43, 1)>;
			};

			i2c3_pins: i2c3-pins {
				pinmux = <APPLE_PINMUX(42, 1)>,
				         <APPLE_PINMUX(41, 1)>;
			};

			i2c4_pins: i2c4-pins {
				pinmux = <APPLE_PINMUX(108, 1)>,
				         <APPLE_PINMUX(107, 1)>;
			};
		};

		i2c0: i2c@3ad010000 {
			compatible = "apple,t8132-i2c", "apple,t8103-i2c";
			reg = <0x3 0xad010000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1062 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-0 = <&i2c0_pins>;
			pinctrl-names = "default";
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			power-domains = <&ps_i2c0>;

			status = "disabled";
		};

		i2c1: i2c@3ad014000 {
			compatible = "apple,t8132-i2c", "apple,t8103-i2c";
			reg = <0x3 0xad014000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1063 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-0 = <&i2c1_pins>;
			pinctrl-names = "default";
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			power-domains = <&ps_i2c1>;

			status = "disabled";
		};

		i2c2: i2c@3ad018000 {
			compatible = "apple,t8132-i2c", "apple,t8103-i2c";
			reg = <0x3 0xad018000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1064 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-0 = <&i2c2_pins>;
			pinctrl-names = "default";
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			power-domains = <&ps_i2c2>;

			status = "disabled";
		};

		i2c3: i2c@3ad01c000 {
			compatible = "apple,t8132-i2c", "apple,t8103-i2c";
			reg = <0x3 0xad01c000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1065 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-0 = <&i2c3_pins>;
			pinctrl-names = "default";
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			power-domains = <&ps_i2c3>;

			status = "disabled";
		};

		i2c4: i2c@3ad020000 {
			compatible = "apple,t8132-i2c", "apple,t8103-i2c";
			reg = <0x3 0xad020000 0x0 0x4000>;
			clocks = <&clkref>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1066 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-0 = <&i2c4_pins>;
			pinctrl-names = "default";
			#address-cells = <0x1>;
			#size-cells = <0x0>;
			power-domains = <&ps_i2c4>;

			status = "disabled";
		};

		fpwm1: pwm@3ad044000 {
			compatible = "apple,t8132-fpwm", "apple,s5l-fpwm";
			reg = <0x3 0xad044000 0x0 0x4000>;
			power-domains = <&ps_fpwm1>;
			clocks = <&clkref>;
			#pwm-cells = <2>;

			status = "disabled";
		};

		serial0: serial@3ad200000 {
			compatible = "apple,s5l-uart";
			reg = <0x3 0xad200000 0x0 0x1000>;
			reg-io-width = <4>;
			interrupt-parent = <&aic>;
			interrupts = <AIC_IRQ 1046 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&clkref>, <&clkref>;
			clock-names = "uart", "clk_uart_baud0";
			power-domains = <&ps_uart0>;

			status = "disabled";
		};
	};

	timer {
		compatible = "arm,armv8-timer";
		interrupt-parent = <&aic>;
		interrupt-names = "phys", "virt", "hyp-phys", "hyp-virt";
		interrupts = <AIC_FIQ AIC_TMR_GUEST_PHYS IRQ_TYPE_LEVEL_HIGH>,
		             <AIC_FIQ AIC_TMR_GUEST_VIRT IRQ_TYPE_LEVEL_HIGH>,
		             <AIC_FIQ AIC_TMR_HV_PHYS IRQ_TYPE_LEVEL_HIGH>,
		             <AIC_FIQ AIC_TMR_HV_VIRT IRQ_TYPE_LEVEL_HIGH>;
	};
};

#include "t8132-pmgr.dtsi"