1/*
2 * Copyright (c) 2017 Linaro Limited
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <nordic/nrf51822_qfaa.dtsi>
9#include "bbc_microbit-pinctrl.dtsi"
10#include <zephyr/dt-bindings/input/input-event-codes.h>
11
12/ {
13	model = "BBC Micro:bit";
14	compatible = "bbc,microbit";
15
16	/* These aliases are provided for compatibility with samples */
17	aliases {
18		sw0 = &buttonA;
19		sw1 = &buttonB;
20		magn0 = &lsm303agr_magn;
21		accel0 = &mma8653fc;
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
39		buttonA: button_0 {
40			label = "BTN_A";
41			gpios = <&gpio0 17 GPIO_ACTIVE_LOW>;
42			zephyr,code = <INPUT_KEY_A>;
43		};
44
45		buttonB: button_1 {
46			label = "BTN_B";
47			gpios = <&gpio0 26 GPIO_ACTIVE_LOW>;
48			zephyr,code = <INPUT_KEY_B>;
49		};
50	};
51
52	led_matrix: led_matrix {
53		compatible = "nordic,nrf-led-matrix";
54		status = "okay";
55		width = <5>;
56		height = <5>;
57		pixel-mapping = [00 13 01 14 02
58				 23 24 25 26 27
59				 11 08 12 28 10
60				 07 06 05 04 03
61				 22 16 20 15 21];
62		row-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>,
63			    <&gpio0 14 GPIO_ACTIVE_HIGH>,
64			    <&gpio0 15 GPIO_ACTIVE_HIGH>;
65		col-gpios = <&gpio0 4 GPIO_ACTIVE_LOW>,
66			    <&gpio0 5 GPIO_ACTIVE_LOW>,
67			    <&gpio0 6 GPIO_ACTIVE_LOW>,
68			    <&gpio0 7 GPIO_ACTIVE_LOW>,
69			    <&gpio0 8 GPIO_ACTIVE_LOW>,
70			    <&gpio0 9 GPIO_ACTIVE_LOW>,
71			    <&gpio0 10 GPIO_ACTIVE_LOW>,
72			    <&gpio0 11 GPIO_ACTIVE_LOW>,
73			    <&gpio0 12 GPIO_ACTIVE_LOW>;
74		refresh-frequency = <50>;
75		timer = <&timer2>;
76		pixel-group-size = <3>;
77	};
78
79	edge_connector: connector {
80		compatible = "microbit,edge-connector";
81		#gpio-cells = <2>;
82		gpio-map-mask = <0xffffffff 0xffffffc0>;
83		gpio-map-pass-thru = <0 0x3f>;
84		gpio-map = <0 0 &gpio0 3 0>,	/* P0, Analog in */
85			   <1 0 &gpio0 2 0>,	/* P1, Analog in */
86			   <2 0 &gpio0 1 0>,	/* P2, Analog in */
87			   <3 0 &gpio0 4 0>,	/* P3, Analog in, LED Col 1 */
88			   <4 0 &gpio0 5 0>,	/* P4, Analog in, LED Col 2 */
89			   <5 0 &gpio0 17 0>,	/* P5, Button A */
90			   <6 0 &gpio0 12 0>,	/* P6, LED Col 9 */
91			   <7 0 &gpio0 11 0>,	/* P7, LED Col 8 */
92			   <8 0 &gpio0 18 0>,	/* P8 */
93			   <9 0 &gpio0 10 0>,	/* P9, LED Col 7 */
94			   <10 0 &gpio0 6 0>,	/* P10, Analog in, LED Col 3 */
95			   <11 0 &gpio0 26 0>,	/* P11, Button B */
96			   <12 0 &gpio0 20 0>,	/* P12 */
97			   <13 0 &gpio0 23 0>,	/* P13, SPI1 SCK */
98			   <14 0 &gpio0 22 0>,	/* P14, SPI1 MISO */
99			   <15 0 &gpio0 21 0>,	/* P15, SPI1 MOSI */
100			   <16 0 &gpio0 16 0>,	/* P16 */
101			   /* 17 and 18 are just 3.3V pins */
102			   <19 0 &gpio0 0 0>,	/* P19, I2C1 SCL */
103			   <20 0 &gpio0 30 0>;	/* P20, I2C1 SDA */
104	};
105};
106
107&gpiote {
108	status = "okay";
109};
110
111&gpio0 {
112	status = "okay";
113	/*
114	 * Use the sensing mechanism for all pins by default, as GPIOTE channels
115	 * are needed for the LED matrix and the SW PWM.
116	 */
117	sense-edge-mask = <0xffffffff>;
118};
119
120&uart0 {
121	status = "okay";
122	current-speed = <115200>;
123	pinctrl-0 = <&uart0_default>;
124	pinctrl-1 = <&uart0_sleep>;
125	pinctrl-names = "default", "sleep";
126};
127
128&i2c0 {
129	status = "okay";
130	clock-frequency = <I2C_BITRATE_FAST>;
131
132	/* See https://tech.microbit.org/hardware/i2c/ for board variants */
133
134	/* v1.3 MMA8653FC (= FXOS8700) + MAG3110 */
135	pinctrl-0 = <&i2c0_default>;
136	pinctrl-1 = <&i2c0_sleep>;
137	pinctrl-names = "default", "sleep";
138
139	mma8653fc: mma8653fc@1d {
140		compatible = "nxp,fxos8700", "nxp,mma8653fc";
141		status = "okay";
142		reg = <0x1d>;
143		int1-gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
144		int2-gpios = <&gpio0 27 GPIO_ACTIVE_LOW>;
145	};
146
147	/* v1.5 variant 1 LSM303AGR */
148	lsm303agr_magn: lsm303agr-magn@1e {
149		compatible = "st,lis2mdl", "st,lsm303agr-magn";
150		status = "disabled";
151		reg = <0x1e>;
152		irq-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>;	/* A3 */
153	};
154
155	lsm303agr_accel: lsm303agr-accel@19 {
156		compatible = "st,lis2dh", "st,lsm303agr-accel";
157		status = "disabled";
158		reg = <0x19>;
159		irq-gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>;
160	};
161};
162
163&flash0 {
164	partitions {
165		compatible = "fixed-partitions";
166		#address-cells = <1>;
167		#size-cells = <1>;
168
169		boot_partition: partition@0 {
170			label = "mcuboot";
171			reg = <0x00000000 0x8000>;
172		};
173
174		slot0_partition: partition@8000 {
175			label = "image-0";
176			reg = <0x00008000 0x1a000>;
177		};
178
179		slot1_partition: partition@22000 {
180			label = "image-1";
181			reg = <0x00022000 0x1a000>;
182		};
183
184		scratch_partition: partition@3c000 {
185			label = "image-scratch";
186			reg = <0x0003c000 0x2000>;
187		};
188
189		storage_partition: partition@3e000 {
190			label = "storage";
191			reg = <0x0003e000 0x00002000>;
192		};
193	};
194};
195