// SPDX-License-Identifier: BSD-3-Clause

/dts-v1/;

#include "qcom-msm8226.dtsi"
#include "pm8226.dtsi"

/delete-node/ &smem_region;

/ {
	model = "Motorola Moto G 4G (2013)";
	compatible = "motorola,peregrine", "qcom,msm8926", "qcom,msm8226";
	chassis-type = "handset";

	aliases {
		mmc0 = &sdhc_1; /* SDC1 eMMC slot */
		mmc1 = &sdhc_2; /* SDC2 SD card slot */
	};

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		framebuffer0: framebuffer@3200000 {
			compatible = "simple-framebuffer";
			reg = <0x03200000 0x800000>;
			width = <720>;
			height = <1280>;
			stride = <(720 * 3)>;
			format = "r8g8b8";
			vsp-supply = <&reg_lcd_pos>;
			vsn-supply = <&reg_lcd_neg>;
			vdd-supply = <&pm8226_l28>;
			vddio-supply = <&vddio_disp_vreg>;
		};
	};

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

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

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

	vddio_disp_vreg: regulator-vddio-disp {
		compatible = "regulator-fixed";
		regulator-name = "vddio_disp";
		gpio = <&tlmm 34 GPIO_ACTIVE_HIGH>;
		startup-delay-us = <300>;
		enable-active-high;
		regulator-boot-on;
		vin-supply = <&pm8226_l8>;
		pinctrl-0 = <&disp_vddio_default>;
		pinctrl-names = "default";
	};

	reserved-memory {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		framebuffer@3200000 {
			reg = <0x03200000 0x800000>;
			no-map;
		};

		smem_region: smem@fa00000 {
			reg = <0x0fa00000 0x100000>;
			no-map;
		};
	};
};

&blsp1_i2c2 {
	clock-frequency = <100000>;
	status = "okay";

	magnetometer@c {
		compatible = "asahi-kasei,ak8963";
		reg = <0xc>;
		interrupts-extended = <&tlmm 38 IRQ_TYPE_EDGE_FALLING>;
		reset-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>;
		vdd-supply = <&pm8226_l19>;
		pinctrl-0 = <&mag_int_default &mag_reset_default>;
		pinctrl-names = "default";
	};

	accelerometer@18 {
		compatible = "st,lis3dh-accel";
		reg = <0x18>;
		interrupts-extended = <&tlmm 1 IRQ_TYPE_EDGE_FALLING>;
		vdd-supply = <&pm8226_l19>;
		pinctrl-0 = <&accel_int_default>;
		pinctrl-names = "default";
		st,drdy-int-pin = <1>;
	};
};

&blsp1_i2c3 {
	clock-frequency = <400000>;
	status = "okay";

	regulator@3e {
		compatible = "ti,tps65132";
		reg = <0x3e>;
		pinctrl-0 = <&reg_lcd_default>;
		pinctrl-names = "default";

		reg_lcd_pos: outp {
			regulator-name = "outp";
			regulator-min-microvolt = <4000000>;
			regulator-max-microvolt = <6000000>;
			regulator-active-discharge = <1>;
			regulator-boot-on;
			enable-gpios = <&tlmm 31 GPIO_ACTIVE_HIGH>;
		};

		reg_lcd_neg: outn {
			regulator-name = "outn";
			regulator-min-microvolt = <4000000>;
			regulator-max-microvolt = <6000000>;
			regulator-active-discharge = <1>;
			regulator-boot-on;
			enable-gpios = <&tlmm 33 GPIO_ACTIVE_HIGH>;
		};
	};

	sensor@48 {
		compatible = "ti,tmp108";
		reg = <0x48>;
		interrupts-extended = <&tlmm 13 IRQ_TYPE_LEVEL_LOW>;
		pinctrl-0 = <&temp_alert_default>;
		pinctrl-names = "default";
		#thermal-sensor-cells = <0>;
	};
};

&blsp1_uart3 {
	status = "okay";
};

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

