/*
   this file is for attribution only of unicorn
   And public attribution of xiaomi platforms(like K2 and so and)
*/
#include "diting-pinctrl.dtsi"
#include "xiaomi-sm8475-common.dtsi"
&soc {
        thermal_message: thermal-message {
                board-sensor = "VIRTUAL-SENSOR0";
        };

};

&qupv3_se4_spi {
	status = "okay";
	qcom,rt;
	pinctrl-0 = <&mi_ts_spi_active &mi_ts_cs_active>;
	pinctrl-1 = <&mi_ts_spi_sleep &mi_ts_cs_suspend>;

	xiaomi_touch@0 {
		status = "okay";
		compatible = "st,spi", "goodix,gt9916S";
		reg = <0>;
		spi-max-frequency = <12000000>;
		interrupt-parent = <&tlmm>;
		interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-names = "pmx_ts_active", "pmx_ts_suspend";
		pinctrl-0 = <&mi_ts_active>;
		pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;

		goodix,reset-gpio = <&tlmm 20 GPIO_ACTIVE_HIGH>;
		goodix,irq-gpio = <&tlmm 21 GPIO_TRANSITORY>;
		goodix,irq-flags = <IRQ_TYPE_EDGE_FALLING>;
		goodix,panel-max-x = <12200>;
		goodix,panel-max-y = <27120>;
		goodix,panel-max-w = <255>;
		goodix,panel-max-p = <4096>;
		goodix,avdd-gpio = <&tlmm 71 GPIO_ACTIVE_HIGH>;
		// TODO: Check this in schematics
		// goodix,avdd-name = "avdd";
		// avdd-supply = <&L7C>;
		goodix,iovdd-name = "vdd";
		vdd-supply = <&L2C>;
		goodix,ts-id-gpio = <&tlmm 119 GPIO_ACTIVE_LOW>;
		goodix,ts-id-gpio-match-value = <0>;
		goodix,firmware-name = "goodix_firmware_l12.bin";
		goodix,config-name = "goodix_cfg_group_l12.bin";

		fts,avdd-gpio = <&tlmm 71 GPIO_ACTIVE_HIGH>;
		//avdd-supply = <&L3C>;
		//vdd-supply = <&L2C>;
		//fts,pwr-reg-name = "avdd";
		fts,bus-reg-name = "vdd";
		fts,irq-gpio = <&tlmm 21 GPIO_TRANSITORY>;
		fts,irq-gpio-name = "fts_irq";
		fts,reset-gpio-enable;
		fts,reset-gpio = <&tlmm 20 GPIO_ACTIVE_HIGH>;
		fts,reset-gpio-name = "fts_rst";
		fts,irq-flags = <0x2008>;
		fts,x-max = <12200>;
		fts,y-max = <27120>;
		fts,support-fod = <1>;
		fts,fod-lx = <4960>;
		fts,fod-ly = <23300>;
		fts,fod-x-size = <2280>;
		fts,fod-y-size = <2280>;
		fts,default-fw-name = "st_fts_l12.ftb";
		fts,non-curved-display = <1>;
		fts,config-array-size = <1>;
		fts,support-super-resolution = <1>;
		fts,touch-follow-performance-def = <3>;
		fts,touch-tap-sensitivity-def = <4>;
		fts,touch-aim-sensitivity-def = <3>;
		fts,touch-tap-stability-def = <3>;
		fts,cornerfilter-area-step1 = <112>;
		fts,cornerfilter-area-step2 = <190>;
		fts,cornerfilter-area-step3 = <280>;
		fts,touch-deadzone-filter-ver = <2 0 0 0 0 0 0 0
						 2 1 0 0 0 0 0 0
						 2 2 0 0 0 2711 0 0
						 2 3 1219 0 1219 2711 0 0>;
		fts,touch-deadzone-filter-hor = <2 0 0 0 1219 0 0 0
						 2 1 0 2711 1219 2711 0 0
						 2 2 0 0 0 2711 0 0
						 2 3 1219 0 1219 2711 0 0>;
		fts,touch-edgezone-filter-ver = <1 0 0 0 0 0 0 0
						 1 1 0 0 0 0 0 0
						 1 2 0 0 42 2711 0 0
						 1 3 1177 0 1219 2711 0 0>;
		fts,touch-edgezone-filter-hor = <1 0 0 0 1219 42 0 0
						 1 1 0 2669 1219 2711 0 0
						 1 2 0 0 42 2711 0 0
						 1 3 1177 0 1219 2711 0 0>;
		fts,touch-cornerzone-filter-ver = <0 0 0 0 0 0 0 0
						   0 1 0 0 0 0 0 0
						   0 2 0 2372 169 2711 0 0
						   0 3 1050 2372 1219 2711 0 0>;
		fts,touch-cornerzone-filter-hor1 = <0 0 0 0 0 0 0 0
						    0 1 0 0 190 190 0 0
						    0 2 0 2521 190 2711 0 0
						    0 3 0 0 0 0 0 0>;
		fts,touch-cornerzone-filter-hor2 = <0 0 1029 0 1219 190 0 0
						    0 1 0 0 0 0 0 0
						    0 2 0 0 0 0 0 0
						    0 3 1029 2521 1219 2711 0 0>;
		fts,touch-normal-edgezone-filter-hor = <1 0 0 0 1219 40 0 0
							1 1 0 2671 1219 2711 0 0
							1 2 0 0 40 2711 0 0
							1 3 1179 0 1219 2711 0 0>;
		fts,touch-normal-cornerzone-filter-hor1 = <0 0 0 0 0 0 0 0
							   0 1 0 0 190 190 0 0
							   0 2 0 2521 190 2711 0 0
							   0 3 0 0 0 0 0 0>;
		fts,touch-normal-cornerzone-filter-hor2 = <0 0 1029 0 1219 190 0 0
							   0 1 0 0 0 0 0 0
							   0 2 0 0 0 0 0 0
							   0 3 1029 2521 1219 2711 0 0>;
		fts,touch-follow-performance = <10 15 1
						8 15 1
						6 15 1
						4 15 1
						2 15 1>;
		fts,touch-tap-sensitivity = <160 150 140 130 100>;
		fts,touch-aim-sensitivity = <12 10 8 6 4>;
		fts,touch-tap-stability = <10 14 18 20 26>;
		fts,touch-expert-array = <6 15 1 130 8 18
					  2 15 1 130 5 18
					  4 15 1 130 4 18>;
		fts,cfg_0 {
			fts,tp-vendor = <0x38>;
			fts,fw-name = "st_fts_l12.ftb";
			fts,limit-name = "stm_fts_production_limits.csv";
		};
	};
};

&tlmm {
        mi_ts_active: mi_ts_active {
                mux {
                                pins = "gpio21", "gpio20";
                                function = "gpio";
                };
		config {
                                pins = "gpio21", "gpio20";
                                drive-strength = <8>;
                                bias-pull-up;
                };
        };
	/* RCV HANDSET CTL */
	rcv_gpio_high: rcv_gpio_high {
		mux {
			pins = "gpio52";
			function = "gpio";
		};

		config {
			pins = "gpio52";
			drive-strength = <2>;
			bias-pull-up;
			output-high;
		};
	};
	rcv_gpio_low: rcv_gpio_low {
		mux {
			pins = "gpio52";
			function = "gpio";
		};

		config {
			pins = "gpio52";
			drive-strength = <2>;
			bias-disable;
			output-low;
		};
	};

	tert_tdm_din_active: tert_tdm_din_active {
		mux {
			pins = "gpio122";
			function = "mi2s2_data0";
		};

		config {
			pins = "gpio122";
			drive-strength = <0x02>;
			bias-disable;
		};
	};

	tert_tdm_dout_active: tert_tdm_dout_active {
		mux {
			pins = "gpio124";
			function = "mi2s2_data1";
		};

		config {
			pins = "gpio124";
			drive-strength = <0x02>;
			bias-disable;
		};
	};

	tert_tdm_clk_active: tert_tdm_clk_active {
		mux {
			pins = "gpio121";
			function = "mi2s2_sck";
		};

		config {
			pins = "gpio121";
			drive-strength = <0x02>;
			bias-disable;
			output-low;
		};
	};

	tert_tdm_ws_active: tert_tdm_ws_active {
		mux {
			pins = "gpio123";
			function = "mi2s2_ws";
		};

		config {
			pins = "gpio123";
			drive-strength = <0x02>;
			bias-disable;
			output-low;
		};
	};
};

&qupv3_se15_i2c {
	status = "ok";
	cs35l41_0: cs35l41@40 {
		status = "ok";
		compatible = "cirrus,cs35l41";
		reset-gpios = <&tlmm 3 0>;
		reg = <0x40>;
		interrupt-parent = <&tlmm>;
		interrupts = <63 0x2008>;
		pinctrl-names = "default";
		pinctrl-0 = <&cirrus_reset_default_0 &cirrus_irq_default_0>;
		cirrus,temp-warn_threshold = <3>;
		cirrus,boost-peak-milliamp = <4000>;
		cirrus,boost-ind-nanohenry = <1000>;
		cirrus,boost-cap-microfarad = <15>;
		cirrus,asp-sdout-hiz = <3>;
		cirrus,right-channel-amp;
		sound-name-prefix = "B";
		cirrus,fast-switch = "B-music.txt", "B-handfree.txt";
		cirrus,gpio-config2 {
			cirrus,gpio-src-select = <0x4>;
			cirrus,gpio-output-enable;
		};
	};
	cs35l41_3: cs35l41@42 {
		status = "ok";
		compatible = "cirrus,cs35l41";
		reset-gpios = <&tlmm 1 0>;
		spk-sw-gpios = <&tlmm 52 0>;
		reg = <0x42>;
		interrupt-parent = <&tlmm>;
		interrupts = <88 0x2008>;
		pinctrl-names = "default", "rcv_gpio_high", "rcv_gpio_low";
		pinctrl-0 = <&cirrus_reset_default_3 &cirrus_irq_default_3>;
		pinctrl-1 = <&rcv_gpio_high>;
		pinctrl-2 = <&rcv_gpio_low>;
		cirrus,temp-warn_threshold = <3>;
		cirrus,boost-peak-milliamp = <4000>;
		cirrus,boost-ind-nanohenry = <1000>;
		cirrus,boost-cap-microfarad = <15>;
		cirrus,asp-sdout-hiz = <3>;
		sound-name-prefix = "T";
		cirrus,fast-switch = "T-music.txt", "T-handset.txt", "T-handfree.txt";
		cirrus,gpio-config2 {
			cirrus,gpio-src-select = <0x4>;
			cirrus,gpio-output-enable;
		};
	};
};

&battery_charger {
	qcom,shutdown-voltage = <3350>;
};

&nxp_eusb2_repeater {
	qcom,param-override-seq = /* override value offset */
		<0x50 0x06
		 0x00 0x07
		 0x63 0x08>;
	qcom,param-override-seq-host =
		<0x40 0x06
		 0x22 0x07
		 0x63 0x08
		 0x01 0x0A>;
};

&soc {
	fingerprint_goodix {
		compatible = "goodix,fingerprint";
		vdda-supply = <&L1C>;
		vddb-supply = <&L3C>;
		goodix,gpio-reset = <&tlmm 41 0x0>;
		goodix,gpio-irq = <&tlmm 40 0x0>;
		status = "ok";
	};
};
&L1C {
	regulator-min-microvolt = <1800000>;
	regulator-max-microvolt = <1800000>;
	qcom,init-voltage = <1800000>;
};

&L3C {
	regulator-boot-on;
	regulator-always-on;
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	qcom,init-voltage = <3300000>;
};
&qseecom_ta_mem {
	size = <0x0 0x2000000>;
};

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

&pmk8350_vadc {
        pinctrl-names = "default";
        pinctrl-0 = <&pm8350_rear_tof_therm_default>;

        pm8350_msm_therm {
                reg = <PM8350_ADC7_AMUX_THM1_100K_PU>;
                label = "pm8350_msm_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pm8350_flash_therm {
                reg = <PM8350_ADC7_AMUX_THM2_100K_PU>;
                label = "pm8350_flash_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pm8350_hot_pocket_therm {
                reg = <PM8350_ADC7_AMUX_THM3_100K_PU>;
                label = "pm8350_hot_pocket_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pm8350_charger0_therm {
                reg = <PM8350B_ADC7_GPIO4_100K_PU>;
                label = "pm8350_charger0_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pa_therm0 {
                reg = <PMR735A_ADC7_GPIO1_100K_PU>;
                label = "pa_therm0";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pa_therm1 {
                reg = <PMR735A_ADC7_GPIO2_100K_PU>;
                label = "pa_therm1";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        wifi_therm {
                reg = <PMR735A_ADC7_GPIO3_100K_PU>;
                label = "wifi_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };

        pm8350b_usb_conn_therm {
                reg = <PM8350B_ADC7_AMUX_THM4_100K_PU>;
                label = "pm8350b_usb_conn_therm";
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
                qcom,pre-scaling = <1 1>;
        };
};

&pmk8350_adc_tm {
        io-channels = <&pmk8350_vadc PM8350_ADC7_AMUX_THM1_100K_PU>,
                        <&pmk8350_vadc PM8350_ADC7_AMUX_THM2_100K_PU>,
                        <&pmk8350_vadc PM8350_ADC7_AMUX_THM3_100K_PU>,
                        <&pmk8350_vadc PM8350B_ADC7_GPIO4_100K_PU>,
                        <&pmk8350_vadc PMR735A_ADC7_GPIO1_100K_PU>,
                        <&pmk8350_vadc PMR735A_ADC7_GPIO2_100K_PU>,
                        <&pmk8350_vadc PMR735A_ADC7_GPIO3_100K_PU>,
			<&pmk8350_vadc PM8350B_ADC7_AMUX_THM4_100K_PU>;

        pm8350_msm_therm {
                reg = <PM8350_ADC7_AMUX_THM1_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pm8350_flash_therm {
                reg = <PM8350_ADC7_AMUX_THM2_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pm8350_hot_pocket_therm {
                reg = <PM8350_ADC7_AMUX_THM3_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pm8350_charger0_therm {
                reg = <PM8350B_ADC7_GPIO4_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pa_therm0 {
                reg = <PMR735A_ADC7_GPIO1_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pa_therm1 {
                reg = <PMR735A_ADC7_GPIO2_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        wifi_therm {
                reg = <PMR735A_ADC7_GPIO3_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };

        pm8350b_usb_conn_therm {
                reg = <PM8350B_ADC7_AMUX_THM4_100K_PU>;
                qcom,ratiometric;
                qcom,hw-settle-time = <200>;
        };


};

&bcl_soc {
        status = "disabled";
};

&thermal_zones {
        cpu_therm {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PM8350_ADC7_AMUX_THM1_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        flash_therm {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PM8350_ADC7_AMUX_THM2_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        quiet_therm {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PM8350_ADC7_AMUX_THM3_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        charger_therm0 {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PM8350B_ADC7_GPIO4_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        pa_therm0 {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PMR735A_ADC7_GPIO1_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        pa_therm1 {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PMR735A_ADC7_GPIO2_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        wifi_therm {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PMR735A_ADC7_GPIO3_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };

        conn_therm {
                polling-delay-passive = <0>;
                polling-delay = <0>;
                thermal-governor = "user_space";
                thermal-sensors = <&pmk8350_adc_tm PM8350B_ADC7_AMUX_THM4_100K_PU>;
                wake-capable-sensor;
                trips {
                        active-config0 {
                                temperature = <125000>;
                                hysteresis = <1000>;
                                type = "passive";
                        };
                };
        };
};


