Merge tag 'csky-for-linus-4.20-fixup-dtb' of https://github.com/c-sky/csky-linux
[linux-block.git] / arch / arm / boot / dts / da850-lego-ev3.dts
CommitLineData
4302a38e
DL
1/*
2 * Device tree for LEGO MINDSTORMS EV3
3 *
4 * Copyright (C) 2017 David Lechner <david@lechnology.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, version 2.
9 */
10
11/dts-v1/;
12#include <dt-bindings/gpio/gpio.h>
13#include <dt-bindings/input/linux-event-codes.h>
14#include <dt-bindings/pwm/pwm.h>
15
16#include "da850.dtsi"
17
18/ {
19 compatible = "lego,ev3", "ti,da850";
20 model = "LEGO MINDSTORMS EV3";
21
22 aliases {
23 serial1 = &serial1;
24 };
25
26 memory@c0000000 {
27 device_type = "memory";
28 reg = <0xc0000000 0x04000000>;
29 };
30
31 /*
32 * The buttons on the EV3 are mapped to keyboard keys.
33 */
34 gpio_keys {
35 compatible = "gpio-keys";
4302a38e
DL
36 label = "EV3 Brick Buttons";
37 pinctrl-names = "default";
d1f94959 38 pinctrl-0 = <&button_bias>;
4302a38e
DL
39
40 center {
41 label = "Center";
42 linux,code = <KEY_ENTER>;
43 gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
44 };
45
46 left {
47 label = "Left";
48 linux,code = <KEY_LEFT>;
49 gpios = <&gpio 102 GPIO_ACTIVE_HIGH>;
50 };
51
52 back {
53 label = "Back";
54 linux,code = <KEY_BACKSPACE>;
55 gpios = <&gpio 106 GPIO_ACTIVE_HIGH>;
56 };
57
58 right {
59 label = "Right";
60 linux,code = <KEY_RIGHT>;
61 gpios = <&gpio 124 GPIO_ACTIVE_HIGH>;
62 };
63
64 down {
65 label = "Down";
66 linux,code = <KEY_DOWN>;
67 gpios = <&gpio 126 GPIO_ACTIVE_HIGH>;
68 };
69
70 up {
71 label = "Up";
72 linux,code = <KEY_UP>;
73 gpios = <&gpio 127 GPIO_ACTIVE_HIGH>;
74 };
75 };
76
77 /*
78 * The EV3 has two built-in bi-color LEDs behind the buttons.
79 */
80 leds {
81 compatible = "gpio-leds";
4302a38e
DL
82
83 left_green {
84 label = "led0:green:brick-status";
85 /* GP6[13] */
86 gpios = <&gpio 103 GPIO_ACTIVE_HIGH>;
87 linux,default-trigger = "default-on";
88 };
89
90 right_red {
91 label = "led1:red:brick-status";
92 /* GP6[7] */
93 gpios = <&gpio 108 GPIO_ACTIVE_HIGH>;
94 linux,default-trigger = "default-on";
95 };
96
97 left_red {
98 label = "led0:red:brick-status";
99 /* GP6[12] */
100 gpios = <&gpio 109 GPIO_ACTIVE_HIGH>;
101 linux,default-trigger = "default-on";
102 };
103
104 right_green {
105 label = "led1:green:brick-status";
106 /* GP6[14] */
107 gpios = <&gpio 110 GPIO_ACTIVE_HIGH>;
108 linux,default-trigger = "default-on";
109 };
110 };
111
112 /*
113 * The EV3 is powered down by turning off the main 5V supply.
114 */
115 gpio-poweroff {
116 compatible = "gpio-poweroff";
117 gpios = <&gpio 107 GPIO_ACTIVE_LOW>;
4302a38e
DL
118 };
119
7723d70b
DL
120 sound {
121 compatible = "pwm-beeper";
122 pinctrl-names = "default";
123 pinctrl-0 = <&ehrpwm0b_pins>;
124 pwms = <&ehrpwm0 1 1000000 0>;
125 amp-supply = <&amp>;
126 };
127
4302a38e
DL
128 /*
129 * This is a 5V current limiting regulator that is shared by USB,
130 * the sensor (input) ports, the motor (output) ports and the A/DC.
131 */
132 vcc5v: regulator1 {
4302a38e
DL
133 compatible = "regulator-fixed";
134 regulator-name = "vcc5v";
135 regulator-min-microvolt = <5000000>;
136 regulator-max-microvolt = <5000000>;
137 gpio = <&gpio 101 0>;
138 over-current-gpios = <&gpio 99 GPIO_ACTIVE_LOW>;
139 enable-active-high;
140 regulator-boot-on;
141 };
8a81ff17
DL
142
143 /*
144 * This is a simple voltage divider on VCC5V to provide a 2.5V
145 * reference signal to the ADC.
146 */
147 adc_ref: regulator2 {
148 compatible = "regulator-fixed";
149 regulator-name = "adc ref";
150 regulator-min-microvolt = <2500000>;
151 regulator-max-microvolt = <2500000>;
152 regulator-boot-on;
153 vin-supply = <&vcc5v>;
154 };
7723d70b
DL
155
156 /*
157 * This is the amplifier for the speaker.
158 */
159 amp: regulator3 {
7723d70b
DL
160 compatible = "regulator-fixed";
161 regulator-name = "amp";
162 gpio = <&gpio 111 GPIO_ACTIVE_HIGH>;
163 enable-active-high;
164 };
b8a46eea
DL
165
166 /*
167 * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack.
168 */
169 battery {
b8a46eea
DL
170 compatible = "lego,ev3-battery";
171 io-channels = <&adc 4>, <&adc 3>;
172 io-channel-names = "voltage", "current";
173 rechargeable-gpios = <&gpio 136 GPIO_ACTIVE_LOW>;
174 };
7d7eff8f 175
4729bef9
DL
176 bt_slow_clk: bt-clock {
177 pinctrl-names = "default";
178 pinctrl-0 = <&ecap2_pins>, <&bt_clock_bias>;
179 compatible = "pwm-clock";
180 #clock-cells = <0>;
181 clock-frequency = <32768>;
182 pwms = <&ecap2 0 30518 0>;
183 };
184
7d7eff8f
DL
185 /* ARM local RAM */
186 memory@ffff0000 {
187 compatible = "syscon", "simple-mfd";
188 reg = <0xffff0000 0x2000>; /* 8k */
189
190 /*
191 * The I2C bootloader looks for this magic value to either
192 * boot normally or boot into a firmware update mode.
193 */
194 reboot-mode {
195 compatible = "syscon-reboot-mode";
196 offset = <0x1ffc>;
197 mode-normal = <0x00000000>;
198 mode-loader = <0x5555aaaa>;
199 };
200 };
4302a38e
DL
201};
202
3652e274
DL
203&ref_clk {
204 clock-frequency = <24000000>;
205};
206
4302a38e
DL
207&pmx_core {
208 status = "okay";
209
2798c4b7
DL
210 ev3_lcd_pins: pinmux_lcd {
211 pinctrl-single,bits = <
d1f94959
DL
212 /* SIMO, CLK */
213 0x14 0x00100100 0x00f00f00
2798c4b7
DL
214 >;
215 };
4302a38e
DL
216};
217
218&pinconf {
219 status = "okay";
220
221 /* Buttons have external pulldown resistors */
222 button_bias: button-bias-groups {
223 disable {
224 groups = "cp5", "cp24", "cp25", "cp28";
225 bias-disable;
226 };
227 };
4729bef9
DL
228
229 bt_clock_bias: bt-clock-bias-groups {
230 disable {
231 groups = "cp2";
232 bias-disable;
233 };
234 };
235
236 bt_pic_bias: bt-pic-bias-groups {
237 disable {
238 groups = "cp20";
239 bias-disable;
240 };
241 };
4302a38e
DL
242};
243
244/* Input port 1 */
245&serial1 {
246 status = "okay";
247 pinctrl-names = "default";
248 pinctrl-0 = <&serial1_rxtx_pins>;
249};
250
4729bef9
DL
251&serial2 {
252 pinctrl-names = "default";
253 pinctrl-0 = <&serial2_rxtx_pins>, <&serial2_rtscts_pins>, <&bt_pic_bias>;
254 status = "okay";
255
256 bluetooth {
257 compatible = "ti,cc2560";
258 clocks = <&bt_slow_clk>;
259 clock-names = "ext_clock";
260 enable-gpios = <&gpio 73 GPIO_ACTIVE_HIGH>;
261 max-speed = <2000000>;
262 nvmem-cells = <&bdaddr>;
263 nvmem-cell-names = "bd-address";
264 };
265};
266
4302a38e
DL
267&rtc0 {
268 status = "okay";
269};
270
271&i2c0 {
272 status = "okay";
273 clock-frequency = <400000>;
274 pinctrl-names = "default";
275 pinctrl-0 = <&i2c0_pins>;
276
277 /*
278 * EEPROM contains the first stage bootloader, HW ID and Bluetooth MAC.
279 */
280 eeprom@50 {
95571b3b 281 compatible = "microchip,24c128", "atmel,24c128";
4302a38e
DL
282 pagesize = <64>;
283 read-only;
284 reg = <0x50>;
4729bef9
DL
285 #address-cells = <1>;
286 #size-cells = <1>;
287
288 bdaddr: bdaddr@3f06 {
289 reg = <0x3f06 0x06>;
290 };
4302a38e
DL
291 };
292};
293
294&wdt {
295 status = "okay";
296};
297
298&mmc0 {
299 status = "okay";
300 max-frequency = <50000000>;
301 bus-width = <4>;
302 cd-gpios = <&gpio 94 GPIO_ACTIVE_LOW>;
303 pinctrl-names = "default";
d1f94959 304 pinctrl-0 = <&mmc0_pins>;
4302a38e
DL
305};
306
307&spi0 {
308 status = "okay";
309 pinctrl-names = "default";
310 pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>, <&spi0_cs3_pin>;
311
312 flash@0 {
313 compatible = "n25q128a13", "jedec,spi-nor";
314 reg = <0>;
315 spi-max-frequency = <50000000>;
316 ti,spi-wdelay = <8>;
317
318 /* Partitions are based on the official firmware from LEGO */
319 partitions {
320 compatible = "fixed-partitions";
321 #address-cells = <1>;
322 #size-cells = <1>;
323
324 partition@0 {
325 label = "U-Boot";
326 reg = <0 0x40000>;
327 };
328
329 partition@40000 {
330 label = "U-Boot Env";
331 reg = <0x40000 0x10000>;
332 };
333
334 partition@50000 {
335 label = "Kernel";
336 reg = <0x50000 0x200000>;
337 };
338
339 partition@250000 {
340 label = "Filesystem";
341 reg = <0x250000 0xa50000>;
342 };
343
344 partition@cb0000 {
345 label = "Storage";
346 reg = <0xcb0000 0x2f0000>;
347 };
348 };
349 };
8a81ff17
DL
350
351 adc: adc@3 {
352 compatible = "ti,ads7957";
353 reg = <3>;
354 #io-channel-cells = <1>;
aea4762f
DL
355 spi-max-frequency = <1000000>;
356 ti,spi-wdelay = <63>;
8a81ff17
DL
357 vref-supply = <&adc_ref>;
358 };
4302a38e
DL
359};
360
2798c4b7
DL
361&spi1 {
362 status = "okay";
363 pinctrl-0 = <&ev3_lcd_pins>;
364 pinctrl-names = "default";
365 cs-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
366
367 display@0{
368 compatible = "lego,ev3-lcd";
369 reg = <0>;
370 spi-max-frequency = <10000000>;
371 a0-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
372 reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
373 };
374};
375
4729bef9
DL
376&ecap2 {
377 status = "okay";
378};
379
7723d70b
DL
380&ehrpwm0 {
381 status = "okay";
382};
383
4302a38e
DL
384&gpio {
385 status = "okay";
b8a46eea
DL
386
387 /* Don't pull down battery voltage adc io channel */
388 batt_volt_en {
389 gpio-hog;
390 gpios = <6 GPIO_ACTIVE_HIGH>;
c5a88cd2 391 output-high;
b8a46eea 392 };
4729bef9
DL
393
394 /* Don't impede Bluetooth clock signal */
395 bt_clock_en {
396 gpio-hog;
397 gpios = <5 GPIO_ACTIVE_HIGH>;
398 input;
399 };
400
401 /*
402 * There is a PIC microcontroller for interfacing with an Apple MFi
403 * chip. This interferes with normal Bluetooth operation, so we need
404 * to make sure it is turned off. Note: The publicly available
405 * schematics from LEGO don't show that these pins are connected to
406 * anything, but they are present in the source code from LEGO.
407 */
408
409 bt_pic_en {
410 gpio-hog;
411 gpios = <51 GPIO_ACTIVE_HIGH>;
412 output-low;
413 };
414
415 bt_pic_rst {
416 gpio-hog;
417 gpios = <78 GPIO_ACTIVE_HIGH>;
418 output-high;
419 };
420
421 bt_pic_cts {
422 gpio-hog;
423 gpios = <87 GPIO_ACTIVE_HIGH>;
424 input;
425 };
4302a38e
DL
426};
427
428&usb_phy {
429 status = "okay";
430};
431
432&usb0 {
433 status = "okay";
434};
435
436&usb1 {
437 status = "okay";
438 vbus-supply = <&vcc5v>;
439};