David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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"; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 36 | label = "EV3 Brick Buttons"; |
| 37 | pinctrl-names = "default"; |
David Lechner | d1f9495 | 2018-02-19 16:29:31 -0600 | [diff] [blame] | 38 | pinctrl-0 = <&button_bias>; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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"; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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>; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 118 | }; |
| 119 | |
David Lechner | 7723d70 | 2017-02-07 13:22:09 -0600 | [diff] [blame] | 120 | sound { |
| 121 | compatible = "pwm-beeper"; |
| 122 | pinctrl-names = "default"; |
| 123 | pinctrl-0 = <&ehrpwm0b_pins>; |
| 124 | pwms = <&ehrpwm0 1 1000000 0>; |
| 125 | amp-supply = <&>; |
| 126 | }; |
| 127 | |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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 { |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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 | }; |
David Lechner | 8a81ff1 | 2017-02-07 13:22:07 -0600 | [diff] [blame] | 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 | }; |
David Lechner | 7723d70 | 2017-02-07 13:22:09 -0600 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * This is the amplifier for the speaker. |
| 158 | */ |
| 159 | amp: regulator3 { |
David Lechner | 7723d70 | 2017-02-07 13:22:09 -0600 | [diff] [blame] | 160 | compatible = "regulator-fixed"; |
| 161 | regulator-name = "amp"; |
| 162 | gpio = <&gpio 111 GPIO_ACTIVE_HIGH>; |
| 163 | enable-active-high; |
| 164 | }; |
David Lechner | b8a46ee | 2017-04-11 16:05:23 -0500 | [diff] [blame] | 165 | |
| 166 | /* |
| 167 | * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack. |
| 168 | */ |
| 169 | battery { |
David Lechner | b8a46ee | 2017-04-11 16:05:23 -0500 | [diff] [blame] | 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 | }; |
David Lechner | 7d7eff8 | 2018-01-11 20:29:50 -0600 | [diff] [blame] | 175 | |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 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 | |
David Lechner | 7d7eff8 | 2018-01-11 20:29:50 -0600 | [diff] [blame] | 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 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 201 | }; |
| 202 | |
David Lechner | 3652e27 | 2018-05-18 11:48:29 -0500 | [diff] [blame] | 203 | &ref_clk { |
| 204 | clock-frequency = <24000000>; |
| 205 | }; |
| 206 | |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 207 | &pmx_core { |
| 208 | status = "okay"; |
| 209 | |
David Lechner | 2798c4b | 2017-08-07 12:39:40 -0500 | [diff] [blame] | 210 | ev3_lcd_pins: pinmux_lcd { |
| 211 | pinctrl-single,bits = < |
David Lechner | d1f9495 | 2018-02-19 16:29:31 -0600 | [diff] [blame] | 212 | /* SIMO, CLK */ |
| 213 | 0x14 0x00100100 0x00f00f00 |
David Lechner | 2798c4b | 2017-08-07 12:39:40 -0500 | [diff] [blame] | 214 | >; |
| 215 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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 | }; |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 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 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 242 | }; |
| 243 | |
| 244 | /* Input port 1 */ |
| 245 | &serial1 { |
| 246 | status = "okay"; |
| 247 | pinctrl-names = "default"; |
| 248 | pinctrl-0 = <&serial1_rxtx_pins>; |
| 249 | }; |
| 250 | |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 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 | |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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 { |
Bartosz Golaszewski | 95571b3 | 2018-01-22 13:55:05 +0100 | [diff] [blame] | 281 | compatible = "microchip,24c128", "atmel,24c128"; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 282 | pagesize = <64>; |
| 283 | read-only; |
| 284 | reg = <0x50>; |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 285 | #address-cells = <1>; |
| 286 | #size-cells = <1>; |
| 287 | |
| 288 | bdaddr: bdaddr@3f06 { |
| 289 | reg = <0x3f06 0x06>; |
| 290 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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"; |
David Lechner | d1f9495 | 2018-02-19 16:29:31 -0600 | [diff] [blame] | 304 | pinctrl-0 = <&mmc0_pins>; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 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 | }; |
David Lechner | 8a81ff1 | 2017-02-07 13:22:07 -0600 | [diff] [blame] | 350 | |
| 351 | adc: adc@3 { |
| 352 | compatible = "ti,ads7957"; |
| 353 | reg = <3>; |
| 354 | #io-channel-cells = <1>; |
| 355 | spi-max-frequency = <10000000>; |
| 356 | vref-supply = <&adc_ref>; |
| 357 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 358 | }; |
| 359 | |
David Lechner | 2798c4b | 2017-08-07 12:39:40 -0500 | [diff] [blame] | 360 | &spi1 { |
| 361 | status = "okay"; |
| 362 | pinctrl-0 = <&ev3_lcd_pins>; |
| 363 | pinctrl-names = "default"; |
| 364 | cs-gpios = <&gpio 44 GPIO_ACTIVE_LOW>; |
| 365 | |
| 366 | display@0{ |
| 367 | compatible = "lego,ev3-lcd"; |
| 368 | reg = <0>; |
| 369 | spi-max-frequency = <10000000>; |
| 370 | a0-gpios = <&gpio 43 GPIO_ACTIVE_HIGH>; |
| 371 | reset-gpios = <&gpio 80 GPIO_ACTIVE_HIGH>; |
| 372 | }; |
| 373 | }; |
| 374 | |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 375 | &ecap2 { |
| 376 | status = "okay"; |
| 377 | }; |
| 378 | |
David Lechner | 7723d70 | 2017-02-07 13:22:09 -0600 | [diff] [blame] | 379 | &ehrpwm0 { |
| 380 | status = "okay"; |
| 381 | }; |
| 382 | |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 383 | &gpio { |
| 384 | status = "okay"; |
David Lechner | b8a46ee | 2017-04-11 16:05:23 -0500 | [diff] [blame] | 385 | |
| 386 | /* Don't pull down battery voltage adc io channel */ |
| 387 | batt_volt_en { |
| 388 | gpio-hog; |
| 389 | gpios = <6 GPIO_ACTIVE_HIGH>; |
David Lechner | c5a88cd | 2017-12-03 16:04:53 -0600 | [diff] [blame] | 390 | output-high; |
David Lechner | b8a46ee | 2017-04-11 16:05:23 -0500 | [diff] [blame] | 391 | }; |
David Lechner | 4729bef | 2018-05-31 15:25:48 -0500 | [diff] [blame] | 392 | |
| 393 | /* Don't impede Bluetooth clock signal */ |
| 394 | bt_clock_en { |
| 395 | gpio-hog; |
| 396 | gpios = <5 GPIO_ACTIVE_HIGH>; |
| 397 | input; |
| 398 | }; |
| 399 | |
| 400 | /* |
| 401 | * There is a PIC microcontroller for interfacing with an Apple MFi |
| 402 | * chip. This interferes with normal Bluetooth operation, so we need |
| 403 | * to make sure it is turned off. Note: The publicly available |
| 404 | * schematics from LEGO don't show that these pins are connected to |
| 405 | * anything, but they are present in the source code from LEGO. |
| 406 | */ |
| 407 | |
| 408 | bt_pic_en { |
| 409 | gpio-hog; |
| 410 | gpios = <51 GPIO_ACTIVE_HIGH>; |
| 411 | output-low; |
| 412 | }; |
| 413 | |
| 414 | bt_pic_rst { |
| 415 | gpio-hog; |
| 416 | gpios = <78 GPIO_ACTIVE_HIGH>; |
| 417 | output-high; |
| 418 | }; |
| 419 | |
| 420 | bt_pic_cts { |
| 421 | gpio-hog; |
| 422 | gpios = <87 GPIO_ACTIVE_HIGH>; |
| 423 | input; |
| 424 | }; |
David Lechner | 4302a38 | 2017-01-13 13:03:42 -0600 | [diff] [blame] | 425 | }; |
| 426 | |
| 427 | &usb_phy { |
| 428 | status = "okay"; |
| 429 | }; |
| 430 | |
| 431 | &usb0 { |
| 432 | status = "okay"; |
| 433 | }; |
| 434 | |
| 435 | &usb1 { |
| 436 | status = "okay"; |
| 437 | vbus-supply = <&vcc5v>; |
| 438 | }; |