drivers: serial: stm32: Move boot-time config to data
Move reset configuration from uart_stm32_data to const uart_stm32_config struct, as this is set once at boot and isn't modified during runtime. Signed-off-by: Kenneth J. Miller <ken@miller.ec>
This commit is contained in:
parent
2531d70ad2
commit
bde1cd8d38
2 changed files with 5 additions and 5 deletions
|
@ -1853,13 +1853,13 @@ static int uart_stm32_init(const struct device *dev)
|
||||||
|
|
||||||
LL_USART_Disable(config->usart);
|
LL_USART_Disable(config->usart);
|
||||||
|
|
||||||
if (!device_is_ready(data->reset.dev)) {
|
if (!device_is_ready(config->reset.dev)) {
|
||||||
LOG_ERR("reset controller not ready");
|
LOG_ERR("reset controller not ready");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset UART to default state using RCC */
|
/* Reset UART to default state using RCC */
|
||||||
(void)reset_line_toggle_dt(&data->reset);
|
(void)reset_line_toggle_dt(&config->reset);
|
||||||
|
|
||||||
/* TX/RX direction */
|
/* TX/RX direction */
|
||||||
LL_USART_SetTransferDirection(config->usart,
|
LL_USART_SetTransferDirection(config->usart,
|
||||||
|
@ -2143,6 +2143,7 @@ static const struct stm32_pclken pclken_##index[] = \
|
||||||
\
|
\
|
||||||
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||||
.usart = (USART_TypeDef *)DT_INST_REG_ADDR(index), \
|
.usart = (USART_TypeDef *)DT_INST_REG_ADDR(index), \
|
||||||
|
.reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \
|
||||||
.pclken = pclken_##index, \
|
.pclken = pclken_##index, \
|
||||||
.pclk_len = DT_INST_NUM_CLOCKS(index), \
|
.pclk_len = DT_INST_NUM_CLOCKS(index), \
|
||||||
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
|
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
|
||||||
|
@ -2162,7 +2163,6 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
|
||||||
\
|
\
|
||||||
static struct uart_stm32_data uart_stm32_data_##index = { \
|
static struct uart_stm32_data uart_stm32_data_##index = { \
|
||||||
.baud_rate = DT_INST_PROP(index, current_speed), \
|
.baud_rate = DT_INST_PROP(index, current_speed), \
|
||||||
.reset = RESET_DT_SPEC_GET(DT_DRV_INST(index)), \
|
|
||||||
UART_DMA_CHANNEL(index, rx, RX, PERIPHERAL, MEMORY) \
|
UART_DMA_CHANNEL(index, rx, RX, PERIPHERAL, MEMORY) \
|
||||||
UART_DMA_CHANNEL(index, tx, TX, MEMORY, PERIPHERAL) \
|
UART_DMA_CHANNEL(index, tx, TX, MEMORY, PERIPHERAL) \
|
||||||
}; \
|
}; \
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
struct uart_stm32_config {
|
struct uart_stm32_config {
|
||||||
/* USART instance */
|
/* USART instance */
|
||||||
USART_TypeDef *usart;
|
USART_TypeDef *usart;
|
||||||
|
/* Reset controller device configuration */
|
||||||
|
const struct reset_dt_spec reset;
|
||||||
/* clock subsystem driving this peripheral */
|
/* clock subsystem driving this peripheral */
|
||||||
const struct stm32_pclken *pclken;
|
const struct stm32_pclken *pclken;
|
||||||
/* number of clock subsystems */
|
/* number of clock subsystems */
|
||||||
|
@ -84,8 +86,6 @@ struct uart_stm32_data {
|
||||||
uint32_t baud_rate;
|
uint32_t baud_rate;
|
||||||
/* clock device */
|
/* clock device */
|
||||||
const struct device *clock;
|
const struct device *clock;
|
||||||
/* Reset controller device configuration */
|
|
||||||
const struct reset_dt_spec reset;
|
|
||||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||||
uart_irq_callback_user_data_t user_cb;
|
uart_irq_callback_user_data_t user_cb;
|
||||||
void *user_data;
|
void *user_data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue