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

#include "msm8909-qrd.dtsi"
#include "msm8909-camera-sensor-skue.dtsi"

/ {
	model = "Qualcomm Technologies, Inc. MSM8909 QRD SKUE";
	compatible = "qcom,msm8909-qrd", "qcom,msm8909", "qcom,qrd";
};

&soc {
	i2c@78b9000 { /* BLSP1 QUP5 */
		focaltech@38 {
			compatible = "focaltech,5x06";
			reg = <0x38>;
			interrupt-parent = <&msm_gpio>;
			interrupts = <13 0x2>;
			vdd-supply = <&pm8909_l17>;
			vcc_i2c-supply = <&pm8909_l6>;
			/* pins used by touchscreen */
			pinctrl-names = "pmx_ts_active","pmx_ts_suspend","pmx_ts_release";
			pinctrl-0 = <&ts_int_active &ts_reset_active>;
			pinctrl-1 = <&ts_int_suspend &ts_reset_suspend>;
			pinctrl-2 = <&ts_release>;
			focaltech,name = "ft6306";
			focaltech,family-id = <0x06>;
			focaltech,reset-gpio = <&msm_gpio 12 0x0>;
			focaltech,irq-gpio = <&msm_gpio 13 0x0>;
			focaltech,display-coords = <0 0 480 854>;
			focaltech,panel-coords = <0 0 480 950>;
			focaltech,button-map= <139 102 158>;
			focaltech,no-force-update;
			focaltech,i2c-pull-up;
			focaltech,group-id = <1>;
			focaltech,hard-reset-delay-ms = <20>;
			focaltech,soft-reset-delay-ms = <200>;
			focaltech,num-max-touches = <2>;
			focaltech,fw-delay-aa-ms = <30>;
			focaltech,fw-delay-55-ms = <30>;
			focaltech,fw-upgrade-id1 = <0x79>;
			focaltech,fw-upgrade-id2 = <0x08>;
			focaltech,fw-delay-readid-ms = <10>;
			focaltech,fw-delay-era-flsh-ms = <2000>;
			focaltech,fw-auto-cal;
			focaltech,ignore-id-check;
		};
	};

	i2c@78b5000 { /* BLSP1 QUP1 */
		aw2013@45 {
			compatible = "awinic,aw2013";
			reg = <0x45>;
			vdd-supply = <&pm8909_l17>;
			vcc-supply = <&pm8909_l6>;

			aw2013,red {
				aw2013,name = "red";
				aw2013,id = <0>;
				aw2013,max-brightness = <255>;
				aw2013,max-current = <1>;
				aw2013,rise-time-ms = <2>;
				aw2013,hold-time-ms = <1>;
				aw2013,fall-time-ms = <2>;
				aw2013,off-time-ms = <1>;
			};

			aw2013,green {
				aw2013,name = "green";
				aw2013,id = <1>;
				aw2013,max-brightness = <255>;
				aw2013,max-current = <1>;
				aw2013,rise-time-ms = <2>;
				aw2013,hold-time-ms = <1>;
				aw2013,fall-time-ms = <2>;
				aw2013,off-time-ms = <1>;
			};

			aw2013,blue {
				aw2013,name = "blue";
				aw2013,id = <2>;
				aw2013,max-brightness = <255>;
				aw2013,max-current = <1>;
				aw2013,rise-time-ms = <2>;
				aw2013,hold-time-ms = <1>;
				aw2013,fall-time-ms = <2>;
				aw2013,off-time-ms = <1>;
			};
		};
	};

	gen-vkeys {
		compatible = "qcom,gen-vkeys";
		label = "ft5x06_ts";
		qcom,disp-maxx = <480>;
		qcom,disp-maxy = <854>;
		qcom,panel-maxx = <480>;
		qcom,panel-maxy = <946>;
		qcom,key-codes = <139 172 158>;
		qcom,y-offset = <0>;
	};

	sound {
		compatible = "qcom,msm8952-audio-codec";
		qcom,model = "msm8909-skue-snd-card";
		reg =   <0x7702000 0x4>,
			<0x7702004 0x4>,
			<0x7702008 0x4>;
		reg-names =
			"csr_gp_io_mux_mic_ctl",
			"csr_gp_io_mux_spkr_ctl",
			"csr_gp_io_lpaif_pri_pcm_pri_mode_muxsel";
		qcom,msm-snd-card-id = <0>;
		qcom,msm-codec-type = "internal";
		qcom,msm-ext-pa = "primary";
		qcom,msm-mclk-freq = <9600000>;
		qcom,msm-mbhc-hphl-swh = <1>;
		qcom,msm-mbhc-gnd-swh = <0>;
		qcom,msm-hs-micbias-type = "internal";
		qcom,msm-micbias1-ext-cap;
		qcom,msm-micbias2-ext-cap;
		qcom,audio-routing =
			"RX_BIAS", "MCLK",
			"SPK_RX_BIAS", "MCLK",
			"INT_LDO_H", "MCLK",
			"MIC BIAS Internal1", "Handset Mic",
			"MIC BIAS Internal2", "Headset Mic",
			"AMIC1", "MIC BIAS Internal1",
			"AMIC2", "MIC BIAS Internal2";
		qcom,msm-gpios =
			"pri_i2s",
			"us_eu_gpio";
		qcom,pinctrl-names =
			"all_off",
			"pri_i2s_act",
			"us_eu_gpio_act",
			"pri_i2s_us_eu_gpio_act";
		pinctrl-names =
			"all_off",
			"pri_i2s_act",
			"us_eu_gpio_act",
			"pri_i2s_us_eu_gpio_act";
		pinctrl-0 = <&cdc_pdm_lines_sus &cross_conn_det_sus
							&vdd_spkdrv_sus>;
		pinctrl-1 = <&cdc_pdm_lines_act &cross_conn_det_sus
							&vdd_spkdrv_act>;
		pinctrl-2 = <&cdc_pdm_lines_sus &cross_conn_det_act
							&vdd_spkdrv_sus>;
		pinctrl-3 = <&cdc_pdm_lines_act &cross_conn_det_act
							&vdd_spkdrv_act>;
		asoc-platform = <&pcm0>, <&pcm1>, <&pcm2>, <&voip>, <&voice>,
				<&loopback>, <&compress>, <&hostless>,
				<&afe>, <&lsm>, <&routing>, <&lpa>,
				<&voice_svc>;
		asoc-platform-names = "msm-pcm-dsp.0", "msm-pcm-dsp.1",
				"msm-pcm-dsp.2", "msm-voip-dsp",
				"msm-pcm-voice", "msm-pcm-loopback",
				"msm-compress-dsp", "msm-pcm-hostless",
				"msm-pcm-afe", "msm-lsm-client",
				"msm-pcm-routing", "msm-pcm-lpa",
				"msm-voice-svc";
		asoc-cpu = <&dai_pri_auxpcm>, <&dai_hdmi>,
				<&dai_mi2s0>, <&dai_mi2s1>,
				<&dai_mi2s2>, <&dai_mi2s3>,
				<&dai_mi2s5>, <&dai_mi2s6>,
				<&sb_0_rx>, <&sb_0_tx>, <&sb_1_rx>, <&sb_1_tx>,
				<&sb_3_rx>, <&sb_3_tx>, <&sb_4_rx>, <&sb_4_tx>,
				<&bt_sco_rx>, <&bt_sco_tx>,
				<&int_fm_rx>, <&int_fm_tx>,
				<&afe_pcm_rx>, <&afe_pcm_tx>,
				<&afe_proxy_rx>, <&afe_proxy_tx>,
				<&incall_record_rx>, <&incall_record_tx>,
				<&incall_music_rx>, <&incall_music_2_rx>;
		asoc-cpu-names = "msm-dai-q6-auxpcm.1", "msm-dai-q6-hdmi.8",
				"msm-dai-q6-mi2s.0", "msm-dai-q6-mi2s.1",
				"msm-dai-q6-mi2s.2", "msm-dai-q6-mi2s.3",
				"msm-dai-q6-mi2s.5", "msm-dai-q6-mi2s.6",
				"msm-dai-q6-dev.16384",	"msm-dai-q6-dev.16385",
				"msm-dai-q6-dev.16386", "msm-dai-q6-dev.16387",
				"msm-dai-q6-dev.16390", "msm-dai-q6-dev.16391",
				"msm-dai-q6-dev.16392",	"msm-dai-q6-dev.16393",
				"msm-dai-q6-dev.12288", "msm-dai-q6-dev.12289",
				"msm-dai-q6-dev.12292", "msm-dai-q6-dev.12293",
				"msm-dai-q6-dev.224", "msm-dai-q6-dev.225",
				"msm-dai-q6-dev.241", "msm-dai-q6-dev.240",
				"msm-dai-q6-dev.32771", "msm-dai-q6-dev.32772",
				"msm-dai-q6-dev.32773", "msm-dai-q6-dev.32770";
		asoc-codec = <&stub_codec>, <&pm8909_conga_dig>;
		asoc-codec-names = "msm-stub-codec.1", "cajon_codec";
	};
};

