// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
// Copyright (c) 2022, Pawel Dembicki <paweldembicki@gmail.com>.
// Copyright (c) 2022, Giammarco Marzano <stich86@gmail.com>.
// Copyright (c) 2023, Andreas Böhler <dev@aboehler.at>

#include "qcom-ipq4019.dtsi"
#include <dt-bindings/soc/qcom,tcsr.h>
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>

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

	chosen {
		/*
		 * bootargs forced by u-boot bootipq command:
		 * 'ubi.mtd=rootfs root=mtd:ubi_rootfs rootfstype=squashfs rootwait'
		 */
		bootargs-append = " root=/dev/ubiblock0_1";
	};

	leds {
		compatible = "gpio-leds";

		led_status: led-0 {
			function = LED_FUNCTION_POWER;
			color = <LED_COLOR_ID_BLUE>;
		};
	};

	gpio_export {
		compatible = "gpio-export";
		#size-cells = <0>;

		gpio_modem_reset: modem {
			gpio-export,name = "modem-reset";
			gpio-export,output = <0>;
		};
	};

	keys {
		compatible = "gpio-keys";

		key_reset: key-reset {
			label = "reset";
			linux,code = <KEY_RESTART>;
		};

		key_wps: key-wps {
			label = "wps";
			linux,code = <KEY_WPS_BUTTON>;
		};
	};

	soc {
		tcsr@1949000 {
			compatible = "qcom,tcsr";
			reg = <0x1949000 0x100>;
			qcom,wifi_glb_cfg = <TCSR_WIFI_GLB_CFG>;
		};

		tcsr@194b000 {
			/* select hostmode */
			compatible = "qcom,tcsr";
			reg = <0x194b000 0x100>;
			qcom,usb-hsphy-mode-select = <TCSR_USB_HSPHY_HOST_MODE>;
			status = "okay";
		};

		ess_tcsr@1953000 {
			compatible = "qcom,tcsr";
			reg = <0x1953000 0x1000>;
			qcom,ess-interface-select = <TCSR_ESS_PSGMII>;
		};

		tcsr@1957000 {
			compatible = "qcom,tcsr";
			reg = <0x1957000 0x100>;
			qcom,wifi_noc_memtype_m0_m2 = <TCSR_WIFI_NOC_MEMTYPE_M0_M2>;
		};
	};
};

&mdio {
	status = "okay";
};

&prng {
	status = "okay";
};

&watchdog {
	status = "okay";
};

&blsp_dma {
	status = "okay";
};

&usb2 {
	status = "okay";
};

&usb3 {
	status = "okay";
};

&blsp1_uart1 {
	pinctrl-0 = <&serial_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&crypto {
	status = "okay";
};

&cryptobam {
	status = "okay";
};

&gmac {
	status = "okay";
	nvmem-cell-names = "mac-address";
	nvmem-cells = <&macaddr_mac_0 2>;
};

&switch {
	status = "okay";
};

&swport2 {
	status = "okay";

	label = "lan1";
};

&swport3 {
	status = "okay";

	label = "lan2";
};

&swport4 {
	status = "okay";

	label = "lan3";
};

&swport5 {
	status = "okay";

	label = "lan4";
};

&qpic_bam {
	status = "okay";
};

&usb2_hs_phy {
	status = "okay";
};

&usb3_ss_phy {
	status = "okay";
};

&usb3_hs_phy {
	status = "okay";
};

&wifi0 {
	status = "okay";
	nvmem-cell-names = "pre-calibration", "mac-address";
	nvmem-cells = <&precal_art_1000>, <&macaddr_mac_0 0>;
};

&wifi1 {
	status = "okay";
	nvmem-cell-names = "pre-calibration", "mac-address";
	nvmem-cells = <&precal_art_5000>, <&macaddr_mac_0 1>;
};
