#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

#include "waipio-pmic-overlay.dtsi"
#include "waipio-thermal-overlay.dtsi"

&ufsphy_mem {
	compatible = "qcom,ufs-phy-qmp-v4-waipio";

	vdda-phy-supply = <&pm8350_l5>;
	vdda-pll-supply = <&pm8350_l6>;
	vdda-phy-max-microamp = <173000>;
	vdda-pll-max-microamp = <24900>;

	status = "ok";
};

&ufshc_mem {
	vdd-hba-supply = <&gcc_ufs_phy_gdsc>;

	vcc-supply = <&pm8350_l7>;
	vcc-max-microamp = <1100000>;

	vccq-supply = <&pm8350_l9>;
	vccq-max-microamp = <1200000>;

	qcom,vddp-ref-clk-supply = <&pm8350_l9>;
	qcom,vddp-ref-clk-max-microamp = <100>;

	qcom,vccq-parent-supply = <&pm8350_s12>;
	qcom,vccq-parent-max-microamp = <210000>;

	status = "ok";
};

&sdhc_2 {
	status = "ok";
	vdd-supply = <&pm8350c_l9>;
	qcom,vdd-voltage-level = <2960000 2960000>;
	qcom,vdd-current-level = <0 800000>;

	vdd-io-supply = <&pm8350c_l6>;
	qcom,vdd-io-voltage-level = <1800000 2960000>;
	qcom,vdd-io-current-level = <0 22000>;

	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&sdc2_on>;
	pinctrl-1 = <&sdc2_off>;

	cd-gpios = <&tlmm 92 GPIO_ACTIVE_LOW>;
};

&soc {
	gpio_keys {
		compatible = "gpio-keys";
		label = "gpio-keys";

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

		vol_up {
			label = "volume_up";
			gpios = <&pm8350_gpios 6 GPIO_ACTIVE_LOW>;
			linux,input-type = <1>;
			linux,code = <KEY_VOLUMEUP>;
			gpio-key,wakeup;
			debounce-interval = <15>;
			linux,can-disable;
		};
	};
};

&pm8350b_haptics {
	status = "ok";
};

&pm8350c_switch0 {
	qcom,led-mask = <9>; /* Channels 1 & 4 */
	qcom,symmetry-en;
};

&pm8350c_switch1 {
	qcom,led-mask = <6>; /* Channels 2 & 3 */
	qcom,symmetry-en;
};

&pm8350c_switch2 {
	qcom,led-mask = <15>; /* All Channels */
	qcom,symmetry-en;
};

&pm8350c_flash {
	status = "ok";
};

