drivers/i2c/Kconfig.nrfx: Choose driver type basing on DT compatible

Remove prompts from Kconfig options `I2C_x_NRF_TWI*` that select
the type of nrfx driver (for TWI or TWIM peripheral) to be used
for a given instance. This prevents the options from being modified
from configuration files.
Instead, make one of these options selected by default according to the
"compatible" property set for the corresponding I2C node in devicetree.

This eliminates the need of changing both the "compatible" property in
devicetree and the Kconfig option selecting the driver type when a user
wants to switch between TWI and TWIM for a given instance.

Since all `I2C_x_NRF_TWI*` options are made "hidden" by this commit,
all their occurrences in configuration files are removed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
This commit is contained in:
Andrzej Głąbek 2020-03-25 14:25:30 +00:00 committed by Carles Cufí
commit bf0c4a841d
8 changed files with 44 additions and 96 deletions

View file

@ -50,16 +50,6 @@ config I2C_1
endif # I2C endif # I2C
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWIM
depends on I2C_0
endchoice
choice I2C_1_NRF_TYPE
default I2C_1_NRF_TWIM
depends on I2C_1
endchoice
config ADC_0 config ADC_0
default y default y
depends on ADC depends on ADC

View file

@ -12,11 +12,6 @@ config I2C_0
default y default y
depends on I2C depends on I2C
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWIM
depends on I2C_0
endchoice
config BT_CTLR config BT_CTLR
default BT default BT

View file

@ -23,17 +23,8 @@ config I2C_0
config I2C_1 config I2C_1
default y default y
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWIM
depends on I2C_0
endchoice
if I2C_1 if I2C_1
choice I2C_1_NRF_TYPE
default I2C_1_NRF_TWIM
endchoice
config GPIO_SX1509B config GPIO_SX1509B
default y default y

View file

@ -13,11 +13,6 @@ if I2C
config I2C_0 config I2C_0
default y default y
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWIM
depends on I2C_0
endchoice
endif # I2C endif # I2C
config BT_CTLR config BT_CTLR

View file

@ -20,16 +20,6 @@ config I2C_0
config I2C_1 config I2C_1
default n default n
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWIM
depends on I2C_0
endchoice
choice I2C_1_NRF_TYPE
default I2C_1_NRF_TWIM
depends on I2C_1
endchoice
endif # I2C endif # I2C
config PWM_0 config PWM_0

View file

@ -43,8 +43,6 @@ endchoice
endif # LVGL endif # LVGL
rsource "boards/*.defconfig"
endif # DISPLAY endif # DISPLAY
endif # SHIELD_SSD1306_128X64 || SHIELD_SSD1306_128X32 endif # SHIELD_SSD1306_128X64 || SHIELD_SSD1306_128X32

View file

@ -1,7 +0,0 @@
# Copyright (c) 2019 Linaro Limited
# SPDX-License-Identifier: Apache-2.0
choice I2C_0_NRF_TYPE
default I2C_0_NRF_TWI
depends on BOARD_REEL_BOARD
endchoice

View file

