// SPDX-License-Identifier: GPL-2.0
/dts-v1/;

#include <dt-bindings/input/linux-event-codes.h>
#include <dt-bindings/input/gpio-keys.h>

#include "tegra194-p2888.dtsi"

/ {
	model = "NVIDIA Jetson AGX Xavier Developer Kit";
	compatible = "nvidia,p2972-0000", "nvidia,tegra194";

	bus@0 {
		aconnect@2900000 {
			status = "okay";

			dma-controller@2930000 {
				status = "okay";
			};

			interrupt-controller@2a40000 {
				status = "okay";
			};

			ahub@2900800 {
				status = "okay";

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

					port@0 {
						reg = <0x0>;

						xbar_admaif0_ep: endpoint {
							remote-endpoint = <&admaif0_ep>;
						};
					};

					port@1 {
						reg = <0x1>;

						xbar_admaif1_ep: endpoint {
							remote-endpoint = <&admaif1_ep>;
						};
					};

					port@2 {
						reg = <0x2>;

						xbar_admaif2_ep: endpoint {
							remote-endpoint = <&admaif2_ep>;
						};
					};

					port@3 {
						reg = <0x3>;

						xbar_admaif3_ep: endpoint {
							remote-endpoint = <&admaif3_ep>;
						};
					};

					port@4 {
						reg = <0x4>;

						xbar_admaif4_ep: endpoint {
							remote-endpoint = <&admaif4_ep>;
						};
					};

					port@5 {
						reg = <0x5>;

						xbar_admaif5_ep: endpoint {
							remote-endpoint = <&admaif5_ep>;
						};
					};

					port@6 {
						reg = <0x6>;

						xbar_admaif6_ep: endpoint {
							remote-endpoint = <&admaif6_ep>;
						};
					};

					port@7 {
						reg = <0x7>;

						xbar_admaif7_ep: endpoint {
							remote-endpoint = <&admaif7_ep>;
						};
					};

					port@8 {
						reg = <0x8>;

						xbar_admaif8_ep: endpoint {
							remote-endpoint = <&admaif8_ep>;
						};
					};

					port@9 {
						reg = <0x9>;

						xbar_admaif9_ep: endpoint {
							remote-endpoint = <&admaif9_ep>;
						};
					};

					port@a {
						reg = <0xa>;

						xbar_admaif10_ep: endpoint {
							remote-endpoint = <&admaif10_ep>;
						};
					};

					port@b {
						reg = <0xb>;

						xbar_admaif11_ep: endpoint {
							remote-endpoint = <&admaif11_ep>;
						};
					};

					port@c {
						reg = <0xc>;

						xbar_admaif12_ep: endpoint {
							remote-endpoint = <&admaif12_ep>;
						};
					};

					port@d {
						reg = <0xd>;

						xbar_admaif13_ep: endpoint {
							remote-endpoint = <&admaif13_ep>;
						};
					};

					port@e {
						reg = <0xe>;

						xbar_admaif14_ep: endpoint {
							remote-endpoint = <&admaif14_ep>;
						};
					};

					port@f {
						reg = <0xf>;

						xbar_admaif15_ep: endpoint {
							remote-endpoint = <&admaif15_ep>;
						};
					};

					port@10 {
						reg = <0x10>;

						xbar_admaif16_ep: endpoint {
							remote-endpoint = <&admaif16_ep>;
						};
					};

					port@11 {
						reg = <0x11>;

						xbar_admaif17_ep: endpoint {
							remote-endpoint = <&admaif17_ep>;
						};
					};

					port@12 {
						reg = <0x12>;

						xbar_admaif18_ep: endpoint {
							remote-endpoint = <&admaif18_ep>;
						};
					};

					port@13 {
						reg = <0x13>;

						xbar_admaif19_ep: endpoint {
							remote-endpoint = <&admaif19_ep>;
						};
					};

					xbar_i2s1_port: port@14 {
						reg = <0x14>;

						xbar_i2s1_ep: endpoint {
							remote-endpoint = <&i2s1_cif_ep>;
						};
					};

					xbar_i2s2_port: port@15 {
						reg = <0x15>;

						xbar_i2s2_ep: endpoint {
							remote-endpoint = <&i2s2_cif_ep>;
						};
					};

					xbar_i2s4_port: port@17 {
						reg = <0x17>;

						xbar_i2s4_ep: endpoint {
							remote-endpoint = <&i2s4_cif_ep>;
						};
					};

					xbar_i2s6_port: port@19 {
						reg = <0x19>;

						xbar_i2s6_ep: endpoint {
							remote-endpoint = <&i2s6_cif_ep>;
						};
					};

					xbar_dmic3_port: port@1c {
						reg = <0x1c>;

						xbar_dmic3_ep: endpoint {
							remote-endpoint = <&dmic3_cif_ep>;
						};
					};
				};

				admaif@290f000 {
					status = "okay";

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

						admaif0_port: port@0 {
							reg = <0x0>;

							admaif0_ep: endpoint {
								remote-endpoint = <&xbar_admaif0_ep>;
							};
						};

						admaif1_port: port@1 {
							reg = <0x1>;

							admaif1_ep: endpoint {
								remote-endpoint = <&xbar_admaif1_ep>;
							};
						};

						admaif2_port: port@2 {
							reg = <0x2>;

							admaif2_ep: endpoint {
								remote-endpoint = <&xbar_admaif2_ep>;
							};
						};

						admaif3_port: port@3 {
							reg = <0x3>;

							admaif3_ep: endpoint {
								remote-endpoint = <&xbar_admaif3_ep>;
							};
						};

						admaif4_port: port@4 {
							reg = <0x4>;

							admaif4_ep: endpoint {
								remote-endpoint = <&xbar_admaif4_ep>;
							};
						};

						admaif5_port: port@5 {
							reg = <0x5>;

							admaif5_ep: endpoint {
								remote-endpoint = <&xbar_admaif5_ep>;
							};
						};

						admaif6_port: port@6 {
							reg = <0x6>;

							admaif6_ep: endpoint {
								remote-endpoint = <&xbar_admaif6_ep>;
							};
						};

						admaif7_port: port@7 {
							reg = <0x7>;

							admaif7_ep: endpoint {
								remote-endpoint = <&xbar_admaif7_ep>;
							};
						};

						admaif8_port: port@8 {
							reg = <0x8>;

							admaif8_ep: endpoint {
								remote-endpoint = <&xbar_admaif8_ep>;
							};
						};

						admaif9_port: port@9 {
							reg = <0x9>;

							admaif9_ep: endpoint {
								remote-endpoint = <&xbar_admaif9_ep>;
							};
						};

						admaif10_port: port@a {
							reg = <0xa>;

							admaif10_ep: endpoint {
								remote-endpoint = <&xbar_admaif10_ep>;
							};
						};

						admaif11_port: port@b {
							reg = <0xb>;

							admaif11_ep: endpoint {
								remote-endpoint = <&xbar_admaif11_ep>;
							};
						};

						admaif12_port: port@c {
							reg = <0xc>;

							admaif12_ep: endpoint {
								remote-endpoint = <&xbar_admaif12_ep>;
							};
						};

						admaif13_port: port@d {
							reg = <0xd>;

							admaif13_ep: endpoint {
								remote-endpoint = <&xbar_admaif13_ep>;
							};
						};

						admaif14_port: port@e {
							reg = <0xe>;

							admaif14_ep: endpoint {
								remote-endpoint = <&xbar_admaif14_ep>;
							};
						};

						admaif15_port: port@f {
							reg = <0xf>;

							admaif15_ep: endpoint {
								remote-endpoint = <&xbar_admaif15_ep>;
							};
						};

						admaif16_port: port@10 {
							reg = <0x10>;

							admaif16_ep: endpoint {
								remote-endpoint = <&xbar_admaif16_ep>;
							};
						};

						admaif17_port: port@11 {
							reg = <0x11>;

							admaif17_ep: endpoint {
								remote-endpoint = <&xbar_admaif17_ep>;
							};
						};

						admaif18_port: port@12 {
							reg = <0x12>;

							admaif18_ep: endpoint {
								remote-endpoint = <&xbar_admaif18_ep>;
							};
						};

						admaif19_port: port@13 {
							reg = <0x13>;

							admaif19_ep: endpoint {
								remote-endpoint = <&xbar_admaif19_ep>;
							};
						};
					};
				};

				i2s@2901000 {
					status = "okay";

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

						port@0 {
							reg = <0>;

							i2s1_cif_ep: endpoint {
								remote-endpoint = <&xbar_i2s1_ep>;
							};
						};

						i2s1_port: port@1 {
							reg = <1>;

							i2s1_dap_ep: endpoint {
								dai-format = "i2s";
								remote-endpoint = <&rt5658_ep>;
							};
						};
					};
				};

				i2s@2901100 {
					status = "okay";

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

						port@0 {
							reg = <0>;

							i2s2_cif_ep: endpoint {
								remote-endpoint = <&xbar_i2s2_ep>;
							};
						};

						i2s2_port: port@1 {
							reg = <1>;

							i2s2_dap_ep: endpoint {
								dai-format = "i2s";
								/* Place holder for external Codec */
							};
						};
					};
				};

				i2s@2901300 {
					status = "okay";

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

						port@0 {
							reg = <0>;

							i2s4_cif_ep: endpoint {
								remote-endpoint = <&xbar_i2s4_ep>;
							};
						};

						i2s4_port: port@1 {
							reg = <1>;

							i2s4_dap_ep: endpoint {
								dai-format = "i2s";
								/* Place holder for external Codec */
							};
						};
					};
				};

				i2s@2901500 {
					status = "okay";

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

						port@0 {
							reg = <0>;

							i2s6_cif_ep: endpoint {
								remote-endpoint = <&xbar_i2s6_ep>;
							};
						};

						i2s6_port: port@1 {
							reg = <1>;

							i2s6_dap_ep: endpoint@0 {
								dai-format = "i2s";
								/* Place holder for external Codec */
							};
						};
					};
				};

				dmic@2904200 {
					status = "okay";

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

						port@0 {
							reg = <0>;

							dmic3_cif_ep: endpoint {
								remote-endpoint = <&xbar_dmic3_ep>;
							};
						};

						dmic3_port: port@1 {
							reg = <1>;

							dmic3_dap_ep: endpoint {
								/* Place holder for external Codec */
							};
						};
					};
				};
			};
		};

		i2c@3160000 {
			eeprom@56 {
				compatible = "atmel,24c02";
				reg = <0x56>;

				label = "system";
				vcc-supply = <&vdd_1v8ls>;
				address-width = <8>;
				pagesize = <8>;
				size = <256>;
				read-only;
			};
		};

		ddc: i2c@31c0000 {
			status = "okay";
		};

		/* SDMMC1 (SD/MMC) */
		mmc@3400000 {
			status = "okay";
		};

		hda@3510000 {
			nvidia,model = "NVIDIA Jetson AGX Xavier HDA";
			status = "okay";
		};

		padctl@3520000 {
			status = "okay";

			pads {
				usb2 {
					lanes {
						usb2-0 {
							status = "okay";
						};

						usb2-1 {
							status = "okay";
						};

						usb2-3 {
							status = "okay";
						};
					};
				};

				usb3 {
					lanes {
						usb3-0 {
							status = "okay";
						};

						usb3-2 {
							status = "okay";
						};

						usb3-3 {
							status = "okay";
						};
					};
				};
			};

			ports {
				usb2-0 {
					mode = "host";
					status = "okay";
				};

				usb2-1 {
					mode = "host";
					status = "okay";
				};

				usb2-3 {
					mode = "host";
					status = "okay";
				};

				usb3-0 {
					nvidia,usb2-companion = <1>;
					status = "okay";
				};

				usb3-2 {
					nvidia,usb2-companion = <0>;
					status = "okay";
				};

				usb3-3 {
					nvidia,usb2-companion = <3>;
					maximum-speed = "super-speed";
					status = "okay";
				};
			};
		};

		usb@3610000 {
			status = "okay";

			phys =	<&{/bus@0/padctl@3520000/pads/usb2/lanes/usb2-0}>,
				<&{/bus@0/padctl@3520000/pads/usb2/lanes/usb2-1}>,
				<&{/bus@0/padctl@3520000/pads/usb2/lanes/usb2-3}>,
				<&{/bus@0/padctl@3520000/pads/usb3/lanes/usb3-0}>,
				<&{/bus@0/padctl@3520000/pads/usb3/lanes/usb3-2}>,
				<&{/bus@0/padctl@3520000/pads/usb3/lanes/usb3-3}>;
			phy-names = "usb2-0", "usb2-1", "usb2-3", "usb3-0", "usb3-2", "usb3-3";
		};

		i2c@c250000 {
			status = "okay";

			rt5658: audio-codec@1a {
				status = "okay";

				compatible = "realtek,rt5658";
				reg = <0x1a>;
				interrupt-parent = <&gpio>;
				interrupts = <TEGRA194_MAIN_GPIO(S, 5) GPIO_ACTIVE_HIGH>;
				clocks = <&bpmp TEGRA194_CLK_AUD_MCLK>;
				clock-names = "mclk";
				realtek,jd-src = <2>;
				sound-name-prefix = "CVB-RT";

				port {
					rt5658_ep: endpoint {
						remote-endpoint = <&i2s1_dap_ep>;
						mclk-fs = <256>;
					};
				};
			};
		};

		pwm@c340000 {
			status = "okay";
		};

		host1x@13e00000 {
			display-hub@15200000 {
				status = "okay";
			};

			dpaux@155c0000 {
				status = "okay";
			};

			dpaux@155d0000 {
				status = "okay";
			};

			dpaux@155e0000 {
				status = "okay";
			};

			/* DP0 */
			sor@15b00000 {
				status = "okay";

				avdd-io-hdmi-dp-supply = <&vdd_1v0>;
				vdd-hdmi-dp-pll-supply = <&vdd_1v8hs>;

				nvidia,dpaux = <&dpaux0>;
			};

			/* DP1 */
			sor@15b40000 {
				status = "okay";

				avdd-io-hdmi-dp-supply = <&vdd_1v0>;
				vdd-hdmi-dp-pll-supply = <&vdd_1v8hs>;

				nvidia,dpaux = <&dpaux1>;
			};

			/* HDMI */
			sor@15b80000 {
				status = "okay";

				avdd-io-hdmi-dp-supply = <&vdd_1v0>;
				vdd-hdmi-dp-pll-supply = <&vdd_1v8hs>;
				hdmi-supply = <&vdd_hdmi>;

				nvidia,ddc-i2c-bus = <&ddc>;
				nvidia,hpd-gpio = <&gpio TEGRA194_MAIN_GPIO(M, 2)
							 GPIO_ACTIVE_LOW>;
			};
		};
	};

	pcie@14100000 {
		status = "okay";

		vddio-pex-ctl-supply = <&vdd_1v8ao>;

		phys = <&p2u_hsio_0>;
		phy-names = "p2u-0";
	};

	pcie@14140000 {
		status = "okay";

		vddio-pex-ctl-supply = <&vdd_1v8ao>;

		phys = <&p2u_hsio_7>;
		phy-names = "p2u-0";
	};

	pcie@14180000 {
		status = "okay";

		vddio-pex-ctl-supply = <&vdd_1v8ao>;

		phys = <&p2u_hsio_2>, <&p2u_hsio_3>, <&p2u_hsio_4>,
		       <&p2u_hsio_5>;
		phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3";
	};

	pcie@141a0000 {
		status = "okay";

		vddio-pex-ctl-supply = <&vdd_1v8ao>;
		vpcie3v3-supply = <&vdd_3v3_pcie>;
		vpcie12v-supply = <&vdd_12v_pcie>;

		phys = <&p2u_nvhs_0>, <&p2u_nvhs_1>, <&p2u_nvhs_2>,
		       <&p2u_nvhs_3>, <&p2u_nvhs_4>, <&p2u_nvhs_5>,
		       <&p2u_nvhs_6>, <&p2u_nvhs_7>;

		phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3", "p2u-4",
			    "p2u-5", "p2u-6", "p2u-7";
	};

	pcie_ep@141a0000 {
		status = "disabled";

		vddio-pex-ctl-supply = <&vdd_1v8ao>;

		reset-gpios = <&gpio TEGRA194_MAIN_GPIO(GG, 1) GPIO_ACTIVE_LOW>;

		nvidia,refclk-select-gpios = <&gpio_aon TEGRA194_AON_GPIO(AA, 5)
					      GPIO_ACTIVE_HIGH>;

		phys = <&p2u_nvhs_0>, <&p2u_nvhs_1>, <&p2u_nvhs_2>,
		       <&p2u_nvhs_3>, <&p2u_nvhs_4>, <&p2u_nvhs_5>,
		       <&p2u_nvhs_6>, <&p2u_nvhs_7>;

		phy-names = "p2u-0", "p2u-1", "p2u-2", "p2u-3", "p2u-4",
			    "p2u-5", "p2u-6", "p2u-7";
	};

	fan: fan {
		compatible = "pwm-fan";
		pwms = <&pwm4 0 45334>;

		cooling-levels = <0 64 128 255>;
		#cooling-cells = <2>;
	};

	gpio-keys {
		compatible = "gpio-keys";

		force-recovery {
			label = "Force Recovery";
			gpios = <&gpio TEGRA194_MAIN_GPIO(G, 0)
				       GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_KEY>;
			linux,code = <KEY_SLEEP>;
			debounce-interval = <10>;
		};

		power {
			label = "Power";
			gpios = <&gpio_aon TEGRA194_AON_GPIO(EE, 4)
					   GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_KEY>;
			linux,code = <KEY_POWER>;
			debounce-interval = <10>;
			wakeup-event-action = <EV_ACT_ASSERTED>;
			wakeup-source;
		};
	};

	sound {
		compatible = "nvidia,tegra186-audio-graph-card";
		status = "okay";

		dais = /* ADMAIF (FE) Ports */
		       <&admaif0_port>, <&admaif1_port>, <&admaif2_port>, <&admaif3_port>,
		       <&admaif4_port>, <&admaif5_port>, <&admaif6_port>, <&admaif7_port>,
		       <&admaif8_port>, <&admaif9_port>, <&admaif10_port>, <&admaif11_port>,
		       <&admaif12_port>, <&admaif13_port>, <&admaif14_port>, <&admaif15_port>,
		       <&admaif16_port>, <&admaif17_port>, <&admaif18_port>, <&admaif19_port>,
		       /* XBAR Ports */
		       <&xbar_i2s1_port>, <&xbar_i2s2_port>, <&xbar_i2s4_port>,
		       <&xbar_i2s6_port>, <&xbar_dmic3_port>,
		       /* BE I/O Ports */
		       <&i2s1_port>, <&i2s2_port>, <&i2s4_port>, <&i2s6_port>,
		       <&dmic3_port>;

		label = "NVIDIA Jetson AGX Xavier APE";

		widgets =
			"Microphone",	"CVB-RT MIC Jack",
			"Microphone",	"CVB-RT MIC",
			"Headphone",	"CVB-RT HP Jack",
			"Speaker",	"CVB-RT SPK";

		routing =
			/* I2S1 <-> RT5658 */
			"CVB-RT AIF1 Playback",	"I2S1 DAP-Playback",
			"I2S1 DAP-Capture",	"CVB-RT AIF1 Capture",
			/* RT5658 Codec controls */
			"CVB-RT HP Jack",	"CVB-RT HPO L Playback",
			"CVB-RT HP Jack",	"CVB-RT HPO R Playback",
			"CVB-RT IN1P",		"CVB-RT MIC Jack",
			"CVB-RT IN2P",		"CVB-RT MIC Jack",
			"CVB-RT SPK",		"CVB-RT SPO Playback",
			"CVB-RT DMIC L1",	"CVB-RT MIC",
			"CVB-RT DMIC L2",	"CVB-RT MIC",
			"CVB-RT DMIC R1",	"CVB-RT MIC",
			"CVB-RT DMIC R2",	"CVB-RT MIC";
	};

	thermal-zones {
		cpu {
			polling-delay = <0>;
			polling-delay-passive = <500>;
			status = "okay";

			trips {
				cpu_trip_critical: critical {
					temperature = <96500>;
					hysteresis = <0>;
					type = "critical";
				};

				cpu_trip_hot: hot {
					temperature = <70000>;
					hysteresis = <2000>;
					type = "hot";
				};

				cpu_trip_active: active {
					temperature = <50000>;
					hysteresis = <2000>;
					type = "active";
				};

				cpu_trip_passive: passive {
					temperature = <30000>;
					hysteresis = <2000>;
					type = "passive";
				};
			};

			cooling-maps {
				cpu-critical {
					cooling-device = <&fan 3 3>;
					trip = <&cpu_trip_critical>;
				};

				cpu-hot {
					cooling-device = <&fan 2 2>;
					trip = <&cpu_trip_hot>;
				};

				cpu-active {
					cooling-device = <&fan 1 1>;
					trip = <&cpu_trip_active>;
				};

				cpu-passive {
					cooling-device = <&fan 0 0>;
					trip = <&cpu_trip_passive>;
				};
			};
		};

		gpu {
			polling-delay = <0>;
			polling-delay-passive = <500>;
			status = "okay";

			trips {
				gpu_alert0: critical {
					temperature = <99000>;
					hysteresis = <0>;
					type = "critical";
				};
			};
		};

		aux {
			polling-delay = <0>;
			polling-delay-passive = <500>;
			status = "okay";

			trips {
				aux_alert0: critical {
					temperature = <90000>;
					hysteresis = <0>;
					type = "critical";
				};
			};
		};
	};
};