/* Copyright (c) 2016-2018, 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.
 */

/ {
	model = "Qualcomm Technologies, Inc. SDX20";
	compatible = "qcom,sdx20";
	qcom,msm-id = <314 0x0>, <333 0x0>;

	timer {
		compatible = "arm,armv7-timer";
		interrupts = <1 13 0xf08>,
			<1 12 0xf08>,
			<1 10 0xf08>,
			<1 11 0xf08>;
		clock-frequency = <19200000>;
		status = "disabled";
	};

	aliases {
		sdhc1 = &sdhc_1; /* SDC1 eMMC/SD/SDIO slot */
	};

};

&tsens0 {
	qcom,sensor-id = <0 1 2 3 4>;
};

&mss_mem {
	reg = <0x88000000 0x7300000>;
};

&reserved_mem {
	linux,cma {
		compatible = "shared-dma-pool";
		alloc-ranges = <0 0x90000000>;
		reusable;
		alignment = <0x400000>;
		size = <0xc00000>;
		linux,cma-default;
	};
};

&soc {
	/* SD card 2.95 V supply */
	sdc_vreg: sdc_vreg {
		compatible = "regulator-fixed";
		regulator-name = "sdc_vreg";
		startup-delay-us = <4000>;
		enable-active-high;
		gpio = <&tlmm_pinmux 80 0>;
	};

	i2c_3: i2c@78B7000 { /* BLSP1 QUP3 */
		wcd9xxx_codec@d{
			qcom,cdc-reset-gpio = <&tlmm_pinmux 72 0>;
			swr_master {
				compatible = "qcom,swr-wcd";
				#address-cells = <2>;
				#size-cells = <0>;
				wsa881x_211: wsa881x@20170211 {
					compatible = "qcom,wsa881x";
					reg = <0x00 0x20170211>;
					qcom,spkr-sd-n-gpio =
						<&tlmm_pinmux 76 0>;
				};
				wsa881x_212: wsa881x@20170212 {
					compatible = "qcom,wsa881x";
					reg = <0x00 0x20170212>;
					qcom,spkr-sd-n-gpio =
						<&tlmm_pinmux 76 0>;
				};
				wsa881x_213: wsa881x@21170213 {
					compatible = "qcom,wsa881x";
					reg = <0x00 0x21170213>;
					qcom,spkr-sd-n-gpio =
						<&tlmm_pinmux 76 0>;
				};
				wsa881x_214: wsa881x@21170214 {
					compatible = "qcom,wsa881x";
					reg = <0x00 0x21170214>;
					qcom,spkr-sd-n-gpio =
						<&tlmm_pinmux 76 0>;
				};
			};
		};
	};

	compress: qcom,msm-compress-dsp {
		compatible = "qcom,msm-compress-dsp";
		qcom,adsp-version = "MDSP 2.8";
	};

	ipa_hw: qcom,ipa@07B00000 {
		qcom,ipa-hw-ver = <12>; /* IPA core version = IPAv3.5 */
		/delete-property/qcom,use-rg10-limitation-mitigation;
		qcom,throughput-threshold = <600 1200>; /* NOM TURBO */
	};

	qcom,ipa_fws {
		compatible = "qcom,pil-tz-generic";
		qcom,pas-id = <0xf>;
		qcom,firmware-name = "ipa_fws";
		qcom,pil-force-shutdown;
	};

	qcom,msm-cpufreq {
		qcom,cpufreq-table =
			<  307200 >,
			<  614400 >,
			< 1017600 >,
			< 1401600 >;
	};

	usb_detect: qcom,gpio-usbdetect {
		compatible = "qcom,gpio-usbdetect";
		interrupt-parent = <&spmi_bus>;
		interrupts = <0x0 0x0d 0x0>;
		interrupt-names = "vbus_det_irq";
	};

	cnss_sdio: qcom,cnss_sdio {
		compatible = "qcom,cnss_sdio";
		subsys-name = "AR6320_SDIO";
		vdd-wlan-supply = <&rome_vreg>;
		vdd-wlan-xtal-supply = <&pmd9650_l5>;
		vdd-wlan-io-supply = <&pmd9650_l6>;
		qcom,wlan-ramdump-dynamic = <0x200000>;
		qcom,is-antenna-shared;
		status = "disabled";
	};

	wcd9xxx_intc: wcd9xxx-irq {
		compatible = "qcom,wcd9xxx-irq";
		interrupt-controller;
		#interrupt-cells = <1>;
		interrupt-parent = <&tlmm_pinmux>;
		qcom,gpio-connect = <&tlmm_pinmux 73 0>;
	};

	/delete-node/ qcom,spm@b009000;
	/delete-node/ qcom,mpm@601b8;
	/delete-node/ qcom,lpm-levels;
};

&clock_gcc {
	compatible = "qcom,gcc-sdx20";
	reg = <0x1800000 0x80000>,
		<0xb008018 0x44>;
	reg-names = "cc_base", "apcs_base";
};

&clock_cpu  {
	compatible = "qcom,clock-a7-sdx20";

	qcom,speed0-bin-v0 =
		<         0 RPM_SMD_REGULATOR_LEVEL_NONE >,
		< 307200000 RPM_SMD_REGULATOR_LEVEL_LOW_SVS >,
		< 614400000 RPM_SMD_REGULATOR_LEVEL_SVS >,
		< 1017600000 RPM_SMD_REGULATOR_LEVEL_NOM >,
		< 1401600000 RPM_SMD_REGULATOR_LEVEL_TURBO >;
};

&rpm_bus {
		compatible = "qcom,rpm-glink";
		qcom,glink-edge = "rpm";
		rpm-channel-name = "rpm_requests";
		/delete-property/ rpm-channel-type;
};

#include "sdx20-bus.dtsi"

&pcie0 {
	qcom,phy-sequence = <0x804 0x01 0x00
				0x034 0x14 0x00
				0x138 0x30 0x00
				0x048 0x07 0x00
				0x15c 0x06 0x00
				0x090 0x01 0x00
				0x088 0x20 0x00
				0x0f0 0x00 0x00
				0x0f8 0x01 0x00
				0x0f4 0xc9 0x00
				0x11c 0xff 0x00
				0x120 0x3f 0x00
				0x164 0x01 0x00
				0x154 0x00 0x00
				0x148 0x0a 0x00
				0x0b0 0x82 0x00
				0x0c0 0x02 0x00
				0x0bc 0xea 0x00
				0x0b8 0xab 0x00
				0x0a0 0x00 0x00
				0x09c 0x0d 0x00
				0x098 0x04 0x00
				0x13c 0x00 0x00
				0x060 0x08 0x00
				0x068 0x16 0x00
				0x070 0x34 0x00
				0x15c 0x16 0x00
				0x138 0x33 0x00
				0x03c 0x02 0x00
				0x040 0x07 0x00
				0x080 0x04 0x00
				0x0dc 0x00 0x00
				0x0d8 0x3f 0x00
				0x00c 0x09 0x00
				0x05c 0x19 0x00
				0x038 0x10 0x00
				0x010 0x01 0x00
				0x01c 0x40 0x00
				0x020 0x01 0x00
				0x014 0x02 0x00
				0x018 0x00 0x00
				0x024 0x7e 0x00
				0x028 0x15 0x00
				0x244 0x02 0x00
				0x2a4 0x12 0x00
				0x260 0x10 0x00
				0x28c 0x06 0x00
				0x504 0x03 0x00
				0x500 0x1c 0x00
				0x50c 0x14 0x00
				0x4d4 0x0e 0x00
				0x4d8 0x04 0x00
				0x4dc 0x1a 0x00
				0x434 0x4b 0x00
				0x414 0x04 0x00
				0x40c 0x04 0x00
				0x4f8 0x71 0x00
				0x564 0x59 0x00
				0x568 0x59 0x00
				0x4fc 0x80 0x00
				0x51c 0x40 0x00
				0x444 0xf1 0x00
				0x43c 0x40 0x00
				0x8c8 0x83 0x00
				0x8cc 0x09 0x00
				0x8d0 0xa2 0x00
				0x8d4 0x40 0x00
				0x8c4 0x01 0x00
				0x854 0x04 0x00
				0x804 0x03 0x00
				0x62c 0x52 0x00
				0x654 0x50 0x00
				0x65c 0x1a 0x00
				0x660 0x06 0x00
				0x9ac 0x00 0x00
				0x8a0 0x01 0x00
				0x9e0 0x00 0x00
				0x9dc 0x01 0x00
				0x9a8 0x00 0x00
				0x8a4 0x01 0x00
				0x8a8 0x73 0x00
				0x9d8 0xaa 0x00
				0xa0c 0x0d 0x00
				0x800 0x00 0x00
				0x808 0x03 0x00>;

	perst-gpio = <&tlmm_pinmux 61 0>;
	wake-gpio = <&tlmm_pinmux 58 0>;

	vreg-1.8-supply = <&pmd9650_l1>;
	qcom,vreg-1.8-voltage-level = <1224000 1224000 0>;

	qcom,pcie-phy-ver = <0x21>;
};

