Skip to content

Commit 53b53a5

Browse files
soc: atmel_sam0: Add support for SAML21 parts
Implement support for SAML21 parts, tested on a SAML21 Xplained Pro dev board. Confirmed operational peripherals: UART, GPIO, PWM, ADC. Signed-off-by: Attie Grande <[email protected]>
1 parent 3824024 commit 53b53a5

File tree

13 files changed

+906
-0
lines changed

13 files changed

+906
-0
lines changed

dts/arm/atmel/saml21.dtsi

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* Copyright (c) 2021 Argentum Systems Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <atmel/saml2x.dtsi>
8+
9+
/ {
10+
soc {
11+
usb0: usb@41000000 {
12+
compatible = "atmel,sam0-usb";
13+
status = "disabled";
14+
reg = <0x41000000 0x1000>;
15+
interrupts = <6 0>;
16+
num-bidir-endpoints = <8>;
17+
label = "USB0";
18+
};
19+
20+
dmac: dmac@44000400 {
21+
compatible = "atmel,sam0-dmac";
22+
reg = <0x44000400 0x50>;
23+
interrupts = <5 0>;
24+
label = "DMA_0";
25+
#dma-cells = <2>;
26+
};
27+
28+
tcc0: tcc@42001400 {
29+
compatible = "atmel,sam0-tcc";
30+
reg = <0x42001400 0x80>;
31+
interrupts = <14 0>;
32+
label = "TCC_0";
33+
clocks = <&gclk 25>, <&mclk 0x1c 5>;
34+
clock-names = "GCLK", "MCLK";
35+
36+
channels = <4>;
37+
counter-size = <24>;
38+
};
39+
40+
tcc1: tcc@42001800 {
41+
compatible = "atmel,sam0-tcc";
42+
reg = <0x42001800 0x80>;
43+
interrupts = <15 0>;
44+
label = "TCC_1";
45+
clocks = <&gclk 25>, <&mclk 0x1c 6>;
46+
clock-names = "GCLK", "MCLK";
47+
48+
channels = <4>;
49+
counter-size = <24>;
50+
};
51+
52+
tcc2: tcc@42001c00 {
53+
compatible = "atmel,sam0-tcc";
54+
reg = <0x42001C00 0x80>;
55+
interrupts = <16 0>;
56+
label = "TCC_2";
57+
clocks = <&gclk 26>, <&mclk 0x1c 7>;
58+
clock-names = "GCLK", "MCLK";
59+
60+
channels = <2>;
61+
counter-size = <16>;
62+
};
63+
};
64+
};
65+
66+
&dac {
67+
interrupts = <24 0>;
68+
clocks = <&gclk 32>, <&mclk 0x1c 12>;
69+
clock-names = "GCLK", "MCLK";
70+
};
71+
72+
&sercom0 {
73+
interrupts = <8 0>;
74+
clocks = <&gclk 18>, <&mclk 0x1c 0>;
75+
clock-names = "GCLK", "MCLK";
76+
};
77+
78+
&sercom1 {
79+
interrupts = <9 0>;
80+
clocks = <&gclk 19>, <&mclk 0x1c 1>;
81+
clock-names = "GCLK", "MCLK";
82+
};
83+
84+
&sercom2 {
85+
interrupts = <10 0>;
86+
clocks = <&gclk 20>, <&mclk 0x1c 2>;
87+
clock-names = "GCLK", "MCLK";
88+
};
89+
90+
&sercom3 {
91+
interrupts = <11 0>;
92+
clocks = <&gclk 21>, <&mclk 0x1c 3>;
93+
clock-names = "GCLK", "MCLK";
94+
};
95+
96+
&sercom4 {
97+
interrupts = <12 0>;
98+
clocks = <&gclk 22>, <&mclk 0x1c 4>;
99+
clock-names = "GCLK", "MCLK";
100+
};
101+
102+
&sercom5 {
103+
interrupts = <13 0>;
104+
clocks = <&gclk 24>, <&mclk 0x20 1>;
105+
clock-names = "GCLK", "MCLK";
106+
};
107+
108+
&tc4 {
109+
interrupts = <21 0>;
110+
clocks = <&gclk 29>, <&mclk 0x20 2>;
111+
clock-names = "GCLK", "MCLK";
112+
};
113+
114+
&adc {
115+
interrupts = <22 0>;
116+
interrupt-names = "resrdy";
117+
clocks = <&gclk 30>, <&mclk 0x20 3>;
118+
clock-names = "GCLK", "MCLK";
119+
};

