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

#include "mt7628an.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

/ {
	model = "Huasifei SHF283";
	compatible = "huasifei,shf283", "mediatek,mt7628an-soc";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
	};

	chosen {
		bootargs = "console=ttyS0,115200";
	};

	gpio-keys {
		compatible = "gpio-keys";

		button-reset {
			label = "reset";
			gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";

		led-0 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_STATUS;
			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
		};

		led-1 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_WLAN;
			gpios = <&gpio 35 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};

		led_power: led-2 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_POWER;
			gpios = <&gpio 37 GPIO_ACTIVE_LOW>;
		};

		led-3 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_WAN;
			gpios = <&gpio 43 GPIO_ACTIVE_LOW>;
		};
	};

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

		modem-reset {
			gpio-export,name = "modem_reset";
			gpio-export,output = <0>;
			gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
		};
	};
};

&ethernet {
	nvmem-cells = <&macaddr_factory_28 0>;
	nvmem-cell-names = "mac-address";
};

&pcie {
	status = "okay";
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <12000000>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "bootloader";
				reg = <0x0 0x30000>;
				read-only;
			};

			partition@30000 {
				label = "config";
				reg = <0x30000 0x10000>;
				read-only;
			};

			partition@40000 {
				label = "factory";
				reg = <0x40000 0x10000>;
				read-only;

				nvmem-layout {
					eeprom_factory_0: eeprom@0 {
						reg = <0x0 0x400>;
					};

					macaddr_factory_28: macaddr@28 {
						compatible = "mac-base";
						reg = <0x28 0x6>;
						#nvmem-cell-cells = <1>;
					};
				};
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0xfb0000>;
			};
		};
	};
};

&state_default {
	gpio {
		groups = "i2c";
		function = "gpio";
	};
};

&uart1 {
	status = "okay";
};

&wmac {
	nvmem-cells = <&eeprom_factory_0>;
	nvmem-cell-names = "eeprom";
	status = "okay";
};
