Skip to content

Commit

Permalink
drivers: Add driver for SC18IS604 I2C controller
Browse files Browse the repository at this point in the history
This driver relies on the asynchronous transfer functions provided by the
MFD driver to handle interrupts through non-blocking system work queue
items.

The asynchronous API function is implemented via fully non-blocking work
items running on the system work queue. Tracking each in-flight transfer
requires ~100 bytes of heap allocation, so the driver requests some heap
space by default.

Signed-off-by: Sarah Renkhoff <[email protected]>
  • Loading branch information
Irockasingranite committed Jul 9, 2024
1 parent a2dd05f commit 1f29cd0
Show file tree
Hide file tree
Showing 10 changed files with 951 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

add_subdirectory_ifdef(CONFIG_DISPLAY display)
add_subdirectory_ifdef(CONFIG_GPIO gpio)
add_subdirectory_ifdef(CONFIG_I2C i2c)
add_subdirectory_ifdef(CONFIG_MFD mfd)
add_subdirectory_ifdef(CONFIG_RTC rtc)
add_subdirectory_ifdef(CONFIG_SENSOR sensor)
1 change: 1 addition & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ menu "Device Drivers"

rsource "display/Kconfig"
rsource "gpio/Kconfig"
rsource "i2c/Kconfig"
rsource "mfd/Kconfig"
rsource "rtc/Kconfig"
rsource "sensor/Kconfig"
Expand Down
10 changes: 10 additions & 0 deletions drivers/i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright (c) 2024 TiaC Systems
# SPDX-License-Identifier: Apache-2.0

# Add to the existing i2c library from zephyr instead of defining our own.
# It is actually required to add I2C drivers to that library, otherwise
# build errors can occur!
zephyr_library_amend()

zephyr_library_sources_ifdef(CONFIG_I2C_SC18IS604 i2c_sc18is604.c)
zephyr_library_sources_ifdef(CONFIG_I2C_CALLBACK i2c_sc18is604_callback.c)
8 changes: 8 additions & 0 deletions drivers/i2c/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 TiaC Systems
# SPDX-License-Identifier: Apache-2.0

if I2C

rsource "Kconfig.sc18is604"

endif # I2C
29 changes: 29 additions & 0 deletions drivers/i2c/Kconfig.sc18is604
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2024 TiaC Systems
# SPDX-License-Identifier: Apache-2.0

menuconfig I2C_SC18IS604
bool "I2C controller part of an SC18IM604 bridge"
default y
depends on DT_HAS_NXP_SC18IS604_I2C_ENABLED
depends on MFD_SC18IS604
select MFD_SC18IS604_ASYNC
select POLL # dependency of MFD_SC18IS604_ASYNC
select DYNAMIC_THREAD # dependency of MFD_SC18IS604_ASYNC
select THREAD_STACK_INFO # dependency of DYNAMIC_THREAD
help
Enable driver for I2C controller part of an SC18IM604 bridge.

config I2C_SC18IS604_INIT_PRIORITY
int "Init priority"
default 60
depends on I2C_SC18IS604
help
Device driver initialization priority.

if I2C_CALLBACK

config HEAP_MEM_POOL_ADD_SIZE_I2C_SC18IS604
int
default 512 # Enough for 5 in-flight async transfers

endif
Loading

0 comments on commit 1f29cd0

Please sign in to comment.