&pcie_ep {
	qcom,phy-init = <0x804 0x01 0x0 0x1
			0x034 0x14 0x0 0x1
			0x138 0x30 0x00 0x1
			0x048 0x07 0x00 0x1
			0x15c 0x06 0x00 0x1
			0x090 0x01 0x00 0x1
			0x088 0x20 0x00 0x1
			0x0f0 0x00 0x00 0x1
			0x0f8 0x01 0x00 0x1
			0x0f4 0xc9 0x00 0x1
			0x11c 0xff 0x00 0x1
			0x120 0x3f 0x00 0x1
			0x164 0x01 0x00 0x1
			0x154 0x00 0x00 0x1
			0x148 0x0a 0x00 0x1

			0x0b0 0x19 0x00 0x1
			0x0c0 0x00 0x00 0x1
			0x0bc 0x00 0x00 0x1
			0x0b8 0x00 0x00 0x1
			0x0a0 0x00 0x00 0x1
			0x09c 0x02 0x00 0x1
			0x098 0x7f 0x00 0x1
			0x13c 0x00 0x00 0x1
			0x060 0x30 0x00 0x1
			0x068 0x18 0x00 0x1
			0x070 0x02 0x00 0x1
			0x15c 0x06 0x00 0x1
			0x138 0x30 0x00 0x1
			0x03c 0x07 0x00 0x1
			0x040 0x06 0x00 0x1
			0x080 0x00 0x00 0x1
			0x0dc 0x03 0x00 0x1
			0x0d8 0xfb 0x00 0x1
			0x00c 0x01 0x00 0x1

			0x244 0x02 0x00 0x1
			0x2a4 0x12 0x00 0x1
			0x260 0x10 0x00 0x1
			0x28c 0x06 0x00 0x1
			0x504 0x03 0x00 0x1
			0x500 0x1c 0x00 0x1
			0x50c 0x14 0x00 0x1
			0x4d4 0x0e 0x00 0x1
			0x4d8 0x04 0x00 0x1
			0x4dc 0x1a 0x00 0x1
			0x434 0x4b 0x00 0x1
			0x414 0x04 0x00 0x1
			0x40c 0x04 0x00 0x1
			0x4f8 0x71 0x00 0x1
			0x564 0x59 0x00 0x1
			0x568 0x59 0x00 0x1
			0x4fc 0x80 0x00 0x1
			0x51c 0x40 0x00 0x1
			0x444 0x71 0x00 0x1
			0x43c 0x40 0x00 0x1

			0x8c8 0x83 0x00 0x1
			0x8cc 0x09 0x00 0x1
			0x8d0 0xa2 0x00 0x1
			0x8d4 0x40 0x00 0x1
			0x8c4 0x02 0x0 0x1

			0x854 0x00 0x0 0x1

			0x62c 0x52 0x00 0x1
			0x654 0x50 0x00 0x1
			0x65c 0x1a 0x00 0x1
			0x660 0x06 0x00 0x1

			0x8a0 0x01 0x00 0x1
			0x9e0 0x00 0x00 0x1
			0x9dc 0x01 0x00 0x1
			0x9a8 0x00 0x00 0x1
			0x8a4 0x01 0x00 0x1
			0x8a8 0x73 0x00 0x1
			0x9d8 0xaa 0x00 0x1
			0x9b0 0x03 0x00 0x1
			0xa0c 0x0d 0x00 0x1

			0x644 0x0E 0x0 0x1

			0x800 0x00 0x0 0x1
			0x808 0x03 0x0 0x1>;

	perst-gpio = <&tlmm_pinmux 61 0>;
	wake-gpio = <&tlmm_pinmux 58 0>;
	clkreq-gpio = <&tlmm_pinmux 60 0>;

	vreg-1.8-supply = <&pmd9650_l1>;
	qcom,vreg-1.8-voltage-level = <1224000 1224000 0>;

	qcom,pcie-phy-ver = <5>;
	qcom,pcie-perst-enum;
	qcom,pcie-mhi-a7-irq;
	status = "disabled";
};

&cnss_pcie {
	wlan-en-gpio = <&tlmm_pinmux 74 0>;
};

&pmd9650_gpios {
	gpio@c500 { /* GPIO 6 - Rome 3.3V control */
		status = "ok";
		qcom,mode = <1>;		/* Digital output*/
		qcom,output-type = <0>;		/* CMOS logic */
		qcom,invert = <1>;		/* Output high */
		qcom,vin-sel = <0>;		/* VPH_PWR */
		qcom,src-sel = <0>;		/* Constant */
		qcom,out-strength = <1>;	/* High drive strength */
		qcom,master-en = <1>;		/* Enable GPIO */
	};

	gpio@c700 { /* GPIO 8 - BT_EN */
		status = "ok";
		qcom,mode = <1>;         /* Digital output*/
		qcom,pull = <4>;         /* Pulldown 10uA */
		qcom,vin-sel = <0>;      /* VPH_PWR */
		qcom,src-sel = <0>;      /* GPIO */
		qcom,invert = <0>;       /* Invert */
		qcom,master-en = <1>;    /* Enable GPIO */
	};
};

&mss {
	/delete-property/qcom,qdsp6v61-1-1;
	qcom,qdsp6v62-1-4;
};

&mhi_device {
	interrupts = <0 119 0>;
	interrupt-names = "mhi-device-inta";
	qcom,mhi-ifc-id = <0x030317cb>;
	qcom,mhi-interrupt;
	status = "disabled";
};

#include "sdx20-usb.dtsi"
#include "sdx20-pm.dtsi"

&usb3 {
	vbus_dwc3-supply = <&smb1351_otg_supply>;
};