&spmi_bus {
	qcom,pm8909@0 {
		qcom,leds@a300 {
			status = "okay";
			qcom,led_mpp_4 {
				label = "mpp";
				linux,name = "button-backlight";
				linux,default-trigger = "none";
				qcom,default-state = "off";
				qcom,max-current = <40>;
				qcom,current-setting = <5>;
				qcom,id = <6>;
				qcom,mode = "manual";
				qcom,source-sel = <1>;
				qcom,mode-ctrl = <0x60>;
			};
		};
	};
};

&sdc2_cd_on {
	/delete-property/ bias-pull-up;
	bias-pull-down;
};

&sdc2_cd_off {
	/delete-property/ bias-disable;
	bias-pull-down;
};

&sdhc_2 {
	qcom,nonremovable;

	interrupts = <0 1>;
	interrupt-map = <0 &intc 0 125 0
			1 &intc 0 221 0>;
	interrupt-names = "hc_irq", "pwr_irq";
	/delete-property/ cd-gpios;
};

&pm8909_mpps {
	mpp@a000 { /* MPP 1 */
		/* VDD_PX */
		status = "disabled";
	};

	mpp@a100 { /* MPP 2 */
		/* Backlight PWM */
		qcom,mode = <1>;		/* Digital output */
		qcom,invert = <0>;		/* Disable invert */
		qcom,src-sel = <4>;		/* DTEST1 */
		qcom,vin-sel = <0>;		/* VPH_PWR */
		qcom,master-en = <1>;		/* Enable MPP */
	};

	mpp@a200 { /* MPP 3 */
		/* VREF DAC */
		status = "disabled";
	};

	mpp@a300 { /* MPP 4 */
		/* HR LED */
		status = "disabled";
	};
};

&mdss_mdp {
	qcom,mdss-pref-prim-intf = "dsi";
};

&dsi_hx8379c_fwvga_video {
	qcom,cont-splash-enabled;
	qcom,mdss-dsi-pwm-gpio = <&pm8909_mpps 2 0>;
	qcom,panel-supply-entries = <&dsi_panel_pwr_supply>;
};

&msm_gpio {
	pmx_mdss {
		mdss_dsi_active: mdss_dsi_active {
			mux {
				pins = "gpio25";
			};
			config {
				pins = "gpio25";
			};
		};
		mdss_dsi_suspend: mdss_dsi_suspend {
			mux {
				pins = "gpio25";
			};
			config {
				pins = "gpio25";
			};
		};
	};
	pmx_mdss_te {
		mdss_te_active: mdss_te_active {
			mux {
				pins = "gpio24";
			};
			config {
				pins = "gpio24";
			};
		};
		mdss_te_suspend: mdss_te_suspend {
			mux {
				pins = "gpio24";
			};
			config {
				pins = "gpio24";
			};
		};
	};
};

&mdss_dsi0 {
	qcom,dsi-pref-prim-pan = <&dsi_hx8379c_fwvga_video>;
	pinctrl-names = "mdss_default", "mdss_sleep";
	pinctrl-0 = <&mdss_dsi_active &mdss_te_active>;
	pinctrl-1 = <&mdss_dsi_suspend &mdss_te_suspend>;

	qcom,platform-reset-gpio = <&msm_gpio 25 0>;
};

&pm8909_vadc {
	chan@30 {
		qcom,scale-function = <14>;
	};
};

&pm8909_adc_tm {
	chan@30 {
		qcom,scale-function = <8>;
	};
};

&pm8909_chg {
	qcom,vddmax-mv = <4350>;
	qcom,vddsafe-mv = <4380>;
	qcom,vinmin-mv = <4470>;
	qcom,batt-hot-percentage = <25>;
	qcom,batt-cold-percentage = <80>;
	qcom,tchg-mins = <360>;
	qcom,disable-vbatdet-based-recharge;
	status = "okay";
};

/ {
	qrd_batterydata: qcom,battery-data {
		qcom,rpull-up-kohm = <0>;
		qcom,vref-batt-therm = <1800000>;

		#include "batterydata-qrd-skue-4v35-2000mah.dtsi"
	};
};

&pm8909_bms {
	status = "okay";
	qcom,resume-soc = <95>;
	qcom,use-reported-soc;
	qcom,force-bms-active-on-charger;
	qcom,battery-data = <&qrd_batterydata>;
};
