Skip to content

Commit a106a5e

Browse files
teburdcarlescufi
authored andcommitted
i2c: SAM Add RTIO support for I2C
Support i2c with a seperate driver for sam twihs that implements RTIO. Signed-off-by: Tom Burdick <[email protected]>
1 parent a560d47 commit a106a5e

File tree

4 files changed

+499
-8
lines changed

4 files changed

+499
-8
lines changed

drivers/i2c/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
zephyr_library()
44

55
zephyr_library_sources(i2c_common.c)
6+
7+
if(CONFIG_I2C_RTIO)
8+
zephyr_library_sources(i2c_rtio.c)
9+
zephyr_library_sources_ifdef(CONFIG_I2C_SAM_TWIHS i2c_sam_twihs_rtio.c)
10+
else()
611
zephyr_library_sources_ifdef(CONFIG_I2C_SHELL i2c_shell.c)
712
zephyr_library_sources_ifdef(CONFIG_I2C_BITBANG i2c_bitbang.c)
813
zephyr_library_sources_ifdef(CONFIG_I2C_TELINK_B91 i2c_b91.c)
@@ -52,10 +57,10 @@ zephyr_library_sources_ifdef(CONFIG_I2C_STM32_V2
5257
i2c_ll_stm32_v2.c
5358
i2c_ll_stm32.c
5459
)
60+
endif()
5561

5662
zephyr_library_sources_ifdef(CONFIG_I2C_TEST i2c_test.c)
5763

58-
zephyr_library_sources_ifdef(CONFIG_I2C_RTIO i2c_rtio.c)
5964
zephyr_library_sources_ifdef(CONFIG_USERSPACE i2c_handlers.c)
6065

6166
add_subdirectory_ifdef(CONFIG_I2C_TARGET target)

drivers/i2c/Kconfig

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ config I2C_CALLBACK
4040
help
4141
API and implementations of i2c_transfer_cb.
4242

43+
config I2C_RTIO
44+
bool "I2C RTIO API"
45+
help
46+
API and implementations of I2C for RTIO
47+
4348
# Include these first so that any properties (e.g. defaults) below can be
4449
# overridden (by defining symbols in multiple locations)
4550
source "drivers/i2c/Kconfig.b91"
@@ -56,6 +61,7 @@ source "drivers/i2c/Kconfig.sbcon"
5661
source "drivers/i2c/Kconfig.sifive"
5762
source "drivers/i2c/Kconfig.stm32"
5863
source "drivers/i2c/Kconfig.sam0"
64+
source "drivers/i2c/Kconfig.sam_twihs"
5965
source "drivers/i2c/Kconfig.litex"
6066
source "drivers/i2c/Kconfig.lpc11u6x"
6167
source "drivers/i2c/Kconfig.npcx"
@@ -88,13 +94,6 @@ config I2C_GECKO
8894
help
8995
Enable the SiLabs Gecko I2C bus driver.
9096

91-
config I2C_SAM_TWIHS
92-
bool "Atmel SAM (TWIHS) I2C driver"
93-
default y
94-
depends on DT_HAS_ATMEL_SAM_I2C_TWIHS_ENABLED
95-
help
96-
Enable Atmel SAM MCU Family (TWIHS) I2C bus driver.
97-
9897
config I2C_SAM_TWIM
9998
bool "Atmel SAM (TWIM) I2C driver"
10099
default y

drivers/i2c/Kconfig.sam_twihs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# sam twihs I2C support
2+
3+
# Copyright (c) 2023 Intel Corporation
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
menuconfig I2C_SAM_TWIHS
7+
bool "Atmel SAM (TWIHS) I2C driver"
8+
default y
9+
depends on DT_HAS_ATMEL_SAM_I2C_TWIHS_ENABLED
10+
help
11+
Enable Atmel SAM MCU Family (TWIHS) I2C bus driver.
12+
13+
if I2C_SAM_TWIHS
14+
if I2C_RTIO
15+
16+
config I2C_SAM_TWIHS_SQ_SIZE
17+
int "Submission queue size for blocking calls"
18+
default 4
19+
help
20+
Blocking i2c calls when I2C_RTIO is enabled are copied into a per driver
21+
submission queue. The queue depth determines the number of possible i2c_msg
22+
structs that may be in the array given to i2c_transfer. A sensible default
23+
is going to be 4 given the device address, register address, and a value
24+
to be read or written.
25+
26+
config I2C_SAM_TWIHS_CQ_SIZE
27+
int "Completion queue size for blocking calls"
28+
default 4
29+
help
30+
Blocking i2c calls when I2C_RTIO is enabled are copied into a per driver
31+
submission queue. The queue depth determines the number of possible i2c_msg
32+
structs that may be in the array given to i2c_transfer. A sensible default
33+
is going to be 4 given the device address, register address, and a value
34+
to be read or written.
35+
36+
endif # I2C_RTIO
37+
endif # I2C_SAM_TWIHS

0 commit comments

Comments
 (0)