// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Device Tree file for x220 board
 *
 * Copyright (C) 2025 Allied Telesis Labs
 */

/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include "armada-xp-98dx3236.dtsi"
#include "mvebu-u-boot.dtsi"

/ {
	model = "x220";
	compatible = "marvell,armadaxp-98dx3236", "marvell,armadaxp-mv78260",
		     "marvell,armadaxp", "marvell,armada-370-xp";

	chosen {
		stdout-path = "serial0:115200n8";
		bootargs = "console=ttyS0,115200";
	};

	aliases {
		i2c0 = &i2c0;
		spi0 = &spi0;
	};

	memory {
		device_type = "memory";
		reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
	};
};

&L2 {
	arm,parity-enable;
	marvell,ecc-enable;
};

&devbus_bootcs {
	status = "okay";

	/* Device Bus parameters are required */

	/* Read parameters */
	devbus,bus-width    = <16>;
	devbus,turn-off-ps  = <60000>;
	devbus,badr-skew-ps = <0>;
	devbus,acc-first-ps = <124000>;
	devbus,acc-next-ps  = <248000>;
	devbus,rd-setup-ps  = <0>;
	devbus,rd-hold-ps   = <0>;

	/* Write parameters */
	devbus,sync-enable = <0>;
	devbus,wr-high-ps  = <60000>;
	devbus,wr-low-ps   = <60000>;
	devbus,ale-wr-ps   = <60000>;
};

&uart0 {
	status = "okay";
};

&i2c0 {
	clock-frequency = <100000>;
	status = "okay";

	rtc@68 {
		compatible = "dallas,ds1340";
		reg = <0x68>;
	};

	adt7476a@2e {
		compatible = "adi,adt7476";
		reg = <0x2e>;
	};

	sfpgpio: gpio@27 {
		#address-cells = <2>;
		#size-cells = <0>;
		compatible = "nxp,pca9555";
		reg = <0x27>;
		gpio-controller;
		#gpio-cells = <2>;
	};

	systemgpio: gpio@25 {
		#address-cells = <1>;
		#size-cells = <0>;
		compatible = "nxp,pca9555";
		reg = <0x25>;
		gpio-controller;
		#gpio-cells = <2>;

		nand-protect {
			gpio-hog;
			gpios = <6 GPIO_ACTIVE_HIGH>;
			output-high;
			line-name = "nand-protect";
		};

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

		phy-reset {
			gpio-hog;
			gpios = <5 GPIO_ACTIVE_LOW>;
			output-high;
			line-name = "phy-reset";
		};

		led-enable {
			gpio-hog;
			gpios = <13 GPIO_ACTIVE_HIGH>;
			output-low;
			line-name = "led-enable";
		};
	};
};

&watchdog {
	status = "okay";
};

&usb0 {
	status = "okay";
};

&spi0 {
	status = "okay";

	spi-flash@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spi-flash", "jedec,spi-nor";
		reg = <0>; /* Chip select 0 */
		spi-max-frequency = <20000000>;
	};
};

&nand_controller {
	compatible = "marvell,armada370-nand-controller";
	label = "pxa3xx_nand-0";
	status = "okay";
	nand-rb = <0>;
	nand-on-flash-bbt;
	nand-ecc-strength = <4>;
	nand-ecc-step-size = <512>;
};

&{/} {
	boot-board {
		compatible = "atl,boot-board";
		present-gpio = <&systemgpio 12 GPIO_ACTIVE_HIGH>;
		override-gpio = <&gpio0 31 GPIO_ACTIVE_HIGH>;
	};
};

