Skip to content

Commit 2c66a2a

Browse files
XenuIsWatchingkartben
authored andcommitted
drivers: i3c: add i3c controller and target kconfigs
I3C can contain a lot of features that may be unused. Add Kconfigs for enabling controller and/or target code. Choosing just one can reduce the code size footprint. Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
1 parent 4102010 commit 2c66a2a

File tree

12 files changed

+470
-213
lines changed

12 files changed

+470
-213
lines changed

drivers/i3c/CMakeLists.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/i3c.h)
66

77
zephyr_library()
8+
zephyr_library_sources_ifdef(CONFIG_I3C_CONTROLLER i3c_ccc.c)
9+
zephyr_library_sources_ifdef(CONFIG_I3C_CONTROLLER i3c_common.c)
810

9-
zephyr_library_sources(
10-
i3c_ccc.c
11-
i3c_common.c
12-
)
13-
14-
if(CONFIG_I3C_NUM_OF_DESC_MEM_SLABS GREATER 0)
11+
if(DEFINED CONFIG_I3C_NUM_OF_DESC_MEM_SLABS AND CONFIG_I3C_NUM_OF_DESC_MEM_SLABS GREATER 0)
1512
zephyr_library_sources(i3c_mem_slab.c)
1613
endif()
1714

18-
if(CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS GREATER 0)
15+
if(DEFINED CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS AND CONFIG_I3C_I2C_NUM_OF_DESC_MEM_SLABS GREATER 0)
1916
zephyr_library_sources(i3c_i2c_mem_slab.c)
2017
endif()
2118

drivers/i3c/Kconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,34 @@ module = I3C
1515
module-str = i3c
1616
source "subsys/logging/Kconfig.template.log_config"
1717

18+
choice I3C_MODE
19+
prompt "I3C Mode Selection"
20+
default I3C_DUAL_ROLE
21+
help
22+
Select the role in which I3C is enabled.
23+
At least one of Controller or Target must be enabled.
24+
25+
Selecting only one can reduce the code footprint size.
26+
27+
config I3C_CONTROLLER_ROLE_ONLY
28+
bool "I3C Controller only"
29+
30+
config I3C_TARGET_ROLE_ONLY
31+
bool "I3C Target only"
32+
33+
config I3C_DUAL_ROLE
34+
bool "Both I3C Controller and Target"
35+
36+
endchoice
37+
38+
config I3C_CONTROLLER
39+
bool
40+
default y if I3C_DUAL_ROLE || I3C_CONTROLLER_ROLE_ONLY
41+
42+
config I3C_TARGET
43+
bool
44+
default y if I3C_DUAL_ROLE || I3C_TARGET_ROLE_ONLY
45+
1846
config I3C_SHELL
1947
bool "I3C Shell"
2048
depends on SHELL
@@ -26,6 +54,7 @@ config I3C_SHELL
2654

2755
config I3C_TARGET_BUFFER_MODE
2856
bool "I3C target driver for buffer mode"
57+
depends on I3C_TARGET
2958
help
3059
This is an option to enable buffer mode.
3160

@@ -108,6 +137,8 @@ config I3C_INIT_RSTACT
108137
This determines whether the bus initialization routine
109138
sends a reset action command to I3C targets.
110139

140+
if I3C_CONTROLLER && I3C_TARGET
141+
111142
config I3C_NUM_OF_DESC_MEM_SLABS
112143
int "Number of I3C Device Descriptors Mem Slabs"
113144
default 3
@@ -124,6 +155,10 @@ config I3C_I2C_NUM_OF_DESC_MEM_SLABS
124155
there is a device encounted through DEFTGTS that is not
125156
within known I2C devices.
126157

158+
endif # I3C_CONTROLLER && I3C_TARGET
159+
160+
if I3C_CONTROLLER
161+
127162
config I3C_RTIO
128163
bool "I3C RTIO API"
129164
select EXPERIMENTAL
@@ -168,6 +203,8 @@ config I3C_RTIO_FALLBACK_MSGS
168203

169204
endif # I3C_RTIO
170205

206+
endif # I3C_CONTROLLER
207+
171208
comment "Device Drivers"
172209

173210
rsource "Kconfig.nxp"

drivers/i3c/Kconfig.cdns

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "subsys/logging/Kconfig.template.log_config"
88

99
config I3C_CADENCE
1010
bool "Cadence I3C driver"
11-
select I3C_IBI_WORKQUEUE if I3C_USE_IBI
11+
select I3C_IBI_WORKQUEUE if I3C_USE_IBI && I3C_CONTROLLER
1212
depends on DT_HAS_CDNS_I3C_ENABLED
1313
default y
1414
help

drivers/i3c/Kconfig.dw

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ source "subsys/logging/Kconfig.template.log_config"
88

99
menuconfig I3C_DW
1010
bool "DW I3C support"
11-
select I3C_IBI_WORKQUEUE if I3C_USE_IBI
11+
select I3C_IBI_WORKQUEUE if I3C_USE_IBI && I3C_CONTROLLER
1212
depends on DT_HAS_SNPS_DESIGNWARE_I3C_ENABLED
1313
depends on CLOCK_CONTROL
1414
default y

0 commit comments

Comments
 (0)