// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
 */
/dts-v1/;

#include "qcom-sdx65.dtsi"
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
#include <arm64/qcom/pmk8350.dtsi>
#include <arm64/qcom/pm7250b.dtsi>
#include "qcom-pmx65.dtsi"

/ {
	model = "Qualcomm Technologies, Inc. SDX65 MTP";
	compatible = "qcom,sdx65-mtp", "qcom,sdx65";
	qcom,board-id = <0x2010008 0x302>;

	aliases {
		serial0 = &blsp1_uart3;
	};

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

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		mpss_dsm: memory@8c400000 {
			no-map;
			reg = <0x8c400000 0x3200000>;
		};

		ipa_fw_mem: memory@8fced000 {
			no-map;
			reg = <0x8fced000 0x10000>;
		};

		mpss_adsp_mem: memory@90800000 {
			no-map;
			reg = <0x90800000 0x10000000>;
		};
	};

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

	vreg_bob_3p3: pmx65_bob {
		compatible = "regulator-fixed";
		regulator-name = "vreg_bob_3p3";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;

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

		vin-supply = <&vph_pwr>;
	};
};

&apps_rsc {
	regulators-0 {
		compatible = "qcom,pmx65-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-l1-supply = <&vreg_s2b_1p224>;
		vdd-l2-l18-supply = <&vreg_s2b_1p224>;
		vdd-l3-supply = <&vreg_s8b_0p824>;
		vdd-l4-supply = <&vreg_s7b_0p936>;
		vdd-l5-l6-l16-supply = <&vreg_s4b_1p824>;
		vdd-l7-supply = <&vreg_s3b_0p776>;
		vdd-l8-l9-supply = <&vreg_s8b_0p824>;
		vdd-l10-supply = <&vreg_bob_3p3>;
		vdd-l11-l13-supply = <&vreg_bob_3p3>;
		vdd-l12-supply = <&vreg_s2b_1p224>;
		vdd-l14-supply = <&vreg_s3b_0p776>;
		vdd-l15-supply = <&vreg_s2b_1p224>;
		vdd-l17-supply = <&vreg_s8b_0p824>;
		vdd-l19-supply = <&vreg_s3b_0p776>;
		vdd-l20-supply = <&vreg_s7b_0p936>;
		vdd-l21-supply = <&vreg_s7b_0p936>;

		vreg_s2b_1p224: smps2 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1400000>;
		};

		vreg_s3b_0p776: smps3 {
			regulator-min-microvolt = <500000>;
			regulator-max-microvolt = <1040000>;
		};

		vreg_s4b_1p824: smps4 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2024000>;
		};

		vreg_s7b_0p936: smps7 {
			regulator-min-microvolt = <500000>;
			regulator-max-microvolt = <1040000>;
		};

		vreg_s8b_0p824: smps8 {
			regulator-min-microvolt = <304000>;
			regulator-max-microvolt = <1300000>;
		};

		vreg_l1b_1p2: ldo1 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo2 {
			regulator-min-microvolt = <1128000>;
			regulator-max-microvolt = <1128000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo3 {
			regulator-min-microvolt = <300000>;
			regulator-max-microvolt = <960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l4b_0p88: ldo4 {
			regulator-min-microvolt = <880000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l5b_1p8: ldo5 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo6 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo7 {
			regulator-min-microvolt = <752000>;
			regulator-max-microvolt = <752000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo8 {
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo9 {
			regulator-min-microvolt = <800000>;
			regulator-max-microvolt = <800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		vreg_l10b_3p08: ldo10 {
			regulator-min-microvolt = <3088000>;
			regulator-max-microvolt = <3088000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo11 {
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <2928000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo12 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo13 {
			regulator-min-microvolt = <1704000>;
			regulator-max-microvolt = <2928000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo14 {
			regulator-min-microvolt = <600000>;
			regulator-max-microvolt = <800000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo15 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo16 {
			regulator-min-microvolt = <1776000>;
			regulator-max-microvolt = <1776000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo17 {
			regulator-min-microvolt = <300000>;
			regulator-max-microvolt = <960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo19 {
			regulator-min-microvolt = <752000>;
			regulator-max-microvolt = <752000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo20 {
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		ldo21 {
			regulator-min-microvolt = <912000>;
			regulator-max-microvolt = <912000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};
};

&blsp1_uart3 {
	status = "okay";
};

&ipa {
	qcom,gsi-loader = "skip";
	status = "okay";
};

&pcie_ep {
	pinctrl-0 = <&pcie_ep_clkreq_default
		     &pcie_ep_perst_default
		     &pcie_ep_wake_default>;
	pinctrl-names = "default";

	reset-gpios = <&tlmm 57 GPIO_ACTIVE_LOW>;
	wake-gpios = <&tlmm 53 GPIO_ACTIVE_LOW>;

	status = "okay";
};

&pcie_phy {
	vdda-phy-supply = <&vreg_l1b_1p2>;
	vdda-pll-supply = <&vreg_l4b_0p88>;

	status = "okay";
};

&qpic_bam {
	status = "okay";
};

&qpic_nand {
	status = "okay";

	nand@0 {
		reg = <0>;

		nand-ecc-strength = <4>;
		nand-ecc-step-size = <512>;
		nand-bus-width = <8>;
		/* ico and efs2 partitions are secured */
		secure-regions = /bits/ 64 <0x500000 0x500000
					    0xa00000 0xb00000>;
	};
};

&remoteproc_mpss {
	memory-region = <&mpss_adsp_mem>;
	status = "okay";
};

&tlmm {
	pcie_ep_clkreq_default: pcie-ep-clkreq-default-state {
		pins = "gpio56";
		function = "pcie_clkreq";
		drive-strength = <2>;
		bias-disable;
	};

	pcie_ep_perst_default: pcie-ep-perst-default-state {
		pins = "gpio57";
		function = "gpio";
		drive-strength = <2>;
		bias-pull-down;
	};

	pcie_ep_wake_default: pcie-ep-wake-default-state {
		pins = "gpio53";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};
};

&usb {
	status = "okay";
};

&usb_dwc3 {
	dr_mode = "peripheral";
};

&usb_hsphy {
	vdda-pll-supply = <&vreg_l4b_0p88>;
	vdda33-supply = <&vreg_l10b_3p08>;
	vdda18-supply = <&vreg_l5b_1p8>;
	status = "okay";
};

&usb_qmpphy {
	vdda-phy-supply = <&vreg_l4b_0p88>;
	vdda-pll-supply = <&vreg_l1b_1p2>;
	status = "okay";
};