Skip to content

Commit 308b941

Browse files
boards: silabs: add ADC io-channels on multiples boards
The goal to add the zephyr,user io-channels is to be able to run the ADC samples without having an overlays for each boards. Signed-off-by: Martin Hoff <[email protected]>
1 parent cb5e4f3 commit 308b941

File tree

7 files changed

+184
-0
lines changed

7 files changed

+184
-0
lines changed

boards/silabs/radio_boards/slwrb4180a/slwrb4180a-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,10 @@
2121
silabs,input-filter;
2222
};
2323
};
24+
25+
iadc0_default: iadc0_default {
26+
group0 {
27+
silabs,analog-bus = <ABUS_AEVEN0_IADC0>;
28+
};
29+
};
2430
};

boards/silabs/radio_boards/slwrb4180a/slwrb4180a.dts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/dts-v1/;
88
#include <silabs/xg21/efr32mg21a020f1024im32.dtsi>
9+
#include <dt-bindings/adc/silabs-adc.h>
910
#include <zephyr/dt-bindings/input/input-event-codes.h>
1011
#include "slwrb4180a-pinctrl.dtsi"
1112

@@ -30,6 +31,7 @@
3031
sw0 = &button0;
3132
sw1 = &button1;
3233
watchdog0 = &wdog0;
34+
adc0 = &adc0;
3335
};
3436

3537
leds {
@@ -64,6 +66,37 @@
6466
};
6567
};
6668

69+
joystick {
70+
compatible = "adc-keys";
71+
io-channels = <&adc0 0>;
72+
keyup-threshold-mv = <3300>;
73+
74+
select-key {
75+
press-thresholds-mv = <33>;
76+
zephyr,code = <INPUT_KEY_ENTER>;
77+
};
78+
79+
left-key {
80+
press-thresholds-mv = <1980>;
81+
zephyr,code = <INPUT_KEY_LEFT>;
82+
};
83+
84+
down-key {
85+
press-thresholds-mv = <1650>;
86+
zephyr,code = <INPUT_KEY_DOWN>;
87+
};
88+
89+
up-key {
90+
press-thresholds-mv = <2831>;
91+
zephyr,code = <INPUT_KEY_UP>;
92+
};
93+
94+
right-key {
95+
press-thresholds-mv = <2533>;
96+
zephyr,code = <INPUT_KEY_RIGHT>;
97+
};
98+
};
99+
67100
exp_header: exp-header {
68101
compatible = "silabs,exp-header";
69102
#gpio-cells = <2>;
@@ -80,6 +113,10 @@
80113
gpio-map-mask = <0xffffffff 0x0>;
81114
gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>;
82115
};
116+
117+
zephyr,user {
118+
io-channels = <&adc0 0>;
119+
};
83120
};
84121

85122
&cpu0 {
@@ -128,6 +165,24 @@
128165
clocks = <&lfxo>;
129166
};
130167

168+
&adc0 {
169+
pinctrl-0 = <&iadc0_default>;
170+
pinctrl-names = "default";
171+
#address-cells = <1>;
172+
#size-cells = <0>;
173+
status = "okay";
174+
175+
channel@0 {
176+
reg = <0>;
177+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
178+
zephyr,gain = "ADC_GAIN_1";
179+
zephyr,input-positive = <IADC_INPUT_PA0>;
180+
zephyr,reference = "ADC_REF_VDD_1";
181+
zephyr,resolution = <12>;
182+
zephyr,vref-mv = <3300>;
183+
};
184+
};
185+
131186
&usart0 {
132187
current-speed = <115200>;
133188
pinctrl-0 = <&usart0_default>;

boards/silabs/radio_boards/slwrb4180b/slwrb4180b-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,10 @@
2020
silabs,input-filter;
2121
};
2222
};
23+
24+
iadc0_default: iadc0_default {
25+
group0 {
26+
silabs,analog-bus = <ABUS_AEVEN0_IADC0>;
27+
};
28+
};
2329
};

boards/silabs/radio_boards/slwrb4180b/slwrb4180b.dts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
/dts-v1/;
99
#include <silabs/xg21/efr32mg21a020f1024im32.dtsi>
10+
#include <dt-bindings/adc/silabs-adc.h>
1011
#include <zephyr/dt-bindings/input/input-event-codes.h>
1112
#include "slwrb4180b-pinctrl.dtsi"
1213

@@ -30,6 +31,7 @@
3031
sw0 = &button0;
3132
sw1 = &button1;
3233
watchdog0 = &wdog0;
34+
adc0 = &adc0;
3335
};
3436

3537
leds {
@@ -62,6 +64,37 @@
6264
};
6365
};
6466

