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