// SPDX-License-Identifier: GPL-2.0
/*
 * AM62x LP SK: https://www.ti.com/tool/SK-AM62-LP
 *
 * Copyright (C) 2021-2023 Texas Instruments Incorporated - https://www.ti.com/
 */

/dts-v1/;

#include "k3-am62x-sk-common.dtsi"

/ {
	compatible = "ti,am62-lp-sk", "ti,am625";
	model = "Texas Instruments AM62x LP SK";

	vmain_pd: regulator-0 {
		/* TPS65988 PD CONTROLLER OUTPUT */
		compatible = "regulator-fixed";
		regulator-name = "vmain_pd";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-always-on;
		regulator-boot-on;
	};

	vcc_5v0: regulator-1 {
		/* Output of TPS630702RNMR */
		compatible = "regulator-fixed";
		regulator-name = "vcc_5v0";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vmain_pd>;
		regulator-always-on;
		regulator-boot-on;
	};

	vcc_3v3_sys: regulator-2 {
		/* output of LM61460-Q1 */
		compatible = "regulator-fixed";
		regulator-name = "vcc_3v3_sys";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&vmain_pd>;
		regulator-always-on;
		regulator-boot-on;
	};

	vdd_mmc1: regulator-3 {
		/* TPS22918DBVR */
		compatible = "regulator-fixed";
		regulator-name = "vdd_mmc1";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		enable-active-high;
		vin-supply = <&vcc_3v3_sys>;
		gpio = <&exp1 3 GPIO_ACTIVE_HIGH>;
	};

	vddshv_sdio: regulator-4 {
		compatible = "regulator-gpio";
		regulator-name = "vddshv_sdio";
		pinctrl-names = "default";
		pinctrl-0 = <&vddshv_sdio_pins_default>;
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <3300000>;
		regulator-boot-on;
		vin-supply = <&ldo1_reg>;
		gpios = <&main_gpio0 31 GPIO_ACTIVE_HIGH>;
		states = <1800000 0x0>,
			 <3300000 0x1>;
	};
};

&main_pmx0 {
	vddshv_sdio_pins_default: vddshv-sdio-default-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x07c, PIN_OUTPUT, 7) /* (M19) GPMC0_CLK.GPIO0_31 */
		>;
	};

	main_gpio1_ioexp_intr_pins_default: main-gpio1-ioexp-intr-default-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x01d4, PIN_INPUT, 7) /* (C13) UART0_RTSn.GPIO1_23 */
		>;
	};

	pmic_irq_pins_default: pmic-irq-default-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x01f4, PIN_INPUT, 0) /* (B16) EXTINTn */
		>;
	};
};

&main_i2c1 {
	exp1: gpio@22 {
		compatible = "ti,tca6424";
		reg = <0x22>;
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names = "GPIO_CPSW2_RST", "GPIO_CPSW1_RST",
				   "PRU_DETECT", "MMC1_SD_EN",
				   "VPP_LDO_EN", "EXP_PS_3V3_En",
				   "EXP_PS_5V0_En", "EXP_HAT_DETECT",
				   "GPIO_AUD_RSTn", "GPIO_eMMC_RSTn",
				   "UART1_FET_BUF_EN", "BT_UART_WAKE_SOC",
				   "GPIO_HDMI_RSTn", "CSI_GPIO0",
				   "CSI_GPIO1", "GPIO_OLDI_INT",
				   "HDMI_INTn", "TEST_GPIO2",
				   "MCASP1_FET_EN", "MCASP1_BUF_BT_EN",
				   "MCASP1_FET_SEL", "UART1_FET_SEL",
				   "", "IO_EXP_TEST_LED";

		interrupt-parent = <&main_gpio1>;
		interrupts = <23 IRQ_TYPE_EDGE_FALLING>;
		interrupt-controller;
		#interrupt-cells = <2>;

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

	exp2: gpio@23 {
		compatible = "ti,tca6424";
		reg = <0x23>;
		gpio-controller;
		#gpio-cells = <2>;
		gpio-line-names = "", "",
				   "", "",
				   "", "",
				   "", "",
				   "WL_LT_EN", "CSI_RSTz",
				   "", "",
				   "", "",
				   "", "",
				   "SPI0_FET_SEL", "SPI0_FET_OE",
				   "GPIO_OLDI_RSTn", "PRU_3V3_EN",
				   "", "",
				   "CSI_VLDO_SEL", "SOC_WLAN_SDIO_RST";
	};
};

&sdhci1 {
	vmmc-supply = <&vdd_mmc1>;
	vqmmc-supply = <&vddshv_sdio>;
};

&cpsw_port2 {
	status = "disabled";
};

&main_i2c0 {
	tps65219: pmic@30 {
		compatible = "ti,tps65219";
		reg = <0x30>;
		buck1-supply = <&vcc_3v3_sys>;
		buck2-supply = <&vcc_3v3_sys>;
		buck3-supply = <&vcc_3v3_sys>;
		ldo1-supply = <&vcc_3v3_sys>;
		ldo2-supply = <&buck2_reg>;
		ldo3-supply = <&vcc_3v3_sys>;
		ldo4-supply = <&vcc_3v3_sys>;

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

		interrupt-parent = <&gic500>;
		interrupts = <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>;
		ti,power-button;

		regulators {
			buck1_reg: buck1 {
				regulator-name = "VDD_CORE";
				regulator-min-microvolt = <750000>;
				regulator-max-microvolt = <750000>;
				regulator-boot-on;
				regulator-always-on;
			};

			buck2_reg: buck2 {
				regulator-name = "VCC1V8_SYS";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-boot-on;
				regulator-always-on;
			};

			buck3_reg: buck3 {
				regulator-name = "VDD_LPDDR4";
				regulator-min-microvolt = <1100000>;
				regulator-max-microvolt = <1100000>;
				regulator-boot-on;
				regulator-always-on;
			};

			ldo1_reg: ldo1 {
				regulator-name = "VDDSHV_SDIO";
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
			};

			ldo2_reg: ldo2 {
				regulator-name = "VDDAR_CORE";
				regulator-min-microvolt = <850000>;
				regulator-max-microvolt = <850000>;
				regulator-boot-on;
				regulator-always-on;
			};

			ldo3_reg: ldo3 {
				regulator-name = "VDDA_1V8";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-boot-on;
				regulator-always-on;
			};

			ldo4_reg: ldo4 {
				regulator-name = "VDD_1V2";
				regulator-min-microvolt = <1200000>;
				regulator-max-microvolt = <1200000>;
				regulator-boot-on;
				regulator-always-on;
			};
		};
	};
};

&tlv320aic3106 {
	DVDD-supply = <&buck2_reg>;
};