// SPDX-License-Identifier: (GPL-2.0 OR MIT)
/*
 * Copyright (c) 2026 SpacemiT (Hangzhou) Technology Co. Ltd
 * Copyright (c) 2026 Yixun Lan <dlan@kernel.org>
 */
#include <dt-bindings/gpio/gpio.h>

#include "k3.dtsi"
#include "k3-pinctrl.dtsi"

/ {
	model = "SpacemiT K3 CoM260 Module";
	compatible = "spacemit,k3-com260", "spacemit,k3";

	memory@100000000 {
		device_type = "memory";
		reg = <0x1 0x00000000 0x4 0x00000000>;
	};

	reg_5v_sys: regulator-5v-sys {
		compatible = "regulator-fixed";
		regulator-name = "P5V0_SYS";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-always-on;
	};
};

&i2c2 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c2_1_cfg>;
	status = "okay";

	eeprom@50 {
		compatible = "atmel,24c02";
		pagesize = <8>;
		reg = <0x50>;
		read-only;
		size = <256>;
		status = "okay";

		nvmem-layout {
			compatible = "onie,tlv-layout";

			mac-address {
				#nvmem-cell-cells = <1>;
			};

			num-macs {
			};

			product-name {
			};

			serial-number {
			};
		};
	};
};

&i2c6_1_cfg {
	i2c6-1-pins {
		power-source = <3300>;
	};
};

&i2c6 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c6_1_cfg>;
	status = "okay";

	temperature-sensor@4c {
		compatible = "sensylink,ctf2301";
		reg = <0x4c>;
	};
};

&i2c8 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c8_cfg>;
	status = "okay";

	pmic@41 {
		compatible = "spacemit,p1";
		reg = <0x41>;
		interrupts = <64 IRQ_TYPE_LEVEL_HIGH>;
		vin1-supply = <&reg_5v_sys>;
		vin2-supply = <&reg_5v_sys>;
		vin3-supply = <&reg_5v_sys>;
		vin4-supply = <&reg_5v_sys>;
		vin5-supply = <&reg_5v_sys>;
		vin6-supply = <&reg_5v_sys>;
		aldoin-supply = <&reg_5v_sys>;
		dldoin1-supply = <&buck4>;
		dldoin2-supply = <&buck4>;

		regulators {
			buck1: buck1 {
				regulator-min-microvolt = <1050000>;
				regulator-max-microvolt = <1050000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			buck2: buck2 {
				regulator-min-microvolt = <1050000>;
				regulator-max-microvolt = <1050000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			buck3: buck3 {
				regulator-min-microvolt = <800000>;
				regulator-max-microvolt = <800000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			buck4: buck4 {
				regulator-min-microvolt = <2100000>;
				regulator-max-microvolt = <2100000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			buck5: buck5 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			buck6: buck6 {
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <500000>;
				regulator-ramp-delay = <5000>;
				regulator-always-on;
			};

			aldo1: aldo1 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;
				regulator-always-on;
				regulator-boot-on;
			};

			aldo2: aldo2 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};

			aldo3: aldo3 {
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <3400000>;
			};

			aldo4: aldo4 {
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo1: dldo1 {
				regulator-min-microvolt = <1200000>;
				regulator-max-microvolt = <1200000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo2: dldo2 {
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo3: dldo3 {
				regulator-min-microvolt = <800000>;
				regulator-max-microvolt = <800000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo4: dldo4 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo5: dldo5 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo6: dldo6 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};

			dldo7: dldo7 {
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;
				regulator-always-on;
				regulator-boot-on;
			};
		};
	};
};

&eth1 {
	pinctrl-names = "default";
	pinctrl-0 = <&gmac1_rgmii_0_cfg>, <&gmac1_phy_0_cfg>;
	phy-mode = "rgmii-id";
	phy-handle = <&phy1>;
	status = "okay";

	mdio {
		phy1: ethernet-phy@1 {
			compatible = "ethernet-phy-id001c.c916";
			reg = <1>;
			reset-gpios = <&gpio 1 5 GPIO_ACTIVE_LOW>;
			reset-assert-us = <10000>;
			reset-deassert-us = <50000>;
		};
	};
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_0_cfg>;
	status = "okay";
};