1/*
2 * Device Tree file for SolidRun Clearfog revision A1 rev 2.0 (88F6828)
3 *
4 *  Copyright (C) 2015 Russell King
5 *
6 * This board is in development; the contents of this file work with
7 * the A1 rev 2.0 of the board, which does not represent final
8 * production board.  Things will change, don't expect this file to
9 * remain compatible info the future.
10 *
11 * This file is dual-licensed: you can use it either under the terms
12 * of the GPL or the X11 license, at your option. Note that this dual
13 * licensing only applies to this file, and not this project as a
14 * whole.
15 *
16 *  a) This file is free software; you can redistribute it and/or
17 *     modify it under the terms of the GNU General Public License
18 *     version 2 as published by the Free Software Foundation.
19 *
20 *     This file is distributed in the hope that it will be useful
21 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
22 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 *     GNU General Public License for more details.
24 *
25 * Or, alternatively
26 *
27 *  b) Permission is hereby granted, free of charge, to any person
28 *     obtaining a copy of this software and associated documentation
29 *     files (the "Software"), to deal in the Software without
30 *     restriction, including without limitation the rights to use
31 *     copy, modify, merge, publish, distribute, sublicense, and/or
32 *     sell copies of the Software, and to permit persons to whom the
33 *     Software is furnished to do so, subject to the following
34 *     conditions:
35 *
36 *     The above copyright notice and this permission notice shall be
37 *     included in all copies or substantial portions of the Software.
38 *
39 *     THE SOFTWARE IS PROVIDED , WITHOUT WARRANTY OF ANY KIND
40 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
41 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
42 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
43 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY
44 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
45 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
46 *     OTHER DEALINGS IN THE SOFTWARE.
47 */
48
49/dts-v1/;
50#include <dt-bindings/input/input.h>
51#include <dt-bindings/gpio/gpio.h>
52#include "armada-388.dtsi"
53
54/ {
55	model = "SolidRun Clearfog A1";
56	compatible = "solidrun,clearfog-a1", "marvell,armada388",
57		"marvell,armada385", "marvell,armada380";
58
59	aliases {
60		/* So that mvebu u-boot can update the MAC addresses */
61		ethernet1 = &eth0;
62		ethernet2 = &eth1;
63		ethernet3 = &eth2;
64		spi1 = &spi1;
65		i2c0 = &i2c0;
66		i2c1 = &i2c1;
67	};
68
69	chosen {
70		stdout-path = "serial0:115200n8";
71	};
72
73	memory {
74		device_type = "memory";
75		reg = <0x00000000 0x10000000>; /* 256 MB */
76	};
77
78	reg_3p3v: regulator-3p3v {
79		compatible = "regulator-fixed";
80		regulator-name = "3P3V";
81		regulator-min-microvolt = <3300000>;
82		regulator-max-microvolt = <3300000>;
83		regulator-always-on;
84	};
85
86	soc {
87		ranges = <MBUS_ID(0xf0, 0x01) 0 0xf1000000 0x100000
88			  MBUS_ID(0x01, 0x1d) 0 0xfff00000 0x100000
89			  MBUS_ID(0x09, 0x19) 0 0xf1100000 0x10000
90			  MBUS_ID(0x09, 0x15) 0 0xf1110000 0x10000>;
91
92		internal-regs {
93			ethernet@30000 {
94				mac-address = [00 50 43 02 02 02];
95				phy-mode = "sgmii";
96				status = "okay";
97
98				fixed-link {
99					speed = <1000>;
100					full-duplex;
101				};
102			};
103
104			ethernet@34000 {
105				mac-address = [00 50 43 02 02 03];
106				managed = "in-band-status";
107				phy-mode = "sgmii";
108				status = "okay";
109			};
110
111			ethernet@70000 {
112				mac-address = [00 50 43 02 02 01];
113				pinctrl-0 = <&ge0_rgmii_pins>;
114				pinctrl-names = "default";
115				phy = <&phy_dedicated>;
116				phy-mode = "rgmii-id";
117				status = "okay";
118			};
119
120			i2c@11000 {
121				/* Is there anything on this? */
122				clock-frequency = <100000>;
123				pinctrl-0 = <&i2c0_pins>;
124				pinctrl-names = "default";
125				status = "okay";
126
127				/*
128				 * PCA9655 GPIO expander, up to 1MHz clock.
129				 *  0-CON3 CLKREQ#
130				 *  1-CON3 PERST#
131				 *  2-CON2 PERST#
132				 *  3-CON3 W_DISABLE
133				 *  4-CON2 CLKREQ#
134				 *  5-USB3 overcurrent
135				 *  6-USB3 power
136				 *  7-CON2 W_DISABLE
137				 *  8-JP4 P1
138				 *  9-JP4 P4
139				 * 10-JP4 P5
140				 * 11-m.2 DEVSLP
141				 * 12-SFP_LOS
142				 * 13-SFP_TX_FAULT
143				 * 14-SFP_TX_DISABLE
144				 * 15-SFP_MOD_DEF0
145				 */
146				expander0: gpio-expander@20 {
147					/*
148					 * This is how it should be:
149					 * compatible = "onnn,pca9655",
150					 *	 "nxp,pca9555";
151					 * but you can't do this because of
152					 * the way I2C works.
153					 */
154					compatible = "nxp,pca9555";
155					gpio-controller;
156					#gpio-cells = <2>;
157					reg = <0x20>;
158
159					pcie1_0_clkreq {
160						gpio-hog;
161						gpios = <0 GPIO_ACTIVE_LOW>;
162						input;
163						line-name = "pcie1.0-clkreq";
164					};
165					pcie1_0_w_disable {
166						gpio-hog;
167						gpios = <3 GPIO_ACTIVE_LOW>;
168						output-low;
169						line-name = "pcie1.0-w-disable";
170					};
171					pcie2_0_clkreq {
172						gpio-hog;
173						gpios = <4 GPIO_ACTIVE_LOW>;
174						input;
175						line-name = "pcie2.0-clkreq";
176					};
177					pcie2_0_w_disable {
178						gpio-hog;
179						gpios = <7 GPIO_ACTIVE_LOW>;
180						output-low;
181						line-name = "pcie2.0-w-disable";
182					};
183					usb3_ilimit {
184						gpio-hog;
185						gpios = <5 GPIO_ACTIVE_LOW>;
186						input;
187						line-name = "usb3-current-limit";
188					};
189					usb3_power {
190						gpio-hog;
191						gpios = <6 GPIO_ACTIVE_HIGH>;
192						output-high;
193						line-name = "usb3-power";
194					};
195					m2_devslp {
196						gpio-hog;
197						gpios = <11 GPIO_ACTIVE_HIGH>;
198						output-low;
199						line-name = "m.2 devslp";
200					};
201				};
202
203				/* The MCP3021 is 100kHz clock only */
204				mikrobus_adc: mcp3021@4c {
205					compatible = "microchip,mcp3021";
206					reg = <0x4c>;
207				};
208
209				/* Also something at 0x64 */
210			};
211
212			i2c@11100 {
213				/*
214				 * Routed to SFP, mikrobus, and PCIe.
215				 * SFP limits this to 100kHz, and requires
216				 *  an AT24C01A/02/04 with address pins tied
217				 *  low, which takes addresses 0x50 and 0x51.
218				 * Mikrobus doesn't specify beyond an I2C
219				 *  bus being present.
220				 * PCIe uses ARP to assign addresses, or
221				 *  0x63-0x64.
222				 */
223				clock-frequency = <100000>;
224				pinctrl-0 = <&clearfog_i2c1_pins>;
225				pinctrl-names = "default";
226				status = "okay";
227			};
228
229			mdio@72004 {
230				pinctrl-0 = <&mdio_pins>;
231				pinctrl-names = "default";
232
233				phy_dedicated: ethernet-phy@0 {
234					/*
235					 * Annoyingly, the marvell phy driver
236					 * configures the LED register, rather
237					 * than preserving reset-loaded setting.
238					 * We undo that rubbish here.
239					 */
240					marvell,reg-init = <3 16 0 0x101e>;
241					reg = <0>;
242				};
243			};
244
245			pinctrl@18000 {
246				clearfog_dsa0_clk_pins: clearfog-dsa0-clk-pins {
247					marvell,pins = "mpp46";
248					marvell,function = "ref";
249				};
250				clearfog_dsa0_pins: clearfog-dsa0-pins {
251					marvell,pins = "mpp23", "mpp41";
252					marvell,function = "gpio";
253				};
254				clearfog_i2c1_pins: i2c1-pins {
255					/* SFP, PCIe, mSATA, mikrobus */
256					marvell,pins = "mpp26", "mpp27";
257					marvell,function = "i2c1";
258				};
259				clearfog_sdhci_cd_pins: clearfog-sdhci-cd-pins {
260					marvell,pins = "mpp20";
261					marvell,function = "gpio";
262				};
263				clearfog_sdhci_pins: clearfog-sdhci-pins {
264					marvell,pins = "mpp21", "mpp28",
265						       "mpp37", "mpp38",
266						       "mpp39", "mpp40";
267					marvell,function = "sd0";
268				};
269				clearfog_spi1_cs_pins: spi1-cs-pins {
270					marvell,pins = "mpp55";
271					marvell,function = "spi1";
272				};
273				mikro_pins: mikro-pins {
274					/* int: mpp22 rst: mpp29 */
275					marvell,pins = "mpp22", "mpp29";
276					marvell,function = "gpio";
277				};
278				mikro_spi_pins: mikro-spi-pins {
279					marvell,pins = "mpp43";
280					marvell,function = "spi1";
281				};
282				mikro_uart_pins: mikro-uart-pins {
283					marvell,pins = "mpp24", "mpp25";
284					marvell,function = "ua1";
285				};
286				rear_button_pins: rear-button-pins {
287					marvell,pins = "mpp34";
288					marvell,function = "gpio";
289				};
290			};
291
292			rtc@a3800 {
293				/*
294				 * If the rtc doesn't work, run "date reset"
295				 * twice in u-boot.
296				 */
297				status = "okay";
298			};
299
300			sata@a8000 {
301				/* pinctrl? */
302				status = "okay";
303			};
304
305			sata@e0000 {
306				/* pinctrl? */
307				status = "okay";
308			};
309
310			sdhci@d8000 {
311				bus-width = <4>;
312				cd-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
313				no-1-8-v;
314				pinctrl-0 = <&clearfog_sdhci_pins
315					     &clearfog_sdhci_cd_pins>;
316				pinctrl-names = "default";
317				status = "okay";
318				vmmc = <&reg_3p3v>;
319				wp-inverted;
320			};
321
322			serial@12000 {
323				pinctrl-0 = <&uart0_pins>;
324				pinctrl-names = "default";
325				status = "okay";
326				u-boot,dm-pre-reloc;
327			};
328
329			serial@12100 {
330				/* mikrobus uart */
331				pinctrl-0 = <&mikro_uart_pins>;
332				pinctrl-names = "default";
333				status = "okay";
334			};
335
336			spi1: spi@10680 {
337				/*
338				 * CS0: W25Q32
339				 * CS1:
340				 * CS2: mikrobus
341				 */
342				pinctrl-0 = <&spi1_pins &clearfog_spi1_cs_pins &mikro_spi_pins>;
343				pinctrl-names = "default";
344				status = "okay";
345
346				spi-flash@0 {
347					#address-cells = <1>;
348					#size-cells = <0>;
349					compatible = "w25q32", "jedec,spi-nor", "spi-flash";
350					reg = <0>; /* Chip select 0 */
351					spi-max-frequency = <3000000>;
352				};
353			};
354
355			usb3@f8000 {
356				status = "okay";
357			};
358		};
359
360		pcie-controller {
361			status = "okay";
362			/*
363			 * The two PCIe units are accessible through
364			 * the mini-PCIe connectors on the board.
365			 */
366			pcie@2,0 {
367				/* Port 1, Lane 0. CONN3, nearest power. */
368				reset-gpios = <&expander0 1 GPIO_ACTIVE_LOW>;
369				status = "okay";
370			};
371			pcie@3,0 {
372				/* Port 2, Lane 0. CONN2, nearest CPU. */
373				reset-gpios = <&expander0 2 GPIO_ACTIVE_LOW>;
374				status = "okay";
375			};
376		};
377	};
378
379	sfp: sfp {
380		compatible = "sff,sfp";
381		i2c-bus = <&i2c1>;
382		los-gpio = <&expander0 12 GPIO_ACTIVE_HIGH>;
383		moddef0-gpio = <&expander0 15 GPIO_ACTIVE_LOW>;
384		sfp,ethernet = <&eth2>;
385		tx-disable-gpio = <&expander0 14 GPIO_ACTIVE_HIGH>;
386		tx-fault-gpio = <&expander0 13 GPIO_ACTIVE_HIGH>;
387	};
388
389	dsa@0 {
390		compatible = "marvell,dsa";
391		dsa,ethernet = <&eth1>;
392		dsa,mii-bus = <&mdio>;
393		pinctrl-0 = <&clearfog_dsa0_clk_pins &clearfog_dsa0_pins>;
394		pinctrl-names = "default";
395		#address-cells = <2>;
396		#size-cells = <0>;
397
398		switch@0 {
399			#address-cells = <1>;
400			#size-cells = <0>;
401			reg = <4 0>;
402
403			port@0 {
404				reg = <0>;
405				label = "lan1";
406			};
407
408			port@1 {
409				reg = <1>;
410				label = "lan2";
411			};
412
413			port@2 {
414				reg = <2>;
415				label = "lan3";
416			};
417
418			port@3 {
419				reg = <3>;
420				label = "lan4";
421			};
422
423			port@4 {
424				reg = <4>;
425				label = "lan5";
426			};
427
428			port@5 {
429				reg = <5>;
430				label = "cpu";
431			};
432
433			port@6 {
434				/* 88E1512 external phy */
435				reg = <6>;
436				label = "lan6";
437				fixed-link {
438					speed = <1000>;
439					full-duplex;
440				};
441			};
442		};
443	};
444
445	gpio-keys {
446		compatible = "gpio-keys";
447		pinctrl-0 = <&rear_button_pins>;
448		pinctrl-names = "default";
449
450		button_0 {
451			/* The rear SW3 button */
452			label = "Rear Button";
453			gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;
454			linux,can-disable;
455			linux,code = <BTN_0>;
456		};
457	};
458};
459
460/*
461+#define A38x_CUSTOMER_BOARD_1_MPP16_23         0x00400011
462MPP18: gpio		? (pca9655 int?)
463MPP19: gpio		? (clkreq?)
464MPP20: gpio		? (sd0 detect)
465MPP21: sd0:cmd		x sd0
466MPP22: gpio		x mikro int
467MPP23: gpio		x switch irq
468+#define A38x_CUSTOMER_BOARD_1_MPP24_31         0x22043333
469MPP24: ua1:rxd		x mikro rx
470MPP25: ua1:txd		x mikro tx
471MPP26: i2c1:sck		x mikro sck
472MPP27: i2c1:sda		x mikro sda
473MPP28: sd0:clk		x sd0
474MPP29: gpio		x mikro rst
475MPP30: ge1:txd2		? (config)
476MPP31: ge1:txd3		? (config)
477+#define A38x_CUSTOMER_BOARD_1_MPP32_39         0x44400002
478MPP32: ge1:txctl	? (unused)
479MPP33: gpio		? (pic_com0)
480MPP34: gpio		x rear button (pic_com1)
481MPP35: gpio		? (pic_com2)
482MPP36: gpio		? (unused)
483MPP37: sd0:d3		x sd0
484MPP38: sd0:d0		x sd0
485MPP39: sd0:d1		x sd0
486+#define A38x_CUSTOMER_BOARD_1_MPP40_47         0x41144004
487MPP40: sd0:d2		x sd0
488MPP41: gpio		x switch reset
489MPP42: gpio		? sw1-1
490MPP43: spi1:cs2		x mikro cs
491MPP44: sata3:prsnt	? (unused)
492MPP45: ref:clk_out0	?
493MPP46: ref:clk_out1	x switch clk
494MPP47: 4		? (unused)
495+#define A38x_CUSTOMER_BOARD_1_MPP48_55         0x40333333
496MPP48: tdm:pclk
497MPP49: tdm:fsync
498MPP50: tdm:drx
499MPP51: tdm:dtx
500MPP52: tdm:int
501MPP53: tdm:rst
502MPP54: gpio		? (pwm)
503MPP55: spi1:cs1		x slic
504+#define A38x_CUSTOMER_BOARD_1_MPP56_63         0x00004444
505MPP56: spi1:mosi	x mikro mosi
506MPP57: spi1:sck		x mikro sck
507MPP58: spi1:miso	x mikro miso
508MPP59: spi1:cs0		x w25q32
509*/
510