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

#include "ar7100.dtsi"

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

/ {
	compatible = "aruba,ap-175", "qca,ar7161";
	model = "Aruba AP-175";

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

	aliases {
		led-boot = &led_power_amber;
		led-failsafe = &led_power_amber;
		led-upgrade = &led_power_amber;
		label-mac-device = &eth0;
	};

	leds {
		compatible = "gpio-leds";

		/* These internal LEDs cannot be seen when case is closed */
		internal_2g_green {
			label = "green:internal_2g";
			gpios = <&gpio 3 GPIO_ACTIVE_HIGH>;
		};

		internal_5g_green {
			label = "green:internal_5g";
			gpios = <&gpio 4 GPIO_ACTIVE_HIGH>;
		};

        /* These external LEDs are visible from the bottom panel */

		led_power_amber: power_amber {
			label = "amber:power";
			gpios = <&gpio_ext 5 GPIO_ACTIVE_HIGH>;
			panic-indicator;
		};

		r1_act_blue {
			label = "blue:r1_act";
			gpios = <&gpio_ext 0 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "phy1tpt";
		};

		r1_rssi1_blue {
			label = "blue:r1_rssi1";
			gpios = <&gpio_ext 1 GPIO_ACTIVE_HIGH>;
		};

		r1_rssi2_blue {
			label = "blue:r1_rssi2";
			gpios = <&gpio_ext 2 GPIO_ACTIVE_HIGH>;
		};

		r1_rssi3_blue {
			label = "blue:r1_rssi3";
			gpios = <&gpio_ext 3 GPIO_ACTIVE_HIGH>;
		};

		r1_rssi4_blue {
			label = "blue:r1_rssi4";
			gpios = <&gpio_ext 4 GPIO_ACTIVE_HIGH>;
		};

		r0_act_amber {
			label = "amber:r0_act";
			gpios = <&gpio_ext 8 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "phy0tpt";
		};

		r0_rssi1_amber {
			label = "amber:r0_rssi1";
			gpios = <&gpio_ext 9 GPIO_ACTIVE_HIGH>;
		};

		r0_rssi2_amber {
			label = "amber:r0_rssi2";
			gpios = <&gpio_ext 10 GPIO_ACTIVE_HIGH>;
		};

		r0_rssi3_amber {
			label = "amber:r0_rssi3";
			gpios = <&gpio_ext 11 GPIO_ACTIVE_HIGH>;
		};

		r0_rssi4_amber {
			label = "amber:r0_rssi4";
			gpios = <&gpio_ext 12 GPIO_ACTIVE_HIGH>;
		};
	};

	keys {
		compatible = "gpio-keys";

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

	i2c0: i2c {
		compatible = "i2c-gpio";
		i2c-gpio,delay-us = <10>;
		i2c-gpio,timeout-ms = <1>;
		sda-gpios = <&gpio 1 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
		scl-gpios = <&gpio 2 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;

		#address-cells = <1>;
		#size-cells = <0>;
	};
};

&pcie0 {
	status = "okay";

	ath9k0: wifi@0,11 {
		compatible = "pci168c,0029";
		nvmem-cells = <&macaddr_hwinfo_1c>;
		nvmem-cell-names = "mac-address";
		mac-address-increment = <1>;
		reg = <0x8800 0 0 0 0>;
		#gpio-cells = <2>;
		gpio-controller;
	};

	ath9k1: wifi@0,12 {
		compatible = "pci168c,0029";
		nvmem-cells = <&macaddr_hwinfo_1c>;
		nvmem-cell-names = "mac-address";
		mac-address-increment = <2>;
		reg = <0x9000 0 0 0 0>;
		#gpio-cells = <2>;
		gpio-controller;
	};
};

&mdio0 {
	status = "okay";

	phy1: ethernet-phy@1 {
		reg = <0x1>;
	};
};

&eth0 {
	status = "okay";
	nvmem-cells = <&macaddr_hwinfo_1c>;
	nvmem-cell-names = "mac-address";

	phy-mode = "rgmii";
	phy-handle = <&phy1>;
};

&spi {
	status = "okay";

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

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

			partition@0 {
				label = "u-boot";
				reg = <0x000000 0x40000>;
				read-only;
			};

			partition@40000 {
				label = "firmware";
				reg = <0x40000 0xfa0000>;
				compatible = "denx,uimage";
			};

			hwinfo: partition@fe0000 {
				label = "hwinfo";
				reg = <0xfe0000 0x10000>;
				read-only;
			};

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

&hwinfo {
	compatible = "nvmem-cells";
	#address-cells = <1>;
	#size-cells = <1>;

	macaddr_hwinfo_1c: macaddr@1c {
		reg = <0x1c 0x6>;
	};
};

&i2c0 {
	gpio_ext: gpio@21 {
		status = "okay";

		compatible = "ti,tca6416";
		reg = <0x21>;

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

		gpio-controller;
		#gpio-cells = <2>;
	};

	temp-sensor@4a {
		 compatible = "national,lm75";
		 reg = <0x4a>;
	};

	eeprom@50 { /* 24lc2561 */
		compatible = "atmel,24c256","at24";
		#address-cells = <1>;
		#size-cells = <0>;
		reg = <0x50>;
		size = <256>;
	};

	ds1374c: rtc@68 {
		status = "okay";

		compatible = "dallas,ds1374";
		reg = <0x68>;
	};
};
