1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Device Tree file for D-Link DNS-313 1-Bay Network Storage Enclosure
4 */
5
6/dts-v1/;
7
8#include "gemini.dtsi"
9#include <dt-bindings/input/input.h>
10#include <dt-bindings/thermal/thermal.h>
11
12/ {
13	model = "D-Link DNS-313 1-Bay Network Storage Enclosure";
14	compatible = "dlink,dns-313", "cortina,gemini";
15	#address-cells = <1>;
16	#size-cells = <1>;
17
18	memory@0 {
19		/* 64 MB SDRAM in a Nanya NT5DS32M16BS-6K package */
20		device_type = "memory";
21		reg = <0x00000000 0x4000000>;
22	};
23
24	aliases {
25		mdio-gpio0 = &mdio0;
26	};
27
28	chosen {
29		bootargs = "console=ttyS0,19200n8 root=/dev/sda4 rw rootwait";
30		stdout-path = "uart0:19200n8";
31	};
32
33	gpio_keys {
34		compatible = "gpio-keys";
35
36		button-reset {
37			debounce-interval = <100>;
38			wakeup-source;
39			linux,code = <KEY_RESTART>;
40			label = "reset";
41			gpios = <&gpio1 31 GPIO_ACTIVE_LOW>;
42		};
43	};
44
45	leds {
46		compatible = "gpio-leds";
47		led-power {
48			label = "dns313:blue:power";
49			gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
50			default-state = "on";
51			linux,default-trigger = "heartbeat";
52		};
53		led-disk-blue {
54			label = "dns313:blue:disk";
55			gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
56			default-state = "off";
57		};
58		led-disk-green {
59			label = "dns313:green:disk";
60			gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
61			default-state = "off";
62			linux,default-trigger = "disk-read";
63		};
64		led-disk-red {
65			label = "dns313:red:disk";
66			gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
67			default-state = "off";
68			linux,default-trigger = "disk-write";
69		};
70	};
71
72	/*
73	 * This is a ADDA AD0405GB-G73 fan @3000 and 6000 RPM.
74	 */
75	fan0: gpio-fan {
76		compatible = "gpio-fan";
77		gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>,
78			<&gpio0 12 GPIO_ACTIVE_HIGH>;
79		gpio-fan,speed-map = <0 0>, <3000 1>, <6000 2>;
80		#cooling-cells = <2>;
81	};
82
83	/*
84	 * This is the type B USB connector on the device,
85	 * a GPIO-controlled USB VBUS detect
86	 */
87	usb1_phy: phy {
88		compatible = "gpio-usb-b-connector", "usb-b-connector";
89		#phy-cells = <0>;
90		vbus-gpios = <&gpio0 18 GPIO_ACTIVE_LOW>;
91	};
92
93	/* Global Mixed-Mode Technology G751 mounted on GPIO I2C */
94	i2c {
95		compatible = "i2c-gpio";
96		sda-gpios = <&gpio0 15 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
97		scl-gpios = <&gpio0 16 (GPIO_ACTIVE_HIGH|GPIO_OPEN_DRAIN)>;
98		#address-cells = <1>;
99		#size-cells = <0>;
100
101		g751: temperature-sensor@48 {
102			compatible = "gmt,g751";
103			reg = <0x48>;
104			#thermal-sensor-cells = <0>;
105		};
106	};
107
108	thermal-zones {
109		chassis-thermal {
110			/* Poll every 20 seconds */
111			polling-delay = <20000>;
112			/* Poll every 2nd second when cooling */
113			polling-delay-passive = <2000>;
114
115			thermal-sensors = <&g751>;
116
117			/* Tripping points from the fan.script in the rootfs */
118			trips {
119				chassis_alert0: chassis-alert0 {
120					/* At 43 degrees turn on low speed */
121					temperature = <43000>;
122					hysteresis = <3000>;
123					type = "active";
124				};
125				chassis_alert1: chassis-alert1 {
126					/* At 47 degrees turn on high speed */
127					temperature = <47000>;
128					hysteresis = <3000>;
129					type = "active";
130				};
131				chassis_crit: chassis-crit {
132					/* Just shut down at 60 degrees */
133					temperature = <60000>;
134					hysteresis = <2000>;
135					type = "critical";
136				};
137			};
138
139			cooling-maps {
140				map0 {
141					trip = <&chassis_alert0>;
142					cooling-device = <&fan0 1 1>;
143				};
144				map1 {
145					trip = <&chassis_alert1>;
146					cooling-device = <&fan0 2 2>;
147				};
148			};
149		};
150	};
151
152	mdio0: mdio {
153		compatible = "virtual,mdio-gpio";
154		/* Uses MDC and MDIO */
155		gpios = <&gpio0 22 GPIO_ACTIVE_HIGH>, /* MDC */
156			<&gpio0 21 GPIO_ACTIVE_HIGH>; /* MDIO */
157		#address-cells = <1>;
158		#size-cells = <0>;
159
160		/* This is a Realtek RTL8211B Gigabit ethernet transceiver */
161		phy0: ethernet-phy@1 {
162			reg = <1>;
163			device_type = "ethernet-phy";
164		};
165	};
166
167	soc {
168		flash@30000000 {
169			/*
170			 * This is a Eon EN29LV400AB 512 KiB flash with
171			 * three partitions.
172			 */
173			compatible = "cortina,gemini-flash", "jedec-flash";
174			status = "okay";
175			reg = <0x30000000 0x00080000>;
176			#address-cells = <1>;
177			#size-cells = <1>;
178
179			/*
180			 * This "RedBoot" is the Storlink derivative.
181			 */
182			partition@0 {
183				label = "RedBoot";
184				reg = <0x00000000 0x00040000>;
185				read-only;
186			};
187			partition@40000 {
188				label = "MTD1";
189				reg = <0x00040000 0x00020000>;
190				read-only;
191			};
192			partition@60000 {
193				label = "MTD2";
194				reg = <0x00060000 0x00020000>;
195				read-only;
196			};
197		};
198
199		syscon: syscon@40000000 {
200			pinctrl {
201				/*
202				 */
203				gpio0_default_pins: pinctrl-gpio0 {
204					mux {
205						function = "gpio0";
206						groups =
207						/* Used by LEDs conflicts ICE */
208						"gpio0bgrp",
209						/* Used by ? conflicts ICE */
210						"gpio0cgrp",
211						/*
212						 * Used by fan & G751, conflicts LPC,
213						 * UART modem lines, SSP
214						 */
215						"gpio0egrp",
216						/* Used by G751 */
217						"gpio0fgrp",
218						/* Used by MDIO */
219						"gpio0igrp";
220					};
221				};
222				gpio1_default_pins: pinctrl-gpio1 {
223					mux {
224						function = "gpio1";
225						/* Used by "reset" button */
226						groups = "gpio1dgrp";
227					};
228				};
229				pinctrl-gmii {
230					mux {
231						function = "gmii";
232						groups = "gmii_gmac0_grp";
233					};
234					/*
235					 * In the vendor Linux tree, these values are set for the C3
236					 * version of the SL3512 ASIC with the comment "benson suggest"
237					 */
238					conf0 {
239						pins = "R8 GMAC0 RXDV", "U11 GMAC1 RXDV";
240						skew-delay = <0>;
241					};
242					conf1 {
243						pins = "T8 GMAC0 RXC";
244						skew-delay = <10>;
245					};
246					conf2 {
247						pins = "T11 GMAC1 RXC";
248						skew-delay = <15>;
249					};
250					conf3 {
251						pins = "P8 GMAC0 TXEN", "V11 GMAC1 TXEN";
252						skew-delay = <7>;
253					};
254					conf4 {
255						pins = "V7 GMAC0 TXC", "P10 GMAC1 TXC";
256						skew-delay = <10>;
257					};
258					conf5 {
259						/* The data lines all have default skew */
260						pins = "U8 GMAC0 RXD0", "V8 GMAC0 RXD1",
261						       "P9 GMAC0 RXD2", "R9 GMAC0 RXD3",
262						       "R11 GMAC1 RXD0", "P11 GMAC1 RXD1",
263						       "V12 GMAC1 RXD2", "U12 GMAC1 RXD3",
264						       "R10 GMAC1 TXD0", "T10 GMAC1 TXD1",
265						       "U10 GMAC1 TXD2", "V10 GMAC1 TXD3";
266						skew-delay = <7>;
267					};
268					conf6 {
269						pins = "U7 GMAC0 TXD0", "T7 GMAC0 TXD1",
270						       "R7 GMAC0 TXD2", "P7 GMAC0 TXD3";
271						skew-delay = <5>;
272					};
273					/* Set up drive strength on GMAC0 to 16 mA */
274					conf7 {
275						groups = "gmii_gmac0_grp";
276						drive-strength = <16>;
277					};
278				};
279			};
280		};
281
282		sata: sata@46000000 {
283			/* The ROM uses this muxmode */
284			cortina,gemini-ata-muxmode = <0>;
285			cortina,gemini-enable-sata-bridge;
286			status = "okay";
287		};
288
289		gpio0: gpio@4d000000 {
290			pinctrl-names = "default";
291			pinctrl-0 = <&gpio0_default_pins>;
292		};
293
294		gpio1: gpio@4e000000 {
295			pinctrl-names = "default";
296			pinctrl-0 = <&gpio1_default_pins>;
297		};
298
299		ethernet@60000000 {
300			status = "okay";
301
302			ethernet-port@0 {
303				phy-mode = "rgmii";
304				phy-handle = <&phy0>;
305			};
306			ethernet-port@1 {
307				/* Not used in this platform */
308			};
309		};
310
311		ide@63000000 {
312			status = "okay";
313		};
314
315		usb@69000000 {
316			status = "okay";
317			dr_mode = "peripheral";
318			usb-phy = <&usb1_phy>;
319			pinctrl-names = "default";
320			pinctrl-0 = <&usb_default_pins>;
321		};
322	};
323};
324