@ -14,27 +14,29 @@ menuconfig I2C_NRFX
if I2C_NRFX if I2C_NRFX
choice I2C_0_NRF_TYPE # Workaround for not being able to have commas in macro arguments
prompt "I2C Port 0 Driver type" DT_COMPAT_NORDIC_NRF_TWI := nordic,nrf-twi
# In most Nordic SoCs, SPI and TWI peripherals with the same instance DT_COMPAT_NORDIC_NRF_TWIM := nordic,nrf-twim
# number share certain resources and therefore cannot be used at the
# same time (in nRF91 and nRF53 Series this limitation concerns UART # In most Nordic SoCs, SPI and TWI peripherals with the same instance
# peripherals as well). In nRF52810 though, there are only single # number share certain resources and therefore cannot be used at the
# instances of these peripherals and they are arranged in a different # same time (in nRF91 and nRF53 Series this limitation concerns UART
# way, so this limitation does not apply. # peripherals as well). In nRF52810 though, there are only single
depends on I2C_0 && (SOC_NRF52810 || \ # instances of these peripherals and they are arranged in a different
(!SPI_0 && !(SOC_SERIES_NRF91X && UART_0_NRF_UARTE)) || \ # way, so this limitation does not apply.
(!SPI_0 && !(SOC_SERIES_NRF53X && UART_0_NRF_UARTE))) if I2C_0 && (SOC_NRF52810 || \
(!SPI_0 && !(SOC_SERIES_NRF91X && UART_0_NRF_UARTE)) || \
(!SPI_0 && !(SOC_SERIES_NRF53X && UART_0_NRF_UARTE)))
config I2C_0_NRF_TWI config I2C_0_NRF_TWI
bool "nRF TWI 0" def_bool $(dt_nodelabel_has_compat,i2c0,$(DT_COMPAT_NORDIC_NRF_TWI))
depends on HAS_HW_NRF_TWI0 depends on HAS_HW_NRF_TWI0
select NRFX_TWI0 select NRFX_TWI0
help help
Enable nRF TWI Master without EasyDMA on port 0. Enable nRF TWI Master without EasyDMA on port 0.
config I2C_0_NRF_TWIM config I2C_0_NRF_TWIM
bool "nRF TWIM 0" def_bool $(dt_nodelabel_has_compat,i2c0,$(DT_COMPAT_NORDIC_NRF_TWIM))
depends on HAS_HW_NRF_TWIM0 depends on HAS_HW_NRF_TWIM0
select NRFX_TWIM0 select NRFX_TWIM0
help help
@ -42,27 +44,25 @@ config I2C_0_NRF_TWIM
This peripheral accepts transfers from RAM only, This peripheral accepts transfers from RAM only,
if provided buffer is placed in flash, transfer will fail. if provided buffer is placed in flash, transfer will fail.
endchoice endif # I2C_0 && (SOC_NRF52810 || ...
choice I2C_1_NRF_TYPE # In Nordic SoCs, SPI and TWI peripherals with the same instance number
prompt "I2C Port 1 Driver type" # share certain resources and therefore cannot be used at the same time
# In Nordic SoCs, SPI and TWI peripherals with the same instance number # (in nRF91 and nRF53 Series this limitation concerns UART peripherals
# share certain resources and therefore cannot be used at the same time # as well).
# (in nRF91 and nRF53 Series this limitation concerns UART peripherals if I2C_1 && !SPI_1 && \
# as well). !(SOC_SERIES_NRF91X && UART_1_NRF_UARTE) && \
depends on I2C_1 && !SPI_1 && \ !(SOC_SERIES_NRF53X && UART_1_NRF_UARTE)
!(SOC_SERIES_NRF91X && UART_1_NRF_UARTE) && \
!(SOC_SERIES_NRF53X && UART_1_NRF_UARTE)
config I2C_1_NRF_TWI config I2C_1_NRF_TWI
bool "nRF TWI 1" def_bool $(dt_nodelabel_has_compat,i2c1,$(DT_COMPAT_NORDIC_NRF_TWI))
depends on HAS_HW_NRF_TWI1 depends on HAS_HW_NRF_TWI1
select NRFX_TWI1 select NRFX_TWI1
help help
Enable nRF TWI Master without EasyDMA on port 1. Enable nRF TWI Master without EasyDMA on port 1.
config I2C_1_NRF_TWIM config I2C_1_NRF_TWIM
bool "nRF TWIM 1" def_bool $(dt_nodelabel_has_compat,i2c1,$(DT_COMPAT_NORDIC_NRF_TWIM))
depends on HAS_HW_NRF_TWIM1 depends on HAS_HW_NRF_TWIM1
select NRFX_TWIM1 select NRFX_TWIM1
help help
@ -70,20 +70,18 @@ config I2C_1_NRF_TWIM
This peripheral accepts transfers from RAM only, This peripheral accepts transfers from RAM only,
if provided buffer is placed in flash, transfer will fail. if provided buffer is placed in flash, transfer will fail.
endchoice endif # I2C_1 && !SPI_1 && ...
choice I2C_2_NRF_TYPE # In Nordic SoCs, SPI and TWI peripherals with the same instance number
prompt "I2C Port 2 Driver type" # share certain resources and therefore cannot be used at the same time
# In Nordic SoCs, SPI and TWI peripherals with the same instance number # (in nRF91 and nRF53 Series this limitation concerns UART peripherals
# share certain resources and therefore cannot be used at the same time # as well).
# (in nRF91 and nRF53 Series this limitation concerns UART peripherals if I2C_2 && !SPI_2 && \
# as well). !(SOC_SERIES_NRF91X && UART_2_NRF_UARTE) && \
depends on I2C_2 && !SPI_2 && \ !(SOC_SERIES_NRF53X && UART_2_NRF_UARTE)
!(SOC_SERIES_NRF91X && UART_2_NRF_UARTE) && \
!(SOC_SERIES_NRF53X && UART_2_NRF_UARTE)
config I2C_2_NRF_TWIM config I2C_2_NRF_TWIM
bool "nRF TWIM 2" def_bool $(dt_nodelabel_has_compat,i2c2,$(DT_COMPAT_NORDIC_NRF_TWIM))
depends on HAS_HW_NRF_TWIM2 depends on HAS_HW_NRF_TWIM2
select NRFX_TWIM2 select NRFX_TWIM2
help help
@ -91,20 +89,18 @@ config I2C_2_NRF_TWIM
This peripheral accepts transfers from RAM only, This peripheral accepts transfers from RAM only,
if provided buffer is placed in flash, transfer will fail. if provided buffer is placed in flash, transfer will fail.
endchoice endif # I2C_2 && !SPI_2 && ...
choice I2C_3_NRF_TYPE # In Nordic SoCs, SPI and TWI peripherals with the same instance number
prompt "I2C Port 3 Driver type" # share certain resources and therefore cannot be used at the same time
# In Nordic SoCs, SPI and TWI peripherals with the same instance number # (in nRF91 and nRF53 Series this limitation concerns UART peripherals
# share certain resources and therefore cannot be used at the same time # as well).
# (in nRF91 and nRF53 Series this limitation concerns UART peripherals if I2C_3 && !SPI_3 && \
# as well). !(SOC_SERIES_NRF91X && UART_3_NRF_UARTE) && \
depends on I2C_3 && !SPI_3 && \ !(SOC_SERIES_NRF53X && UART_3_NRF_UARTE)
!(SOC_SERIES_NRF91X && UART_3_NRF_UARTE) && \
!(SOC_SERIES_NRF53X && UART_3_NRF_UARTE)
config I2C_3_NRF_TWIM config I2C_3_NRF_TWIM
bool "nRF TWIM 3" def_bool $(dt_nodelabel_has_compat,i2c3,$(DT_COMPAT_NORDIC_NRF_TWIM))
depends on HAS_HW_NRF_TWIM3 depends on HAS_HW_NRF_TWIM3
select NRFX_TWIM3 select NRFX_TWIM3
help help
@ -112,6 +108,6 @@ config I2C_3_NRF_TWIM
This peripheral accepts transfers from RAM only, This peripheral accepts transfers from RAM only,
if provided buffer is placed in flash, transfer will fail. if provided buffer is placed in flash, transfer will fail.
endchoice endif # I2C_3 && !SPI_3 && ...
endif # I2C_NRFX endif # I2C_NRFX