// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2021, Linaro Limited
 */

/dts-v1/;

#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
#include "sm8450.dtsi"
#include "pm8350.dtsi"
#include "pm8350b.dtsi"
#include "pm8350c.dtsi"
#include "pm8450.dtsi"
#include "pmk8350.dtsi"
#include "pmr735a.dtsi"
#include "pmr735b.dtsi"

/ {
	model = "Qualcomm Technologies, Inc. SM8450 QRD";
	compatible = "qcom,sm8450-qrd", "qcom,sm8450";
	chassis-type = "handset";

	aliases {
		serial0 = &uart7;
	};

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

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

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

&apps_rsc {
	regulators-0 {
		compatible = "qcom,pm8350-rpmh-regulators";
		qcom,pmic-id = "b";

		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>;
		vdd-s7-supply = <&vph_pwr>;
		vdd-s8-supply = <&vph_pwr>;
		vdd-s9-supply = <&vph_pwr>;
		vdd-s10-supply = <&vph_pwr>;
		vdd-s11-supply = <&vph_pwr>;
		vdd-s12-supply = <&vph_pwr>;

		vdd-l1-l4-supply = <&vreg_s11b_0p95>;
		vdd-l2-l7-supply = <&vreg_bob>;
		vdd-l3-l5-supply = <&vreg_bob>;
		vdd-l6-l9-l10-supply = <&vreg_s12b_1p25>;
		vdd-l8-supply = <&vreg_s2h_0p95>;

		vreg_s10b_1p8: smps10 {
			regulator-name = "vreg_s10b_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		vreg_s11b_0p95: smps11 {
			regulator-name = "vreg_s11b_0p95";
			regulator-min-microvolt = <848000>;
			regulator-max-microvolt = <1104000>;
		};

		vreg_s12b_1p25: smps12 {
			regulator-name = "vreg_s12b_1p25";
			regulator-min-microvolt = <1224000>;
			regulator-max-microvolt = <1400000>;
		};

		vreg_l1b_0p91: ldo1 {
			regulator-name = "vreg_l1b_0p91";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <920000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l2b_3p07: ldo2 {
			regulator-name = "vreg_l2b_3p07";
			regulator-min-microvolt = <3072000>;
			regulator-max-microvolt = <3072000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3b_0p9: ldo3 {
			regulator-name = "vreg_l3b_0p9";
			regulator-min-microvolt = <904000>;
			regulator-max-microvolt = <904000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l5b_0p88: ldo5 {
			regulator-name = "vreg_l5b_0p88";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <888000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6b_1p2: ldo6 {
			regulator-name = "vreg_l6b_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l7b_2p5: ldo7 {
			regulator-name = "vreg_l7b_2p5";
			regulator-min-microvolt = <2504000>;
			regulator-max-microvolt = <2504000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l9b_1p2: ldo9 {
			regulator-name = "vreg_l9b_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-1 {
		compatible = "qcom,pm8350c-rpmh-regulators";
		qcom,pmic-id = "c";

		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>;
		vdd-s7-supply = <&vph_pwr>;
		vdd-s8-supply = <&vph_pwr>;
		vdd-s9-supply = <&vph_pwr>;
		vdd-s10-supply = <&vph_pwr>;

		vdd-l1-l12-supply = <&vreg_bob>;
		vdd-l2-l8-supply = <&vreg_bob>;
		vdd-l3-l4-l5-l7-l13-supply = <&vreg_bob>;
		vdd-l6-l9-l11-supply = <&vreg_bob>;

		vdd-bob-supply = <&vph_pwr>;

		vreg_s1c_1p86: smps1 {
			regulator-name = "vreg_s1c_1p86";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2024000>;
		};

		vreg_s10c_1p05: smps10 {
			regulator-name = "vreg_s10c_1p05";
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1100000>;
		};

		vreg_bob: bob {
			regulator-name = "vreg_bob";
			regulator-min-microvolt = <3008000>;
			regulator-max-microvolt = <3960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
		};

		vreg_l1c_1p8: ldo1 {
			regulator-name = "vreg_l1c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3c_3p0: ldo3 {
			regulator-name = "vreg_l3c_3p0";
			regulator-min-microvolt = <3296000>;
			regulator-max-microvolt = <3304000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l4c_1p8: ldo4 {
			regulator-name = "vreg_l4c_1p8";
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <3000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l5c_1p8: ldo5 {
			regulator-name = "vreg_l5c_1p8";
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <3000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l6c_1p8: ldo6 {
			regulator-name = "vreg_l6c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l7c_3p0: ldo7 {
			regulator-name = "vreg_l7c_3p0";
			regulator-min-microvolt = <3008000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l8c_1p8: ldo8 {
			regulator-name = "vreg_l8c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l9c_2p96: ldo9 {
			regulator-name = "vreg_l9c_2p96";
			regulator-min-microvolt = <2960000>;
			regulator-max-microvolt = <3008000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l12c_1p8: ldo12 {
			regulator-name = "vreg_l12c_1p8";
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1968000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l13c_3p0: ldo13 {
			regulator-name = "vreg_l13c_3p0";
			regulator-min-microvolt = <3000000>;
			regulator-max-microvolt = <3000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-2 {
		compatible = "qcom,pm8450-rpmh-regulators";
		qcom,pmic-id = "h";

		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>;

		vdd-l2-supply = <&vreg_bob>;
		vdd-l3-supply = <&vreg_bob>;
		vdd-l4-supply = <&vreg_bob>;

		vreg_s2h_0p95: smps2 {
			regulator-name = "vreg_s2h_0p95";
			regulator-min-microvolt = <848000>;
			regulator-max-microvolt = <1104000>;
		};

		vreg_s3h_0p5: smps3 {
			regulator-name = "vreg_s3h_0p5";
			regulator-min-microvolt = <500000>;
			regulator-max-microvolt = <500000>;
		};

		vreg_l2h_0p91: ldo2 {
			regulator-name = "vreg_l2h_0p91";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l3h_0p91: ldo3 {
			regulator-name = "vreg_l3h_0p91";
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-3 {
		compatible = "qcom,pmr735a-rpmh-regulators";
		qcom,pmic-id = "e";

		vdd-s1-supply = <&vph_pwr>;
		vdd-s2-supply = <&vph_pwr>;
		vdd-s3-supply = <&vph_pwr>;

		vdd-l1-l2-supply = <&vreg_s2e_0p85>;
		vdd-l3-supply = <&vreg_s1e_1p25>;
		vdd-l4-supply = <&vreg_s1c_1p86>;
		vdd-l5-l6-supply = <&vreg_s1c_1p86>;
		vdd-l7-bob-supply = <&vreg_bob>;

		vreg_s1e_1p25: smps1 {
			regulator-name = "vreg_s1e_1p25";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1296000>;
		};

		vreg_s2e_0p85: smps2 {
			regulator-name = "vreg_s2e_0p85";
			regulator-min-microvolt = <500000>;
			regulator-max-microvolt = <1040000>;
		};

		vreg_l1e_0p8: ldo1 {
			regulator-name = "vreg_l1e_0p8";
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <800000>;
		};

		vreg_l2e_0p8: ldo2 {
			regulator-name = "vreg_l2e_0p8";
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <800000>;
		};

		vreg_l3e_1p2: ldo3 {
			regulator-name = "vreg_l3e_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};

		vreg_l4e_1p7: ldo4 {
			regulator-name = "vreg_l4e_1p7";
			regulator-min-microvolt = <1776000>;
			regulator-max-microvolt = <1776000>;
		};

		vreg_l5e_0p88: ldo5 {
			regulator-name = "vreg_l5e_0p88";
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <880000>;
		};

		vreg_l6e_1p2: ldo6 {
			regulator-name = "vreg_l6e_1p2";
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};
	};
};

&pcie0 {
	status = "okay";
};

&pcie0_phy {
	status = "okay";
	vdda-phy-supply = <&vreg_l5b_0p88>;
	vdda-pll-supply = <&vreg_l6b_1p2>;
};

&gpi_dma0 {
	status = "okay";
};

&i2c5 {
	status = "okay";
};

&qupv3_id_0 {
	status = "okay";
};

&qupv3_id_2 {
	status = "okay";
};

&remoteproc_adsp {
	status = "okay";
	firmware-name = "qcom/sm8450/adsp.mbn";
};

&remoteproc_cdsp {
	status = "okay";
	firmware-name = "qcom/sm8450/cdsp.mbn";
};

&remoteproc_mpss {
	status = "okay";
	firmware-name = "qcom/sm8450/modem.mbn";
};

&remoteproc_slpi {
	status = "okay";
	firmware-name = "qcom/sm8450/slpi.mbn";
};

&sdhc_2 {
	cd-gpios = <&tlmm 92 GPIO_ACTIVE_HIGH>;
	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&sdc2_default_state &sdc2_card_det_n>;
	pinctrl-1 = <&sdc2_sleep_state &sdc2_card_det_n>;
	vmmc-supply = <&vreg_l9c_2p96>;
	vqmmc-supply = <&vreg_l6c_1p8>;
	no-sdio;
	no-mmc;
	status = "okay";
};

&spi4 {
	status = "okay";
};

&spi18 {
	status = "okay";
};

&spi19 {
	status = "okay";
};

&tlmm {
	gpio-reserved-ranges = <28 4>, <36 4>;

	sdc2_card_det_n: sd-card-det-n-state {
		pins = "gpio92";
		function = "gpio";
		drive-strength = <2>;
		bias-pull-up;
	};
};

&uart7 {
	status = "okay";
};

&ufs_mem_hc {
	status = "okay";

	reset-gpios = <&tlmm 210 GPIO_ACTIVE_LOW>;

	vcc-supply = <&vreg_l7b_2p5>;
	vcc-max-microamp = <1100000>;
	vccq-supply = <&vreg_l9b_1p2>;
	vccq-max-microamp = <1200000>;
};

&ufs_mem_phy {
	status = "okay";

	vdda-phy-supply = <&vreg_l5b_0p88>;
	vdda-pll-supply = <&vreg_l6b_1p2>;
};

&usb_1 {
	status = "okay";
};

&usb_1_dwc3 {
	dr_mode = "peripheral";
};

&usb_1_hsphy {
	status = "okay";

	vdda-pll-supply = <&vreg_l5b_0p88>;
	vdda18-supply = <&vreg_l1c_1p8>;
	vdda33-supply = <&vreg_l2b_3p07>;
};

&usb_1_qmpphy {
	status = "okay";

	vdda-phy-supply = <&vreg_l6b_1p2>;
	vdda-pll-supply = <&vreg_l1b_0p91>;
};