1/*
2 * Copyright (c) 2017 Theobroma Systems Design und Consulting GmbH
3 *
4 * This file is dual-licensed: you can use it either under the terms
5 * of the GPL or the X11 license, at your option. Note that this dual
6 * licensing only applies to this file, and not this project as a
7 * whole.
8 *
9 *  a) This file is free software; you can redistribute it and/or
10 *     modify it under the terms of the GNU General Public License as
11 *     published by the Free Software Foundation; either version 2 of the
12 *     License, or (at your option) any later version.
13 *
14 *     This file is distributed in the hope that it will be useful,
15 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *     GNU General Public License for more details.
18 *
19 * Or, alternatively,
20 *
21 *  b) Permission is hereby granted, free of charge, to any person
22 *     obtaining a copy of this software and associated documentation
23 *     files (the "Software"), to deal in the Software without
24 *     restriction, including without limitation the rights to use,
25 *     copy, modify, merge, publish, distribute, sublicense, and/or
26 *     sell copies of the Software, and to permit persons to whom the
27 *     Software is furnished to do so, subject to the following
28 *     conditions:
29 *
30 *     The above copyright notice and this permission notice shall be
31 *     included in all copies or substantial portions of the Software.
32 *
33 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
34 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
35 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
36 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
37 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
38 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
39 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
40 *     OTHER DEALINGS IN THE SOFTWARE.
41 */
42
43/dts-v1/;
44#include "rk3399-puma.dtsi"
45
46/ {
47	model = "Theobroma Systems RK3399-Q7 SoM";
48	compatible = "tsd,rk3399-puma-haikou", "rockchip,rk3399";
49
50	chosen {
51		stdout-path = "serial0:115200n8";
52	};
53
54	leds {
55		pinctrl-0 = <&led_pin_module>, <&led_sd_haikou>;
56
57		sd-card-led {
58			label = "sd_card_led";
59			gpios = <&gpio1 RK_PA2 GPIO_ACTIVE_HIGH>;
60			linux,default-trigger = "mmc0";
61		};
62	};
63
64	i2s0-sound {
65		compatible = "simple-audio-card";
66		simple-audio-card,format = "i2s";
67		simple-audio-card,name = "Haikou,I2S-codec";
68		simple-audio-card,mclk-fs = <512>;
69
70		simple-audio-card,codec {
71			clocks = <&sgtl5000_clk>;
72			sound-dai = <&sgtl5000>;
73		};
74
75		simple-audio-card,cpu {
76			bitclock-master;
77			frame-master;
78			sound-dai = <&i2s0>;
79		};
80	};
81
82	sgtl5000_clk: sgtl5000-oscillator  {
83			compatible = "fixed-clock";
84			#clock-cells = <0>;
85			clock-frequency  = <24576000>;
86	};
87
88	dc_12v: dc-12v {
89		compatible = "regulator-fixed";
90		regulator-name = "dc_12v";
91		regulator-always-on;
92		regulator-boot-on;
93		regulator-min-microvolt = <12000000>;
94		regulator-max-microvolt = <12000000>;
95	};
96
97	vcc3v3_baseboard: vcc3v3-baseboard {
98		compatible = "regulator-fixed";
99		regulator-name = "vcc3v3_baseboard";
100		regulator-always-on;
101		regulator-boot-on;
102		regulator-min-microvolt = <3300000>;
103		regulator-max-microvolt = <3300000>;
104		vin-supply = <&dc_12v>;
105	};
106
107	vcc5v0_baseboard: vcc5v0-baseboard {
108		compatible = "regulator-fixed";
109		regulator-name = "vcc5v0_baseboard";
110		regulator-always-on;
111		regulator-boot-on;
112		regulator-min-microvolt = <5000000>;
113		regulator-max-microvolt = <5000000>;
114		vin-supply = <&dc_12v>;
115	};
116
117	vcc5v0_otg: vcc5v0-otg-regulator {
118		compatible = "regulator-fixed";
119		enable-active-high;
120		gpio = <&gpio0 RK_PA2 GPIO_ACTIVE_HIGH>;
121		pinctrl-names = "default";
122		pinctrl-0 = <&otg_vbus_drv>;
123		regulator-name = "vcc5v0_otg";
124		regulator-always-on;
125	};
126
127	vdda_codec: vdda-codec {
128		compatible = "regulator-fixed";
129		regulator-name = "vdda_codec";
130		regulator-boot-on;
131		regulator-min-microvolt = <3300000>;
132		regulator-max-microvolt = <3300000>;
133		vin-supply = <&vcc5v0_baseboard>;
134	};
135
136	vddd_codec: vddd-codec {
137		compatible = "regulator-fixed";
138		regulator-name = "vddd_codec";
139		regulator-boot-on;
140		regulator-min-microvolt = <1600000>;
141		regulator-max-microvolt = <1600000>;
142		vin-supply = <&vcc5v0_baseboard>;
143	};
144};
145
146&hdmi {
147	ddc-i2c-bus = <&i2c3>;
148	status = "okay";
149};
150
151&i2c1 {
152	status = "okay";
153	clock-frequency = <400000>;
154};
155
156&i2c2 {
157	status = "okay";
158	clock-frequency = <400000>;
159};
160
161&i2c3 {
162	i2c-scl-rising-time-ns = <450>;
163	i2c-scl-falling-time-ns = <15>;
164	status = "okay";
165};
166
167&i2c4 {
168	status = "okay";
169	clock-frequency = <400000>;
170
171	sgtl5000: codec@0a {
172		compatible = "fsl,sgtl5000";
173		reg = <0x0a>;
174		clocks = <&sgtl5000_clk>;
175		#sound-dai-cells = <0>;
176		VDDA-supply = <&vdda_codec>;
177		VDDIO-supply = <&vdda_codec>;
178		VDDD-supply = <&vddd_codec>;
179		status = "okay";
180	};
181};
182
183&i2c6 {
184	status = "okay";
185	clock-frequency = <400000>;
186};
187
188&pcie_phy {
189	status = "okay";
190};
191
192&pcie0 {
193	ep-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_LOW>;
194	num-lanes = <4>;
195	pinctrl-names = "default";
196	pinctrl-0 = <&pcie_clkreqn_cpm>;
197	status = "okay";
198};
199
200&pinctrl {
201	pinctrl-names = "default";
202	pinctrl-0 = <&haikou_pin_hog>;
203
204	hog {
205		haikou_pin_hog: haikou-pin-hog {
206			rockchip,pins =
207			  /* LID_BTN */
208			  <RK_GPIO0 RK_PA4 RK_FUNC_GPIO &pcfg_pull_up>,
209			  /* BATLOW# */
210			  <RK_GPIO0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_up>,
211			  /* SLP_BTN# */
212			  <RK_GPIO0 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>,
213			  /* BIOS_DISABLE# */
214			  <RK_GPIO0 RK_PB1 RK_FUNC_GPIO &pcfg_pull_up>;
215		};
216	};
217
218	leds {
219		led_sd_haikou: led-sd-gpio {
220			rockchip,pins =
221			  <RK_GPIO1 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
222		};
223	};
224
225	usb2 {
226		otg_vbus_drv: otg-vbus-drv {
227			rockchip,pins =
228			  <RK_GPIO0 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
229		};
230	};
231};
232
233&pwm0 {
234	status = "okay";
235};
236
237&sdmmc {
238	bus-width = <4>;
239	cap-mmc-highspeed;
240	cap-sd-highspeed;
241	cd-gpios = <&gpio0 RK_PA7 GPIO_ACTIVE_LOW>;
242	disable-wp;
243	max-frequency = <150000000>;
244	pinctrl-names = "default";
245	pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
246	vmmc-supply = <&vcc3v3_baseboard>;
247	status = "okay";
248};
249
250&spi5 {
251	status = "okay";
252};
253
254&tcphy0 {
255	status = "okay";
256};
257
258&u2phy0 {
259	status = "okay";
260};
261
262&usbdrd3_0 {
263	status = "okay";
264};
265
266&usbdrd_dwc3_0 {
267	dr_mode = "otg";
268	status = "okay";
269};
270
271&u2phy0_host {
272	phy-supply = <&vcc5v0_otg>;
273	status = "okay";
274};
275
276&uart0 {
277	pinctrl-names = "default";
278	pinctrl-0 = <&uart0_xfer &uart0_cts &uart0_rts>;
279	status = "okay";
280};
281
282&uart2 {
283	status = "okay";
284};
285
286&usb_host0_ehci {
287	status = "okay";
288};
289
290&usb_host0_ohci {
291	status = "okay";
292};
293
294&vopb {
295	status = "okay";
296};
297
298&vopb_mmu {
299	status = "okay";
300};
301
302&vopl {
303	status = "okay";
304};
305
306&vopl_mmu {
307	status = "okay";
308};
309