Skip to content

drivers: i2c: rts5912 i2c dirver #89386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/i2c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ zephyr_library_sources_ifdef(CONFIG_I2C_RCAR i2c_rcar.c)
zephyr_library_sources_ifdef(CONFIG_I2C_RENESAS_RA_IIC i2c_renesas_ra_iic.c)
zephyr_library_sources_ifdef(CONFIG_I2C_RENESAS_RA_SCI_B i2c_renesas_ra_sci_b.c)
zephyr_library_sources_ifdef(CONFIG_I2C_RENESAS_RZ_RIIC i2c_renesas_rz_riic.c)
zephyr_library_sources_ifdef(CONFIG_I2C_RTS5912 i2c_realtek_rts5912.c)
zephyr_library_sources_ifdef(CONFIG_I2C_RV32M1_LPI2C i2c_rv32m1_lpi2c.c)
zephyr_library_sources_ifdef(CONFIG_I2C_SAM0 i2c_sam0.c)
zephyr_library_sources_ifdef(CONFIG_I2C_SAM_TWI i2c_sam_twi.c)
Expand Down
3 changes: 2 additions & 1 deletion drivers/i2c/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ config I2C_ALLOW_NO_STOP_TRANSACTIONS
depends on !I2C_STM32
depends on !I2C_GD32
depends on !I2C_ESP32
depends on !I2C_DW
depends on (!I2C_DW || I2C_RTS5912)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CONFIG_I2C_ALLOW_NO_STOP_TRANSACTIONS is deprecated and will be removed. The RTS5912 driver needs to work without this option.

Copy link
Contributor Author

@Titan-Realtek Titan-Realtek May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, Keith
currently I need to enable the CONFIG to allow driver do not send a STOP bit at a special i2c msg combination,
such as CROS i2c_controller.c , i2c_read_sized_block() funciton, the first message transaction only has START flag and without STOP flag :

/*
* Send device reg space offset, and read back block length.
* Keep this session open without a stop.
*/
rv = i2c_xfer_unlocked(port, addr_flags, &reg, 1, &block_length,
					1, I2C_XFER_START);

if I don't enable this CONFIG , ZEPHYR i2c transport layer will force to add STOP bit

if (!IS_ENABLED(CONFIG_I2C_ALLOW_NO_STOP_TRANSACTIONS)) {
	msgs[num_msgs - 1].flags |= I2C_MSG_STOP;
}

then after first transaction done, the dw i2c ip will setup again and send a START+ADDR at second message.
so, I need to enable the flag and combine the new variable "need_setup" to control the IP don't setup again and continue to read the data with STOP flag.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The plan to deprecate CONFIG_I2C_ALLOW_NO_STOP_TRANSACTIONS has been delayed. This is okay for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it, thanks.

select DEPRECATED
help
Allow I2C transactions with no STOP on the last message. This is
Expand Down Expand Up @@ -146,6 +146,7 @@ source "drivers/i2c/Kconfig.omap"
source "drivers/i2c/Kconfig.rcar"
source "drivers/i2c/Kconfig.renesas_ra"
source "drivers/i2c/Kconfig.renesas_rz"
source "drivers/i2c/Kconfig.rts5912"
source "drivers/i2c/Kconfig.sam0"
source "drivers/i2c/Kconfig.sam_twihs"
source "drivers/i2c/Kconfig.sbcon"
Expand Down
9 changes: 8 additions & 1 deletion drivers/i2c/Kconfig.dw
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ menuconfig I2C_DW
config I2C_DW_CLOCK_SPEED
int "Set the clock speed for I2C"
depends on I2C_DW
default 110 if I2C_RTS5912
default 32

config I2C_DW_LPSS_DMA
bool "Use I2C integrated DMA for asynchronous transfer"
depends on I2C_DW
depends on (I2C_DW && !I2C_RTS5912)
select DMA
select DMA_INTEL_LPSS
help
Expand All @@ -28,3 +29,9 @@ config I2C_DW_RW_TIMEOUT_MS
int "Set the Read/Write timeout in milliseconds"
depends on I2C_DW
default 100

config I2C_DW_EXTENDED_SUPPORT
bool "Extended DW features"
help
This option enables support for the SCL/SDA timeout registers and some
additional features of the DW I2C controller.
18 changes: 18 additions & 0 deletions drivers/i2c/Kconfig.rts5912
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2025 Realtek, SIBG-SD7
# SPDX-License-Identifier: Apache-2.0

menuconfig I2C_RTS5912
bool "Realtek RTS5912 I2C support"
default y
depends on DT_HAS_REALTEK_RTS5912_I2C_ENABLED
select I2C_ALLOW_NO_STOP_TRANSACTIONS
select I2C_DW_EXTENDED_SUPPORT
help
Enable the Realtek RTS5912 I2C driver

config I2C_RTS5912_INIT_PRIORITY
int "RTS5912 Init priority"
depends on I2C_RTS5912
default 51
help
I2C device driver initialization priority.
Loading
Loading