// SPDX-License-Identifier: GPL-2.0+ OR MIT
/*
 * Mac Pro (M2 Ultra, 2023) and Mac Studio (M2 Ultra, 2023)
 *
 * This file contains the parts common to J180 and J475 devices with t6022.
 *
 * target-type: J180d / J475d
 *
 * Copyright The Asahi Linux Contributors
 */

/* delete power-domains for missing disp0 / disp0_die1 */
/delete-node/ &ps_disp0_cpu0;
/delete-node/ &ps_disp0_fe;

/delete-node/ &ps_disp0_cpu0_die1;
/delete-node/ &ps_disp0_fe_die1;

/* USB Type C */
&i2c0 {
	/* front-right */
	hpm4: usb-pd@39 {
		compatible = "apple,cd321x";
		reg = <0x39>;
		interrupt-parent = <&pinctrl_ap>;
		interrupts = <44 IRQ_TYPE_LEVEL_LOW>;
		interrupt-names = "irq";

		typec4: connector {
			compatible = "usb-c-connector";
			power-role = "dual";
			data-role = "dual";

			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					typec4_connector_hs: endpoint {
						remote-endpoint = <&dwc3_4_hs>;
					};
				};
				port@1 {
					reg = <1>;
					typec4_connector_ss: endpoint {
						remote-endpoint = <&atcphy4_typec_lanes>;
					};
				};
			};
		};
	};

	/* front-left */
	hpm5: usb-pd@3a {
		compatible = "apple,cd321x";
		reg = <0x3a>;
		interrupt-parent = <&pinctrl_ap>;
		interrupts = <44 IRQ_TYPE_LEVEL_LOW>;
		interrupt-names = "irq";

		typec5: connector {
			compatible = "usb-c-connector";
			power-role = "dual";
			data-role = "dual";

			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					reg = <0>;
					typec5_connector_hs: endpoint {
						remote-endpoint = <&dwc3_5_hs>;
					};
				};
				port@1 {
					reg = <1>;
					typec5_connector_ss: endpoint {
						remote-endpoint = <&atcphy5_typec_lanes>;
					};
				};
			};
		};
	};
};


/* USB controllers on die 1 */
&dwc3_0_die1 {
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			dwc3_4_hs: endpoint {
				remote-endpoint = <&typec4_connector_hs>;
			};
		};

		port@1 {
			reg = <1>;
			dwc3_4_ss: endpoint {
				remote-endpoint = <&atcphy4_usb3>;
			};
		};
	};
};

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

		port@0 {
			reg = <0>;
			dwc3_5_hs: endpoint {
				remote-endpoint = <&typec5_connector_hs>;
			};
		};

		port@1 {
			reg = <1>;
			dwc3_5_ss: endpoint {
				remote-endpoint = <&atcphy5_usb3>;
			};
		};
	};
};

/* Type-C PHYs */
&atcphy0_die1 {
	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			atcphy4_typec_lanes: endpoint {
				remote-endpoint = <&typec4_connector_ss>;
			};
		};

		port@1 {
			reg = <1>;
			atcphy4_usb3: endpoint {
				remote-endpoint = <&dwc3_4_ss>;
			};
		};
	};
};

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

		port@0 {
			reg = <0>;
			atcphy5_typec_lanes: endpoint {
				remote-endpoint = <&typec5_connector_ss>;
			};
		};

		port@1 {
			reg = <1>;
			atcphy5_usb3: endpoint {
				remote-endpoint = <&dwc3_5_ss>;
			};
		};
	};
};