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

#include "mt7628an.dtsi"

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

/{
	compatible = "bliot,smart-gateway", "mediatek,mt7628an-soc";
	model = "DSI0177";

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

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

	memory@0 {
		device_type = "memory";
		//reg = <0x0 0x8000000>;
		reg = <0x0 0x4000000>;
		//reg = <0x0 0x2000000>;
	};

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

		led_power: power {
			label = "pwrled";
			gpios = <&gpio 4 1>;
		};

		led_error: error {
			label = "errled";
			gpios = <&gpio 5 1>;
		};

		led_zigbee: zigbee {
			label = "zigbee";
			gpios = <&gpio 19 1>;
		};

		led_wanlink: wanlink {
			label = "wanlink";
			gpios = <&gpio 14 1>;
		};

		led_wandata: wandata {
			label = "wandata";
			gpios = <&gpio 15 1>;
		};



	};

  	gpio-keys-polled {
    		compatible = "gpio-keys-polled";
    		#address-cells = <1>;
    		#size-cells = <0>;
    		poll-interval = <20>;

    		pair {
      			label = "BTN_0";
      			gpios = <&gpio 3 1>;
      			linux,code = <0x100>;
    		};
    		wps {
      			label = "BTN_1";
      			gpios = <&gpio 2 1>;
      			linux,code = <0x101>;
    		};
  	};
	sdhci@10130000 {
		status = "okay";
		mediatek,cd-low;
	};
};

&pinctrl {
	state_default: pinctrl0 {
		gpio {
			ralink,group = "wdt", "refclk", "wled_an","p1led_an","p2led_an";
			ralink,function = "gpio";
		};
	};
};

&ethernet {
	mtd-mac-address = <&factory 0x28>;
};

&wmac {
	status = "okay";
	ralink,mtd-eeprom = <&factory 0x0>;
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;
		m25p,chunked-io = <32>;

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

			partition@0 {
				label = "u-boot";
				reg = <0x0 0x30000>;
				/* read-only; */
			};

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

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

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

&uart1 {
	status = "okay";
};
&uart2 {
	status = "okay";
};

&ehci {
	status = "okay";
};

&ohci {
	status = "okay";
};
