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

#include "msm8916-pm8916.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/interrupt-controller/irq.h>

/ {
	aliases {
		mmc0 = &sdhc_1; /* eMMC */
		mmc1 = &sdhc_2; /* SD card */
		serial0 = &blsp_uart2;
	};

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

	reserved-memory {
		/* Additional memory used by Samsung firmware modifications */
		tz-apps@85500000 {
			reg = <0x0 0x85500000 0x0 0xb00000>;
			no-map;
		};
	};

	gpio_hall_sensor: gpio-hall-sensor {
		compatible = "gpio-keys";

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

		label = "GPIO Hall Effect Sensor";

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

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

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

		label = "GPIO Buttons";

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

		button-home {
			label = "Home Key";
			gpios = <&tlmm 109 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_HOMEPAGE>;
		};
	};

	i2c_muic: i2c-muic {
		compatible = "i2c-gpio";
		sda-gpios = <&tlmm 105 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&tlmm 106 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

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

		#address-cells = <1>;
		#size-cells = <0>;

		muic: extcon@25 {
			compatible = "siliconmitus,sm5703-muic";
			reg = <0x25>;

			interrupt-parent = <&tlmm>;
			interrupts = <12 IRQ_TYPE_EDGE_FALLING>;

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

&blsp_i2c5 {
	status = "okay";

	touchscreen: touchscreen@50 {
		compatible = "imagis,ist3038c";
		reg = <0x50>;

		interrupt-parent = <&tlmm>;
		interrupts = <13 IRQ_TYPE_EDGE_FALLING>;

		touchscreen-size-x = <720>;
		touchscreen-size-y = <1280>;

		vddio-supply = <&pm8916_l6>;

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

&blsp_uart2 {
	status = "okay";
};

&pm8916_resin {
	status = "okay";
	linux,code = <KEY_VOLUMEDOWN>;
};

&sdhc_1 {
	status = "okay";
};

&sdhc_2 {
	status = "okay";

	pinctrl-names = "default", "sleep";
	pinctrl-0 = <&sdc2_default &sdc2_cd_default>;
	pinctrl-1 = <&sdc2_sleep &sdc2_cd_default>;

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

&usb {
	extcon = <&muic>, <&muic>;
	status = "okay";
};

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

&wcnss {
	status = "okay";
};

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

&tlmm {
	gpio_hall_sensor_default: gpio-hall-sensor-default-state {
		pins = "gpio52";
		function = "gpio";

		drive-strength = <2>;
		bias-disable;
	};

	gpio_keys_default: gpio-keys-default-state {
		pins = "gpio107", "gpio109";
		function = "gpio";

		drive-strength = <2>;
		bias-pull-up;
	};

	muic_i2c_default: muic-i2c-default-state {
		pins = "gpio105", "gpio106";
		function = "gpio";

		drive-strength = <2>;
		bias-disable;
	};

	muic_int_default: muic-int-default-state {
		pins = "gpio12";
		function = "gpio";

		drive-strength = <2>;
		bias-disable;
	};

	sdc2_cd_default: sdc2-cd-default-state {
		pins = "gpio38";
		function = "gpio";

		drive-strength = <2>;
		bias-disable;
	};

	tsp_int_default: tsp-int-default-state {
		pins = "gpio13";
		function = "gpio";

		drive-strength = <2>;
		bias-disable;
	};
};