Skip to content

Commit 257c28a

Browse files
ananglnashif
authored andcommitted
drivers: nrfx: Add Kconfig checks for mutually exclusive peripherals
In Nordic SoCs, SPI and TWI peripherals with the same instance number share certain resources and therefore cannot be used at the same time (in nRF91 Series this limitation concerns UART peripherals as well). This patch adds Kconfig checks ensuring that only one of such mutually exclusive peripherals can be enabled. Signed-off-by: Andrzej Głąbek <[email protected]>
1 parent cc185bc commit 257c28a

File tree

3 files changed

+62
-32
lines changed

3 files changed

+62
-32
lines changed

drivers/i2c/Kconfig.nrfx

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ menuconfig I2C_NRFX
1717

1818
if I2C_NRFX
1919

20-
# In most Nordic SoCs the SPI and TWI peripherals with the same instance
21-
# number share certain resources and cannot be used at the same time.
22-
# In nRF52810 there are only single instances of these peripherals and
23-
# they are arranged in a different way so this limitation does not apply.
24-
if I2C_0 && (!SPI_0 || SOC_NRF52810)
20+
# In most Nordic SoCs, SPI and TWI peripherals with the same instance number
21+
# share certain resources and therefore cannot be used at the same time
22+
# (in nRF91 Series this limitation concerns UART peripherals as well).
23+
# In nRF52810 though, there are only single instances of these peripherals
24+
# and they are arranged in a different way, so this limitation does not apply.
25+
if I2C_0 && (SOC_NRF52810 || \
26+
(!SPI_0 && !(SOC_SERIES_NRF91X && UART_0_NRF_UARTE)))
2527

2628
choice I2C_0_NRF_TYPE
2729
prompt "I2C Port 0 Driver type"
@@ -44,10 +46,12 @@ config I2C_0_NRF_TWIM
4446

4547
endchoice
4648

47-
endif # I2C_0 && (!SPI_0 || SOC_NRF52810)
49+
endif # I2C_0 && (SOC_NRF52810 || ...
4850

49-
# Nordic TWIx1 and SPIx1 instances can not be used at the same time.
50-
if I2C_1 && !SPI_1
51+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
52+
# share certain resources and therefore cannot be used at the same time
53+
# (in nRF91 Series this limitation concerns UART peripherals as well).
54+
if I2C_1 && !SPI_1 && !(SOC_SERIES_NRF91X && UART_1_NRF_UARTE)
5155

5256
choice I2C_1_NRF_TYPE
5357
prompt "I2C Port 1 Driver type"
@@ -70,10 +74,12 @@ config I2C_1_NRF_TWIM
7074

7175
endchoice
7276

73-
endif # I2C_1 && !SPI_1
77+
endif # I2C_1 && !SPI_1 && !(SOC_SERIES_NRF91X && UART_1_NRF_UARTE)
7478

75-
# Nordic TWIx2 and SPIx2 instances can not be used at the same time.
76-
if I2C_2 && !SPI_2
79+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
80+
# share certain resources and therefore cannot be used at the same time
81+
# (in nRF91 Series this limitation concerns UART peripherals as well).
82+
if I2C_2 && !SPI_2 && !(SOC_SERIES_NRF91X && UART_2_NRF_UARTE)
7783

7884
choice I2C_2_NRF_TYPE
7985
prompt "I2C Port 2 Driver type"
@@ -89,10 +95,12 @@ config I2C_2_NRF_TWIM
8995

9096
endchoice
9197

92-
endif # I2C_2 && !SPI_2
98+
endif # I2C_2 && !SPI_2 && !(SOC_SERIES_NRF91X && UART_2_NRF_UARTE)
9399

94-
# Nordic TWIx3 and SPIx3 instances can not be used at the same time.
95-
if I2C_3 && !SPI_3
100+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
101+
# share certain resources and therefore cannot be used at the same time
102+
# (in nRF91 Series SoCs this limitation concerns UART peripherals as well).
103+
if I2C_3 && !SPI_3 && !(SOC_SERIES_NRF91X && UART_3_NRF_UARTE)
96104

97105
choice I2C_3_NRF_TYPE
98106
prompt "I2C Port 3 Driver type"
@@ -108,6 +116,6 @@ config I2C_3_NRF_TWIM
108116

109117
endchoice
110118

111-
endif # I2C_3 && !SPI_3
119+
endif # I2C_3 && !SPI_3 && !(SOC_SERIES_NRF91X && UART_3_NRF_UARTE)
112120

113121
endif #I2C_NRFX

drivers/serial/Kconfig.nrfx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ config UART_0_NRF_UART
3333

