Skip to content

Commit d5aad38

Browse files
ChiHuaLdkalowsk
authored andcommitted
drivers: i2c: npcx: add support for NPCKn variant
In NPCXn variant, the I2C peripheral hardware uses FIFO for data transfer, while in NPCKn variant, it uses DMA. This change separates the FIFO-specific code from the common controller logic and adds support for DMA mode. Signed-off-by: Mulin Chao <[email protected]> Signed-off-by: Jun Lin <[email protected]>
1 parent 612c324 commit d5aad38

File tree

6 files changed

+925
-498
lines changed

6 files changed

+925
-498
lines changed

drivers/i2c/CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,18 @@ zephyr_library_sources_ifdef(CONFIG_I2C_MCHP_MSS i2c_mchp_mss.c)
4848
zephyr_library_sources_ifdef(CONFIG_I2C_MCUX i2c_mcux.c)
4949
zephyr_library_sources_ifdef(CONFIG_I2C_MCUX_FLEXCOMM i2c_mcux_flexcomm.c)
5050
zephyr_library_sources_ifdef(CONFIG_I2C_NIOS2 i2c_nios2.c)
51-
zephyr_library_sources_ifdef(CONFIG_I2C_NPCX i2c_npcx_controller.c)
52-
zephyr_library_sources_ifdef(CONFIG_I2C_NPCX i2c_npcx_port.c)
51+
52+
zephyr_library_sources_ifdef(CONFIG_I2C_NPCX_DMA_DRIVEN
53+
i2c_npcx_controller.c
54+
i2c_npcx_controller_dma.c
55+
i2c_npcx_port.c
56+
)
57+
zephyr_library_sources_ifdef(CONFIG_I2C_NPCX_FIFO_DRIVEN
58+
i2c_npcx_controller.c
59+
i2c_npcx_controller_fifo.c
60+
i2c_npcx_port.c
61+
)
62+
5363
zephyr_library_sources_ifdef(CONFIG_I2C_NRFX_TWIS i2c_nrfx_twis.c)
5464
zephyr_library_sources_ifdef(CONFIG_I2C_NUMAKER i2c_numaker.c)
5565
zephyr_library_sources_ifdef(CONFIG_I2C_NXP_II2C i2c_nxp_ii2c.c)

drivers/i2c/Kconfig.npcx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ config I2C_NPCX_PORT_INIT_PRIORITY
2020
help
2121
Initialization priority for the I2C port on an NPCX device, must be
2222
set to a lower priority than the controller one (I2C_INIT_PRIORITY).
23+
24+
config I2C_NPCX_FIFO_DRIVEN
25+
bool
26+
default y
27+
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_NUVOTON_NPCX_I2C_CTRL),dma-driven,False)
28+
depends on I2C_NPCX
29+
help
30+
For I2C peripherals that support FIFO mode, data transfers shall be performed
31+
using FIFO‑driven transactions.
32+
33+
config I2C_NPCX_DMA_DRIVEN
34+
bool
35+
default y
36+
depends on $(dt_compat_any_has_prop,$(DT_COMPAT_NUVOTON_NPCX_I2C_CTRL),dma-driven,True)
37+
depends on I2C_NPCX
38+
help
39+
For I2C peripherals that support DMA mode, data transfers shall be performed
40+
using DMA‑driven transactions.

0 commit comments

Comments
 (0)