Skip to content

Commit 8654ac9

Browse files
dts: bindings: introduce nordic,nrf-pad-groups
Some nordic platforms have quite complex pad groups which belong to power domains. Introduce bindings for these groups and describe the pad groups of the nrf54h20. Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
1 parent 87e9f3a commit 8654ac9

File tree

4 files changed

+115
-46
lines changed

4 files changed

+115
-46
lines changed

drivers/pinctrl/pinctrl_nrf.c

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,63 +111,63 @@ static const nrf_gpio_pin_drive_t drive_modes[NRF_DRIVE_COUNT] = {
111111
#define NRF_PSEL_TDM(reg, line) ((NRF_TDM_Type *)reg)->PSEL.line
112112
#endif
113113

114-
#define PORT_PD_EXISTS(node_id) \
114+
#define PAD_PD_EXISTS(node_id) \
115115
COND_CODE_1( \
116116
DT_NODE_EXISTS(node_id), \
117117
(DT_NODE_HAS_PROP(node_id, power_domains)), \
118118
(0) \
119119
)
120120

121-
#define PORT_PD_DEV_GET_OR_NULL(node_id) \
121+
#define PAD_PD_DEV_GET_OR_NULL(node_id) \
122122
COND_CODE_1( \
123123
DT_NODE_EXISTS(node_id), \
124124
(DEVICE_DT_GET_OR_NULL(DT_PHANDLE(node_id, power_domains))), \
125125
(NULL) \
126126
)
127127

128128
#define PORTS_HAVE_PD \
129-
PORT_PD_EXISTS(DT_NODELABEL(gpio0)) || \
130-
PORT_PD_EXISTS(DT_NODELABEL(gpio1)) || \
131-
PORT_PD_EXISTS(DT_NODELABEL(gpio2)) || \
132-
PORT_PD_EXISTS(DT_NODELABEL(gpio3)) || \
133-
PORT_PD_EXISTS(DT_NODELABEL(gpio4)) || \
134-
PORT_PD_EXISTS(DT_NODELABEL(gpio5)) || \
135-
PORT_PD_EXISTS(DT_NODELABEL(gpio6)) || \
136-
PORT_PD_EXISTS(DT_NODELABEL(gpio7)) || \
137-
PORT_PD_EXISTS(DT_NODELABEL(gpio8)) || \
138-
PORT_PD_EXISTS(DT_NODELABEL(gpio9))
129+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p0)) || \
130+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p1)) || \
131+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p2)) || \
132+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p3)) || \
133+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p4)) || \
134+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p5)) || \
135+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p6)) || \
136+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p7)) || \
137+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p8)) || \
138+
PAD_PD_EXISTS(DT_NODELABEL(pad_group_p9))
139139

140140
#if PORTS_HAVE_PD
141141

142-
static const struct device *const port_pd_devs[] = {
143-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio0)),
144-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio1)),
145-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio2)),
146-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio3)),
147-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio4)),
148-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio5)),
149-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio6)),
150-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio7)),
151-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio8)),
152-
PORT_PD_DEV_GET_OR_NULL(DT_NODELABEL(gpio9)),
142+
static const struct device *const pad_pd_devs[] = {
143+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p0)),
144+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p1)),
145+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p2)),
146+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p3)),
147+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p4)),
148+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p5)),
149+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p6)),
150+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p7)),
151+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p8)),
152+
PAD_PD_DEV_GET_OR_NULL(DT_NODELABEL(pad_group_p9)),
153153
};
154154

155-
static atomic_t port_pd_masks[ARRAY_SIZE(port_pd_devs)];
155+
static atomic_t pad_pd_masks[ARRAY_SIZE(pad_pd_devs)];
156156

157-
static int port_pd_request_pin(uint16_t pin_number)
157+
static int pad_pd_request_pin(uint16_t pin_number)
158158
{
159159
uint8_t port_number = NRF_GET_PORT(pin_number);
160160
uint16_t port_pin_number = NRF_GET_PORT_PIN(pin_number);
161-
const struct device *port_pd_dev = port_pd_devs[port_number];
162-
atomic_t *port_pd_mask = &port_pd_masks[port_number];
161+
const struct device *pad_pd_dev = pad_pd_devs[port_number];
162+
atomic_t *pad_pd_mask = &pad_pd_masks[port_number];
163163

164-
if (atomic_test_and_set_bit(port_pd_mask, port_pin_number)) {
164+
if (atomic_test_and_set_bit(pad_pd_mask, port_pin_number)) {
165165
/* already requested */
166166
return 0;
167167
}
168168

169-
if (pm_device_runtime_get(port_pd_dev)) {
170-
atomic_clear_bit(port_pd_mask, port_pin_number);
169+
if (pm_device_runtime_get(pad_pd_dev)) {
170+
atomic_clear_bit(pad_pd_mask, port_pin_number);
171171
return -EIO;
172172
}
173173

@@ -176,24 +176,24 @@ static int port_pd_request_pin(uint16_t pin_number)
176176
return 0;
177177
}
178178

179-
static int port_pd_release_pin(uint16_t pin_number)
179+
static int pad_pd_release_pin(uint16_t pin_number)
180180
{
181181
uint8_t port_number = NRF_GET_PORT(pin_number);
182182
uint16_t port_pin_number = NRF_GET_PORT_PIN(pin_number);
183-
const struct device *port_pd_dev = port_pd_devs[port_number];
184-
atomic_t *port_pd_mask = &port_pd_masks[port_number];
183+
const struct device *pad_pd_dev = pad_pd_devs[port_number];
184+
atomic_t *pad_pd_mask = &pad_pd_masks[port_number];
185185

186-
if (!atomic_test_and_clear_bit(port_pd_mask, port_pin_number)) {
186+
if (!atomic_test_and_clear_bit(pad_pd_mask, port_pin_number)) {
187187
/* already released */
188188
return 0;
189189
}
190190

191191
/* power domain may become inactive, retain shall be enabled */
192192
nrf_gpio_pin_retain_enable(pin_number);
193193

194-
if (pm_device_runtime_put(port_pd_dev)) {
194+
if (pm_device_runtime_put(pad_pd_dev)) {
195195
nrf_gpio_pin_retain_disable(pin_number);
196-
atomic_set_bit(port_pd_mask, port_pin_number);
196+
atomic_set_bit(pad_pd_mask, port_pin_number);
197197
return -EIO;
198198
}
199199

@@ -202,13 +202,13 @@ static int port_pd_release_pin(uint16_t pin_number)
202202

203203
#else
204204

205-
static int port_pd_request_pin(uint16_t pin_number)
205+
static int pad_pd_request_pin(uint16_t pin_number)
206206
{
207207
ARG_UNUSED(pin_number);
208208
return 0;
209209
}
210210

211-
static int port_pd_release_pin(uint16_t pin_number)
211+
static int pad_pd_release_pin(uint16_t pin_number)
212212
{
213213
ARG_UNUSED(pin_number);
214214
return 0;
@@ -590,7 +590,7 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
590590
uint32_t pin = psel;
591591

592592
/* enable pin */
593-
port_pd_request_pin(pin);
593+
pad_pd_request_pin(pin);
594594
port_pin_clock_set(pin, NRF_GET_CLOCKPIN_ENABLE(pins[i]));
595595

596596
if (write != NO_WRITE) {
@@ -609,7 +609,7 @@ int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
609609

610610
if (NRF_GET_LP(pins[i]) == NRF_LP_ENABLE) {
611611
/* disable pin */
612-
port_pd_release_pin(pin);
612+
pad_pd_release_pin(pin);
613613
port_pin_clock_set(pin, false);
614614
}
615615
}

dts/bindings/gpio/nordic,nrf-gpio.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ properties:
3737
3838
port = <1>;
3939
40+
pad-group:
41+
type: phandle
42+
description: |
43+
The pad group this GPIO port can be muxed to. The pad group is
44+
presumed to be "always on" if omitted.
45+
4046
gpio-cells:
4147
- pin
4248
- flags
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2025 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
Nordic nRF pad groups.
6+
7+
The pad groups describe groups of pads connected to
8+
package pins of the SoC. A pad group will have a
9+
combination of IO, VDD and GND pads. A pad group
10+
will have a single supply and belong to a single
11+
power domain.
12+
13+
compatible: "nordic,nrf-pad-groups"
14+
15+
child-binding:
16+
description: Nordic nRF GPIO pad group.
17+
18+
properties:
19+
power-domains:
20+
type: phandle-array
21+
description: Pad group's power domain.
22+
23+
data-pads-mask:
24+
type: int
25+
description: Mask of data pads.
26+
27+
clock-pads-mask:
28+
type: int
29+
description: Mask of clock pads.
30+
31+
fast-pads-mask:
32+
type: int
33+
description: Mask of fast pads.

dts/vendor/nordic/nrf54h20.dtsi

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,34 @@
246246
status = "disabled";
247247
};
248248

249+
pad-groups {
250+
compatible = "nordic,nrf-pad-groups";
251+
252+
pad_group_p0: p0 {
253+
power-domains = <&gdpwr_slow_main>;
254+
};
255+
256+
pad_group_p1: p1 {
257+
power-domains = <&gdpwr_slow_main>;
258+
};
259+
260+
pad_group_p2: p2 {
261+
power-domains = <&gdpwr_slow_main>;
262+
};
263+
264+
pad_group_p6: p6 {
265+
power-domains = <&gdpwr_fast_active_1>;
266+
};
267+
268+
pad_group_p7: p7 {
269+
power-domains = <&gdpwr_fast_active_1>;
270+
};
271+
272+
pad_group_p9: p9 {
273+
power-domains = <&gdpwr_slow_main>;
274+
};
275+
};
276+
249277
soc {
250278
#address-cells = <1>;
251279
#size-cells = <1>;
@@ -848,6 +876,7 @@
848876
gpiote-instance = <&gpiote130>;
849877
ngpios = <12>;
850878
port = <0>;
879+
pad-group = <&pad_group_p0>;
851880
};
852881

853882
gpio1: gpio@938200 {
@@ -860,6 +889,7 @@
860889
gpiote-instance = <&gpiote130>;
861890
ngpios = <12>;
862891
port = <1>;
892+
pad-group = <&pad_group_p1>;
863893
};
864894

865895
gpio2: gpio@938400 {
@@ -872,6 +902,7 @@
872902
gpiote-instance = <&gpiote130>;
873903
ngpios = <12>;
874904
port = <2>;
905+
pad-group = <&pad_group_p2>;
875906
};
876907

877908
gpio6: gpio@938c00 {
@@ -880,11 +911,10 @@
880911
status = "disabled";
881912
#gpio-cells = <2>;
882913
gpio-controller;
883-
power-domains = <&gdpwr_slow_main>,
884-
<&gdpwr_fast_active_1>;
885-
power-domain-names = "peripheral", "pad";
914+
power-domains = <&gdpwr_slow_main>;
886915
ngpios = <14>;
887916
port = <6>;
917+
pad-group = <&pad_group_p6>;
888918
};
889919

890920
gpio7: gpio@938e00 {
@@ -893,11 +923,10 @@
893923
status = "disabled";
894924
#gpio-cells = <2>;
895925
gpio-controller;
896-
power-domains = <&gdpwr_slow_main>,
897-
<&gdpwr_fast_active_1>;
898-
power-domain-names = "peripheral", "pad";
926+
power-domains = <&gdpwr_slow_main>;
899927
ngpios = <8>;
900928
port = <7>;
929+
pad-group = <&pad_group_p7>;
901930
};
902931

903932
gpio9: gpio@939200 {
@@ -910,6 +939,7 @@
910939
gpiote-instance = <&gpiote130>;
911940
ngpios = <6>;
912941
port = <9>;
942+
pad-group = <&pad_group_p9>;
913943
};
914944

915945
dppic131: dppic@981000 {

0 commit comments

Comments
 (0)