driver/uart: add enum parity element on devicetree bindings

It helps configurations of the parity mode for uart interfaces

Signed-off-by: Luc Viala <lviala@zaack.io>
This commit is contained in:
Luc Viala 2021-06-07 14:50:56 +02:00 committed by Kumar Gala
commit 7105875ff4
6 changed files with 23 additions and 22 deletions

View file

@ -27,6 +27,7 @@ struct mcux_flexcomm_config {
const struct device *clock_dev;
clock_control_subsys_t clock_subsys;
uint32_t baud_rate;
uint8_t parity;
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
void (*irq_config_func)(const struct device *dev);
#endif
@ -247,6 +248,7 @@ static int mcux_flexcomm_init(const struct device *dev)
{
const struct mcux_flexcomm_config *config = dev->config;
usart_config_t usart_config;
usart_parity_mode_t parity_mode;
uint32_t clock_freq;
/* Get the clock frequency */
@ -255,9 +257,18 @@ static int mcux_flexcomm_init(const struct device *dev)
return -EINVAL;
}
if (config->parity == UART_CFG_PARITY_ODD) {
parity_mode = kUSART_ParityOdd;
} else if (config->parity == UART_CFG_PARITY_EVEN) {
parity_mode = kUSART_ParityEven;
} else {
parity_mode = kUSART_ParityDisabled;
}
USART_GetDefaultConfig(&usart_config);
usart_config.enableTx = true;
usart_config.enableRx = true;
usart_config.parityMode = parity_mode;
usart_config.baudRate_Bps = config->baud_rate;
USART_Init(config->base, &usart_config, clock_freq);
@ -321,6 +332,7 @@ static const struct mcux_flexcomm_config mcux_flexcomm_##n##_config = { \
.clock_subsys = \
(clock_control_subsys_t)DT_INST_CLOCKS_CELL(n, name),\
.baud_rate = DT_INST_PROP(n, current_speed), \
.parity = DT_ENUM_IDX_OR(DT_DRV_INST(n), parity, UART_CFG_PARITY_NONE), \
IRQ_FUNC_INIT \
}

View file

@ -1572,7 +1572,7 @@ static const struct uart_stm32_config uart_stm32_cfg_##index = { \
.enr = DT_INST_CLOCKS_CELL(index, bits) \
}, \
.hw_flow_control = DT_INST_PROP(index, hw_flow_control), \
.parity = DT_INST_PROP_OR(index, parity, UART_CFG_PARITY_NONE), \
.parity = DT_ENUM_IDX_OR(DT_DRV_INST(index), parity, UART_CFG_PARITY_NONE), \
.pinctrl_list = uart_pins_##index, \
.pinctrl_list_size = ARRAY_SIZE(uart_pins_##index), \
}; \

View file

@ -14,13 +14,6 @@ properties:
clocks:
required: true
parity:
required: false
type: int
description: |
Configures the parity of the adapter. Value 0 for none, 1 for odd
and 2 for even parity. Default to none if not specified.
pinctrl-0:
type: phandles
required: false

View file

@ -11,13 +11,6 @@ properties:
interrupts:
required: true
parity:
required: false
type: int
description: |
Configures the parity of the adapter. Value 0 for none, 1 for odd
and 2 for even parity. Default to none if not specified.
pinctrl-0:
type: phandles
required: false

View file

@ -11,13 +11,6 @@ properties:
interrupts:
required: true
parity:
required: false
type: int
description: |
Configures the parity of the adapter. Value 0 for none, 1 for odd
and 2 for even parity. Default to none if not specified.
pinctrl-0:
type: phandles
required: false

View file

@ -19,3 +19,13 @@ properties:
type: boolean
required: false
description: Set to enable RTS/CTS flow control at boot time
parity:
required: false
type: string
description: |
Configures the parity of the adapter. Enumeration id 0 for none, 1 for odd
and 2 for even parity. Default to none if not specified.
enum:
- "none"
- "odd"
- "even"