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

/dts-v1/;
#include <dt-bindings/thermal/thermal.h>

#include "rk3528-mangopi-m28.dtsi"

/ {
	model = "Widora MangoPi M28C";
	compatible = "widora,mangopi-m28c", "rockchip,rk3528";

	gpio-export {
		compatible = "gpio-export";

		modem-reset {
			gpio-export,name = "MODEM-RST";
			gpio-export,output = <0>;
			gpios = <&gpio4 RK_PA3 GPIO_ACTIVE_LOW>;
		};

		modem-power {
			gpio-export,name = "MODEM-PWR";
			gpio-export,output = <1>;
			gpios = <&gpio4 RK_PB1 GPIO_ACTIVE_HIGH>;
		};
	};

	fan: pwm-fan {
		compatible = "pwm-fan";
		cooling-levels = <0 100 150 200 255>;
		#cooling-cells = <2>;
		pwms = <&pwm3 0 1000000 0>;
	};
};

&gpio_leds {
	pinctrl-names = "default";
	pinctrl-0 = <&work_led_pin>;
};

&pwm3 {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm3m0_pins>;
	status = "okay";
};

&soc_thermal {
	trips {
		cpu_passive: trip-cpu-passive {
			temperature = <45000>;
			hysteresis = <2000>;
			type = "active";
		};

		cpu_active: trip-cpu-active {
			temperature = <55000>;
			hysteresis = <2000>;
			type = "active";
		};

		cpu_warm: trip-cpu-warm {
			temperature = <65000>;
			hysteresis = <2000>;
			type = "active";
		};

		cpu_hot: trip-cpu-hot {
			temperature = <75000>;
			hysteresis = <2000>;
			type = "active";
		};
	};

	cooling-maps {
		map-cpu-passive {
			trip = <&cpu_passive>;
			cooling-device = <&fan THERMAL_NO_LIMIT 1>;
		};

		map-cpu-active {
			trip = <&cpu_active>;
			cooling-device = <&fan 1 2>;
		};

		map-cpu-warm {
			trip = <&cpu_warm>;
			cooling-device = <&fan 2 3>;
		};

		map-cpu-hot {
			trip = <&cpu_hot>;
			cooling-device = <&fan 3 THERMAL_NO_LIMIT>;
		};
	};
};

&rgmii_led1 {
	color = <LED_COLOR_ID_GREEN>;
};

&rgmii_led2 {
	color = <LED_COLOR_ID_AMBER>;
};

&usb_host0_xhci {
	phys = <&usb2phy_otg>, <&combphy PHY_TYPE_USB3>;
	phy-names = "usb2-phy", "usb3-phy";
};
