linux/arch/arm64/boot/dts/rockchip/rk3568-qnap-ts433.dts

// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
/*
 * Copyright (c) 2021 Rockchip Electronics Co., Ltd.
 * Copyright (c) 2024 Uwe Kleine-König
 */

/dts-v1/;

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

/ {
	model = "Qnap TS-433-4G NAS System 4-Bay";
	compatible = "qnap,ts433", "rockchip,rk3568";

	aliases {
		ethernet0 = &gmac0;
		mmc0 = &sdhci;
		rtc0 = &rtc_rv8263;
	};

	chosen {
		stdout-path = "serial2:115200n8";
	};

	keys {
		compatible = "gpio-keys";
		pinctrl-0 = <&copy_button_pin>, <&reset_button_pin>;
		pinctrl-names = "default";

		key-copy {
			label = "copy";
			gpios = <&gpio0 RK_PB6 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_COPY>;
		};

		key-reset {
			label = "reset";
			gpios = <&gpio0 RK_PB5 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";

		led-0 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_DISK;
			gpios = <&gpio1 RK_PD5 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "disk-activity";
			pinctrl-names = "default";
			pinctrl-0 = <&hdd1_led_pin>;
		};

		led-1 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_DISK;
			gpios = <&gpio1 RK_PD6 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "disk-activity";
			pinctrl-names = "default";
			pinctrl-0 = <&hdd2_led_pin>;
		};

		led-2 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_DISK;
			gpios = <&gpio1 RK_PD7 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "disk-activity";
			pinctrl-names = "default";
			pinctrl-0 = <&hdd3_led_pin>;
		};

		led-3 {
			color = <LED_COLOR_ID_GREEN>;
			function = LED_FUNCTION_DISK;
			gpios = <&gpio2 RK_PA0 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "disk-activity";
			pinctrl-names = "default";
			pinctrl-0 = <&hdd4_led_pin>;
		};
	};

	dc_12v: regulator-dc-12v {
		compatible = "regulator-fixed";
		regulator-name = "dc_12v";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <12000000>;
		regulator-max-microvolt = <12000000>;
	};

	vcc3v3_pcie: regulator-vcc3v3-pcie {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3_pcie";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		enable-active-high;
		gpios = <&gpio0 RK_PD4 GPIO_ACTIVE_HIGH>;
		vin-supply = <&dc_12v>;
	};

	vcc3v3_sys: regulator-vcc3v3-sys {
		compatible = "regulator-fixed";
		regulator-name = "vcc3v3_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		vin-supply = <&dc_12v>;
	};

	vcc5v0_host: regulator-vcc5v0-host {
		compatible = "regulator-fixed";
		enable-active-high;
		pinctrl-names = "default";
		pinctrl-0 = <&vcc5v0_host_en>;
		gpio = <&gpio0 RK_PA6 GPIO_ACTIVE_HIGH>;
		regulator-name = "vcc5v0_host";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_usb>;
	};

	vcc5v0_otg: regulator-vcc5v0-otg {
		compatible = "regulator-fixed";
		enable-active-high;
		gpio = <&gpio0 RK_PA5 GPIO_ACTIVE_HIGH>;
		pinctrl-names = "default";
		pinctrl-0 = <&vcc5v0_otg_en>;
		regulator-name = "vcc5v0_otg";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&vcc5v0_usb>;
	};

	vcc5v0_sys: regulator-vcc5v0-sys {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_sys";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&dc_12v>;
	};

	vcc5v0_usb: regulator-vcc5v0-usb {
		compatible = "regulator-fixed";
		regulator-name = "vcc5v0_usb";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <5000000>;
		regulator-max-microvolt = <5000000>;
		vin-supply = <&dc_12v>;
	};
};

/* connected to usb_host0_xhci */
&combphy0 {
	status = "okay";
};

/* connected to sata1 */
&combphy1 {
	status = "okay";
};

/* connected to sata2 */
&combphy2 {
	status = "okay";
};

&cpu0 {
	cpu-supply = <&vdd_cpu>;
};

&cpu1 {
	cpu-supply = <&vdd_cpu>;
};

&cpu2 {
	cpu-supply = <&vdd_cpu>;
};

&cpu3 {
	cpu-supply = <&vdd_cpu>;
};

&gmac0 {
	assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
	assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>;
	assigned-clock-rates = <0>, <125000000>;
	clock_in_out = "output";
	phy-handle = <&rgmii_phy0>;
	phy-mode = "rgmii-id";
	pinctrl-names = "default";
	pinctrl-0 = <&gmac0_miim
		     &gmac0_tx_bus2
		     &gmac0_rx_bus2
		     &gmac0_rgmii_clk
		     &gmac0_rgmii_bus>;
	status = "okay";
};

