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