// 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/phy/phy.h>

#include "k3-com260.dtsi"

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

	aliases {
		serial0 = &uart0;
		ethernet0 = &eth1;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};

	reg_hub_5v: regulator-usb3-hub-5v {
		compatible = "regulator-fixed";
		regulator-name = "USB30_HUB";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		regulator-boot-on;
		regulator-always-on;
		vin-supply = <&reg_5v_sys>;
	};

	reg_vbus_5v: regulator-usb3-vbus-5v {
		compatible = "regulator-fixed";
		regulator-name = "USB30_VBUS";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&reg_5v_sys>;
		gpio = <&gpio K3_GPIO(67) GPIO_ACTIVE_HIGH>;
		enable-active-high;
	};

	rfkill-pcie-wlan {
		compatible = "rfkill-gpio";
		label = "rfkill-pcie-wlan";
		radio-type = "wlan";
		shutdown-gpios = <&gpio K3_GPIO(73) GPIO_ACTIVE_LOW>;
	};

	rfkill-usb-bt {
		compatible = "rfkill-gpio";
		label = "rfkill-usb-bt";
		radio-type = "bluetooth";
		shutdown-gpios = <&gpio K3_GPIO(57) GPIO_ACTIVE_LOW>;
	};
};

&combophy {
	spacemit,apmu = <&syscon_apmu 0x14>;
	status = "okay";
};

&i2c1 {
	pinctrl-names = "default";
	pinctrl-0 = <&i2c1_1_cfg>;
	status = "okay";

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

&usb2_host {
	status = "okay";
};

&usb2_phy {
	status = "okay";
};

&usb3b {
	phys = <&usb3b_u2phy>, <&combophy 2 PHY_TYPE_USB3>;
	phy-names = "usb2-phy", "usb3-phy";
	status = "okay";
	vbus-supply = <&reg_vbus_5v>;
	#address-cells = <1>;
	#size-cells = <0>;

	hub_2_0: hub@1 {
		compatible = "usb2109,2817";
		reg = <1>;
		vdd-supply = <&reg_hub_5v>;
		peer-hub = <&hub_3_0>;
		reset-gpios = <&gpio K3_GPIO(53) GPIO_ACTIVE_LOW>;
	};

	hub_3_0: hub@2 {
		compatible = "usb2109,817";
		reg = <2>;
		vdd-supply = <&reg_hub_5v>;
		peer-hub = <&hub_2_0>;
		reset-gpios = <&gpio K3_GPIO(53) GPIO_ACTIVE_LOW>;
	};
};

&usb3b_u2phy {
	status = "okay";
};

&sdhci0 {
	pinctrl-names = "default","uhs";
	pinctrl-0 = <&mmc1_cfg>;
	pinctrl-1 = <&mmc1_uhs_cfg>;
	bus-width = <4>;
	cd-gpios = <&gpio K3_GPIO(4) GPIO_ACTIVE_HIGH>;
	no-mmc;
	no-sdio;
	disable-wp;
	cap-sd-highspeed;
	vmmc-supply = <&aldo4>;
	vqmmc-supply = <&aldo1>;
	sd-uhs-sdr25;
	sd-uhs-sdr50;
	sd-uhs-sdr104;
	status = "okay";
};