&gpu {
	mali-supply = <&vdd_gpu>;
	status = "okay";
};

&i2c0 {
	status = "okay";

	pmic@20 {
		compatible = "rockchip,rk809";
		reg = <0x20>;
		interrupt-parent = <&gpio0>;
		interrupts = <RK_PA3 IRQ_TYPE_LEVEL_LOW>;
		#clock-cells = <1>;
		pinctrl-names = "default";
		pinctrl-0 = <&pmic_int_l>;
		system-power-controller;
		vcc1-supply = <&vcc3v3_sys>;
		vcc2-supply = <&vcc3v3_sys>;
		vcc3-supply = <&vcc3v3_sys>;
		vcc4-supply = <&vcc3v3_sys>;
		vcc5-supply = <&vcc3v3_sys>;
		vcc6-supply = <&vcc3v3_sys>;
		vcc7-supply = <&vcc3v3_sys>;
		vcc8-supply = <&vcc3v3_sys>;
		vcc9-supply = <&vcc3v3_sys>;
		wakeup-source;

		regulators {
			vdd_logic: DCDC_REG1 {
				regulator-name = "vdd_logic";
				regulator-always-on;
				regulator-boot-on;
				regulator-initial-mode = <0x2>;
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <6001>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdd_gpu: DCDC_REG2 {
				regulator-name = "vdd_gpu";
				regulator-always-on;
				regulator-initial-mode = <0x2>;
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <6001>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_ddr: DCDC_REG3 {
				regulator-name = "vcc_ddr";
				regulator-always-on;
				regulator-boot-on;
				regulator-initial-mode = <0x2>;

				regulator-state-mem {
					regulator-on-in-suspend;
				};
			};

			vdd_npu: DCDC_REG4 {
				regulator-name = "vdd_npu";
				regulator-initial-mode = <0x2>;
				regulator-min-microvolt = <500000>;
				regulator-max-microvolt = <1350000>;
				regulator-ramp-delay = <6001>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_1v8: DCDC_REG5 {
				regulator-name = "vcc_1v8";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdda0v9_image: LDO_REG1 {
				regulator-name = "vdda0v9_image";
				regulator-always-on;
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdda_0v9: LDO_REG2 {
				regulator-name = "vdda_0v9";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vdda0v9_pmu: LDO_REG3 {
				regulator-name = "vdda0v9_pmu";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <900000>;
				regulator-max-microvolt = <900000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <900000>;
				};
			};

			vccio_acodec: LDO_REG4 {
				regulator-name = "vccio_acodec";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vccio_sd: LDO_REG5 {
				regulator-name = "vccio_sd";
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <3300000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc3v3_pmu: LDO_REG6 {
				regulator-name = "vcc3v3_pmu";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <3300000>;
				regulator-max-microvolt = <3300000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <3300000>;
				};
			};

			vcca_1v8: LDO_REG7 {
				regulator-name = "vcca_1v8";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcca1v8_pmu: LDO_REG8 {
				regulator-name = "vcca1v8_pmu";
				regulator-always-on;
				regulator-boot-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-on-in-suspend;
					regulator-suspend-microvolt = <1800000>;
				};
			};

			vcca1v8_image: LDO_REG9 {
				regulator-name = "vcca1v8_image";
				regulator-always-on;
				regulator-min-microvolt = <1800000>;
				regulator-max-microvolt = <1800000>;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc_3v3: SWITCH_REG1 {
				regulator-name = "vcc_3v3";
				regulator-always-on;
				regulator-boot-on;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};

			vcc3v3_sd: SWITCH_REG2 {
				regulator-name = "vcc3v3_sd";
				/*
				 * turning this off, breaks access to both
				 * PCIe controllers, refclk generator perhaps
				 */
				regulator-always-on;
				regulator-boot-on;

				regulator-state-mem {
					regulator-off-in-suspend;
				};
			};
		};
	};

	vdd_cpu: regulator@40 {
		compatible = "silergy,syr827";
		reg = <0x40>;
		fcs,suspend-voltage-selector = <1>;
		regulator-name = "vdd_cpu";
		regulator-always-on;
		regulator-boot-on;
		regulator-min-microvolt = <712500>;
		regulator-max-microvolt = <1390000>;
		regulator-ramp-delay = <2300>;
		vin-supply = <&vcc5v0_sys>;
	};
};

&i2c1 {
	status = "okay";

	rtc_rv8263: rtc@51 {
		compatible = "microcrystal,rv8263";
		reg = <0x51>;
		wakeup-source;
	};

	/* eeprom for vital-product-data on the mainboard */
	eeprom@54 {
		compatible = "giantec,gt24c04a", "atmel,24c04";
		reg = <0x54>;
		label = "VPD_MB";
		num-addresses = <2>;
		pagesize = <16>;
		read-only;
	};

	/* eeprom for vital-product-data on the backplane */
	eeprom@56 {
		compatible = "giantec,gt24c04a", "atmel,24c04";
		reg = <0x56>;
		label = "VPD_BP";
		num-addresses = <2>;
		pagesize = <16>;
		read-only;
	};
};

&mdio0 {
	rgmii_phy0: ethernet-phy@0 {
		compatible = "ethernet-phy-ieee802.3-c22";
		reg = <0x0>;
	};
};

&pcie30phy {
	data-lanes = <1 2>;
	status = "okay";
};

/* Connected to a JMicron AHCI SATA controller */
&pcie3x1 {
	reset-gpios = <&gpio0 RK_PC7 GPIO_ACTIVE_HIGH>;
	vpcie3v3-supply = <&vcc3v3_pcie>;
	status = "okay";
};

/* Connected to the 2.5G NIC for the upper network jack */
&pcie3x2 {
	num-lanes = <1>;
	reset-gpios = <&gpio2 RK_PD6 GPIO_ACTIVE_HIGH>;
	vpcie3v3-supply = <&vcc3v3_pcie>;
	status = "okay";
};

&pinctrl {
	keys {
		copy_button_pin: copy-button-pin {
			rockchip,pins = <0 RK_PB6 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		reset_button_pin: reset-button-pin {
			rockchip,pins = <0 RK_PB5 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	leds {
		hdd1_led_pin: hdd1-led-pin {
			rockchip,pins = <1 RK_PD5 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		hdd2_led_pin: hdd2-led-pin {
			rockchip,pins = <1 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		hdd3_led_pin: hdd3-led-pin {
			rockchip,pins = <1 RK_PD7 RK_FUNC_GPIO &pcfg_pull_up>;
		};

		hdd4_led_pin: hdd4_led-pin {
			rockchip,pins = <2 RK_PA0 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	pmic {
		pmic_int_l: pmic-int-l {
			rockchip,pins = <0 RK_PA3 RK_FUNC_GPIO &pcfg_pull_up>;
		};
	};

	usb {
		vcc5v0_host_en: vcc5v0-host-en {
			rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>;
		};

		vcc5v0_otg_en: vcc5v0-otg-en {
			rockchip,pins = <0 RK_PA5 RK_FUNC_GPIO &pcfg_pull_none>;
		};
	};
};

&pmu_io_domains {
	vccio4-supply = <&vcc_1v8>;
	vccio6-supply = <&vcc_1v8>;
	status = "okay";
};

&sata1 {
	status = "okay";
};

&sata2 {
	status = "okay";
};

&sdhci {
	bus-width = <8>;
	max-frequency = <200000000>;
	non-removable;
	status = "okay";
};

&tsadc {
	rockchip,hw-tshut-mode = <1>;
	rockchip,hw-tshut-polarity = <0>;
	status = "okay";
};

/*
 * Connected to an MCU, that provides access to more LEDs,
 * buzzer, fan control and more.
 */
&uart0 {
	status = "okay";
};

/*
 * Pins available on CN3 connector at TTL voltage level (3V3).
 * ,_  _.
 * |1234|  1=TX 2=VCC
 * `----'  3=RX 4=GND
 */
&uart2 {
	status = "okay";
};

&usb2phy0 {
	status = "okay";
};

/* connected to usb_host0_xhci */
&usb2phy0_otg {
	phy-supply = <&vcc5v0_otg>;
	status = "okay";
};

&usb2phy1 {
	status = "okay";
};

/* connected to usb_host1_ehci/ohci */
&usb2phy1_host {
	phy-supply = <&vcc5v0_host>;
	status = "okay";
};

/* connected to usb_host0_ehci/ohci */
&usb2phy1_otg {
	phy-supply = <&vcc5v0_host>;
	status = "okay";
};

/* right port backside */
&usb_host0_ehci {
	status = "okay";
};

&usb_host0_ohci {
	status = "okay";
};

/* front port */
&usb_host0_xhci {
	dr_mode = "host";
	status = "okay";
};

/* left port backside */
&usb_host1_ehci {
	status = "okay";
};

&usb_host1_ohci {
	status = "okay";
};