Merge branch 'for-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu
[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                 #address-cells = <1>;
37                 #size-cells = <0>;
38                 label = "EV3 Brick Buttons";
39                 pinctrl-names = "default";
40                 pinctrl-0 = <&button_pins>, <&button_bias>;
41
42                 center {
43                         label = "Center";
44                         linux,code = <KEY_ENTER>;
45                         gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
46                 };
47
48                 left {
49                         label = "Left";
50                         linux,code = <KEY_LEFT>;
51                         gpios = <&gpio 102 GPIO_ACTIVE_HIGH>;
52                 };
53
54                 back {
55                         label = "Back";
56                         linux,code = <KEY_BACKSPACE>;
57                         gpios = <&gpio 106 GPIO_ACTIVE_HIGH>;
58                 };
59
60                 right {
61                         label = "Right";
62                         linux,code = <KEY_RIGHT>;
63                         gpios = <&gpio 124 GPIO_ACTIVE_HIGH>;
64                 };
65
66                 down {
67                         label = "Down";
68                         linux,code = <KEY_DOWN>;
69                         gpios = <&gpio 126 GPIO_ACTIVE_HIGH>;
70                 };
71
72                 up {
73                         label = "Up";
74                         linux,code = <KEY_UP>;
75                         gpios = <&gpio 127 GPIO_ACTIVE_HIGH>;
76                 };
77         };
78
79         /*
80          * The EV3 has two built-in bi-color LEDs behind the buttons.
81          */
82         leds {
83                 compatible = "gpio-leds";
84                 pinctrl-names = "default";
85                 pinctrl-0 = <&led_pins>;
86
87                 left_green {
88                         label = "led0:green:brick-status";
89                         /* GP6[13] */
90                         gpios = <&gpio 103 GPIO_ACTIVE_HIGH>;
91                         linux,default-trigger = "default-on";
92                 };
93
94                 right_red {
95                         label = "led1:red:brick-status";
96                         /* GP6[7] */
97                         gpios = <&gpio 108 GPIO_ACTIVE_HIGH>;
98                         linux,default-trigger = "default-on";
99                 };
100
101                 left_red {
102                         label = "led0:red:brick-status";
103                         /* GP6[12] */
104                         gpios = <&gpio 109 GPIO_ACTIVE_HIGH>;
105                         linux,default-trigger = "default-on";
106                 };
107
108                 right_green {
109                         label = "led1:green:brick-status";
110                         /* GP6[14] */
111                         gpios = <&gpio 110 GPIO_ACTIVE_HIGH>;
112                         linux,default-trigger = "default-on";
113                 };
114         };
115
116         /*
117          * The EV3 is powered down by turning off the main 5V supply.
118          */
119         gpio-poweroff {
120                 compatible = "gpio-poweroff";
121                 gpios = <&gpio 107 GPIO_ACTIVE_LOW>;
122                 pinctrl-names = "default";
123                 pinctrl-0 = <&system_power_pin>;
124         };
125
126         sound {
127                 compatible = "pwm-beeper";
128                 pinctrl-names = "default";
129                 pinctrl-0 = <&ehrpwm0b_pins>;
130                 pwms = <&ehrpwm0 1 1000000 0>;
131                 amp-supply = <&amp>;
132         };
133
134         /*
135          * This is a 5V current limiting regulator that is shared by USB,
136          * the sensor (input) ports, the motor (output) ports and the A/DC.
137          */
138         vcc5v: regulator1 {
139                 pinctrl-names = "default";
140                 pinctrl-0 = <&vcc5v_pins>;
141                 compatible = "regulator-fixed";
142                 regulator-name = "vcc5v";
143                 regulator-min-microvolt = <5000000>;
144                 regulator-max-microvolt = <5000000>;
145                 gpio = <&gpio 101 0>;
146                 over-current-gpios = <&gpio 99 GPIO_ACTIVE_LOW>;
147                 enable-active-high;
148                 regulator-boot-on;
149         };
150
151         /*
152          * This is a simple voltage divider on VCC5V to provide a 2.5V
153          * reference signal to the ADC.
154          */
155         adc_ref: regulator2 {
156                 compatible = "regulator-fixed";
157                 regulator-name = "adc ref";
158                 regulator-min-microvolt = <2500000>;
159                 regulator-max-microvolt = <2500000>;
160                 regulator-boot-on;
161                 vin-supply = <&vcc5v>;
162         };
163
164         /*
165          * This is the amplifier for the speaker.
166          */
167         amp: regulator3 {
168                 pinctrl-names = "default";
169                 pinctrl-0 = <&amp_pins>;
170                 compatible = "regulator-fixed";
171                 regulator-name = "amp";
172                 gpio = <&gpio 111 GPIO_ACTIVE_HIGH>;
173                 enable-active-high;
174         };
175
176         /*
177          * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack.
178          */
179         battery {
180                 pinctrl-names = "default";
181                 pinctrl-0 = <&battery_pins>;
182                 compatible = "lego,ev3-battery";
183                 io-channels = <&adc 4>, <&adc 3>;
184                 io-channel-names = "voltage", "current";
185                 rechargeable-gpios = <&gpio 136 GPIO_ACTIVE_LOW>;
186         };
187 };
188
189 &pmx_core {
190         status = "okay";
191
192         mmc0_cd_pin: pinmux_mmc0_cd {
193                 pinctrl-single,bits = <
194                         /* GP5[14] */
195                         0x2C 0x00000080 0x000000f0
196                 >;
197         };
198
199         button_pins: pinmux_button_pins {
200                 pinctrl-single,bits = <
201                         /* GP1[13] */
202                         0x8 0x00000800 0x00000f00
203                         /* GP6[10] */
204                         0x34 0x00800000 0x00f00000
205                         /* GP6[6] */
206                         0x38 0x00000080 0x000000f0
207                         /* GP7[12], GP7[14], GP7[15] */
208                         0x40 0x00808800 0x00f0ff00
209                 >;
210         };
211
212         led_pins: pinmux_led_pins {
213                 pinctrl-single,bits = <
214                         /* GP6[12], GP6[13], GP6[14] */
215                         0x34 0x00008880 0x0000fff0
216                         /* GP6[7] */
217                         0x38 0x00000008 0x0000000f
218                 >;
219         };
220
221         system_power_pin: pinmux_system_power {
222                 pinctrl-single,bits = <
223                         /* GP6[11] */
224                         0x34 0x00080000 0x000f0000
225                 >;
226         };
227
228         vcc5v_pins: pinmux_vcc5v {
229                 pinctrl-single,bits = <
230                         /* GP6[5] */
231                         0x40 0x00000080 0x000000f0
232                         /* GP6[3] */
233                         0x4c 0x00008000 0x0000f000
234                 >;
235         };
236
237         amp_pins: pinmux_amp_pins {
238                 pinctrl-single,bits = <
239                         /* GP6[15] */
240                         0x34 0x00000008 0x0000000f
241                 >;
242         };
243
244         battery_pins: pinmux_battery_pins {
245                 pinctrl-single,bits = <
246                         /* GP0[6] */
247                         0x04 0x00000080 0x000000f0
248                         /* GP8[8] */
249                         0x4c 0x00000080 0x000000f0
250                 >;
251         };
252
253         ev3_lcd_pins: pinmux_lcd {
254                 pinctrl-single,bits = <
255                         /* SIMO, GP2[11], GP2[12], CLK */
256                         0x14 0x00188100 0x00ffff00
257                         /* GP5[0] */
258                         0x30 0x80000000 0xf0000000
259                 >;
260         };
261 };
262
263 &pinconf {
264         status = "okay";
265
266         /* Buttons have external pulldown resistors */
267         button_bias: button-bias-groups {
268                 disable {
269                         groups = "cp5", "cp24", "cp25", "cp28";
270                         bias-disable;
271                 };
272         };
273 };
274
275 /* Input port 1 */
276 &serial1 {
277         status = "okay";
278         pinctrl-names = "default";
279         pinctrl-0 = <&serial1_rxtx_pins>;
280 };
281
282 &rtc0 {
283         status = "okay";
284 };
285
286 &i2c0 {
287         status = "okay";
288         clock-frequency = <400000>;
289         pinctrl-names = "default";
290         pinctrl-0 = <&i2c0_pins>;
291
292         /*
293          * EEPROM contains the first stage bootloader, HW ID and Bluetooth MAC.
294          */
295         eeprom@50 {
296                 compatible = "microchip,24c128";
297                 pagesize = <64>;
298                 read-only;
299                 reg = <0x50>;
300         };
301 };
302
303 &wdt {
304         status = "okay";
305 };
306
307 &mmc0 {
308         status = "okay";
309         max-frequency = <50000000>;
310         bus-width = <4>;
311         cd-gpios = <&gpio 94 GPIO_ACTIVE_LOW>;
312         pinctrl-names = "default";
313         pinctrl-0 = <&mmc0_pins>, <&mmc0_cd_pin>;
314 };
315
316 &spi0 {
317         status = "okay";
318         pinctrl-names = "default";
319         pinctrl-0 = <&spi0_pins>, <&spi0_cs0_pin>, <&spi0_cs3_pin>;
320
321         flash@0 {
322                 compatible = "n25q128a13", "jedec,spi-nor";
323                 reg = <0>;
324                 spi-max-frequency = <50000000>;
325                 ti,spi-wdelay = <8>;
326
327                 /* Partitions are based on the official firmware from LEGO */
328                 partitions {
329                         compatible = "fixed-partitions";
330                         #address-cells = <1>;
331                         #size-cells = <1>;
332
333                         partition@0 {
334                                 label = "U-Boot";
335                                 reg = <0 0x40000>;
336                         };
337
338                         partition@40000 {
339                                 label = "U-Boot Env";
340                                 reg = <0x40000 0x10000>;
341                         };
342
343                         partition@50000 {
344                                 label = "Kernel";
345                                 reg = <0x50000 0x200000>;
346                         };
347
348                         partition@250000 {
349                                 label = "Filesystem";
350                                 reg = <0x250000 0xa50000>;
351                         };
352
353                         partition@cb0000 {
354                                 label = "Storage";
355                                 reg = <0xcb0000 0x2f0000>;
356                         };
357                 };
358         };
359
360         adc: adc@3 {
361                 compatible = "ti,ads7957";
362                 reg = <3>;
363                 #io-channel-cells = <1>;
364                 spi-max-frequency = <10000000>;
365                 vref-supply = <&adc_ref>;
366         };
367 };
368
369 &spi1 {
370         status = "okay";
371         pinctrl-0 = <&ev3_lcd_pins>;
372         pinctrl-names = "default";
373         cs-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
374
375         display@0{
376                 compatible = "lego,ev3-lcd";
377                 reg = <0>;
378                 spi-max-frequency = <10000000>;
379                 a0-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>;
380                 reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>;
381         };
382 };
383
384 &ehrpwm0 {
385         status = "okay";
386 };
387
388 &gpio {
389         status = "okay";
390
391         /* Don't pull down battery voltage adc io channel */
392         batt_volt_en {
393                 gpio-hog;
394                 gpios = <6 GPIO_ACTIVE_HIGH>;
395                 output-high;
396         };
397 };
398
399 &usb_phy {
400         status = "okay";
401 };
402
403 &usb0 {
404         status = "okay";
405 };
406
407 &usb1 {
408         status = "okay";
409         vbus-supply = <&vcc5v>;
410 };