arch/arm/rtl8721f: add GPIO character driver support - #19582
Merged
Conversation
The shared port ISR clears interrupt status with GPIO_INTStatusClearEdge(), which only clears edge latches. For a level-triggered pin the status stays asserted as long as the level is active, so the ISR re-enters forever once the level fires -- the system hangs before the application can even service the event. Remember at configure time whether a pin is level-triggered, and in the ISR mask such a pin (GPIO_INTConfig DISABLE) before invoking the callback. The application re-enables it via go_enable() after servicing. Edge pins are left unmasked, so their behaviour is unchanged. This fixes a hang reproducible on RTL8721Dx and RTL8721F when a level-high/level-low interrupt pin is used. Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn> Assisted-by: Claude <noreply@anthropic.com>
Wire the shared Ameba GPIO driver into the RTL8721F (amebagreen2) build and
add the EVB board glue:
- arch/arm/src/rtl8721f: build ameba_gpio.c (CMake/Make.defs), source the
common Ameba Kconfig, and add ameba_gpio_chip.h describing the chip's
three GPIO ports (A/B/C), their IRQs and the APBPeriph clock bit.
- arch/arm/src/common/ameba: teach the driver that amebagreen2's ROM
GPIO_Init does not call PAD_PullCtrl or GPIO_INTMode, so call both
explicitly after GPIO_Init; on RTL8721Dx (ram_common) these are harmless
redundant writes. Add the AMEBA_PORT_C / AMEBA_PC() helpers.
- boards/arm/rtl8721f/rtl8721f_evb: register output/input/interrupt demo
pins, add the bringup hook, and provide a minimal 'gpio' NSH defconfig.
- Documentation: add a GPIO section for the RTL8721F EVB and fix a
rising/falling typo in the PKE8721DAF page.
Hardware-verified on the RTL8721F EVB: output, input, and all interrupt
trigger/polarity combinations (rising/falling edge, level high/low).
Signed-off-by: dechao_gong <dechao_gong@realsil.com.cn>
Assisted-by: Claude <noreply@anthropic.com>
jerpelea
requested changes
Jul 30, 2026
jerpelea
left a comment
Contributor
There was a problem hiding this comment.
please replace
Co-Authored-By:
with
Assisted-by:
dcgong2917
force-pushed
the
rtl8721f-gpio
branch
from
July 31, 2026 01:34
592d9cc to
2dd3ed4
Compare
Contributor
Author
|
@jerpelea Thanks for the review. Replaced Co-Authored-By: with Assisted-by: in both commits and force-pushed. Please take another look. |
xiaoxiang781216
approved these changes
Jul 31, 2026
jerpelea
approved these changes
Jul 31, 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
Adds GPIO character-driver support for the RTL8721F and the RTL8721F EVB
board, plus a fix to the shared Ameba GPIO ISR that this port uncovered on
hardware.
Two commits:
arch/arm/common/ameba: fix level-triggered GPIO interrupt storm
The shared port ISR clears interrupt status with
GPIO_INTStatusClearEdge(), which only clears edge latches. For alevel-triggered pin the status stays asserted while the level is active,
so the ISR re-enters forever once the level fires — the system hangs
before the application can service the event. The pin is now masked in
the ISR before the callback and re-enabled by the application via
go_enable(). Edge pins are unchanged. This also affects RTL8721Dx(already in-tree).
arch/arm/rtl8721f: add GPIO character driver support
Wires the shared
ameba_gpio.cinto the RTL8721F build (three GPIOports A/B/C), adds the chip header, board glue, a minimal
gpioNSHdefconfig, and documentation. On amebagreen2 the ROM
GPIO_Initdoesnot call
PAD_PullCtrl/GPIO_INTMode, so the driver now calls bothexplicitly (harmless redundant writes on RTL8721Dx).
Impact
chips (RTL8721Dx, RTL8721F). Edge-triggered and non-interrupt GPIO
behaviour is unchanged.
rtl8721f_evb/gpio.Testing
Hardware-verified on the RTL8721F EVB (
rtl8721f_evb/gpioconfig) viaapps/examples/gpio:rising edge, falling edge, level high, level low. Level cases confirmed
the storm fix (system survives; without the fix it hangs).