/* Copyright (c) 2021, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

/* This file is only for rtwo device */

#include "crow-eqe-products-common-overlay.dtsi"
#include "crow-eqe-fingerprint-overlay.dtsi"
#include "crow-eqe-sensors-overlay.dtsi"
#include "crow-moto-common-st-nfc.dtsi"
#include "crow-moto-common-charger.dtsi"
#include "crow-eqe-charger-overlay.dtsi"
#include "crow-eqe-thermal-overlay.dtsi"
#include "moto-eqe-external-camera-pmic.dtsi"

&soc {
	mmi_relay {
		compatible = "mmi,sys-relay";
	};

};

&qseecom_mem {
	size = <0x0 0x1800000>;
};

&qseecom_ta_mem {
	size = <0x0 0x2000000>;
};

&tlmm {
	/* reserve FP GPIOs: gpio12,13,14,15 24 25 26 27 for NFC 111 112 for WLAN*/
	qcom,gpios-reserved = <12 13 14 15 24 25 26 27 111 112>;

	redriver_enable: redriver_enable {
		mux {
			pins = "gpio55";
			function = "gpio";
		};

		config {
			pins = "gpio55";
			drive-strength = <2>;
			bias-disable; /* NO PULL */
			output-high;
		};
	};
	redriver_disable: redriver_disable {
		mux {
			pins = "gpio55";
			function = "gpio";
		};

		config {
			pins = "gpio55";
			drive-strength = <2>;
			output-low;
		};
	};
};

&usb0 {
	ssusb_redriver = <&redriver>;
};

&qupv3_se8_i2c {
	status = "ok";
	redriver:redriver@30{
		compatible = "parade,ps5169-redriver";
		reg = <0x30>;
		vcc-supply = <&L7B>;
		pinctrl-names = "default";
		pinctrl-0 = <&redriver_enable>;
		redriver,enable-gpio = <&tlmm 55 0x00>;
		redriver,orientation-gpio = <&tlmm 83 0x00>;
		config-seq =
			/* <reg_offset, value, delay_us> */
			<0x9d 0x80 10000
			0x9d 0x00 0
			0x40 0x80 0
			0x8d 0x01 0
			0x90 0x01 0
			0x51 0x87 0
			0x50 0x20 0
			0x54 0x11 0
			0x5d 0x66 0
			0x52 0x50 0
			0x55 0x00 0
			0x56 0x00 0
			0x57 0x00 0
			0x58 0x00 0
			0x59 0x00 0
			0x5a 0x00 0
			0x5b 0x00 0
			0x5e 0x07 0
			0x5f 0x00 0
			0x60 0x00 0
			0x61 0x03 0
			0x65 0x40 0
			0x66 0x00 0
			0x67 0x03 0
			0x75 0x0c 0
			0x77 0x00 0
			0x78 0x7c 0>;
	};
};

&L16B {
	regulator-min-microvolt = <3000000>;
	regulator-max-microvolt = <3000000>;
	qcom,init-voltage = <3000000>;
	regulator-boot-on;
	regulator-always-on;
};

&tlmm {
    laser_xsdn_active: laser_xsdn_active {
		mux {
			pins = "gpio131";
			function = "gpio";
		};

		config {
			pins = "gpio131";
			drive-strength = <2>;
			bias-disable;
		};
	};

	laser_xsdn_suspend: laser_xsdn_suspend {
		mux {
			pins = "gpio131";
			function = "gpio";
		};

		config {
			pins = "gpio131";
			drive-strength = <2>;
			bias-pull-down;
		};
	};

	laser_int_active: laser_int_active {
		mux {
			pins = "gpio69";
			function = "gpio";
		};

		config {
			pins = "gpio69";
			drive-strength = <2>;
			bias-pull-up;
		};
	};

	laser_int_suspend: laser_int_suspend {
		mux {
			pins = "gpio69";
			function = "gpio";
		};

		config {
			pins = "gpio69";
			drive-strength = <2>;
			bias-pull-down;
		};
	};
};

&qupv3_se1_i2c {
	status = "okay";
	qcom,noise-rjct-scl = <3>;
	qcom,noise-rjct-sda = <3>;
	stmvl53l1@29 {
		status = "ok";
		compatible = "st,stmvl53l1";
		reg = <0x29>;
		vdd-vl53l1-supply = <&L16B>;
		gpios = <&tlmm 131 0>, <&tlmm 69 0>;
		pinctrl-names = "laser_default", "laser_suspend";
		pinctrl-0 = <&laser_xsdn_active &laser_int_active>;
		pinctrl-1 = <&laser_xsdn_suspend &laser_int_suspend>;
		st,sensorthreshold = <60 65>;
		st,xtalkval = <0x0 0x0 0x0>;
	};
};
