arch/arm/rtl8721dx: add shared Ameba GPIO driver.#19484
Merged
Conversation
raulcxw
requested review from
davids5,
jerpelea and
johannes-nivus
as code owners
July 20, 2026 03:44
acassis
previously approved these changes
Jul 20, 2026
Add a board-agnostic GPIO driver for Realtek Ameba chips, exposing pins
through the NuttX GPIO (ioexpander) upper half at /dev/gpioN.
- arch/arm/src/common/ameba/ameba_gpio.{c,h}: the shared driver, sitting
directly on the SDK fwlib register layer. The fwlib GPIO API it calls
resolves at link time from the on-chip ROM symbol table, except
GPIO_INTStatusGet/ClearEdge which are not in ROM and are compiled in
from fwlib ram_common/ameba_gpio.c (that object also carries GPIO_Init,
harmlessly overriding the equivalent ROM copy). Pin interrupts are
dispatched NuttX-natively: the port's NVIC vector is owned by NuttX
via irq_attach, and the ISR reads and clears status through the fwlib
GPIO_INTStatus* helpers.
- The driver keeps nothing IC-specific: the port count, the per-port
NVIC vectors and the RCC gate bits come from a per-chip
<ameba_gpio_chip.h> resolved on the include path, so bringing up a new
Ameba chip only adds that header, not a change to the shared driver.
- arch/arm/src/common/ameba/Kconfig: a shared "Ameba Peripheral Support"
menu with the AMEBA_GPIO option, sourced by each Ameba chip's Kconfig so
it is reused across ICs (RTL8721Dx, RTL8720F, ...).
- arch/arm/src/rtl8721dx: provide ameba_gpio_chip.h, wire the driver into
both the Make/Kconfig and CMake builds, and compile the fwlib
ameba_gpio.c register layer into libameba_fwlib for the RTL8721Dx.
- boards/arm/rtl8721dx/pke8721daf: board pin table (rtl8721dx_gpio.c),
bring-up registration, and a standalone gpio defconfig.
- Documentation: describe the gpio configuration and pin encoding.
tools/nxstyle: whitelist the Ameba "GPIO_" SDK ROM symbol prefix (alongside
the existing FLASH_/IPC_/... Ameba prefixes) so the vendor GPIO API's mixed-case
identifiers do not trip nxstyle, matching how the other Ameba SDK prefixes are
handled.
Assisted-by: Claude Code:claude-opus-4-8
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
xiaoxiang781216
approved these changes
Jul 21, 2026
jerpelea
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a board-agnostic GPIO driver for Realtek Ameba chips, exposing pins through
the NuttX GPIO (ioexpander) upper half at
/dev/gpioN.arch/arm/src/common/ameba/ameba_gpio.{c,h}— the shared driver, sittingdirectly on the SDK fwlib register layer. The fwlib GPIO API it calls
resolves at link time from the on-chip ROM symbol table, except
GPIO_INTStatusGet/ClearEdgewhich are not in ROM and are compiled in fromthe fwlib
ram_common/ameba_gpio.c. Pin interrupts are dispatchedNuttX-natively: the port's NVIC vector is owned by NuttX via
irq_attach, andthe ISR reads/clears status through the fwlib helpers.
and RCC gate bits come from a per-chip
<ameba_gpio_chip.h>resolved on theinclude path, so bringing up a new Ameba chip only adds that header, not a
change to the shared driver.
common/ameba/Kconfig— a shared "Ameba Peripheral Support" menu with theAMEBA_GPIOoption, sourced by each Ameba chip's Kconfig so it is reusedacross ICs (RTL8721Dx, RTL8720F, ...).
arch/arm/src/rtl8721dx— provideameba_gpio_chip.h, wire the driverinto both the make and CMake builds, and compile the fwlib register layer
(
ameba_gpio.c) intolibameba_fwlibfor the RTL8721Dx.boards/arm/rtl8721dx/pke8721daf— board pin table (rtl8721dx_gpio.c),bring-up registration, and a standalone
gpiodefconfig.tools/nxstyle— whitelist the AmebaGPIO_SDK ROM symbol prefix(alongside the existing
FLASH_/IPC_/... Ameba prefixes) so the vendor GPIOAPI's mixed-case identifiers do not trip nxstyle.
gpioconfiguration and pin encoding.Impact
AMEBA_GPIOdriver +pke8721daf:gpioconfiguration. Off by default;no effect on existing configurations.
Testing
Fork CI on top of current apache/master, all green — the
pke8721daf:gpioconfig builds under both build systems, and the existing
nshconfigs for bothboards still build:
pke8721daf:gpio — make and CMake
Hardware-verified on the pke8721daf (RTL8721Dx) with the make build: the driver
was exercised on target through
/dev/gpio*(input read, output write and pininterrupts). The CMake build of the same config is CI-verified (above).