// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/*
 * Copyright 2022 Google LLC
 */

/dts-v1/;
#include "mt8186-corsola.dtsi"
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/{
	pp1000_edpbrdg: regulator-pp1000-edpbrdg {
		compatible = "regulator-fixed";
		regulator-name = "pp1000_edpbrdg";
		pinctrl-names = "default";
		pinctrl-0 = <&en_pp1000_edpbrdg>;
		enable-active-high;
		regulator-boot-on;
		gpio = <&pio 29 GPIO_ACTIVE_HIGH>;
		vin-supply = <&pp3300_z2>;
	};

	pp1800_edpbrdg_dx: regulator-pp1800-edpbrdg-dx {
		compatible = "regulator-fixed";
		regulator-name = "pp1800_edpbrdg_dx";
		pinctrl-names = "default";
		pinctrl-0 = <&en_pp1800_edpbrdg>;
		enable-active-high;
		regulator-boot-on;
		gpio = <&pio 30 GPIO_ACTIVE_HIGH>;
		vin-supply = <&mt6366_vio18_reg>;
	};

	pp3300_edp_dx: regulator-pp3300-edp-dx {
		compatible = "regulator-fixed";
		regulator-name = "pp3300_edp_dx";
		pinctrl-names = "default";
		pinctrl-0 = <&en_pp3300_edpbrdg>;
		enable-active-high;
		regulator-boot-on;
		gpio = <&pio 31 GPIO_ACTIVE_HIGH>;
		vin-supply = <&pp3300_z2>;
	};
};

&dsi_out {
	remote-endpoint = <&anx7625_in>;
};

&i2c0 {
	clock-frequency = <400000>;

	anx_bridge: anx7625@58 {
		compatible = "analogix,anx7625";
		reg = <0x58>;
		pinctrl-names = "default";
		pinctrl-0 = <&anx7625_pins>;
		enable-gpios = <&pio 96 GPIO_ACTIVE_HIGH>;
		reset-gpios = <&pio 98 GPIO_ACTIVE_HIGH>;
		vdd10-supply = <&pp1000_edpbrdg>;
		vdd18-supply = <&pp1800_edpbrdg_dx>;
		vdd33-supply = <&pp3300_edp_dx>;
		analogix,lane0-swing = /bits/ 8 <0x70 0x30>;
		analogix,lane1-swing = /bits/ 8 <0x70 0x30>;

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

			port@0 {
				reg = <0>;

				anx7625_in: endpoint {
					remote-endpoint = <&dsi_out>;
					data-lanes = <0 1 2 3>;
				};
			};

			port@1 {
				reg = <1>;

				anx7625_out: endpoint {
					remote-endpoint = <&panel_in>;
				};
			};
		};

		aux-bus {
			panel: panel {
				compatible = "edp-panel";
				power-supply = <&pp3300_disp_x>;
				backlight = <&backlight_lcd0>;

				port {
					panel_in: endpoint {
						remote-endpoint = <&anx7625_out>;
					};
				};
			};
		};
	};
};

&i2c1 {
	touchscreen: touchscreen@5d {
		compatible = "goodix,gt7375p";
		reg = <0x5d>;
		interrupts-extended = <&pio 12 IRQ_TYPE_EDGE_FALLING>;
		pinctrl-names = "default";
		pinctrl-0 = <&touchscreen_pins>;
		reset-gpios = <&pio 60 GPIO_ACTIVE_LOW>;
		vdd-supply = <&pp3300_s3>;
		goodix,no-reset-during-suspend;
	};
};

&i2c2 {
	i2c-scl-internal-delay-ns = <22000>;

	/* second source component */
	trackpad@2c {
		compatible = "hid-over-i2c";
		reg = <0x2c>;
		hid-descr-addr = <0x20>;
		interrupts-extended = <&pio 11 IRQ_TYPE_LEVEL_LOW>;
		vdd-supply = <&pp3300_s3>;
		wakeup-source;
	};
};

&keyboard_controller {
	function-row-physmap = <
		MATRIX_KEY(0x00, 0x02, 0)	/* T1 */
		MATRIX_KEY(0x03, 0x02, 0)	/* T2 */
		MATRIX_KEY(0x02, 0x02, 0)	/* T3 */
		MATRIX_KEY(0x01, 0x02, 0)	/* T4 */
		MATRIX_KEY(0x03, 0x04, 0)	/* T5 */
		MATRIX_KEY(0x02, 0x04, 0)	/* T6 */
		MATRIX_KEY(0x01, 0x04, 0)	/* T7 */
		MATRIX_KEY(0x02, 0x09, 0)	/* T8 */
		MATRIX_KEY(0x01, 0x09, 0)	/* T9 */
		MATRIX_KEY(0x00, 0x04, 0)	/* T10 */
	>;

	linux,keymap = <
		MATRIX_KEY(0x00, 0x02, KEY_BACK)
		MATRIX_KEY(0x03, 0x02, KEY_REFRESH)
		MATRIX_KEY(0x02, 0x02, KEY_ZOOM)
		MATRIX_KEY(0x01, 0x02, KEY_SCALE)
		MATRIX_KEY(0x03, 0x04, KEY_BRIGHTNESSDOWN)
		MATRIX_KEY(0x02, 0x04, KEY_BRIGHTNESSUP)
		MATRIX_KEY(0x01, 0x04, KEY_MICMUTE)
		MATRIX_KEY(0x02, 0x09, KEY_MUTE)
		MATRIX_KEY(0x01, 0x09, KEY_VOLUMEDOWN)
		MATRIX_KEY(0x00, 0x04, KEY_VOLUMEUP)
		CROS_STD_MAIN_KEYMAP
	>;
};

&pio {
	anx7625_pins: anx7625-pins {
		pins-int {
			pinmux = <PINMUX_GPIO9__FUNC_GPIO9>;
			input-enable;
			bias-disable;
		};

		pins-reset {
			pinmux = <PINMUX_GPIO98__FUNC_GPIO98>;
			output-low;
		};

		pins-power-en {
			pinmux = <PINMUX_GPIO96__FUNC_GPIO96>;
			output-low;
		};
	};

	en_pp1000_edpbrdg: pp1000-edpbrdg-en-pins {
		pins-vreg-en {
			pinmux = <PINMUX_GPIO29__FUNC_GPIO29>;
			output-low;
		};
	};

	en_pp1800_edpbrdg: pp1800-edpbrdg-en-pins {
		pins-vreg-en {
			pinmux = <PINMUX_GPIO30__FUNC_GPIO30>;
			output-low;
		};
	};

	en_pp3300_edpbrdg: pp3300-edpbrdg-en-pins {
		pins-vreg-en {
			pinmux = <PINMUX_GPIO31__FUNC_GPIO31>;
			output-low;
		};
	};
};
