Skip to content

Commit e69a0ed

Browse files
committed
drivers: serial: stm32: use new pinctrl API
Use the new pinctrl API to configure pins. Signed-off-by: Gerard Marull-Paretas <[email protected]>
1 parent ac3269c commit e69a0ed

File tree

5 files changed

+8
-45
lines changed

5 files changed

+8
-45
lines changed

drivers/serial/uart_stm32.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include <soc.h>
2121
#include <init.h>
2222
#include <drivers/uart.h>
23-
#include <drivers/pinmux.h>
24-
#include <pinmux/pinmux_stm32.h>
2523
#include <drivers/clock_control.h>
2624
#include <pm/pm.h>
2725

@@ -1430,9 +1428,7 @@ static int uart_stm32_init(const struct device *dev)
14301428
}
14311429

14321430
/* Configure dt provided device signals when available */
1433-
err = stm32_dt_pinctrl_configure(config->pinctrl_list,
1434-
config->pinctrl_list_size,
1435-
(uint32_t)UART_STRUCT(dev));
1431+
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
14361432
if (err < 0) {
14371433
return err;
14381434
}
@@ -1580,8 +1576,7 @@ static void uart_stm32_irq_config_func_##index(const struct device *dev) \
15801576
#define STM32_UART_INIT(index) \
15811577
STM32_UART_IRQ_HANDLER_DECL(index) \
15821578
\
1583-
static const struct soc_gpio_pinctrl uart_pins_##index[] = \
1584-
ST_STM32_DT_INST_PINCTRL(index, 0); \
1579+
PINCTRL_DT_INST_DEFINE(index) \
15851580
\
15861581
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
15871582
.uconf = { \
@@ -1593,9 +1588,8 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
15931588
}, \
15941589
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
15951590
.parity = DT_ENUM_IDX_OR(DT_DRV_INST(index), parity, UART_CFG_PARITY_NONE), \
1591+
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
15961592
STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
1597-
.pinctrl_list = uart_pins_##index, \
1598-
.pinctrl_list_size = ARRAY_SIZE(uart_pins_##index), \
15991593
}; \
16001594
\
16011595
static struct uart_stm32_data uart_stm32_data_##index = { \

drivers/serial/uart_stm32.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
1313
#define ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
1414

15-
#include <drivers/pinmux.h>
15+
#include <drivers/pinctrl.h>
1616

1717
/* device config */
1818
struct uart_stm32_config {
@@ -23,8 +23,7 @@ struct uart_stm32_config {
2323
bool hw_flow_control;
2424
/* initial parity, 0 for none, 1 for odd, 2 for even */
2525
int parity;
26-
const struct soc_gpio_pinctrl *pinctrl_list;
27-
size_t pinctrl_list_size;
26+
const struct pinctrl_dev_config *pcfg;
2827
#if defined(CONFIG_PM) \
2928
&& !defined(CONFIG_UART_INTERRUPT_DRIVEN) \
3029
&& !defined(CONFIG_UART_ASYNC_API)

dts/bindings/serial/st,stm32-lpuart.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ description: STM32 LPUART
22

33
compatible: "st,stm32-lpuart"
44

5-
include: uart-controller.yaml
5+
include: [uart-controller.yaml, pinctrl-device.yaml]
66

77
properties:
88
reg:
@@ -13,13 +13,3 @@ properties:
1313

1414
clocks:
1515
required: true
16-
17-
pinctrl-0:
18-
type: phandles
19-
required: false
20-
description: |
21-
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
22-
that the phandles will reference pinctrl nodes.
23-
24-
For example the USART1 would be
25-
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;

dts/bindings/serial/st,stm32-uart.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@ description: STM32 UART
22

33
compatible: "st,stm32-uart"
44

5-
include: uart-controller.yaml
5+
include: [uart-controller.yaml, pinctrl-device.yaml]
66

77
properties:
88
reg:
99
required: true
1010

1111
interrupts:
1212
required: true
13-
14-
pinctrl-0:
15-
type: phandles
16-
required: false
17-
description: |
18-
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
19-
that the phandles will reference pinctrl nodes.
20-
21-
For example the USART1 would be
22-
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;

dts/bindings/serial/st,stm32-usart.yaml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@ description: STM32 USART
22

33
compatible: "st,stm32-usart"
44

5-
include: uart-controller.yaml
5+
include: [uart-controller.yaml, pinctrl-device.yaml]
66

77
properties:
88
reg:
99
required: true
1010

1111
interrupts:
1212
required: true
13-
14-
pinctrl-0:
15-
type: phandles
16-
required: false
17-
description: |
18-
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
19-
that the phandles will reference pinctrl nodes.
20-
21-
For example the USART1 would be
22-
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;

0 commit comments

Comments
 (0)