drivers: spi_ll_stm32: Get SPI configuration from DT
Get SPI_*_BASE_ADDRESS, SPI_*_NAME, SPI_*_IRQ and SPI_*_IRQ_PRI from DT. Signed-off-by: Yannis Damigos <giannis.damigos@gmail.com>
This commit is contained in:
parent
2e3983512a
commit
3a03b28f87
3 changed files with 24 additions and 15 deletions
|
@ -55,6 +55,7 @@ config SPI_STM32
|
|||
prompt "STM32 MCU SPI controller driver"
|
||||
depends on SPI && SOC_FAMILY_STM32
|
||||
depends on SOC_SERIES_STM32L4X || SOC_SERIES_STM32F0X || SOC_SERIES_STM32F3X || SOC_SERIES_STM32F4X
|
||||
select HAS_DTS_SPI
|
||||
default n
|
||||
help
|
||||
Enable SPI support on the STM32 family of processors.
|
||||
|
@ -149,13 +150,13 @@ config SPI_1
|
|||
config SPI_1_NAME
|
||||
string
|
||||
prompt "SPI port 1 device name"
|
||||
depends on SPI_1
|
||||
depends on SPI_1 && !HAS_DTS_SPI
|
||||
default "SPI_1"
|
||||
|
||||
config SPI_1_IRQ_PRI
|
||||
int
|
||||
prompt "Port 0 interrupt priority"
|
||||
depends on SPI_1
|
||||
depends on SPI_1 && !HAS_DTS_SPI
|
||||
|
||||
config SPI_1_DEFAULT_CFG
|
||||
hex "Port 1 default configuration"
|
||||
|
@ -188,13 +189,13 @@ config SPI_2
|
|||
config SPI_2_NAME
|
||||
string
|
||||
prompt "SPI port 2 device name"
|
||||
depends on SPI_2
|
||||
depends on SPI_2 && !HAS_DTS_SPI
|
||||
default "SPI_2"
|
||||
|
||||
config SPI_2_IRQ_PRI
|
||||
int
|
||||
prompt "Port 2 interrupt priority"
|
||||
depends on SPI_2
|
||||
depends on SPI_2 && !HAS_DTS_SPI
|
||||
|
||||
config SPI_2_DEFAULT_CFG
|
||||
hex "Port 2 default configuration"
|
||||
|
@ -227,13 +228,13 @@ config SPI_3
|
|||
config SPI_3_NAME
|
||||
string
|
||||
prompt "SPI port 3 device name"
|
||||
depends on SPI_3
|
||||
depends on SPI_3 && !HAS_DTS_SPI
|
||||
default "SPI_3"
|
||||
|
||||
config SPI_3_IRQ_PRI
|
||||
int
|
||||
prompt "Port 3 interrupt priority"
|
||||
depends on SPI_3
|
||||
depends on SPI_3 && !HAS_DTS_SPI
|
||||
|
||||
config SPI_4
|
||||
bool
|
||||
|
|
|
@ -465,7 +465,7 @@ static void spi_stm32_irq_config_func_1(struct device *port);
|
|||
#endif
|
||||
|
||||
static const struct spi_stm32_config spi_stm32_cfg_1 = {
|
||||
.spi = (SPI_TypeDef *) SPI1_BASE,
|
||||
.spi = (SPI_TypeDef *) CONFIG_SPI_1_BASE_ADDRESS,
|
||||
.pclken = {
|
||||
#ifdef CONFIG_SOC_SERIES_STM32F0X
|
||||
.enr = LL_APB1_GRP2_PERIPH_SPI1,
|
||||
|
@ -493,9 +493,9 @@ DEVICE_AND_API_INIT(spi_stm32_1, CONFIG_SPI_1_NAME, &spi_stm32_init,
|
|||
#ifdef CONFIG_SPI_STM32_INTERRUPT
|
||||
static void spi_stm32_irq_config_func_1(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(SPI1_IRQn, CONFIG_SPI_1_IRQ_PRI,
|
||||
IRQ_CONNECT(CONFIG_SPI_1_IRQ, CONFIG_SPI_1_IRQ_PRI,
|
||||
spi_stm32_isr, DEVICE_GET(spi_stm32_1), 0);
|
||||
irq_enable(SPI1_IRQn);
|
||||
irq_enable(CONFIG_SPI_1_IRQ);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -508,7 +508,7 @@ static void spi_stm32_irq_config_func_2(struct device *port);
|
|||
#endif
|
||||
|
||||
static const struct spi_stm32_config spi_stm32_cfg_2 = {
|
||||
.spi = (SPI_TypeDef *) SPI2_BASE,
|
||||
.spi = (SPI_TypeDef *) CONFIG_SPI_2_BASE_ADDRESS,
|
||||
.pclken = {
|
||||
.enr = LL_APB1_GRP1_PERIPH_SPI2,
|
||||
.bus = STM32_CLOCK_BUS_APB1
|
||||
|
@ -531,9 +531,9 @@ DEVICE_AND_API_INIT(spi_stm32_2, CONFIG_SPI_2_NAME, &spi_stm32_init,
|
|||
#ifdef CONFIG_SPI_STM32_INTERRUPT
|
||||
static void spi_stm32_irq_config_func_2(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(SPI2_IRQn, CONFIG_SPI_2_IRQ_PRI,
|
||||
IRQ_CONNECT(CONFIG_SPI_2_IRQ, CONFIG_SPI_2_IRQ_PRI,
|
||||
spi_stm32_isr, DEVICE_GET(spi_stm32_2), 0);
|
||||
irq_enable(SPI2_IRQn);
|
||||
irq_enable(CONFIG_SPI_2_IRQ);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -546,7 +546,7 @@ static void spi_stm32_irq_config_func_3(struct device *port);
|
|||
#endif
|
||||
|
||||
static const struct spi_stm32_config spi_stm32_cfg_3 = {
|
||||
.spi = (SPI_TypeDef *) SPI3_BASE,
|
||||
.spi = (SPI_TypeDef *) CONFIG_SPI_3_BASE_ADDRESS,
|
||||
.pclken = {
|
||||
.enr = LL_APB1_GRP1_PERIPH_SPI3,
|
||||
.bus = STM32_CLOCK_BUS_APB1
|
||||
|
@ -569,9 +569,9 @@ DEVICE_AND_API_INIT(spi_stm32_3, CONFIG_SPI_3_NAME, &spi_stm32_init,
|
|||
#ifdef CONFIG_SPI_STM32_INTERRUPT
|
||||
static void spi_stm32_irq_config_func_3(struct device *dev)
|
||||
{
|
||||
IRQ_CONNECT(SPI3_IRQn, CONFIG_SPI_3_IRQ_PRI,
|
||||
IRQ_CONNECT(CONFIG_SPI_3_IRQ, CONFIG_SPI_3_IRQ_PRI,
|
||||
spi_stm32_isr, DEVICE_GET(spi_stm32_3), 0);
|
||||
irq_enable(SPI3_IRQn);
|
||||
irq_enable(CONFIG_SPI_3_IRQ);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -26,3 +26,11 @@ config HAS_DTS_I2C_DEVICE
|
|||
help
|
||||
This option specifies that the target platform supports device tree
|
||||
configuration for sensors.
|
||||
|
||||
config HAS_DTS_SPI
|
||||
bool
|
||||
default n
|
||||
depends on HAS_DTS
|
||||
help
|
||||
This option specifies that the target platform supports device tree
|
||||
configuration for SPI.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue