serial: Provide new numbering scheme for stm32 UART
There was a misalignment between Zephyr UART device numbering and SoC UART IP. Device "UART_1" was mapped to IP USART_2, which could be confusing for user. This commit allows to align "UART_1" to IP USART_1. Change is propagated to all STM32F103RB/STM32F401RE based boards and respective pinmux drivers Change-Id: Ia8099dfeec7b9c0c686c2a58ccb4dbb1a55b6537 Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
575207c6ff
commit
2fcf3435c1
13 changed files with 160 additions and 159 deletions
|
@ -319,57 +319,6 @@ static int uart_stm32_init(struct device *dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_STM32_PORT_0
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_stm32_irq_config_func_0(struct device *dev);
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
static const struct uart_stm32_config uart_stm32_dev_cfg_0 = {
|
||||
.uconf = {
|
||||
.base = (uint8_t *)USART1_BASE,
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_stm32_irq_config_func_0,
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
},
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART1),
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
.pclken = { .bus = STM32F4X_CLOCK_BUS_APB2,
|
||||
.enr = STM32F4X_CLOCK_ENABLE_USART1 },
|
||||
#endif /* CONFIG_SOC_SERIES_STM32FX */
|
||||
};
|
||||
|
||||
static struct uart_stm32_data uart_stm32_dev_data_0 = {
|
||||
.huart = {
|
||||
.Init = {
|
||||
.BaudRate = CONFIG_UART_STM32_PORT_0_BAUD_RATE} }
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(uart_stm32_0, CONFIG_UART_STM32_PORT_0_NAME,
|
||||
&uart_stm32_init,
|
||||
&uart_stm32_dev_data_0, &uart_stm32_dev_cfg_0,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&uart_stm32_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_stm32_irq_config_func_0(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
#define PORT_0_IRQ STM32F1_IRQ_USART1
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
#define PORT_0_IRQ STM32F4_IRQ_USART1
|
||||
#endif
|
||||
IRQ_CONNECT(PORT_0_IRQ,
|
||||
CONFIG_UART_STM32_PORT_0_IRQ_PRI,
|
||||
uart_stm32_isr, DEVICE_GET(uart_stm32_0),
|
||||
0);
|
||||
irq_enable(PORT_0_IRQ);
|
||||
}
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
#endif /* CONFIG_UART_STM32_PORT_0 */
|
||||
|
||||
|
||||
#ifdef CONFIG_UART_STM32_PORT_1
|
||||
|
||||
|
@ -379,16 +328,16 @@ static void uart_stm32_irq_config_func_1(struct device *dev);
|
|||
|
||||
static const struct uart_stm32_config uart_stm32_dev_cfg_1 = {
|
||||
.uconf = {
|
||||
.base = (uint8_t *)USART2_BASE,
|
||||
.base = (uint8_t *)USART1_BASE,
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_stm32_irq_config_func_1,
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
},
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART2),
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART1),
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
.pclken = { .bus = STM32F4X_CLOCK_BUS_APB1,
|
||||
.enr = STM32F4X_CLOCK_ENABLE_USART2 },
|
||||
.pclken = { .bus = STM32F4X_CLOCK_BUS_APB2,
|
||||
.enr = STM32F4X_CLOCK_ENABLE_USART1 },
|
||||
#endif /* CONFIG_SOC_SERIES_STM32FX */
|
||||
};
|
||||
|
||||
|
@ -408,9 +357,9 @@ DEVICE_AND_API_INIT(uart_stm32_1, CONFIG_UART_STM32_PORT_1_NAME,
|
|||
static void uart_stm32_irq_config_func_1(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
#define PORT_1_IRQ STM32F1_IRQ_USART2
|
||||
#define PORT_1_IRQ STM32F1_IRQ_USART1
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
#define PORT_1_IRQ STM32F4_IRQ_USART2
|
||||
#define PORT_1_IRQ STM32F4_IRQ_USART1
|
||||
#endif
|
||||
IRQ_CONNECT(PORT_1_IRQ,
|
||||
CONFIG_UART_STM32_PORT_1_IRQ_PRI,
|
||||
|
@ -431,16 +380,17 @@ static void uart_stm32_irq_config_func_2(struct device *dev);
|
|||
|
||||
static const struct uart_stm32_config uart_stm32_dev_cfg_2 = {
|
||||
.uconf = {
|
||||
.base = (uint8_t *)USART3_BASE,
|
||||
.base = (uint8_t *)USART2_BASE,
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_stm32_irq_config_func_2,
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
},
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART3),
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART2),
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F40X_CLOCK_SUBSYS_USART3),
|
||||
#endif /* CONFIG_SOC_SERIES_STM32F4X */
|
||||
.pclken = { .bus = STM32F4X_CLOCK_BUS_APB1,
|
||||
.enr = STM32F4X_CLOCK_ENABLE_USART2 },
|
||||
#endif /* CONFIG_SOC_SERIES_STM32FX */
|
||||
};
|
||||
|
||||
static struct uart_stm32_data uart_stm32_dev_data_2 = {
|
||||
|
@ -459,9 +409,9 @@ DEVICE_AND_API_INIT(uart_stm32_2, CONFIG_UART_STM32_PORT_2_NAME,
|
|||
static void uart_stm32_irq_config_func_2(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
#define PORT_2_IRQ STM32F1_IRQ_USART3
|
||||
#define PORT_2_IRQ STM32F1_IRQ_USART2
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
#define PORT_2_IRQ STM32F4_IRQ_USART3
|
||||
#define PORT_2_IRQ STM32F4_IRQ_USART2
|
||||
#endif
|
||||
IRQ_CONNECT(PORT_2_IRQ,
|
||||
CONFIG_UART_STM32_PORT_2_IRQ_PRI,
|
||||
|
@ -472,3 +422,54 @@ static void uart_stm32_irq_config_func_2(struct device *dev)
|
|||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
#endif /* CONFIG_UART_STM32_PORT_2 */
|
||||
|
||||
|
||||
#ifdef CONFIG_UART_STM32_PORT_3
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_stm32_irq_config_func_3(struct device *dev);
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
static const struct uart_stm32_config uart_stm32_dev_cfg_3 = {
|
||||
.uconf = {
|
||||
.base = (uint8_t *)USART3_BASE,
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
.irq_config_func = uart_stm32_irq_config_func_3,
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
},
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART3),
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
.clock_subsys = UINT_TO_POINTER(STM32F40X_CLOCK_SUBSYS_USART3),
|
||||
#endif /* CONFIG_SOC_SERIES_STM32F4X */
|
||||
};
|
||||
|
||||
static struct uart_stm32_data uart_stm32_dev_data_3 = {
|
||||
.huart = {
|
||||
.Init = {
|
||||
.BaudRate = CONFIG_UART_STM32_PORT_3_BAUD_RATE} }
|
||||
};
|
||||
|
||||
DEVICE_AND_API_INIT(uart_stm32_3, CONFIG_UART_STM32_PORT_3_NAME,
|
||||
&uart_stm32_init,
|
||||
&uart_stm32_dev_data_3, &uart_stm32_dev_cfg_3,
|
||||
PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
|
||||
&uart_stm32_driver_api);
|
||||
|
||||
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
||||
static void uart_stm32_irq_config_func_3(struct device *dev)
|
||||
{
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F1X
|
||||
#define PORT_3_IRQ STM32F1_IRQ_USART3
|
||||
#elif CONFIG_SOC_SERIES_STM32F4X
|
||||
#define PORT_3_IRQ STM32F4_IRQ_USART3
|
||||
#endif
|
||||
IRQ_CONNECT(PORT_3_IRQ,
|
||||
CONFIG_UART_STM32_PORT_3_IRQ_PRI,
|
||||
uart_stm32_isr, DEVICE_GET(uart_stm32_3),
|
||||
0);
|
||||
irq_enable(PORT_3_IRQ);
|
||||
}
|
||||
#endif /* CONFIG_UART_INTERRUPT_DRIVEN */
|
||||
|
||||
#endif /* CONFIG_UART_STM32_PORT_3 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue