1/*
2 * Copyright (c) 2017 Fuzhou Rockchip Electronics Co., Ltd.
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-sapphire.dtsi"
45
46/ {
47	model = "Excavator-RK3399 Board";
48	compatible = "rockchip,rk3399-sapphire-excavator", "rockchip,rk3399";
49
50	adc-keys {
51		compatible = "adc-keys";
52		io-channels = <&saradc 1>;
53		io-channel-names = "buttons";
54		keyup-threshold-microvolt = <1800000>;
55		poll-interval = <100>;
56
57		button-up {
58			label = "Volume Up";
59			linux,code = <KEY_VOLUMEUP>;
60			press-threshold-microvolt = <100000>;
61		};
62
63		button-down {
64			label = "Volume Down";
65			linux,code = <KEY_VOLUMEDOWN>;
66			press-threshold-microvolt = <300000>;
67		};
68
69		back {
70			label = "Back";
71			linux,code = <KEY_BACK>;
72			press-threshold-microvolt = <985000>;
73		};
74
75		menu {
76			label = "Menu";
77			linux,code = <KEY_MENU>;
78			press-threshold-microvolt = <1314000>;
79		};
80	};
81
82	edp_panel: edp-panel {
83		compatible ="lg,lp079qx1-sp0v", "simple-panel";
84		backlight = <&backlight>;
85		enable-gpios = <&gpio4 RK_PC6 GPIO_ACTIVE_HIGH>;
86		pinctrl-names = "default";
87		pinctrl-0 = <&lcd_panel_reset>;
88		power-supply = <&vcc3v3_s0>;
89
90		ports {
91			panel_in_edp: endpoint {
92				remote-endpoint = <&edp_out_panel>;
93			};
94		};
95	};
96
97	rt5651-sound {
98		compatible = "simple-audio-card";
99		simple-audio-card,name = "realtek,rt5651-codec";
100		simple-audio-card,format = "i2s";
101		simple-audio-card,mclk-fs = <256>;
102		simple-audio-card,widgets =
103			"Microphone", "Mic Jack",
104			"Headphone", "Headphone Jack";
105		simple-audio-card,routing =
106			"Mic Jack", "MICBIAS1",
107			"IN1P", "Mic Jack",
108			"Headphone Jack", "HPOL",
109			"Headphone Jack", "HPOR";
110		simple-audio-card,cpu {
111			sound-dai = <&i2s0>;
112		};
113		simple-audio-card,codec {
114			sound-dai = <&rt5651>;
115		};
116	};
117
118	sdio_pwrseq: sdio-pwrseq {
119		compatible = "mmc-pwrseq-simple";
120		clocks = <&rk808 1>;
121		clock-names = "ext_clock";
122		pinctrl-names = "default";
123		pinctrl-0 = <&wifi_enable_h>;
124
125		/*
126		 * On the module itself this is one of these (depending
127		 * on the actual card populated):
128		 * - SDIO_RESET_L_WL_REG_ON
129		 * - PDN (power down when low)
130		 */
131		reset-gpios = <&gpio0 RK_PB2 GPIO_ACTIVE_LOW>;
132	};
133};
134
135&backlight {
136	enable-gpios = <&gpio1 RK_PB5 GPIO_ACTIVE_HIGH>;
137	status = "okay";
138};
139
140&edp {
141	status = "okay";
142
143	ports {
144		edp_out: port@1 {
145			reg = <1>;
146			#address-cells = <1>;
147			#size-cells = <0>;
148
149			edp_out_panel: endpoint@0 {
150				reg = <0>;
151				remote-endpoint = <&panel_in_edp>;
152			};
153		};
154	};
155};
156
157&i2c1 {
158	i2c-scl-rising-time-ns = <300>;
159	i2c-scl-falling-time-ns = <15>;
160	status = "okay";
161
162	rt5651: rt5651@1a {
163		compatible = "rockchip,rt5651";
164		reg = <0x1a>;
165		clocks = <&cru SCLK_I2S_8CH_OUT>;
166		clock-names = "mclk";
167		hp-det-gpio = <&gpio4 RK_PC4 GPIO_ACTIVE_LOW>;
168		spk-con-gpio = <&gpio0 RK_PB3 GPIO_ACTIVE_HIGH>;
169		#sound-dai-cells = <0>;
170	};
171};
172
173&i2c4 {
174	i2c-scl-rising-time-ns = <600>;
175	i2c-scl-falling-time-ns = <20>;
176	status = "okay";
177
178	accelerometer@68 {
179		compatible = "invensense,mpu6500";
180		reg = <0x68>;
181		interrupt-parent = <&gpio1>;
182		interrupts = <RK_PC6 IRQ_TYPE_EDGE_RISING>;
183	};
184};
185
186&i2s0 {
187	rockchip,playback-channels = <8>;
188	rockchip,capture-channels = <8>;
189	#sound-dai-cells = <0>;
190	status = "okay";
191};
192
193&pcie_phy {
194	status = "okay";
195};
196
197&pcie0 {
198	ep-gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_HIGH>;
199	num-lanes = <4>;
200	pinctrl-names = "default";
201	pinctrl-0 = <&pcie_clkreqn_cpm>;
202	status = "okay";
203};
204
205&pinctrl {
206	sdio-pwrseq {
207		wifi_enable_h: wifi-enable-h {
208			rockchip,pins = <0 RK_PB2 RK_FUNC_GPIO &pcfg_pull_none>;
209		};
210	};
211
212	lcd-panel {
213		lcd_panel_reset: lcd-panel-reset {
214			rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
215		};
216	};
217};
218
219&sdio0 {
220	bus-width = <4>;
221	cap-sd-highspeed;
222	cap-sdio-irq;
223	clock-frequency = <50000000>;
224	disable-wp;
225	keep-power-in-suspend;
226	max-frequency = <50000000>;
227	mmc-pwrseq = <&sdio_pwrseq>;
228	non-removable;
229	pinctrl-names = "default";
230	pinctrl-0 = <&sdio0_bus4 &sdio0_cmd &sdio0_clk>;
231	sd-uhs-sdr104;
232	status = "okay";
233};
234
235&spdif {
236	i2c-scl-rising-time-ns = <450>;
237	i2c-scl-falling-time-ns = <15>;
238	#sound-dai-cells = <0>;
239	status = "okay";
240};
241