67+
joystick {
68+
compatible = "adc-keys";
69+
io-channels = <&adc0 0>;
70+
keyup-threshold-mv = <3300>;
71+
72+
select-key {
73+
press-thresholds-mv = <33>;
74+
zephyr,code = <INPUT_KEY_ENTER>;
75+
};
76+
77+
left-key {
78+
press-thresholds-mv = <1980>;
79+
zephyr,code = <INPUT_KEY_LEFT>;
80+
};
81+
82+
down-key {
83+
press-thresholds-mv = <1650>;
84+
zephyr,code = <INPUT_KEY_DOWN>;
85+
};
86+
87+
up-key {
88+
press-thresholds-mv = <2831>;
89+
zephyr,code = <INPUT_KEY_UP>;
90+
};
91+
92+
right-key {
93+
press-thresholds-mv = <2533>;
94+
zephyr,code = <INPUT_KEY_RIGHT>;
95+
};
96+
};
97+
6598
exp_header: exp-header {
6699
compatible = "silabs,exp-header";
67100
#gpio-cells = <2>;
@@ -78,6 +111,10 @@
78111
gpio-map-mask = <0xffffffff 0x0>;
79112
gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>;
80113
};
114+
115+
zephyr,user {
116+
io-channels = <&adc0 0>;
117+
};
81118
};
82119

83120
&cpu0 {
@@ -126,6 +163,24 @@
126163
clocks = <&lfxo>;
127164
};
128165

166+
&adc0 {
167+
pinctrl-0 = <&iadc0_default>;
168+
pinctrl-names = "default";
169+
#address-cells = <1>;
170+
#size-cells = <0>;
171+
status = "okay";
172+
173+
channel@0 {
174+
reg = <0>;
175+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
176+
zephyr,gain = "ADC_GAIN_1";
177+
zephyr,input-positive = <IADC_INPUT_PA0>;
178+
zephyr,reference = "ADC_REF_VDD_1";
179+
zephyr,resolution = <12>;
180+
zephyr,vref-mv = <3300>;
181+
};
182+
};
183+
129184
&usart0 {
130185
current-speed = <115200>;
131186
pinctrl-0 = <&usart0_default>;

boards/silabs/radio_boards/xg27/xg27_rb4194a.dts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
sw1 = &button1;
3737
watchdog0 = &wdog0;
3838
dht0 = &si7021;
39+
adc0 = &adc0;
3940
};
4041

4142
leds {

boards/silabs/radio_boards/xg29_rb4412a/xg29_rb4412a-pinctrl.dtsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
};
2222
};
2323

24+
iadc0_default: iadc0_default {
25+
group0 {
26+
silabs,analog-bus = <ABUS_CDODD0_IADC0>;
27+
};
28+
};
29+
2430
itm_default: itm_default {
2531
group0 {
2632
pins = <GPIO_SWV_PA3>;

boards/silabs/radio_boards/xg29_rb4412a/xg29_rb4412a.dts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
/dts-v1/;
88
#include <silabs/xg29/efr32mg29b140f1024im40.dtsi>
9+
#include <dt-bindings/adc/silabs-adc.h>
910
#include <zephyr/dt-bindings/input/input-event-codes.h>
1011
#include <zephyr/dt-bindings/pwm/pwm.h>
1112
#include <zephyr/dt-bindings/regulator/silabs_dcdc.h>
@@ -35,6 +36,7 @@
3536
sw1 = &button1;
3637
watchdog0 = &wdog0;
3738
dht0 = &si7021;
39+
adc0 = &adc0;
3840
};
3941

4042
leds {
@@ -75,6 +77,37 @@
7577
};
7678
};
7779

80+
joystick {
81+
compatible = "adc-keys";
82+
io-channels = <&adc0 0>;
83+
keyup-threshold-mv = <3300>;
84+
85+
select-key {
86+
press-thresholds-mv = <33>;
87+
zephyr,code = <INPUT_KEY_ENTER>;
88+
};
89+
90+
left-key {
91+
press-thresholds-mv = <1980>;
92+
zephyr,code = <INPUT_KEY_LEFT>;
93+
};
94+
95+
down-key {
96+
press-thresholds-mv = <1650>;
97+
zephyr,code = <INPUT_KEY_DOWN>;
98+
};
99+
100+
up-key {
101+
press-thresholds-mv = <2831>;
102+
zephyr,code = <INPUT_KEY_UP>;
103+
};
104+
105+
right-key {
106+
press-thresholds-mv = <2533>;
107+
zephyr,code = <INPUT_KEY_RIGHT>;
108+
};
109+
};
110+
78111
display_enable: sensor_enable: gpio_switch_0 {
79112
compatible = "regulator-fixed";
80113
enable-gpios = <&gpioc 7 GPIO_ACTIVE_HIGH>;
@@ -98,6 +131,10 @@
98131
gpio-map-mask = <0xffffffff 0x0>;
99132
gpio-map-pass-thru = <0x0 GPIO_DT_FLAGS_MASK>;
100133
};
134+
135+
zephyr,user {
136+
io-channels = <&adc0 0>;
137+
};
101138
};
102139

103140
&cpu0 {
@@ -210,6 +247,24 @@
210247
};
211248
};
212249

250+
&adc0 {
251+
pinctrl-0 = <&iadc0_default>;
252+
pinctrl-names = "default";
253+
#address-cells = <1>;
254+
#size-cells = <0>;
255+
status = "okay";
256+
257+
channel@0 {
258+
reg = <0>;
259+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
260+
zephyr,gain = "ADC_GAIN_1";
261+
zephyr,input-positive = <IADC_INPUT_PD3>;
262+
zephyr,reference = "ADC_REF_VDD_1";
263+
zephyr,resolution = <12>;
264+
zephyr,vref-mv = <3300>;
265+
};
266+
};
267+
213268
&gpio {
214269
status = "okay";
215270
};

0 commit comments

Comments
 (0)