Skip to content

arch/arm/ameba: add shared I2C master driver (RTL8721Dx + RTL8721F) - #19780

Open
dcgong2917 wants to merge 2 commits into
apache:masterfrom
dcgong2917:ameba-i2c
Open

arch/arm/ameba: add shared I2C master driver (RTL8721Dx + RTL8721F)#19780
dcgong2917 wants to merge 2 commits into
apache:masterfrom
dcgong2917:ameba-i2c

Conversation

@dcgong2917

Copy link
Copy Markdown
Contributor

Summary

Adds a shared NuttX I2C master lower-half for the Realtek Ameba I2C
controllers (I2C0/I2C1) under arch/arm/src/common/ameba, driven through
the SDK fwlib DesignWare block in polling mode. Per-chip wiring
(controller count, non-secure register bases, APB clock masks, crossbar
pad-mux codes and the fwlib I2C_InitTypeDef layout) is isolated in a
per-chip ameba_i2c_chip.h, so each SoC only supplies a same-named header.

Two commits:

  • arch/arm/rtl8721dx: add shared Ameba I2C driver — introduces the common
    driver + RTL8721Dx chip header + pke8721daf board glue + i2c defconfig.
  • arch/arm/rtl8721f: add I2C master driver support — wires the same shared
    driver into the RTL8721F (amebagreen2) build via its chip header + EVB
    board glue + i2c defconfig (no change to the shared driver).

Each controller registers at /dev/i2cN and is exercised with the
system/i2c i2ctool.

Impact

New optional feature (CONFIG_AMEBA_I2C, default n); no impact when
disabled. Touches only arch/arm/src/common/ameba, arch/arm/src/rtl8721dx,
arch/arm/src/rtl8721f, their boards, and one nxstyle whitelist entry.

Testing

Verified end-to-end on RTL8721F EVB hardware against a second Ameba board
acting as an I2C slave: 7-bit address ACK, register write and read-back
over repeated-START, and full bus scan all pass on I2C0 (PA22/PA23).
Also validated on RTL8721Dx (pke8721daf): SS/FS 100k/400k, 8/16-bit
register access, both I2C0 and I2C1. checkpatch (tools/checkpatch.sh -g)
passes clean on both commits.

Add a shared NuttX I2C master lower-half for the Realtek Ameba I2C
controllers (I2C0/I2C1) in arch/arm/src/common/ameba, driven through
the SDK fwlib in polling mode.  Per-chip wiring (controller count,
register bases, clock masks, crossbar pad-mux codes and the fwlib
I2C_InitTypeDef layout) lives in arch/arm/src/rtl8721dx/ameba_i2c_chip.h
so a port to the other Ameba chips only supplies a same-named header.

Each controller registers as /dev/i2cN from pke8721daf bring-up through
the stock I2C character driver; a dedicated `i2c` defconfig drives the
i2ctool for validation.

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Wire the shared Ameba I2C master lower-half (arch/arm/src/common/
ameba/ameba_i2c.c) into the RTL8721F (amebagreen2) build through a
per-chip header (ameba_i2c_chip.h), and register the RTL8721F EVB
buses at /dev/i2cN.

Per-chip differences from the other Ameba SoCs (non-secure register
bases, crossbar pinmux codes, APB clock masks and the fwlib
I2C_InitTypeDef layout) are isolated in ameba_i2c_chip.h; no change to
the shared driver is needed.

Verified end-to-end on hardware against a second Ameba board acting
as an I2C slave: address ACK, register write and read-back over
repeated-START, and bus scan all pass on I2C0 (PA22/PA23).

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
@github-actions github-actions Bot added Area: Tooling Arch: arm Issues related to ARM (32-bit) architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. Board: arm labels Aug 11, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Area: Tooling Board: arm Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants