// SPDX-License-Identifier: GPL-2.0-only

/dts-v1/;

#include "msm8939-pm8916.dtsi"
#include "msm8916-modem-qdsp6.dtsi"

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

/ {
	model = "Asus ZenFone 2 Laser/Selfie (1080p)";
	compatible = "asus,z00t", "qcom,msm8939";
	chassis-type = "handset";

	aliases {
		mmc0 = &sdhc_1;
		mmc1 = &sdhc_2;
		serial0 = &blsp_uart2;
	};

	battery: battery {
		compatible = "simple-battery";
		device-chemistry = "lithium-ion-polymer";
		voltage-min-design-microvolt = <3400000>;
		voltage-max-design-microvolt = <4400000>;
		energy-full-design-microwatt-hours = <11500000>;
		charge-full-design-microamp-hours = <3000000>;

		ocv-capacity-celsius = <(-20) 0 25 40 60>;
		ocv-capacity-table-0 = <4378000 100>, <4220000 95>, <4125000 90>,
			<4071000 85>, <3977000 80>, <3916000 75>, <3866000 70>,
			<3838000 65>, <3822000 60>, <3809000 55>, <3797000 50>,
			<3784000 45>, <3771000 40>, <3757000 35>, <3743000 30>,
			<3726000 25>, <3707000 20>, <3688000 16>, <3670000 13>,
			<3655000 11>, <3648000 10>, <3636000 9>, <3624000 8>,
			<3612000 7>, <3592000 6>, <3569000 5>, <3540000 4>,
			<3494000 3>, <3418000 2>, <3289000 1>, <3000000 0>;

		ocv-capacity-table-1 = <4378000 100>, <4292000 95>, <4226000 90>,
			<4166000 85>, <4109000 80>, <4064000 75>, <3992000 70>,
			<3942000 65>, <3898000 60>, <3859000 55>, <3826000 50>,
			<3802000 45>, <3788000 40>, <3779000 35>, <3768000 30>,
			<3752000 25>, <3732000 20>, <3712000 16>, <3696000 13>,
			<3688000 11>, <3684000 10>, <3680000 9>, <3675000 8>,
			<3669000 7>, <3658000 6>, <3636000 5>, <3599000 4>,
			<3544000 3>, <3466000 2>, <3341000 1>, <3000000 0>;

		ocv-capacity-table-2 = <4372000 100>, <4306000 95>, <4247000 90>,
			<4190000 85>, <4134000 80>, <4081000 75>, <4030000 70>,
			<3984000 65>, <3930000 60>, <3884000 55>, <3850000 50>,
			<3826000 45>, <3804000 40>, <3786000 35>, <3770000 30>,
			<3753000 25>, <3734000 20>, <3712000 16>, <3693000 13>,
			<3686000 11>, <3684000 10>, <3682000 9>, <3680000 8>,
			<3676000 7>, <3668000 6>, <3643000 5>, <3600000 4>,
			<3542000 3>, <3462000 2>, <3340000 1>, <3000000 0>;

		ocv-capacity-table-3 = <4365000 100>, <4304000 95>, <4246000 90>,
			<4189000 85>, <4133000 80>, <4080000 75>, <4030000 70>,
			<3985000 65>, <3933000 60>, <3886000 55>, <3852000 50>,
			<3827000 45>, <3806000 40>, <3789000 35>, <3769000 30>,
			<3746000 25>, <3726000 20>, <3706000 16>, <3688000 13>,
			<3681000 11>, <3678000 10>, <3676000 9>, <3676000 8>,
			<3672000 7>, <3660000 6>, <3634000 5>, <3588000 4>,
			<3528000 3>, <3448000 2>, <3322000 1>, <3000000 0>;

		ocv-capacity-table-4 = <4358000 100>, <4298000 95>, <4240000 90>,
			<4183000 85>, <4128000 80>, <4076000 75>, <4027000 70>,
			<3983000 65>, <3935000 60>, <3887000 55>, <3852000 50>,
			<3827000 45>, <3806000 40>, <3789000 35>, <3764000 30>,
			<3738000 25>, <3715000 20>, <3695000 16>, <3677000 13>,
			<3672000 11>, <3669000 10>, <3667000 9>, <3666000 8>,
			<3662000 7>, <3652000 6>, <3622000 5>, <3577000 4>,
			<3518000 3>, <3440000 2>, <3321000 1>, <3000000 0>;
	};

	chosen {
		stdout-path = "serial0";
	};

	gpio-keys {
		compatible = "gpio-keys";

		pinctrl-0 = <&gpio_hall_sensor_default>, <&gpio_keys_default>;
		pinctrl-names = "default";

		button-volume-up {
			label = "Volume Up";
			gpios = <&tlmm 107 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEUP>;
			debounce-interval = <15>;
		};

		button-volume-down {
			label = "Volume Down";
			gpios = <&tlmm 117 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEDOWN>;
			debounce-interval = <15>;
		};

		event-hall-sensor {
			label = "Hall Effect Sensor";
			gpios = <&tlmm 108 GPIO_ACTIVE_LOW>;
			linux,input-type = <EV_SW>;
			linux,code = <SW_LID>;
			linux,can-disable;
			debounce-interval = <150>;
		};
	};

	reg_sd_vmmc: regulator-sdcard-vmmc {
		compatible = "regulator-fixed";
		regulator-name = "sdcard-vmmc";
		regulator-min-microvolt = <2950000>;
		regulator-max-microvolt = <2950000>;

		gpio = <&tlmm 87 GPIO_ACTIVE_HIGH>;
		enable-active-high;

		startup-delay-us = <200>;

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

	usb_id: usb-id {
		compatible = "linux,extcon-usb-gpio";
		id-gpios = <&tlmm 110 GPIO_ACTIVE_HIGH>;
		pinctrl-0 = <&usb_id_default>;
		pinctrl-names = "default";
	};
};

&blsp_i2c2 {
	status = "okay";

	magnetometer@c {
		compatible = "asahi-kasei,ak09911";
		reg = <0x0c>;

		vdd-supply = <&pm8916_l8>;
		vid-supply = <&pm8916_l6>;

		reset-gpios = <&tlmm 112 GPIO_ACTIVE_LOW>;
		pinctrl-0 = <&mag_reset_default>;
		pinctrl-names = "default";
	};

	light-sensor@60 {
		compatible = "capella,cm36686", "vishay,vcnl4040";
		reg = <0x60>;

		interrupts-extended = <&tlmm 113 IRQ_TYPE_EDGE_FALLING>;
		proximity-near-level = <30>;

		vdd-supply = <&pm8916_l8>;
		vio-supply = <&pm8916_l6>;

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

	imu@68 {
		compatible = "invensense,mpu6515";
		reg = <0x68>;

		interrupts-extended = <&tlmm 36 IRQ_TYPE_EDGE_RISING>;

		vdd-supply = <&pm8916_l8>;
		vddio-supply = <&pm8916_l6>;

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

		mount-matrix = "0",  "1", "0",
			       "-1", "0", "0",
			       "0",  "0", "1";
	};
};

&blsp_i2c5 {
	status = "okay";

	touchscreen@38 {
		compatible = "edt,edt-ft5306";
		reg = <0x38>;

		interrupts-extended = <&tlmm 13 IRQ_TYPE_EDGE_FALLING>;

		reset-gpios = <&tlmm 12 GPIO_ACTIVE_LOW>;

		vcc-supply = <&pm8916_l8>;
		iovcc-supply = <&pm8916_l6>;

		touchscreen-size-x = <1080>;
		touchscreen-size-y = <1920>;

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

&blsp_uart2 {
	pinctrl-0 = <&blsp_uart2_console_default>;
	pinctrl-1 = <&blsp_uart2_console_sleep>;
	pinctrl-names = "default", "sleep";

	status = "okay";
};

&mpss_mem {
	reg = <0x0 0x86800000 0x0 0x5500000>;
};

&pm8916_bms {
	monitored-battery = <&battery>;

	status = "okay";
};

&pm8916_codec {
	qcom,micbias-lvl = <2800>;
	qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
	qcom,mbhc-vthreshold-high = <75 150 237 450 500>;
	qcom,micbias1-ext-cap;
	qcom,hphl-jack-type-normally-open;

	status = "okay";
};

&pm8916_vib {
	status = "okay";
};

&sdhc_1 {
	status = "okay";
};

&sdhc_2 {
	vmmc-supply = <&reg_sd_vmmc>;

	pinctrl-0 = <&sdc2_default &sdc2_cd_default>;
	pinctrl-1 = <&sdc2_sleep &sdc2_cd_default>;
	pinctrl-names = "default", "sleep";
	cd-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;

	status = "okay";
};

&sound {
	audio-routing =
		"AMIC1", "MIC BIAS External1",
		"AMIC2", "MIC BIAS Internal2",
		"AMIC3", "MIC BIAS External1";

	status = "okay";
};

&usb {
	extcon = <&usb_id>, <&usb_id>;

	status = "okay";
};

&usb_hs_phy {
	extcon = <&usb_id>;
};

&venus {
	status = "okay";
};

&venus_mem {
	status = "okay";
};

&wcnss {
	status = "okay";
};

&wcnss_iris {
	compatible = "qcom,wcn3660b";
};

&wcnss_mem {
	status = "okay";
};

&tlmm {
	touchscreen_default: touchscreen-default-state {
		reset-pins {
			pins = "gpio12";
			function = "gpio";
			drive-strength = <2>;
			bias-disable;
		};

		touch-pins {
			pins = "gpio13";
			function = "gpio";
			drive-strength = <2>;
			bias-pull-up;
		};
	};

	imu_default: imu-default-state {
		pins = "gpio36";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	sdc2_cd_default: sdc2-cd-default-state {
		pins = "gpio38";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	sd_vmmc_en_default: sd-vmmc-en-default-state {
		pins = "gpio87";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	gpio_keys_default: gpio-keys-default-state {
		pins = "gpio107", "gpio117";
		function = "gpio";
		drive-strength = <2>;
		bias-pull-up;
	};

	gpio_hall_sensor_default: gpio-hall-sensor-default-state {
		pins = "gpio108";
		function = "gpio";
		drive-strength = <2>;
		bias-pull-up;
	};

	usb_id_default: usb-id-default-state {
		pins = "gpio110";
		function = "gpio";
		drive-strength = <8>;
		bias-pull-up;
	};

	mag_reset_default: mag-reset-default-state {
		pins = "gpio112";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
	};

	light_int_default: light-int-default-state {
		pins = "gpio113";
		function = "gpio";
		drive-strength = <16>;
		bias-pull-up;
	};
};