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

#include "vr9.dtsi"

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

/ {
	chosen {
		bootargs = "console=ttyLTQ0,115200";
	};

	memory@0 {
		device_type = "memory";
		reg = <0x0 0x10000000>;
	};

	aliases: aliases {
		led-boot = &led_power_green;
		led-failsafe = &led_info_red;
		led-running = &led_power_green;
		led-upgrade = &led_info_red;
	};

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

		power {
			label = "power";
			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_POWER>;
		};

		wifi {
			label = "wifi";
			gpios = <&gpio 29 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RFKILL>;
		};
	};

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

		led_power_green: power_green {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_GREEN>;
			gpios = <&gpio 45 GPIO_ACTIVE_LOW>;
			default-state = "keep";
		};

		led_info_green: info_green {
			label = "green:info";
			gpios = <&gpio 33 GPIO_ACTIVE_LOW>;
		};

		led_info_red: info_red {
			label = "red:info";
			gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
		};
	};
};

&gphy0 {
	lantiq,gphy-mode = <GPHY_MODE_GE>;
};

&gphy1 {
	lantiq,gphy-mode = <GPHY_MODE_GE>;
};

&gpio {
	pinctrl-names = "default";
	pinctrl-0 = <&state_default>;
	gpio-ranges = <&gpio 0 0 56>;

	state_default: pinmux {
		phy-rst {
			lantiq,pins = "io32", "io44";
			lantiq,pull = <0>;
			lantiq,open-drain;
			lantiq,output = <1>;
		};

		pcie-rst {
			lantiq,pins = "io21";
			lantiq,open-drain;
			lantiq,output = <1>;
		};
	};

	usb-vbus {
		gpio-hog;
		line-name = "usb-vbus";
		gpios = <14 GPIO_ACTIVE_HIGH>;
		output-high;
	};

	pcie-enable-dev {
		gpio-hog;
		line-name = "pcie-enable-dev";
		gpios = <22 GPIO_ACTIVE_LOW>;
		output-low;
	};
};

&gswip {
	pinctrl-0 = <&mdio_pins>;
	pinctrl-names = "default";
};

&spi {
	status = "okay";

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

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

			urlader: partition@0 {
				reg = <0x0 0x40000>;
				label = "urlader";
				read-only;
			};

			partition@40000 {
				reg = <0x40000 0x60000>;
				label = "tffs (1)";
				read-only;
			};

			partition@a0000 {
				reg = <0xa0000 0x60000>;
				label = "tffs (2)";
				read-only;
			};
		};
	};
};

&localbus {
	nand1: nand@1 {
		compatible = "lantiq,nand-xway";
		bank-width = <2>;
		reg = <0x1 0x0 0x2000000>;

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

			partition@0 {
				label = "kernel";
				reg = <0x0 0x400000>;
			};

			partition@400000 {
				label = "ubi";
				reg = <0x400000 0x1fc00000>;
			};
		};
	};
};

&pcie0 {
	status = "okay";

	reset-gpios = <&gpio 21 GPIO_ACTIVE_LOW>;
	lantiq,switch-pcie-endianess;
};
