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