// SPDX-License-Identifier: (GPL-2.0-or-later or MIT)

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

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

	keys {
		compatible = "gpio-keys-polled";
		poll-interval = <100>;

		reset {
			label = "reset";
			gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinmux_disable_sys_led>;

		led_power: led-0 {
			label = "green:power";
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_POWER;
			gpios = <&gpio0 0 GPIO_ACTIVE_LOW>;
		};

		led_fault: led-1 {
			label = "amber:fault";
			color = <LED_COLOR_ID_AMBER>;
			function = LED_FUNCTION_FAULT;
			gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;
		};
	};

	sfp0: sfp-p49 {
		compatible = "sff,sfp";
		los-gpio = <&gpio1 11 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 12 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 10 GPIO_ACTIVE_HIGH>;
	};
	sfp1: sfp-p50 {
		compatible = "sff,sfp";
		los-gpio = <&gpio1 14 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 21 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 13 GPIO_ACTIVE_HIGH>;
	};
	sfp2: sfp-p51 {
		compatible = "sff,sfp";
		los-gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 25 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 22 GPIO_ACTIVE_HIGH>;
	};
	sfp3: sfp-p52 {
		compatible = "sff,sfp";
		los-gpio = <&gpio1 27 GPIO_ACTIVE_HIGH>;
		mod-def0-gpio = <&gpio1 28 GPIO_ACTIVE_LOW>;
		tx-disable-gpio = <&gpio1 26 GPIO_ACTIVE_HIGH>;
	};

	ubi-concat {
		compatible = "mtd-concat";
		devices = <&ubiconcat0 &ubiconcat1>;

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

			partition@0 {
				label = "ubi";
				reg = <0x0 0x1d00000>;
			};
		};
	};
};

&ecc0 {
	status = "okay";
};

&spi0 {
	status = "okay";
	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;

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

			partition@0 {
				label = "u-boot";
				reg = <0x0 0xe0000>;
				read-only;
			};
			partition@e0000 {
				label = "u-boot-env";
				reg = <0xe0000 0x10000>;
			};
			partition@f0000 {
				label = "u-boot-env2";
				reg = <0xf0000 0x10000>;
			};
		};
	};
};

&snand {
	status = "okay";
	flash@0 {
		compatible = "spi-nand";
		reg = <0>;

		nand-ecc-engine = <&ecc0>;
		nand-ecc-strength = <6>;
		nand-ecc-step-size = <512>;
		nand-ecc-algo = "bch";
		nand-ecc-placement = "oob";

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

			partition@0 {
				label = "vendor_ubi";
				reg = <0x0 0x4000000>;
				read-only;
			};
			partition@4000000 {
				label = "kernel";
				reg = <0x4000000 0xa00000>;
			};
			ubiconcat0: partition@4a00000 {
				label = "ubiconcat0";
				reg = <0x4a00000 0x1400000>;
			};
			partition@5e00000 {
				label = "runtime2";
				reg = <0x5e00000 0x1500000>;
				read-only;
			};
			ubiconcat1: partition@7300000 {
				label = "ubiconcat1";
				reg = <0x7300000 0x900000>;
			};
		};
	};
};
