drivers: serial: stm32: use new pinctrl API
Use the new pinctrl API to configure pins. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
4b9c3d7134
commit
21a271962c
5 changed files with 8 additions and 45 deletions
|
@ -20,8 +20,6 @@
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <drivers/uart.h>
|
#include <drivers/uart.h>
|
||||||
#include <drivers/pinmux.h>
|
|
||||||
#include <pinmux/pinmux_stm32.h>
|
|
||||||
#include <drivers/clock_control.h>
|
#include <drivers/clock_control.h>
|
||||||
#include <pm/pm.h>
|
#include <pm/pm.h>
|
||||||
|
|
||||||
|
@ -1507,9 +1505,7 @@ static int uart_stm32_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure dt provided device signals when available */
|
/* Configure dt provided device signals when available */
|
||||||
err = stm32_dt_pinctrl_configure(config->pinctrl_list,
|
err = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
config->pinctrl_list_size,
|
|
||||||
(uint32_t)UART_STRUCT(dev));
|
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1657,8 +1653,7 @@ static void uart_stm32_irq_config_func_##index(const struct device *dev) \
|
||||||
#define STM32_UART_INIT(index) \
|
#define STM32_UART_INIT(index) \
|
||||||
STM32_UART_IRQ_HANDLER_DECL(index) \
|
STM32_UART_IRQ_HANDLER_DECL(index) \
|
||||||
\
|
\
|
||||||
static const struct soc_gpio_pinctrl uart_pins_##index[] = \
|
PINCTRL_DT_INST_DEFINE(index) \
|
||||||
ST_STM32_DT_INST_PINCTRL(index, 0); \
|
|
||||||
\
|
\
|
||||||
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||||
.uconf = { \
|
.uconf = { \
|
||||||
|
@ -1670,9 +1665,8 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||||
}, \
|
}, \
|
||||||
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
|
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
|
||||||
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
.parity = DT_INST_ENUM_IDX_OR(index, parity, UART_CFG_PARITY_NONE), \
|
||||||
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(index), \
|
||||||
STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
|
STM32_UART_POLL_IRQ_HANDLER_FUNC(index) \
|
||||||
.pinctrl_list = uart_pins_##index, \
|
|
||||||
.pinctrl_list_size = ARRAY_SIZE(uart_pins_##index), \
|
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
static struct uart_stm32_data uart_stm32_data_##index = { \
|
static struct uart_stm32_data uart_stm32_data_##index = { \
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
||||||
#define ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
#define ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
||||||
|
|
||||||
#include <drivers/pinmux.h>
|
#include <drivers/pinctrl.h>
|
||||||
|
|
||||||
/* device config */
|
/* device config */
|
||||||
struct uart_stm32_config {
|
struct uart_stm32_config {
|
||||||
|
@ -23,8 +23,7 @@ struct uart_stm32_config {
|
||||||
bool hw_flow_control;
|
bool hw_flow_control;
|
||||||
/* initial parity, 0 for none, 1 for odd, 2 for even */
|
/* initial parity, 0 for none, 1 for odd, 2 for even */
|
||||||
int parity;
|
int parity;
|
||||||
const struct soc_gpio_pinctrl *pinctrl_list;
|
const struct pinctrl_dev_config *pcfg;
|
||||||
size_t pinctrl_list_size;
|
|
||||||
#if defined(CONFIG_PM) \
|
#if defined(CONFIG_PM) \
|
||||||
&& !defined(CONFIG_UART_INTERRUPT_DRIVEN) \
|
&& !defined(CONFIG_UART_INTERRUPT_DRIVEN) \
|
||||||
&& !defined(CONFIG_UART_ASYNC_API)
|
&& !defined(CONFIG_UART_ASYNC_API)
|
||||||
|
|
|
@ -2,7 +2,7 @@ description: STM32 LPUART
|
||||||
|
|
||||||
compatible: "st,stm32-lpuart"
|
compatible: "st,stm32-lpuart"
|
||||||
|
|
||||||
include: uart-controller.yaml
|
include: [uart-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -13,13 +13,3 @@ properties:
|
||||||
|
|
||||||
clocks:
|
clocks:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinctrl-0:
|
|
||||||
type: phandles
|
|
||||||
required: false
|
|
||||||
description: |
|
|
||||||
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
|
|
||||||
that the phandles will reference pinctrl nodes.
|
|
||||||
|
|
||||||
For example the USART1 would be
|
|
||||||
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ description: STM32 UART
|
||||||
|
|
||||||
compatible: "st,stm32-uart"
|
compatible: "st,stm32-uart"
|
||||||
|
|
||||||
include: uart-controller.yaml
|
include: [uart-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -10,13 +10,3 @@ properties:
|
||||||
|
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinctrl-0:
|
|
||||||
type: phandles
|
|
||||||
required: false
|
|
||||||
description: |
|
|
||||||
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
|
|
||||||
that the phandles will reference pinctrl nodes.
|
|
||||||
|
|
||||||
For example the USART1 would be
|
|
||||||
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ description: STM32 USART
|
||||||
|
|
||||||
compatible: "st,stm32-usart"
|
compatible: "st,stm32-usart"
|
||||||
|
|
||||||
include: uart-controller.yaml
|
include: [uart-controller.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
reg:
|
reg:
|
||||||
|
@ -10,13 +10,3 @@ properties:
|
||||||
|
|
||||||
interrupts:
|
interrupts:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
pinctrl-0:
|
|
||||||
type: phandles
|
|
||||||
required: false
|
|
||||||
description: |
|
|
||||||
GPIO pin configuration for serial signals (RX, TX, RTS, CTS). We expect
|
|
||||||
that the phandles will reference pinctrl nodes.
|
|
||||||
|
|
||||||
For example the USART1 would be
|
|
||||||
pinctrl-0 = <&usart1_tx_pb6 &usart1_rx_pb7>;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue