Skip to content

Commit 46f33bc

Browse files
erwangonashif
authored andcommitted
drivers/pinmux: stm32: Enable PM_DEVICE_RUNTIME services
Add PM_DEVICE_RUNTIME support Signed-off-by: Erwan Gouriou <[email protected]>
1 parent 13de6e3 commit 46f33bc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/pinmux/stm32/pinmux_stm32.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <gpio/gpio_stm32.h>
2323
#include <drivers/clock_control/stm32_clock_control.h>
2424
#include <pinmux/stm32/pinmux_stm32.h>
25+
#include <pm/device_runtime.h>
2526

2627
#define GPIO_DEVICE(gpio_port) \
2728
COND_CODE_1(DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_port), okay), \
@@ -127,15 +128,27 @@ int stm32_dt_pinctrl_configure(const struct soc_gpio_pinctrl *pinctrl,
127128
STM32_DT_PINMUX_LINE(mux));
128129
port_device = gpio_ports[STM32_PORT(pin)];
129130

131+
#ifdef CONFIG_PM_DEVICE_RUNTIME
132+
ret = pm_device_get_sync(port_device);
133+
#else
130134
ret = gpio_stm32_clock_request(port_device, true);
135+
/* Note, we don't use pm_constraint_foo functions here */
136+
/* since idle period should not happen between clock_on */
137+
/* and clock_off */
138+
#endif
139+
131140
if (ret != 0) {
132141
return ret;
133142
}
134143

135144
stm32_pin_configure(pin, func, STM32_DT_PINMUX_FUNC(mux));
145+
146+
#ifdef CONFIG_PM_DEVICE_RUNTIME
147+
ret = pm_device_put(port_device);
148+
#endif
136149
}
137150

138-
return 0;
151+
return ret;
139152
}
140153

141154
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32f1_pinctrl)

0 commit comments

Comments
 (0)