// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2026 IMD Technologies Ltd
 */

/dts-v1/;

#include "qcs8550-imdt-som.dtsi"

/ {
	model = "IMDT QCS8550 SBC";
	compatible = "imdt,qcs8550-sbc", "imdt,qcs8550-som",
		     "qcom,qcs8550", "qcom,sm8550";
	chassis-type = "embedded";

	aliases {
		serial0 = &uart7;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	connector {
		compatible = "pcie-m2-e-connector";
		vpcie3v3-supply = <&m2e_3p3>;
		vpcie1v8-supply = <&per_pwr>;
		w-disable1-gpios = <&tlmm 80 GPIO_ACTIVE_LOW>;

		pinctrl-0 = <&m2e_wlan_disable>;
		pinctrl-names = "default";

		/* SDIO datapath is disabled because the SDIO lines are
		 * routed through unpopulated resistors.
		 * UART datapath is also disabled as the UART lines are
		 * routed through an analogue mux which currently cannot
		 * be described by a device tree.
		 */
		ports {
			#address-cells = <1>;
			#size-cells = <0>;

			port@0 {
				reg = <0>;
				#address-cells = <1>;
				#size-cells = <0>;

				m2e_pcie_ep: endpoint@0 {
					reg = <0>;
					remote-endpoint = <&pcie0_port0_ep>;
				};
			};
		};
	};

	m2e_3p3: regulator-m2e-3p3 {
		compatible = "regulator-fixed";
		regulator-name = "m2e_3p3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

		pinctrl-0 = <&m2_pd_en_default>;
		pinctrl-names = "default";

		gpio = <&tlmm 144 GPIO_ACTIVE_LOW>;
	};

	/* Enables 5V_PER, 3V3_PER and 1V8_PER rails. 5V_PER and 3V3_PER
	 * aren't used within the DTS but are used for on board logic
	 * level conversion and as rails for pull-ups. 1V8_PER is used
	 * for M2 Key E.
	 */
	per_pwr: regulator-per-pwr {
		compatible = "regulator-fixed";
		regulator-name = "per_pwr";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;

		pinctrl-0 = <&pwr_per_en_default>;
		pinctrl-names = "default";

		gpio = <&tlmm 142 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		regulator-always-on;
		regulator-boot-on;
	};

	sdhci_2_vqmmc: regulator-sdhci-2-vqmmc {
		compatible = "regulator-gpio";

		regulator-name = "sdhci_2_vqmmc";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-type = "voltage";

		pinctrl-0 = <&sd_vset_default>;
		pinctrl-names = "default";

		gpios = <&tlmm 4 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		gpios-states = <0>;
		states = <3300000 0>,
			 <1800000 1>;

		startup-delay-us = <10000>;
	};

	vph_pwr: regulator-vph-pwr {
		compatible = "regulator-fixed";
		regulator-name = "vph_pwr";
		regulator-min-microvolt = <3700000>;
		regulator-max-microvolt = <3700000>;
		regulator-always-on;
		regulator-boot-on;
	};

	usb_id: usb-id {
		compatible = "linux,extcon-usb-gpio";
		id-gpios = <&tlmm 53 GPIO_ACTIVE_HIGH>;
		pinctrl-0 = <&usb_id_default>;
		pinctrl-names = "default";
	};
};

&gpi_dma1 {
	status = "okay";
};

&gpu {
	status = "okay";
};

&gpu_zap_shader {
	firmware-name = "qcom/sm8550/a740_zap.mbn";
};

&i2c_hub_2 {
	clock-frequency = <400000>;

	status = "okay";

	ptn3222: redriver@43 {
		compatible = "nxp,ptn3222";
		reg = <0x43>;
		#phy-cells = <0>;

		vdd1v8-supply = <&vreg_l15b_1p8>;
		vdd3v3-supply = <&vreg_l5b_3p1>;

		pinctrl-0 = <&eusb2_repeater_reset_default>;
		pinctrl-names = "default";

		reset-gpios = <&pm8550vs_d_gpios 4 GPIO_ACTIVE_LOW>;
	};
};

&i2c_master_hub_0 {
	status = "okay";
};

&ipa {
	qcom,gsi-loader = "self";
	memory-region = <&ipa_fw_mem>;
	firmware-name = "qcom/sm8550/ipa_fws.mbn";

	status = "okay";
};

&iris {
	status = "okay";
};

&pcie0 {
	wake-gpios = <&tlmm 96 GPIO_ACTIVE_HIGH>;
	perst-gpios = <&tlmm 94 GPIO_ACTIVE_LOW>;

	pinctrl-0 = <&pcie0_default_state>;
	pinctrl-names = "default";

	status = "okay";
};

&pcie0_phy {
	vdda-phy-supply = <&vreg_l1e_0p88>;
	vdda-pll-supply = <&vreg_l3e_1p2>;

	status = "okay";
};

&pcie0_port0 {
	/* Required for pwrctrl driver bind */
	compatible = "pciclass,0604";

	port {
		pcie0_port0_ep: endpoint {
			remote-endpoint = <&m2e_pcie_ep>;
		};
	};
};

&pm8550_gpios {
	sd_card_detect_default: sd-card-detect-default-state {
		pins = "gpio12";
		function = "normal";
		input-enable;
		output-disable;
		bias-disable;
		power-source = <1>; /* 1.8 V */
	};
};

&pm8550_rpmh_regulators {
	vdd-bob1-supply = <&vph_pwr>;
	vdd-bob2-supply = <&vph_pwr>;
};

&pm8550ve_rpmh_regulators {
	vdd-s4-supply = <&vph_pwr>;
};

&pm8550vs_d_gpios {
	eusb2_repeater_reset_default: eusb2-repeater-reset-default-state {
		pins = "gpio4";
		function = "normal";

		input-enable;
		output-enable;
		bias-disable;

		drive-push-pull;
		power-source = <1>; /* 1.8V */
		qcom,drive-strength = <3>;
	};
};

&pm8550vs_e_rpmh_regulators {
	vdd-s4-supply = <&vph_pwr>;
	vdd-s5-supply = <&vph_pwr>;
};

&pm8550vs_g_rpmh_regulators {
	vdd-s1-supply = <&vph_pwr>;
	vdd-s2-supply = <&vph_pwr>;
	vdd-s3-supply = <&vph_pwr>;
	vdd-s4-supply = <&vph_pwr>;
	vdd-s5-supply = <&vph_pwr>;
	vdd-s6-supply = <&vph_pwr>;
};

&pon_pwrkey {
	status = "okay";
};

&pon_resin {
	linux,code = <KEY_VOLUMEDOWN>;

	status = "okay";
};

&qupv3_id_0 {
	status = "okay";
};

&qupv3_id_1 {
	status = "okay";
};

&remoteproc_adsp {
	firmware-name = "qcom/sm8550/adsp.mbn",
			"qcom/sm8550/adsp_dtb.mbn";

	status = "okay";
};

&remoteproc_cdsp {
	firmware-name = "qcom/sm8550/cdsp.mbn",
			"qcom/sm8550/cdsp_dtb.mbn";

	status = "okay";
};

&sdc2_default {
	clk-pins {
		drive-strength = <16>;
	};

	cmd-pins {
		/delete-property/ bias-pull-up;
		bias-disable;
		drive-strength = <16>;
	};

	data-pins {
		/delete-property/ bias-pull-up;
		bias-disable;
		drive-strength = <16>;
	};
};

&sdhc_2 {
	cd-gpios = <&pm8550_gpios 12 GPIO_ACTIVE_LOW>;

	pinctrl-0 = <&sdc2_default>, <&sd_card_detect_default>;
	pinctrl-1 = <&sdc2_default>, <&sd_card_detect_default>;
	pinctrl-names = "default", "sleep";

	vqmmc-supply = <&sdhci_2_vqmmc>;

	bus-width = <4>;
	no-sdio;
	no-mmc;

	status = "okay";
};

&tlmm {
	/* Reserved I/Os for NFC */
	gpio-reserved-ranges = <32 8>;

	m2_pd_en_default: m2-pd-en-default-state {
		pins = "gpio144";
		function = "gpio";
		drive-strength = <16>;
		drive-open-drain;
	};

	m2e_wlan_disable: m2e-wlan-disable-default-state {
		pins = "gpio80";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	pwr_per_en_default: pwr-per-en-default-state {
		pins = "gpio142";
		function = "gpio";
		drive-strength = <16>;
		bias-disable;
	};

	sd_vset_default: sd-vset-default-state {
		pins = "gpio4";
		function = "gpio";
		drive-strength = <16>;
		bias-disable;
	};

	usb_id_default: usb-id-default-state {
		pins = "gpio53";
		function = "gpio";
		bias-pull-up;
	};
};

&uart7 {
	status = "okay";
};

&ufs_mem_hc {
	reset-gpios = <&tlmm 210 GPIO_ACTIVE_LOW>;

	vcc-supply = <&vreg_l17b_2p5>;
	vcc-max-microamp = <1300000>;
	vccq-supply = <&vreg_l1g_1p2>;
	vccq-max-microamp = <1200000>;
	vdd-hba-supply = <&vreg_l3g_1p2>;

	status = "okay";
};

&ufs_mem_phy {
	vdda-phy-supply = <&vreg_l1d_0p88>;
	vdda-pll-supply = <&vreg_l3e_1p2>;

	status = "okay";
};

&usb_1 {
	dr_mode = "otg";
	extcon = <&usb_id>;

	status = "okay";
};

&usb_1_hsphy {
	vdd-supply = <&vreg_l1e_0p88>;
	vdda12-supply = <&vreg_l3e_1p2>;

	phys = <&ptn3222>;

	status = "okay";
};

&usb_dp_qmpphy {
	vdda-phy-supply = <&vreg_l3e_1p2>;
	vdda-pll-supply = <&vreg_l3f_0p88>;

	status = "okay";
};