Merge tag 'v4.18-rc2' of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds...
[sfrench/cifs-2.6.git] / arch / arm / boot / dts / da850-lego-ev3.dts
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";
36                 label = "EV3 Brick Buttons";
37                 pinctrl-names = "default";
38                 pinctrl-0 = <&button_bias>;
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";
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>;
118         };
119
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
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 {
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         };
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         };
155
156         /*
157          * This is the amplifier for the speaker.
158          */
159         amp: regulator3 {
160                 compatible = "regulator-fixed";
161                 regulator-name = "amp";
162                 gpio = <&gpio 111 GPIO_ACTIVE_HIGH>;
163                 enable-active-high;
164         };
165
166         /*
167          * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack.
168          */
169         battery {
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         };
175
176         /* ARM local RAM */
177         memory@ffff0000 {
178                 compatible = "syscon", "simple-mfd";
179                 reg = <0xffff0000 0x2000>; /* 8k */
180
181                 /*
182                  * The I2C bootloader looks for this magic value to either
183                  * boot normally or boot into a firmware update mode.
184                  */
185                 reboot-mode {
186                         compatible = "syscon-reboot-mode";
187                         offset = <0x1ffc>;
188                         mode-normal = <0x00000000>;
189                         mode-loader = <0x5555aaaa>;
190                 };
191         };
192 };
193
194 &pmx_core {
195         status = "okay";
196
197         ev3_lcd_pins: pinmux_lcd {
198                 pinctrl-single,bits = <
199                         /* SIMO, CLK */
200                         0x14 0x00100100 0x00f00f00
201                 >;
202         };
203 };
204
205 &pinconf {
206         status = "okay";
207
208         /* Buttons have external pulldown resistors */
209         button_bias: button-bias-groups {
210                 disable {
211                         groups = "cp5", "cp24", "cp25", "cp28";
212                         bias-disable;
213                 };
214         };
215 };
216
217 /* Input port 1 */
218 &serial1 {
219         status = "okay";
220         pinctrl-names = "default";
221         pinctrl-0 = <&serial1_rxtx_pins>;
222 };
223
224 &rtc0 {
225         status = "okay";
226 };
227
228 &i2c0 {
229         status = "okay";
230         clock-frequency = <400000>;
231         pinctrl-names = "default";
232         pinctrl-0 = <&i2c0_pins>;
233
234         /*
235          * EEPROM contains the first stage bootloader, HW ID and Bluetooth MAC.
236          */
237         eeprom@50 {
238                 compatible = "microchip,24c128", "atmel,24c128";
239                 pagesize = <64>;
240                 read-only;
241                 reg = <0x50>;
242         };
243 };
244
245 &wdt {
246         status = "okay";
247 };
248
249 &mmc0 {
250         status = "okay";
251         max-frequency = <50000000>;
252         bus-width = <4>;
253         cd-gpios = <&gpio 94 GPIO_ACTIVE_LOW>;
254         pinctrl-names = "default";
255         pinctrl-0 = <&mmc0_pins>;
256 };
257
258 &spi0 {
259         status = "okay";
260         pinctrl-names = "default";
261         pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>, <&spi0_cs3_pin>;
262
263         flash@0 {
264                 compatible = "n25q128a13", "jedec,spi-nor";
265                 reg = <0>;
266                 spi-max-frequency = <50000000>;
267                 ti,spi-wdelay = <8>;
268
269                 /* Partitions are based on the official firmware from LEGO */
270                 partitions {
271                         compatible = "fixed-partitions";
272                         #address-cells = <1>;
273                         #size-cells = <1>;
274
275                         partition@0 {
276                                 label = "U-Boot";
277                                 reg = <0 0x40000>;
278                         };
279
280                         partition@40000 {
281                                 label = "U-Boot Env";
282                                 reg = <0x40000 0x10000>;
283                         };
284
285                         partition@50000 {
286                                 label = "Kernel";
287                                 reg = <0x50000 0x200000>;
288                         };
289
290                         partition@250000 {
291                                 label = "Filesystem";
292                                 reg = <0x250000 0xa50000>;
293                         };
294
295                         partition@cb0000 {
296                                 label = "Storage";
297                                 reg = <0xcb0000 0x2f0000>;
298                         };
299                 };
300         };
301
302         adc: adc@3 {
303                 compatible = "ti,ads7957";
304                 reg = <3>;
305                 #io-channel-cells = <1>;
306                 spi-max-frequency = <10000000>;
307                 vref-supply = <&adc_ref>;
308         };
309 };
310
311 &spi1 {
312         status = "okay";
313         pinctrl-0 = <&ev3_lcd_pins>;
314         pinctrl-names = "default";
315         cs-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
316
317         display@0{
318                 compatible = "lego,ev3-lcd";
319                 reg = <0>;
320                 spi-max-frequency = <10000000>;
321                 a0-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
322                 reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
323         };
324 };
325
326 &ehrpwm0 {
327         status = "okay";
328 };
329
330 &gpio {
331         status = "okay";
332
333         /* Don't pull down battery voltage adc io channel */
334         batt_volt_en {
335                 gpio-hog;
336                 gpios = <6 GPIO_ACTIVE_HIGH>;
337                 output-high;
338         };
339 };
340
341 &usb_phy {
342         status = "okay";
343 };
344
345 &usb0 {
346         status = "okay";
347 };
348
349 &usb1 {
350         status = "okay";
351         vbus-supply = <&vcc5v>;
352 };