1/*
2 * Copyright (c) 2020 Lingao Meng
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <nordic/nrf52833_qiaa.dtsi>
9#include "bbc_microbit_v2-pinctrl.dtsi"
10#include <zephyr/dt-bindings/input/input-event-codes.h>
11
12/ {
13	model = "BBC Micro:bit V2";
14	compatible = "bbc,microbit-v2";
15
16	/* These aliases are provided for compatibility with samples */
17	aliases {
18		sw0 = &buttonA;
19		sw1 = &buttonB;
20		magn0 = &lsm303agr_magn;
21		accel0 = &lsm303agr_accel;
22		watchdog0 = &wdt0;
23	};
24
25	chosen {
26		zephyr,console = &uart0;
27		zephyr,shell-uart = &uart0;
28		zephyr,bt-mon-uart = &uart0;
29		zephyr,bt-c2h-uart = &uart0;
30		zephyr,sram = &sram0;
31		zephyr,flash = &flash0;
32		zephyr,code-partition = &slot0_partition;
33		zephyr,display = &led_matrix;
34	};
35
36	gpio_keys {
37		compatible = "gpio-keys";
38		buttonA: button_0 {
39			label = "BTN_A";
40			gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
41			zephyr,code = <INPUT_KEY_A>;
42		};
43
44		buttonB: button_1 {
45			label = "BTN_B";
46			gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
47			zephyr,code = <INPUT_KEY_B>;
48		};
49	};
50
51	led_matrix: led_matrix {
52		compatible = "nordic,nrf-led-matrix";
53		status = "okay";
54		width = <5>;
55		height = <5>;
56		pixel-mapping = [00 01 02 03 04
57				 10 11 12 13 14
58				 20 21 22 23 24
59				 30 31 32 33 34
60				 40 41 42 43 44];
61		row-gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>,
62			    <&gpio0 22 GPIO_ACTIVE_HIGH>,
63			    <&gpio0 15 GPIO_ACTIVE_HIGH>,
64			    <&gpio0 24 GPIO_ACTIVE_HIGH>,
65			    <&gpio0 19 GPIO_ACTIVE_HIGH>;
66		col-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>,
67			    <&gpio0 11 GPIO_ACTIVE_LOW>,
68			    <&gpio0 31 GPIO_ACTIVE_LOW>,
69			    <&gpio1  5 GPIO_ACTIVE_LOW>,
70			    <&gpio0 30 GPIO_ACTIVE_LOW>;
71		refresh-frequency = <50>;
72		timer = <&timer4>;
73		pwm = <&pwm0>;
74		pixel-group-size = <4>;
75	};
76
77	edge_connector: connector {
78		compatible = "microbit,edge-connector";
79		#gpio-cells = <2>;
80		gpio-map-mask = <0xffffffff 0xffffffc0>;
81		gpio-map-pass-thru = <0 0x3f>;
82		gpio-map = <0 0 &gpio0 2 0>,	/* P0 */
83			   <1 0 &gpio0 3 0>,	/* P1 */
84			   <2 0 &gpio0 4 0>,	/* P2 */
85			   <3 0 &gpio0 31 0>,	/* P3 */
86			   <4 0 &gpio0 28 0>,	/* P4 */
87			   <5 0 &gpio0 14 0>,	/* P5 */
88			   <6 0 &gpio1 5 0>,	/* P6 */
89			   <7 0 &gpio0 11 0>,	/* P7 */
90			   <8 0 &gpio0 10 0>,	/* P8 */
91			   <9 0 &gpio0 9 0>,	/* P9 */
92			   <10 0 &gpio0 30 0>,	/* P10 */
93			   <11 0 &gpio0 23 0>,	/* P11 */
94			   <12 0 &gpio0 12 0>,	/* P12 */
95			   <13 0 &gpio0 17 0>,	/* P13 */
96			   <14 0 &gpio0 1 0>,	/* P14 */
97			   <15 0 &gpio0 13 0>,	/* P15 */
98			   <16 0 &gpio1 2 0>,	/* P16 */
99			   <19 0 &gpio0 26 0>,	/* P19 */
100			   <20 0 &gpio1 0 0>;	/* P20 */
101	};
102};
103
104&gpiote {
105	status = "okay";
106};
107
108&gpio0 {
109	status = "okay";
110};
111
112&gpio1 {
113	status = "okay";
114};
115
116&uart0 {
117	compatible = "nordic,nrf-uart";
118	status = "okay";
119	current-speed = <115200>;
120	pinctrl-0 = <&uart0_default>;
121	pinctrl-1 = <&uart0_sleep>;
122	pinctrl-names = "default", "sleep";
123};
124
125&i2c0 {
126	compatible = "nordic,nrf-twim";
127	status = "okay";
128	clock-frequency = <I2C_BITRATE_FAST>;
129
130	/* See https://tech.microbit.org/hardware/i2c/ for board variants */
131
132	pinctrl-0 = <&i2c0_default>;
133	pinctrl-1 = <&i2c0_sleep>;
134	pinctrl-names = "default", "sleep";
135	lsm303agr_magn: lsm303agr-magn@1e {
136		compatible = "st,lis2mdl", "st,lsm303agr-magn";
137		status = "okay";
138		reg = <0x1e>;
139		irq-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;	/* A3 */
140	};
141
142	lsm303agr_accel: lsm303agr-accel@19 {
143		compatible = "st,lis2dh", "st,lsm303agr-accel";
144		status = "okay";
145		reg = <0x19>;
146		irq-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
147	};
148};
149
150&flash0 {
151
152	partitions {
153		compatible = "fixed-partitions";
154		#address-cells = <1>;
155		#size-cells = <1>;
156
157		boot_partition: partition@0 {
158			label = "mcuboot";
159			reg = <0x00000000 0xC000>;
160		};
161		slot0_partition: partition@c000 {
162			label = "image-0";
163			reg = <0x0000C000 0x32000>;
164		};
165		slot1_partition: partition@3e000 {
166			label = "image-1";
167			reg = <0x0003E000 0x32000>;
168		};
169		scratch_partition: partition@70000 {
170			label = "image-scratch";
171			reg = <0x00070000 0xA000>;
172		};
173		storage_partition: partition@7a000 {
174			label = "storage";
175			reg = <0x0007A000 0x00006000>;
176		};
177	};
178};
179
180zephyr_udc0: &usbd {
181	compatible = "nordic,nrf-usbd";
182	status = "okay";
183};
184