3434
config UART_0_NRF_UARTE
3535
bool "nRF UARTE 0"
36-
depends on HAS_HW_NRF_UARTE0
36+
# In nRF91 Series SoCs, UART peripherals share certain resources with
37+
# SPI and TWI peripherals having the same instance number, and therefore
38+
# these cannot be used simultaneously.
39+
depends on HAS_HW_NRF_UARTE0 && !(SOC_SERIES_NRF91X && (SPI_0 || I2C_0))
3740
select NRF_UARTE_PERIPHERAL
3841
help
3942
Enable nRF UART with EasyDMA on port 0.
@@ -74,7 +77,10 @@ endif # UART_0_NRF_UART || UART_0_NRF_UARTE
7477
# ----------------- port 1 -----------------
7578
config UART_1_NRF_UARTE
7679
bool "nRF UARTE 1"
77-
depends on HAS_HW_NRF_UARTE1
80+
# In nRF91 Series SoCs, UART peripherals share certain resources with
81+
# SPI and TWI peripherals having the same instance number, and therefore
82+
# these cannot be used simultaneously.
83+
depends on HAS_HW_NRF_UARTE1 && !(SOC_SERIES_NRF91X && (SPI_1 || I2C_1))
7884
select NRF_UARTE_PERIPHERAL
7985
help
8086
Enable nRF UART with EasyDMA on port 1.
@@ -113,7 +119,10 @@ endif # UART_1_NRF_UARTE
113119
# ----------------- port 2 -----------------
114120
config UART_2_NRF_UARTE
115121
bool "nRF UARTE 2"
116-
depends on HAS_HW_NRF_UARTE2
122+
# In nRF91 Series SoCs, UART peripherals share certain resources with
123+
# SPI and TWI peripherals having the same instance number, and therefore
124+
# these cannot be used simultaneously.
125+
depends on HAS_HW_NRF_UARTE2 && !(SOC_SERIES_NRF91X && (SPI_2 || I2C_2))
117126
select NRF_UARTE_PERIPHERAL
118127
help
119128
Enable nRF UART with EasyDMA on port 2.
@@ -152,7 +161,10 @@ endif # UART_2_NRF_UARTE
152161
# ----------------- port 3 -----------------
153162
config UART_3_NRF_UARTE
154163
bool "nRF UARTE 3"
155-
depends on HAS_HW_NRF_UARTE3
164+
# In nRF91 Series SoCs, UART peripherals share certain resources with
165+
# SPI and TWI peripherals having the same instance number, and therefore
166+
# these cannot be used simultaneously.
167+
depends on HAS_HW_NRF_UARTE3 && !(SOC_SERIES_NRF91X && (SPI_3 || I2C_3))
156168
select NRF_UARTE_PERIPHERAL
157169
help
158170
Enable nRF UART with EasyDMA on port 3.

drivers/spi/Kconfig.nrfx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ menuconfig SPI_NRFX
1414

1515
if SPI_NRFX
1616

17-
# In most Nordic SoCs the SPI and TWI peripherals with the same instance
18-
# number share certain resources and cannot be used at the same time.
19-
# In nRF52810 there are only single instances of these peripherals and
20-
# they are arranged in a different way so this limitation does not apply.
21-
if SPI_0 && (!I2C_0 || SOC_NRF52810)
17+
# In most Nordic SoCs, SPI and TWI peripherals with the same instance number
18+
# share certain resources and therefore cannot be used at the same time
19+
# (in nRF91 Series this limitation concerns UART peripherals as well).
20+
# In nRF52810 though, there are only single instances of these peripherals
21+
# and they are arranged in a different way, so this limitation does not apply.
22+
if SPI_0 && (SOC_NRF52810 || \
23+
(!I2C_0 && !(SOC_SERIES_NRF91X && UART_0_NRF_UARTE)))
2224

2325
choice
2426
prompt "SPI Port 0 Driver type"
@@ -63,10 +65,12 @@ config SPI_0_NRF_ORC
6365

6466
endif # SPI_0_NRF_SPI || SPI_0_NRF_SPIM || SPI_0_NRF_SPIS
6567

66-
endif # SPI_0 && (!I2C_0 || SOC_NRF52810)
68+
endif # SPI_0 && (SOC_NRF52810 || ...
6769

68-
# Nordic TWIx1 and SPIx1 instances can not be used at the same time.
69-
if SPI_1 && !I2C_1
70+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
71+
# share certain resources and therefore cannot be used at the same time
72+
# (in nRF91 Series this limitation concerns UART peripherals as well).
73+
if SPI_1 && !I2C_1 && !(SOC_SERIES_NRF91X && UART_1_NRF_UARTE)
7074

7175
choice
7276
prompt "SPI Port 1 Driver type"
@@ -111,9 +115,12 @@ config SPI_1_NRF_ORC
111115

112116
endif # SPI_1_NRF_SPI || SPI_1_NRF_SPIM || SPI_1_NRF_SPIS
113117

114-
endif # SPI_1 && !I2C_1
118+
endif # SPI_1 && !I2C_1 && !(SOC_SERIES_NRF91X && UART_1_NRF_UARTE)
115119

116-
if SPI_2
120+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
121+
# share certain resources and therefore cannot be used at the same time
122+
# (in nRF91 Series this limitation concerns UART peripherals as well).
123+
if SPI_2 && !I2C_2 && !(SOC_SERIES_NRF91X && UART_2_NRF_UARTE)
117124

118125
choice
119126
prompt "SPI Port 2 Driver type"
@@ -158,9 +165,12 @@ config SPI_2_NRF_ORC
158165

159166
endif # SPI_2_NRF_SPI || SPI_2_NRF_SPIM || SPI_2_NRF_SPIS
160167

161-
endif # SPI_2
168+
endif # SPI_2 && !I2C_2 && !(SOC_SERIES_NRF91X && UART_2_NRF_UARTE)
162169

163-
if SPI_3
170+
# In Nordic SoCs, SPI and TWI peripherals with the same instance number
171+
# share certain resources and therefore cannot be used at the same time
172+
# (in nRF91 Series this limitation concerns UART peripherals as well).
173+
if SPI_3 && !I2C_3 && !(SOC_SERIES_NRF91X && UART_3_NRF_UARTE)
164174

165175
choice
166176
prompt "SPI Port 3 Driver type"
@@ -206,7 +216,7 @@ config SPI_3_NRF_RX_DELAY
206216
edge of SCK (leading or trailing, depending on the CPHA setting used)
207217
until the input serial data on MISO is actually sampled.
208218

209-
endif # SPI_3
219+
endif # SPI_3 && !I2C_3 && !(SOC_SERIES_NRF91X && UART_3_NRF_UARTE)
210220

211221
if NRFX_SPIM
212222

0 commit comments

Comments
 (0)