// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Device Tree file for DLINK DNS-320L
 *
 * Copyright (C) 2024, Zoltan HERPAI <wigyori@uid0.hu>
 * Copyright (C) 2015, Sunke Schlüters <sunke-dev@schlueters.de>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version
 * 2 of the License, or (at your option) any later version.
 *
 * This file is based on the works of:
 * - Sunke Schlüters <sunke-dev@schlueters.de>
 *   - https://github.com/scus1/dns320l/blob/master/kernel/dts/kirkwood-dns320l.dts
 * - Andreas Böhler <dev@aboehler.at>:
 *   - http://www.aboehler.at/doku/doku.php/projects:dns320l
 *   - http://www.aboehler.at/hg/linux-dns320l/file/ba7a60ad7687/linux-3.12/kirkwood-dns320l.dts
 */

/dts-v1/;

#include "kirkwood.dtsi"
#include "kirkwood-6281.dtsi"

/ {
	model = "D-Link DNS-320L";
	compatible = "dlink,dns320l", "marvell,kirkwood-88f6702", "marvell,kirkwood";

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

	chosen {
		bootargs = "console=ttyS0,115200n8 earlyprintk";
		stdout-path = &uart0;
	};

	gpio-keys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;
		pinctrl-0 = <&pmx_buttons>;
		pinctrl-names = "default";

		button@1 {
			label = "Reset push button";
			linux,code = <KEY_RESTART>;
			gpios = <&gpio0 28 1>;
		};

		button@2 {
			label = "USB unmount button";
			linux,code = <KEY_EJECTCD>;
			gpios = <&gpio0 27 1>;
		};
	};

	gpio-leds {
		compatible = "gpio-leds";
		pinctrl-0 = <&pmx_leds>;
		pinctrl-names = "default";

		blue-usb {
			label = "dns320l:usb:blue";
			gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
			linux,default-trigger = "usbport";
		};

		orange-usb {
			label = "dns320l:usb:orange";
			gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>;
		};

		orange-l-hdd {
			label = "dns320l:orange:l_hdd";
			gpios = <&gpio0 23 GPIO_ACTIVE_HIGH>;
		};

		orange-r-hdd {
			label = "dns320l:orange:r_hdd";
			gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>;
		};
	};

	ocp@f1000000 {
		sata@80000 {
			status = "okay";
			nr-ports = <2>;
		};

		serial@12000 {
			status = "okay";
		};

		serial@12100 {
			pinctrl-0 = <&pmx_uart1>;
			pinctrl-names = "default";
			status = "okay";
		};
	};

	regulators {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <0>;
		pinctrl-0 = <&pmx_power_sata>;
		pinctrl-names = "default";

		sata_power: regulator@1 {
			compatible = "regulator-fixed";
			reg = <1>;
			regulator-name = "SATA Power";
			regulator-min-microvolt = <5000000>;
			regulator-max-microvolt = <5000000>;
			enable-active-high;
			regulator-always-on;
			regulator-boot-on;
			gpios = <&gpio0 24 0>;
		};
	};
};

&nand {
	pinctrl-0 = <&pmx_nand>;
	pinctrl-names = "default";
	chip-delay = <40>;
	status = "okay";

	partition@0 {
		label = "u-boot";
		reg = <0x0000000 0x100000>;
	};

	partition@100000 {
		label = "ubootenv";
		reg = <0x100000 0x20000>;
	};

	partition@120000 {
		label = "ubi";
		reg = <0x120000 0x6de0000>;
	};

	partition@6f00000 {
		label = "mini firmware";
		reg = <0x6f00000 0xa00000>;
	};

	partition@7900000 {
		label = "config";
		reg = <0x7900000 0x500000>;
	};

	partition@7e00000 {
		label = "my-dlink";
		reg = <0x7e00000 0x200000>;
	};
};

&mdio {
	status = "okay";

	ethphy0: ethernet-phy@0 {
		reg = <0>;
	};
};

&pinctrl {
	pmx_sata1: pmx-sata1 {
		marvell,pins = "mpp20";
		marvell,function = "sata1";
	};

	pmx_sata0: pmx-sata0 {
		marvell,pins = "mpp21";
		marvell,function = "sata0";
	};

	pmx_power_sata: pmx-power-sata {
		marvell,pins = "mpp24";
		marvell,function = "gpio";
	};

	pmx_leds: pmx-leds {
		marvell,pins = "mpp22", "mpp23", "mpp25", "mpp26";
		marvell,function = "gpio";
	};

	pmx_buttons: pmx-buttons {
		marvell,pins = "mpp27", "mpp28", "mpp29";
		marvell,function = "gpio";
	};
};

&eth0 {
	status = "okay";
	ethernet0-port@0 {
		phy-handle = <&ethphy0>;
	};
};