&pm8226_vib {
	status = "okay";
};

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

		pm8226_s3: s3 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1300000>;
		};

		pm8226_s4: s4 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2200000>;
		};

		pm8226_s5: s5 {
			regulator-min-microvolt = <1150000>;
			regulator-max-microvolt = <1150000>;
		};

		pm8226_l1: l1 {
			regulator-min-microvolt = <1225000>;
			regulator-max-microvolt = <1225000>;
		};

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

		pm8226_l3: l3 {
			regulator-min-microvolt = <750000>;
			regulator-max-microvolt = <1337500>;
		};

		pm8226_l4: l4 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};

		pm8226_l5: l5 {
			regulator-min-microvolt = <1200000>;
			regulator-max-microvolt = <1200000>;
		};

		pm8226_l6: l6 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
			regulator-allow-set-load;
		};

		pm8226_l7: l7 {
			regulator-min-microvolt = <1850000>;
			regulator-max-microvolt = <1850000>;
		};

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

		pm8226_l9: l9 {
			regulator-min-microvolt = <2050000>;
			regulator-max-microvolt = <2050000>;
		};

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

		pm8226_l12: l12 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <1800000>;
		};

		pm8226_l14: l14 {
			regulator-min-microvolt = <2750000>;
			regulator-max-microvolt = <2750000>;
		};

		pm8226_l15: l15 {
			regulator-min-microvolt = <2800000>;
			regulator-max-microvolt = <2800000>;
		};

		pm8226_l16: l16 {
			regulator-min-microvolt = <3000000>;
			regulator-max-microvolt = <3350000>;
		};

		pm8226_l17: l17 {
			regulator-min-microvolt = <2950000>;
			regulator-max-microvolt = <2950000>;
		};

		pm8226_l18: l18 {
			regulator-min-microvolt = <2950000>;
			regulator-max-microvolt = <2950000>;
		};

		pm8226_l19: l19 {
			regulator-min-microvolt = <2850000>;
			regulator-max-microvolt = <2850000>;
		};

		pm8226_l20: l20 {
			regulator-min-microvolt = <3075000>;
			regulator-max-microvolt = <3075000>;
		};

		pm8226_l21: l21 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2950000>;
			regulator-allow-set-load;
		};

		pm8226_l22: l22 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2950000>;
		};

		pm8226_l23: l23 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <2950000>;
		};

		pm8226_l24: l24 {
			regulator-min-microvolt = <1300000>;
			regulator-max-microvolt = <1350000>;
		};

		pm8226_l25: l25 {
			regulator-min-microvolt = <1775000>;
			regulator-max-microvolt = <2125000>;
		};

		pm8226_l26: l26 {
			regulator-min-microvolt = <1225000>;
			regulator-max-microvolt = <1225000>;
		};

		pm8226_l27: l27 {
			regulator-min-microvolt = <2050000>;
			regulator-max-microvolt = <2050000>;
		};

		pm8226_l28: l28 {
			regulator-min-microvolt = <1800000>;
			regulator-max-microvolt = <3400000>;
			regulator-boot-on;
		};

		pm8226_lvs1: lvs1 {
			/* Pull-up for I2C lines */
			regulator-always-on;
		};
	};
};

&sdhc_1 {
	vmmc-supply = <&pm8226_l17>;
	vqmmc-supply = <&pm8226_l6>;

	bus-width = <8>;
	non-removable;

	status = "okay";
};

&sdhc_2 {
	vmmc-supply = <&pm8226_l18>;
	vqmmc-supply = <&pm8226_l21>;

	bus-width = <4>;
	cd-gpios = <&tlmm 115 GPIO_ACTIVE_HIGH>;

	status = "okay";
};

&smbb {
	qcom,fast-charge-safe-current = <2000000>;
	qcom,fast-charge-current-limit = <1900000>;
	qcom,fast-charge-safe-voltage = <4400000>;
	qcom,minimum-input-voltage = <4300000>;

	status = "okay";
};

&tlmm {
	accel_int_default: accel-int-default-state {
		pins = "gpio1";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
		output-disable;
	};

	disp_vddio_default: disp-vddio-default-state {
		pins = "gpio34";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
		output-high;
	};

	mag_int_default: mag-int-default-state {
		pins = "gpio38";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
		output-disable;
	};

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

	reg_lcd_default: reg-lcd-default-state {
		pins = "gpio31", "gpio33";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
		output-high;
	};

	temp_alert_default: temp-alert-default-state {
		pins = "gpio13";
		function = "gpio";
		drive-strength = <2>;
		bias-disable;
		output-disable;
	};
};

&usb {
	extcon = <&smbb>;
	dr_mode = "peripheral";
	status = "okay";
};

&usb_hs_phy {
	extcon = <&smbb>;
	v1p8-supply = <&pm8226_l10>;
	v3p3-supply = <&pm8226_l20>;
};
