// SPDX-License-Identifier: BSD-3-Clause
/*
 * Copyright (c) 2021, Konrad Dybcio <konrad.dybcio@somainline.org>
 */
/dts-v1/;

#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
#include "sm6350.dtsi"
#include "pm6350.dtsi"

/ {
	model = "Sony Xperia 10 III";
	compatible = "sony,pdx213", "qcom,sm6350";
	chassis-type = "handset";
	qcom,msm-id = <434 0x10000>, <459 0x10000>;
	qcom,board-id = <0x1000B 0>;

	chosen {
		#address-cells = <2>;
		#size-cells = <2>;
		ranges;

		framebuffer: framebuffer@a0000000 {
			compatible = "simple-framebuffer";
			reg = <0 0xa0000000 0 0x2300000>;
			width = <1080>;
			height = <2520>;
			stride = <(1080 * 4)>;
			format = "a8r8g8b8";
			clocks = <&gcc GCC_DISP_AXI_CLK>;
		};
	};

	gpio-keys {
		compatible = "gpio-keys";
		pinctrl-names = "default";
		pinctrl-0 = <&vol_down_n>;

		key-volume-down {
			label = "Volume Down";
			linux,code = <KEY_VOLUMEDOWN>;
			gpios = <&pm6350_gpios 2 GPIO_ACTIVE_LOW>;
		};
	};

	touch_en_vreg: touch-en-regulator {
		compatible = "regulator-fixed";
		regulator-name = "touch_en_vreg";
		gpio = <&tlmm 10 GPIO_ACTIVE_HIGH>;
		enable-active-high;

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

&apps_rsc {
	regulators-0 {
		compatible = "qcom,pm6350-rpmh-regulators";
		qcom,pmic-id = "a";

		pm6350_s1: smps1 {
			regulator-min-microvolt = <1000000>;
			regulator-max-microvolt = <1200000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_s2: smps2 {
			regulator-min-microvolt = <1503000>;
			regulator-max-microvolt = <2048000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l2: ldo2 {
			regulator-min-microvolt = <1503000>;
			regulator-max-microvolt = <1980000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l3: ldo3 {
			regulator-min-microvolt = <2700000>;
			regulator-max-microvolt = <3300000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l4: ldo4 {
			regulator-min-microvolt = <352000>;
			regulator-max-microvolt = <801000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l5: ldo5 {
			regulator-min-microvolt = <1503000>;
			regulator-max-microvolt = <1980000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l6: ldo6 {
			regulator-min-microvolt = <1710000>;
			regulator-max-microvolt = <3544000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l7: ldo7 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <1980000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l8: ldo8 {
			regulator-min-microvolt = <2500000>;
			regulator-max-microvolt = <3544000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l9: ldo9 {
			regulator-min-microvolt = <1650000>;
			regulator-max-microvolt = <3401000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l11: ldo11 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l12: ldo12 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <1980000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l13: ldo13 {
			regulator-min-microvolt = <570000>;
			regulator-max-microvolt = <650000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l14: ldo14 {
			regulator-min-microvolt = <1700000>;
			regulator-max-microvolt = <1900000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l15: ldo15 {
			regulator-min-microvolt = <1100000>;
			regulator-max-microvolt = <1305000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l16: ldo16 {
			regulator-min-microvolt = <830000>;
			regulator-max-microvolt = <921000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l18: ldo18 {
			regulator-min-microvolt = <788000>;
			regulator-max-microvolt = <1049000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l19: ldo19 {
			regulator-min-microvolt = <1080000>;
			regulator-max-microvolt = <1305000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l20: ldo20 {
			regulator-min-microvolt = <530000>;
			regulator-max-microvolt = <801000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l21: ldo21 {
			regulator-min-microvolt = <751000>;
			regulator-max-microvolt = <825000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6350_l22: ldo22 {
			regulator-min-microvolt = <1080000>;
			regulator-max-microvolt = <1305000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};
	};

	regulators-1 {
		compatible = "qcom,pm6150l-rpmh-regulators";
		qcom,pmic-id = "e";

		pm6150l_s8: smps8 {
			regulator-min-microvolt = <313000>;
			regulator-max-microvolt = <1395000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l1: ldo1 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <1980000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l2: ldo2 {
			regulator-min-microvolt = <1170000>;
			regulator-max-microvolt = <1305000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l3: ldo3 {
			regulator-min-microvolt = <1100000>;
			regulator-max-microvolt = <1299000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l4: ldo4 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <3300000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l5: ldo5 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <3300000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l6: ldo6 {
			regulator-min-microvolt = <1700000>;
			regulator-max-microvolt = <2950000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-allow-set-load;
			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
						   RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l7: ldo7 {
			regulator-min-microvolt = <2700000>;
			regulator-max-microvolt = <3544000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l8: ldo8 {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <2000000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l9: ldo9 {
			regulator-min-microvolt = <2700000>;
			regulator-max-microvolt = <2960000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
			regulator-allow-set-load;
			regulator-allowed-modes = <RPMH_REGULATOR_MODE_LPM
						   RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l10: ldo10 {
			regulator-min-microvolt = <3000000>;
			regulator-max-microvolt = <3401000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_l11: ldo11 {
			regulator-min-microvolt = <3000000>;
			regulator-max-microvolt = <3401000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>;
		};

		pm6150l_bob: bob {
			regulator-min-microvolt = <1620000>;
			regulator-max-microvolt = <5492000>;
			regulator-initial-mode = <RPMH_REGULATOR_MODE_AUTO>;
			regulator-allow-bypass;
		};
	};
};

&gpi_dma0 {
	status = "okay";
};

&gpi_dma1 {
	status = "okay";
};

&i2c8 {
	clock-frequency = <400000>;
	status = "okay";

	touchscreen@48 {
		compatible = "samsung,s6sy761";
		reg = <0x48>;
		interrupt-parent = <&tlmm>;
		interrupts = <22 0x2008>;
		vdd-supply = <&pm6350_l11>;
		avdd-supply = <&touch_en_vreg>;

		pinctrl-names = "default";
		pinctrl-0 = <&ts_int_default &ts_active>;
	};
};

&pm6350_gpios {
	vol_down_n: vol-down-n-state {
		pins = "gpio2";
		function = PMIC_GPIO_FUNC_NORMAL;
		power-source = <0>;
		bias-disable;
		input-enable;
	};
};

&pm6350_resin {
	linux,code = <KEY_VOLUMEUP>;
	status = "okay";
};

&qupv3_id_0 {
	status = "okay";
};

&qupv3_id_1 {
	status = "okay";
};

&sdc2_off_state {
	sd-cd-pins {
		pins = "gpio94";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};
};

&sdc2_on_state {
	sd-cd-pins {
		pins = "gpio94";
		function = "gpio";
		drive-strength = <2>;
		bias-pull-up;
	};
};

&sdhc_2 {
	status = "okay";

	vmmc-supply = <&pm6150l_l9>;
	vqmmc-supply = <&pm6150l_l6>;

	cd-gpios = <&tlmm 94 GPIO_ACTIVE_HIGH>;
};

&tlmm {
	gpio-reserved-ranges = <13 4>, <45 2>, <56 2>;

	ts_active: ts-active-state {
		pins = "gpio21";
		function = "gpio";
		drive-strength = <8>;
		bias-pull-up;
	};

	ts_int_default: ts-int-default-state {
		pins = "gpio22";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};
};

&usb_1 {
	status = "okay";
};

&usb_1_dwc3 {
	maximum-speed = "super-speed";
	dr_mode = "peripheral";
};

&usb_1_hsphy {
	status = "okay";
};

&usb_1_qmpphy {
	status = "okay";
};