/dts-v1/;

#include "ipq8074.dtsi"
#include "ipq8074-hk-cpu.dtsi"
#include "ipq8074-ess.dtsi"

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

/ {
	model = "Netgear WAX218";
	compatible = "netgear,wax218", "qcom,ipq8074";

	aliases {
		serial0 = &blsp1_uart5;
		led-boot = &led_power_amber;
		led-failsafe = &led_power_amber;
		led-running = &led_power_amber;
		led-upgrade = &led_power_amber;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		/*
		 * Netgear's U-Boot adds "ubi.mtd=rootfs root=mtd:ubi_rootfs"
		 * That fails to create a UBI block device, so add it here.
		*/
		bootargs-append = " ubi.block=0,rootfs root=/dev/ubiblock0_1";
	};

	keys {
		compatible = "gpio-keys";

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

	led_spi {
		compatible = "spi-gpio";
		#address-cells = <1>;
		#size-cells = <0>;

		sck-gpios = <&tlmm 18 GPIO_ACTIVE_HIGH>;
		mosi-gpios = <&tlmm 19 GPIO_ACTIVE_HIGH>;

		led_gpio: led_gpio@0 {
			compatible = "fairchild,74hc595";
			reg = <0>;
			gpio-controller;
			#gpio-cells = <2>;
			registers-number = <1>;
			enable-gpios = <&tlmm 20 GPIO_ACTIVE_HIGH>;
			spi-max-frequency = <1000000>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led_power_amber: led_power {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_AMBER>;
			gpios = <&led_gpio 1 GPIO_ACTIVE_HIGH>;
		};

		led_lan {
			function = LED_FUNCTION_LAN;
			color = <LED_COLOR_ID_BLUE>;
			gpios = <&led_gpio 2 GPIO_ACTIVE_HIGH>;
		};

		led_wlan_2g {
			label = "blue:wlan2g";
			gpios = <&led_gpio 3 GPIO_ACTIVE_HIGH>;
		};

		led_wlan_5g {
			label = "blue:wlan5g";
			gpios = <&led_gpio 4 GPIO_ACTIVE_HIGH>;
		};
	};
};

&edma {
	status = "okay";
};

&uniphy2 {
	status = "okay";
};

&switch {
	status = "okay";

	ports {
		#address-cells = <1>;
		#size-cells = <0>;

		port@0 {
			reg = <0>;
			ethernet = <&edma>;
			phy-mode = "internal";

			fixed-link {
				speed = <1000>;
				full-duplex;
			};
		};

		swport6: port@6 {
			reg = <6>;
			label = "lan";
			phy-handle = <&qca8081_28>;
			phy-mode = "2500base-x";
			pcs-handle = <&uniphy2 0>;
			nvmem-cells = <&macaddr_ubootenv_ethaddr>;
			nvmem-cell-names = "mac-address";
		};
	};
};

&tlmm {
	mdio_pins: mdio-pins {
		mdc {
			pins = "gpio68";
			function = "mdc";
			drive-strength = <8>;
			bias-pull-up;
		};

		mdio {
			pins = "gpio69";
			function = "mdio";
			drive-strength = <8>;
			bias-pull-up;
		};
	};
};

&mdio {
	status = "okay";

	pinctrl-0 = <&mdio_pins>;
	pinctrl-names = "default";
	reset-gpios = <&tlmm 44 GPIO_ACTIVE_LOW>;

	qca8081_28: ethernet-phy@28 {
		reg = <28>;
	};
};

&qpic_bam {
	status = "okay";
};

&qpic_nand {
	status = "okay";

	nand@0 {
		reg = <0>;
		nand-ecc-strength = <4>;
		nand-ecc-step-size = <512>;
		nand-bus-width = <8>;

		partitions {
			compatible = "qcom,smem-part";

			partition-0-appsblenv {
				label = "0:appsblenv";
				read-only;

				nvmem-layout {
					compatible = "u-boot,env";
					env-size = <0x40000>;

					macaddr_ubootenv_ethaddr: ethaddr {
					};
				};
			};
		};
	};
};

&blsp1_uart5 {
	status = "okay";
};

&wifi {
	status = "okay";

	qcom,ath11k-calibration-variant = "Netgear-WAX218";
};