&qupv3_se9_i2c {
	status = "ok";
	qcom,clk-freq-out = <1000000>;
	#address-cells = <1>;
	#size-cells = <0>;
	nq@28 {
		compatible = "qcom,sn-nci";
		reg = <0x28>;
		qcom,sn-irq = <&tlmm 46 0x00>;
		qcom,sn-ven = <&tlmm 34 0x00>;
		qcom,sn-firm = <&tlmm 45 0x00>;
		qcom,sn-clkreq = <&tlmm 35 0x00>;
		qcom,sn-vdd-1p8-supply = <&S10B>;
		qcom,sn-vdd-1p8-voltage = <1800000 1800000>;
		qcom,sn-vdd-1p8-current = <157000>;
		interrupt-parent = <&tlmm>;
		interrupts = <46 0>;
		interrupt-names = "nfc_irq";
		pinctrl-names = "nfc_active", "nfc_suspend";
		pinctrl-0 = <&nfc_int_active &nfc_enable_active>;
		pinctrl-1 = <&nfc_int_suspend &nfc_enable_suspend>;
	};
};

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

	status = "ok";
	qcom,i2c-touch-active = "focaltech,fts_ts";

	focaltech@38 {
		compatible = "focaltech,fts_ts";
		reg = <0x38>;
		interrupt-parent = <&tlmm>;
		interrupts = <21 0x2008>;
		focaltech,reset-gpio = <&tlmm 20 0x00>;
		focaltech,irq-gpio = <&tlmm 21 0x2008>;
		focaltech,max-touch-number = <5>;
		focaltech,display-coords = <0 0 1080 2340>;
		focaltech,touch-type = "primary";

		vdd-supply = <&L3C>;
		vcc_i2c-supply = <&L8C>;

		pinctrl-names = "pmx_ts_active", "pmx_ts_suspend","pmx_ts_release";
		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&ts_release>;
		focaltech,trusted-touch-mode = "vm_mode";
		focaltech,touch-environment = "pvm";
		focaltech,trusted-touch-type = "primary";
		focaltech,trusted-touch-spi-irq = <754>;
		focaltech,trusted-touch-io-bases = <0x990000 0x910000>;
		focaltech,trusted-touch-io-sizes = <0x1000 0x4000>;
		focaltech,trusted-touch-vm-gpio-list = <&tlmm 16 0 &tlmm 17 0 &tlmm 18 0
						&tlmm 19 0 &tlmm 20 0 &tlmm 21 0x2008>;
	};

	atmel_mxt_ts@4a {
		compatible = "atmel,maxtouch";
		reg = <0x4a>;
		interrupt-parent = <&tlmm>;
		interrupts = <21 0x2008>;
		avdd-supply = <&L3C>;
		vdd-supply = <&L8C>;
		pinctrl-names = "pmx_ts_active", "pmx_ts_suspend";
		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;

		atmel,xy_switch;
		atmel,inverty;
		atmel,invertx;
		reset-gpios = <&tlmm 20 0x00>;
		irq-gpios = <&tlmm 21 0x2008>;
		atmel,panel-coords = <0 0 479 799>;
		atmel,display-coords = <0 0 339 729>;
	};

	synaptics_dsx@22 {
		compatible = "synaptics,dsx-i2c";
		reg = <0x22>;
		interrupt-parent = <&tlmm>;
		interrupts = <21 0x2008>;
		vdd-supply = <&L8C>;
		avdd-supply = <&L3C>;
		pinctrl-names = "pmx_ts_active", "pmx_ts_suspend","pmx_ts_release";
		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&ts_release>;
		synaptics,pwr-reg-name = "avdd";
		synaptics,bus-reg-name = "vdd";
		synaptics,ub-i2c-addr = <0x22>;
		synaptics,max-y-for-2d = <1859>;
		synaptics,irq-gpio = <&tlmm 21 0x2008>;
		synaptics,reset-gpio = <&tlmm 20 0x00>;
		synaptics,irq-on-state = <0>;
		synaptics,power-delay-ms = <200>;
		synaptics,reset-delay-ms = <200>;
		synaptics,reset-on-state = <0>;
		synaptics,reset-active-ms = <20>;
	};

	synaptics_tcm@20 {
		compatible = "synaptics,tcm-i2c";
		reg = <0x20>;
		interrupt-parent = <&tlmm>;
		interrupts = <21 0x2008>;
		pinctrl-names = "pmx_ts_active","pmx_ts_suspend",
					"pmx_ts_release";
		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&ts_release>;
		vdd-supply = <&L8C>;
		avdd-supply = <&L3C>;
		synaptics,pwr-reg-name = "avdd";
		synaptics,bus-reg-name = "vdd";
		synaptics,irq-gpio = <&tlmm 21 0x2008>;
		synaptics,irq-on-state = <0>;
		synaptics,reset-gpio = <&tlmm 20 0x00>;
		synaptics,reset-on-state = <0>;
		synaptics,reset-active-ms = <20>;
		synaptics,reset-delay-ms = <200>;
		synaptics,power-delay-ms = <200>;
		synaptics,ubl-i2c-addr = <0x20>;
		synaptics,extend_report;
		synaptics,firmware-name = "synaptics_firmware.img";
	};

	novatek@62 {
		compatible = "novatek,NVT-ts";
		reg = <0x62>;

		interrupt-parent = <&tlmm>;
		interrupts = <21 0x2008>;

		pinctrl-names = "pmx_ts_active","pmx_ts_suspend",
			"pmx_ts_release";

		pinctrl-0 = <&ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
		pinctrl-2 = <&ts_release>;

		novatek,reset-gpio = <&tlmm 20 0x00>;
		novatek,irq-gpio = <&tlmm 21 0x2008>;

		novatek,trusted-touch-mode = "vm_mode";
		novatek,touch-environment = "pvm";
		novatek,trusted-touch-spi-irq = <754>;
		novatek,trusted-touch-io-bases = <0x990000 0x00910000>;
		novatek,trusted-touch-io-sizes = <0x1000 0x4000>;
		novatek,trusted-touch-vm-gpio-list = <&tlmm 16 0 &tlmm 17 0 &tlmm 18 0
						&tlmm 19 0 &tlmm 20 0 &tlmm 21 0x2008>;
	};
};

&usb0 {
	usb-role-switch;

	dwc3@a600000 {
		usb-role-switch;
		dr_mode = "otg";
	};

	port {
		usb_port0: endpoint {
			remote-endpoint = <&usb_port0_connector>;
		};
	};
};

&ucsi {
	connector {
		port {
			usb_port0_connector: endpoint {
				remote-endpoint = <&usb_port0>;
			};
		};
	};
};