dts/arm/atmel/saml2x.dtsi

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
/*
2+
* Copyright (c) 2021 Argentum Systems Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <mem.h>
8+
#include <arm/armv6-m.dtsi>
9+
#include <dt-bindings/gpio/gpio.h>
10+
#include <dt-bindings/i2c/i2c.h>
11+
#include <dt-bindings/pwm/pwm.h>
12+
13+
/ {
14+
aliases {
15+
watchdog0 = &wdog;
16+
};
17+
18+
chosen {
19+
zephyr,flash-controller = &nvmctrl;
20+
zephyr,entropy = &trng;
21+
};
22+
23+
cpus {
24+
#address-cells = <1>;
25+
#size-cells = <0>;
26+
27+
cpu0: cpu@0 {
28+
device_type = "cpu";
29+
compatible = "arm,cortex-m0+";
30+
reg = <0>;
31+
};
32+
};
33+
34+
sram0: memory@20000000 {
35+
compatible = "mmio-sram";
36+
reg = <0x20000000 0x8000>;
37+
};
38+
39+
id: device_id@80a00c {
40+
compatible = "atmel,sam0-id";
41+
reg = <0x0080A00C 0x4>,
42+
<0x0080A040 0x4>,
43+
<0x0080A044 0x4>,
44+
<0x0080A048 0x4>;
45+
};
46+
47+
soc {
48+
nvmctrl: nvmctrl@41004000 {
49+
compatible = "atmel,sam0-nvmctrl";
50+
label = "FLASH_CTRL";
51+
reg = <0x41004000 0x22>;
52+
interrupts = <4 0>;
53+
lock-regions = <16>;
54+
55+
#address-cells = <1>;
56+
#size-cells = <1>;
57+
58+
flash0: flash@0 {
59+
compatible = "soc-nv-flash";
60+
label = "FLASH_0";
61+
reg = <0 0x40000>;
62+
write-block-size = <4>;
63+
};
64+
};
65+
66+
pm: pm@40000400 {
67+
compatible = "atmel,saml2x-pm";
68+
reg = <0x40000400 0x400>;
69+
interrupts = <0 0>;
70+
#clock-cells = <2>;
71+
};
72+
73+
mclk: mclk@40000400 {
74+
compatible = "atmel,saml2x-mclk";
75+
reg = <0x40000400 0x400>;
76+
#clock-cells = <2>;
77+
};
78+
79+
gclk: gclk@40001800 {
80+
compatible = "atmel,saml2x-gclk";
81+
reg = <0x40001800 0x400>;
82+
#clock-cells = <1>;
83+
};
84+
85+
dmac: dmac@44000400 {
86+
compatible = "atmel,sam0-dmac";
87+
reg = <0x44000400 0x400>;
88+
interrupts = <5 0>;
89+
label = "DMA_0";
90+
#dma-cells = <2>;
91+
};
92+
93+
eic: eic@40002400 {
94+
compatible = "atmel,sam0-eic";
95+
reg = <0x40002400 0x24>;
96+
interrupts = <3 0>;
97+
label = "EIC";
98+
};
99+
100+
wdog: watchdog@40001c00 {
101+
compatible = "atmel,sam0-watchdog";
102+
reg = <0x40001c00 0x0c>;
103+
interrupts = <1 0>;
104+
label = "WATCHDOG_0";
105+
};
106+
107+
sercom0: sercom@42000000 {
108+
compatible = "atmel,sam0-sercom";
109+
reg = <0x42000000 0x40>;
110+
status = "disabled";
111+
label = "SERCOM0";
112+
};
113+
114+
sercom1: sercom@42000400 {
115+
compatible = "atmel,sam0-sercom";
116+
reg = <0x42000400 0x40>;
117+
status = "disabled";
118+
label = "SERCOM1";
119+
};
120+
121+
sercom2: sercom@42000800 {
122+
compatible = "atmel,sam0-sercom";
123+
reg = <0x42000800 0x40>;
124+
status = "disabled";
125+
label = "SERCOM2";
126+
};
127+
128+
sercom3: sercom@42000c00 {
129+
compatible = "atmel,sam0-sercom";
130+
reg = <0x42000C00 0x40>;
131+
status = "disabled";
132+
label = "SERCOM3";
133+
};
134+
135+
sercom4: sercom@42001000 {
136+
compatible = "atmel,sam0-sercom";
137+
reg = <0x42001000 0x40>;
138+
status = "disabled";
139+
label = "SERCOM4";
140+
};
141+
142+
sercom5: sercom@43000400 {
143+
compatible = "atmel,sam0-sercom";
144+
reg = <0x43000400 0x40>;
145+
status = "disabled";
146+
label = "SERCOM5";
147+
};
148+
149+
tc4: tc@43000800 {
150+
compatible = "atmel,sam0-tc32";
151+
reg = <0x43000800 0x34>;
152+
label = "TIMER_4";
153+
};
154+
155+
pinctrl: pinctrl@40002800 {
156+
compatible = "atmel,sam0-pinctrl";
157+
#address-cells = <1>;
158+
#size-cells = <1>;
159+
ranges = <0x40002800 0x40002800 0x100>;
160+
161+
porta: gpio@40002800 {
162+
compatible = "atmel,sam0-gpio";
163+
reg = <0x40002800 0x80>;
164+
label = "PORTA";
165+
gpio-controller;
166+
#gpio-cells = <2>;
167+
#atmel,pin-cells = <2>;
168+
169+
};
170+
171+
portb: gpio@40002880 {
172+
compatible = "atmel,sam0-gpio";
173+
reg = <0x40002880 0x80>;
174+
label = "PORTB";
175+
gpio-controller;
176+
#gpio-cells = <2>;
177+
#atmel,pin-cells = <2>;
178+
};
179+
};
180+
181+
rtc: rtc@40002000 {
182+
compatible = "atmel,sam0-rtc";
183+
reg = <0x40002000 0x1c>;
184+
interrupts = <2 0>;
185+
clock-generator = <0>;
186+
status = "disabled";
187+
label = "RTC";
188+
};
189+
190+
adc: adc@43000c00 {
191+
compatible = "atmel,sam0-adc";
192+
reg = <0x43000c00 0x30>;
193+
label = "ADC_0";
194+
195+
/*
196+
* 16 MHz max, so clock it with the
197+
* 48 MHz DFLL / 2 / 2 = 12 MHz
198+
*/
199+
gclk = <3>;
200+
prescaler = <2>;
201+
#io-channel-cells = <1>;
202+
};
203+
204+
dac: dac@42003000 {
205+
compatible = "atmel,sam0-dac";
206+
status = "disabled";
207+
reg = <0x42003000 0x1a>;
208+
label = "DAC_0";
209+
#io-channel-cells = <0>;
210+
};
211+
212+
trng: random@42003800 {
213+
compatible = "atmel,sam-trng";
214+
reg = <0x42003800 0x24>;
215+
peripheral-id = <0>;
216+
interrupts = <27 0>;
217+
label = "ENTROPY_0";
218+
};
219+
};
220+
};
221+
222+
&nvic {
223+
arm,num-irq-priority-bits = <2>;
224+
};
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2021 Argentum Systems Ltd.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Atmel SAML2x Generic Clock Controller (GCLK)
5+
6+
compatible: "atmel,saml2x-gclk"
7+
8+
include: [clock-controller.yaml, base.yaml]
9+
10+
properties:
11+
reg:
12+
required: true
13+
14+
"#clock-cells":
15+
const: 1
16+
17+
clock-cells:
18+
- periph_ch
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2021 Argentum Systems Ltd.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Atmel SAML2x Generic Clock Controller (MCLK)
5+
6+
compatible: "atmel,saml2x-mclk"
7+
8+
include: [clock-controller.yaml, base.yaml]
9+
10+
properties:
11+
reg:
12+
required: true
13+
14+
"#clock-cells":
15+
const: 2
16+
17+
clock-cells:
18+
- offset
19+
- bit

soc/arm/atmel_sam0/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ config SOC_FAMILY
1313
string
1414
default "atmel_sam0"
1515

16+
source "soc/arm/atmel_sam0/common/Kconfig.saml2x"
1617
source "soc/arm/atmel_sam0/common/Kconfig.samd2x"
1718
source "soc/arm/atmel_sam0/common/Kconfig.samd5x"
1819
source "soc/arm/atmel_sam0/*/Kconfig.soc"

soc/arm/atmel_sam0/common/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ zephyr_sources_ifdef(CONFIG_BOOTLOADER_BOSSA bossa.c)
1010
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMD20 soc_samd2x.c)
1111
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMD21 soc_samd2x.c)
1212
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMR21 soc_samd2x.c)
13+
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAML21 soc_saml2x.c)
1314

1415
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAMD51 soc_samd5x.c)
1516
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SAME51 soc_samd5x.c)

0 commit comments

Comments
 (0)