// SPDX-License-Identifier: GPL-2.0-or-later OR MIT

/dts-v1/;

#include "ipq6000-glinet.dtsi"

/ {
	model = "GL.iNet GL-AXT1800";
	compatible = "glinet,gl-axt1800", "qcom,ipq6018";

	aliases {
		label-mac-device = &dp1;
	};

	vcc_sd: regulator-vcc-sd {
		compatible = "regulator-fixed";
		regulator-name = "vcc_sd";
		regulator-min-microvolt = <1800000>;
		regulator-max-microvolt = <1800000>;
		gpios = <&tlmm 66 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-always-on;
	};

	vcc_fan: regulator-vcc-fan {
		compatible = "regulator-fixed";
		regulator-name = "vcc_fan";
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		gpio = <&tlmm 29 GPIO_ACTIVE_HIGH>;
		enable-active-high;
		regulator-boot-on;
	};

	fan: pwm-fan {
		compatible = "pwm-fan";
		pwms = <&pwm 1 40000 0>;
		fan-supply = <&vcc_fan>;
		interrupt-parent = <&tlmm>;
		interrupts = <31 IRQ_TYPE_EDGE_RISING>;
		cooling-levels = <36 128 192 255>;
		#cooling-cells = <2>;
	};

	thermal-zones {
		cpu-thermal {
			trips {
				cpu_trip_high: active-high {
					temperature = <100000>;
					hysteresis = <2000>;
					type = "active";
				};

				cpu_trip_med: active-med {
					temperature = <75000>;
					hysteresis = <2000>;
					type = "active";
				};

				cpu_trip_low: active-low {
					temperature = <50000>;
					hysteresis = <2000>;
					type = "active";
				};
			};

			cooling-maps {
				cpu-active-high {
					cooling-device = <&fan 3 3>;
					trip = <&cpu_trip_high>;
				};

				cpu-active-med {
					cooling-device = <&fan 2 2>;
					trip = <&cpu_trip_med>;
				};

				cpu-active-low {
					cooling-device = <&fan 1 1>;
					trip = <&cpu_trip_low>;
				};
			};
		};
	};
};

&tlmm {
	pwm_pins: pwm-pins {
		pwm {
			pins = "gpio30";
			function = "pwm13";
			drive-strength = <8>;
		};
	};

	sd_pins: sd-pins {
		sd {
			pins = "gpio62";
			function = "sd_card";
			bias-pull-up;
		};
		ldo {
			pins = "gpio66";
			function = "gpio";
			bias-pull-up;
		};
	};
};

&partitions {
	partition@a00000 {
		label = "rootfs";
		reg = <0x0a00000 0x7280000>;
	};

	partition@7c80000 {
		label = "log";
		reg = <0x7c80000 0x0080000>;
	};
};

&pwm {
	pinctrl-0 = <&pwm_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&sdhc {
	mmc-ddr-1_8v;
	bus-width = <4>;
	cd-gpios = <&tlmm 62 GPIO_ACTIVE_LOW>;
	pinctrl-0 = <&sd_pins>;
	pinctrl-names = "default";
	vqmmc-supply = <&vcc_sd>;
	status = "okay";
};

&switch {
	switch_lan_bmp = <(ESS_PORT2 | ESS_PORT3)>;
	switch_wan_bmp = <ESS_PORT1>;
};

&dp1 {
	status = "okay";
	phy-handle = <&qca8075_0>;
	label = "wan";
	nvmem-cells = <&macaddr_wan>;
	nvmem-cell-names = "mac-address";
};

&dp2 {
	status = "okay";
	phy-handle = <&qca8075_1>;
	label = "lan2";
	nvmem-cells = <&macaddr_lan>;
	nvmem-cell-names = "mac-address";
};

&dp3 {
	status = "okay";
	phy-handle = <&qca8075_2>;
	label = "lan1";
	nvmem-cells = <&macaddr_lan>;
	nvmem-cell-names = "mac-address";
};

&wifi {
	qcom,ath11k-calibration-variant = "GL-iNet-GL-AXT1800";
};
