Use DT macros instead of Kconfig for board pinmux

Stops using CONFIG_device_x style configuration items and checks the
devicetree to determine if the nodes are enabled.

Fixes UEXT serial port not working.
This commit is contained in:
Daniel Fanache
2020-08-17 19:59:58 +02:00
committed by Martin Jäger
parent ee5846323f
commit e427b45352
12 changed files with 55 additions and 157 deletions
@@ -9,26 +9,8 @@ config BOARD
config LIBRE_SOLAR_TYPE_ID
default 4
if UART_CONSOLE
config UART_1
bool
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
+12 -13
View File
@@ -12,31 +12,30 @@
#include <pinmux/stm32/pinmux_stm32.h>
/* pin assignments for NUCLEO-L073RZ board */
static const struct pin_config pinconf[] = {
#ifdef CONFIG_UART_1
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PA9, STM32L0_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32L0_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_UART_2
#endif /* CONFIG_SERIAL || UART_CONSOLE, usart1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL
{STM32_PIN_PA2, STM32L0_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32L0_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_I2C_1
#endif /* CONFIG_SERIAL, usart2 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB6, STM32L0_PINMUX_FUNC_PB6_I2C1_SCL},
{STM32_PIN_PB7, STM32L0_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_SPI_1
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
{STM32_PIN_PB3, STM32L0_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PB4, STM32L0_PINMUX_FUNC_PB4_SPI1_MISO},
{STM32_PIN_PB5, STM32L0_PINMUX_FUNC_PB5_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_ADC_1
#endif /* CONFIG_SPI, spi1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(adc1), okay) && CONFIG_ADC
{STM32_PIN_PA0, STM32L0_PINMUX_FUNC_PA0_ADC_IN0},
#endif /* CONFIG_ADC_1 */
#ifdef CONFIG_DAC_1
#endif /* CONFIG_ADC, adc1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(dac1), okay) && CONFIG_DAC
{STM32_PIN_PA4, STM32L0_PINMUX_FUNC_PA4_DAC_OUT1},
#endif /* CONFIG_ADC_1 */
#endif /* CONFIG_DAC, dac1 */
};
static int pinmux_stm32_init(struct device *port)
@@ -9,40 +9,8 @@ config BOARD
config LIBRE_SOLAR_TYPE_ID
default 7
if UART_CONSOLE
config UART_1
bool
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if PWM
config PWM_STM32_3
bool
default y
depends on PWM
config PWM_STM32_8
bool
default y
depends on PWM
endif # PWM
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
@@ -59,6 +59,5 @@ CONFIG_ARM_MPU=y
CONFIG_PWM=y
CONFIG_I2C=y
CONFIG_I2C_3=y
CONFIG_EEPROM=y
CONFIG_EEPROM_AT24=y
+12 -10
View File
@@ -13,32 +13,34 @@
#include <pinmux/stm32/pinmux_stm32.h>
/* this should normally go to drivers/pinmux/stm32/pinmux_stm32g4x.h */
#define STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1 \
#define STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1 \
(STM32_PINMUX_ALT_FUNC_4 | STM32_PUSHPULL_NOPULL)
static const struct pin_config pinconf[] = {
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PA9, STM32G4X_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32G4X_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_SERIAL || UART_CONSOLE, usart1 */
{STM32_PIN_PC6, STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1},
{STM32_PIN_PC7, STM32G4X_PINMUX_FUNC_PC7_PWM3_CH2},
#ifdef CONFIG_UART_3
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart3), okay) && CONFIG_SERIAL
{STM32_PIN_PC10, STM32G4X_PINMUX_FUNC_PC10_USART3_TX},
{STM32_PIN_PC11, STM32G4X_PINMUX_FUNC_PC11_USART3_RX},
#endif /* CONFIG_UART_3 */
#ifdef CONFIG_I2C_1
#endif /* CONFIG_SERIAL, usart3 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_I2C1_SCL},
{STM32_PIN_PB7, STM32G4X_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_I2C_3
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c3), okay) && CONFIG_I2C
{STM32_PIN_PC8, STM32G4X_PINMUX_FUNC_PC8_I2C3_SCL},
{STM32_PIN_PC9, STM32G4X_PINMUX_FUNC_PC9_I2C3_SDA},
#endif /* CONFIG_I2C_3 */
#ifdef CONFIG_SPI_1
#endif /* CONFIG_I2C, i2c3 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
{STM32_PIN_PB3, STM32G4X_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PB4, STM32G4X_PINMUX_FUNC_PB4_SPI1_MISO},
{STM32_PIN_PB5, STM32G4X_PINMUX_FUNC_PB5_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_USB_DC_STM32
#endif /* CONFIG_SPI, spi1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usb), okay) && CONFIG_USB_DC_STM32
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_USB_DM},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_USB_DP},
#endif /* CONFIG_USB_DC_STM32 */
-18
View File
@@ -9,26 +9,8 @@ config BOARD
config LIBRE_SOLAR_TYPE_ID
default 1
if UART_CONSOLE
config UART_1
bool
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
@@ -31,8 +31,6 @@ CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
CONFIG_I2C=y
CONFIG_I2C_1=y
CONFIG_I2C_2=y
CONFIG_CAN=y
CONFIG_THINGSET_CAN=y
+12 -12
View File
@@ -23,31 +23,31 @@
#endif
static const struct pin_config pinconf[] = {
#ifdef CONFIG_UART_1
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PA9, STM32F0_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32F0_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_UART_2
#endif /* CONFIG_SERIAL || UART_CONSOLE, usart1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL
{STM32_PIN_PA2, STM32F0_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32F0_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_I2C_1
#endif /* CONFIG_SERIAL, usart2 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB6, STM32F0_PINMUX_FUNC_PB6_I2C1_SCL},
{STM32_PIN_PB7, STM32F0_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_I2C_2
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB10, STM32F0_PINMUX_FUNC_PB10_I2C2_SCL},
{STM32_PIN_PB11, STM32F0_PINMUX_FUNC_PB11_I2C2_SDA},
#endif /* CONFIG_I2C_2 */
#ifdef CONFIG_SPI_1
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
{STM32_PIN_PB3, STM32F0_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PB4, STM32F0_PINMUX_FUNC_PB4_SPI1_MISO},
{STM32_PIN_PB5, STM32F0_PINMUX_FUNC_PB5_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_CAN_1
#endif /* CONFIG_SPI, spi1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN
{STM32_PIN_PB8, STM32F0_PINMUX_FUNC_PB8_CAN_RX},
{STM32_PIN_PB9, STM32F0_PINMUX_FUNC_PB9_CAN_TX},
#endif /* CONFIG_CAN_1 */
#endif /* CONFIG_CAN, can1 */
};
static int pinmux_stm32_init(struct device *port)
-17
View File
@@ -9,26 +9,9 @@ config BOARD
config LIBRE_SOLAR_TYPE_ID
default 0
if UART_CONSOLE
#config UART_1
# bool
# default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
+6 -6
View File
@@ -17,20 +17,20 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PA10, STM32G4X_PINMUX_FUNC_PA10_USART1_RX},
{STM32_PIN_PA2, STM32G4X_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32G4X_PINMUX_FUNC_PA3_USART2_RX},
#ifdef CONFIG_I2C_1
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_I2C1_SCL},
{STM32_PIN_PB7, STM32G4X_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_SPI_1
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
{STM32_PIN_PB3, STM32G4X_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PB4, STM32G4X_PINMUX_FUNC_PB4_SPI1_MISO},
{STM32_PIN_PB5, STM32G4X_PINMUX_FUNC_PB5_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_USB_DC_STM32
#endif /* CONFIG_SPI, spi1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usb), okay) && CONFIG_USB_DC_STM32
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_USB_DM},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_USB_DP},
#endif /* CONFIG_USB_DC_STM32 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay)
#if DT_NODE_HAS_STATUS(DT_NODELABEL(can1), okay) && CONFIG_CAN
{STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_FDCAN1_RX},
{STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_FDCAN1_TX},
#endif
+1 -18
View File
@@ -9,29 +9,12 @@ config BOARD
config LIBRE_SOLAR_TYPE_ID
default 5
if UART_CONSOLE
config UART_1
bool
default y
endif # UART_CONSOLE
if I2C
config I2C_1
default y
endif # I2C
if SPI
config SPI_1
default y
config SPI_STM32_INTERRUPT
default y
endif # SPI
endif # BOARD_PWM_2420_LUS
+12 -10
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018 Ilya Tagunov <tagunil@gmail.com>
* Copyright (c) 2020 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -13,28 +13,30 @@
#include <pinmux/stm32/pinmux_stm32.h>
/* this should normally go to drivers/pinmux/stm32/pinmux_stm32l0.h */
#define STM32L0_PINMUX_FUNC_PB1_PWM3_CH4 \
#define STM32L0_PINMUX_FUNC_PB1_PWM3_CH4 \
(STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_NOPULL)
static const struct pin_config pinconf[] = {
#if DT_NODE_HAS_STATUS(DT_NODELABEL(pwm3), okay)
{STM32_PIN_PB1, STM32L0_PINMUX_FUNC_PB1_PWM3_CH4},
#ifdef CONFIG_UART_1
#endif /* CONFIG_PWM, pwm3 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay) && CONFIG_SERIAL
{STM32_PIN_PA9, STM32L0_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32L0_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_UART_2
#endif /* CONFIG_SERIAL || UART_CONSOLE, usart1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay) && CONFIG_SERIAL
{STM32_PIN_PA2, STM32L0_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32L0_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_I2C_1
#endif /* CONFIG_SERIAL, usart2 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && CONFIG_I2C
{STM32_PIN_PB6, STM32L0_PINMUX_FUNC_PB6_I2C1_SCL},
{STM32_PIN_PB7, STM32L0_PINMUX_FUNC_PB7_I2C1_SDA},
#endif /* CONFIG_I2C_1 */
#ifdef CONFIG_SPI_1
#endif /* CONFIG_I2C, i2c1 */
#if DT_NODE_HAS_STATUS(DT_NODELABEL(spi1), okay) && CONFIG_SPI
{STM32_PIN_PB3, STM32L0_PINMUX_FUNC_PB3_SPI1_SCK},
{STM32_PIN_PA11, STM32L0_PINMUX_FUNC_PA11_SPI1_MISO},
{STM32_PIN_PA12, STM32L0_PINMUX_FUNC_PA12_SPI1_MOSI},
#endif /* CONFIG_SPI_1 */
#endif /* CONFIG_SPI, spi1 */
};
static int pinmux_stm32_init(struct device *port)