// SPDX-License-Identifier: GPL-2.0
#include "qcom-msm8974.dtsi"
#include "pm8841.dtsi"
#include "pm8941.dtsi"
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>

/ {
	model = "Samsung Galaxy Note 3";
	compatible = "samsung,hlte", "qcom,msm8974";
	chassis-type = "handset";

	aliases {
		mmc0 = &sdhc_1; /* SDC1 eMMC slot */
		mmc1 = &sdhc_3; /* SDC3 SD card slot */
		serial0 = &blsp1_uart1;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

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

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

		key-home {
			label = "Home Key";
			gpios = <&pm8941_gpios 3 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_HOMEPAGE>;
			wakeup-source;
			debounce-interval = <15>;
		};

		key-volume-down {
			label = "Volume Down";
			gpios = <&pm8941_gpios 2 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEDOWN>;
			debounce-interval = <15>;
		};

		key-volume-up {
			label = "Volume Up";
			gpios = <&pm8941_gpios 5 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_VOLUMEUP>;
			debounce-interval = <15>;
		};
	};

	touch_ldo: regulator-touch {
		compatible = "regulator-fixed";
		regulator-name = "touch-ldo";

		gpio = <&pm8941_gpios 9 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-boot-on;

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

&blsp1_i2c2 {
	status = "okay";

	touchscreen@20 {
		compatible = "syna,rmi4-i2c";
		reg = <0x20>;

		interrupt-parent = <&pm8941_gpios>;
		interrupts = <30 IRQ_TYPE_EDGE_FALLING>;

		vdd-supply = <&pm8941_l10>;
		vio-supply = <&touch_ldo>;

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

		syna,startup-delay-ms = <100>;

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

		rmi4-f01@1 {
			reg = <0x1>;
			syna,nosleep-mode = <1>;
		};

		rmi4-f12@12 {
			reg = <0x12>;
			syna,sensor-type = <1>;
		};
	};
};

&blsp2_i2c6 {
	status = "okay";

	fuelgauge@36 {
		compatible = "maxim,max17048";
		reg = <0x36>;

		maxim,double-soc;
		maxim,rcomp = /bits/ 8 <0x56>;

		interrupt-parent = <&pm8941_gpios>;
		interrupts = <26 IRQ_TYPE_EDGE_FALLING>;

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

&blsp1_uart2 {
	status = "okay";
};

&pm8941_gpios {
	gpio_keys_pin_a: gpio-keys-active-state {
		pins = "gpio2", "gpio3", "gpio5";
		function = "normal";
		bias-pull-up;
		power-source = <PM8941_GPIO_S3>;
	};

	fuelgauge_pin: fuelgauge-int-state {
		pins = "gpio26";
		function = "normal";
		bias-disable;
		input-enable;
		power-source = <PM8941_GPIO_S3>;
	};

	touch_pin: touchscreen-int-state {
		pins = "gpio30";
		function = "normal";
		bias-disable;
		input-enable;
		power-source = <PM8941_GPIO_S3>;
	};

	touch_ldo_pin: touchscreen-ldo-state {
		pins = "gpio9";
		function = "normal";
		output-high;
		power-source = <PM8941_GPIO_S3>;
		qcom,drive-strength = <PMIC_GPIO_STRENGTH_HIGH>;
	};
};

&remoteproc_adsp {
	cx-supply = <&pm8841_s2>;
	status = "okay";
};

&remoteproc_mss {
	cx-supply = <&pm8841_s2>;
	mss-supply = <&pm8841_s3>;
	mx-supply = <&pm8841_s1>;
	pll-supply = <&pm8941_l12>;
	status = "okay";
};

&rpm_requests {
	regulators-0 {
		compatible = "qcom,rpm-pm8841-regulators";

		pm8841_s1: s1 {
			regulator-min-microvolt = <675000>;
			regulator-max-microvolt = <1050000>;
		};

		pm8841_s2: s2 {
			regulator-min-microvolt = <500000>;
			regulator-max-microvolt = <1050000>;
		};

		pm8841_s3: s3 {
			regulator-min-microvolt = <1050000>;
			regulator-max-microvolt = <1050000>;
		};

		pm8841_s4: s4 {
			regulator-min-microvolt = <815000>;
			regulator-max-microvolt = <900000>;
		};
	};

	regulators-1 {
		compatible = "qcom,rpm-pm8941-regulators";

		pm8941_s1: s1 {
			regulator-min-microvolt = <1300000>;
			regulator-max-microvolt = <1300000>;
			regulator-always-on;
		};

		pm8941_s2: s2 {
			regulator-min-microvolt = <2150000>;
			regulator-max-microvolt = <2150000>;
		};

		pm8941_s3: s3 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l1: l1 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};

		pm8941_l2: l2 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};

		pm8941_l3: l3 {
			regulator-min-microvolt = <1050000>;
			regulator-max-microvolt = <1225000>;
		};

		pm8941_l4: l4 {
			regulator-min-microvolt = <1225000>;
			regulator-max-microvolt = <1225000>;
		};

		pm8941_l5: l5 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l6: l6 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l7: l7 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l8: l8 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l9: l9 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2950000>;
		};

		pm8941_l10: l10 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l11: l11 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1350000>;
		};

		pm8941_l12: l12 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-always-on;
		};

		pm8941_l13: l13 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3300000>;
		};

		pm8941_l14: l14 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8941_l15: l15 {
			regulator-min-microvolt = <2050000>;
			regulator-max-microvolt = <2050000>;
		};

		pm8941_l16: l16 {
			regulator-min-microvolt = <2700000>;
			regulator-max-microvolt = <2700000>;
		};

		pm8941_l17: l17 {
			regulator-min-microvolt = <2850000>;
			regulator-max-microvolt = <3000000>;
		};

		pm8941_l18: l18 {
			regulator-min-microvolt = <2850000>;
			regulator-max-microvolt = <2850000>;
		};

		pm8941_l19: l19 {
			regulator-min-microvolt = <2900000>;
			regulator-max-microvolt = <3350000>;
		};

		pm8941_l20: l20 {
			regulator-min-microvolt = <2950000>;
			regulator-max-microvolt = <2950000>;
			regulator-system-load = <200000>;
			regulator-allow-set-load;
		};

		pm8941_l21: l21 {
			regulator-min-microvolt = <2950000>;
			regulator-max-microvolt = <2950000>;
			regulator-system-load = <200000>;
			regulator-allow-set-load;
		};

		pm8941_l22: l22 {
			regulator-min-microvolt = <2500000>;
			regulator-max-microvolt = <3000000>;
		};

		pm8941_l23: l23 {
			regulator-min-microvolt = <2400000>;
			regulator-max-microvolt = <3300000>;
		};

		pm8941_l24: l24 {
			regulator-min-microvolt = <3075000>;
			regulator-max-microvolt = <3075000>;
		};
	};
};

&sdhc_1 {
	vmmc-supply = <&pm8941_l20>;
	vqmmc-supply = <&pm8941_s3>;

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

	status = "okay";
};

&sdhc_3 {
	max-frequency = <100000000>;

	vmmc-supply = <&pm8941_l21>;
	vqmmc-supply = <&pm8941_l21>;

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

	status = "okay";
};

&tlmm {
	sdhc1_pin_a: sdhc1-pin-active-state {
		clk-pins {
			pins = "sdc1_clk";
			drive-strength = <4>;
			bias-disable;
		};

		cmd-data-pins {
			pins = "sdc1_cmd", "sdc1_data";
			drive-strength = <4>;
			bias-pull-up;
		};
	};

	sdhc3_pin_a: sdhc3-pin-active-state {
		pins = "gpio35", "gpio36", "gpio37", "gpio38", "gpio39", "gpio40";
		function = "sdc3";
		drive-strength = <8>;
		bias-disable;
	};
};

&usb {
	phys = <&usb_hs1_phy>;
	phy-select = <&tcsr 0xb000 0>;

	hnp-disable;
	srp-disable;
	adp-disable;

	status = "okay";
};

&usb_hs1_phy {
	v1p8-supply = <&pm8941_l6>;
	v3p3-supply = <&pm8941_l24>;

	qcom,init-seq = /bits/ 8 <0x1 0x64>;

	status = "okay";
};
