Skip to content

drivers: pinctrl: enable the AFIO clock on the CH32V003/20x/30x #89138

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 1 commit into from
May 2, 2025

Conversation

nzmichaelh
Copy link
Collaborator

@nzmichaelh nzmichaelh commented Apr 26, 2025

The Alternate Function IO (AFIO) block must have the clock enabled before use. Some remappings seem to work without, but some like EXTI do not. Fix.

This is the same as #83353 and parts of #87397 but moves the definition to Devicetree.

This is needed by the GPIO EXTI support in #89139

The Alternate Function IO (AFIO) block must have the clock enabled
before configuring. Some remappings seem to work without, but some
like EXTI do not. Fix.

Signed-off-by: Michael Hope <michaelh@juju.nz>
@nzmichaelh
Copy link
Collaborator Author

@recalci FYI

Copy link
Collaborator

@VynDragon VynDragon left a comment

Choose a reason for hiding this comment

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

I prefer this one and it seems it seems it hasnt broken anything on linkW.

@kartben kartben requested a review from Copilot May 2, 2025 08:22
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that the AFIO block clock is enabled via the clock control subsystem rather than relying on in-function remapping logic, which is necessary for proper EXTI support. Key changes include removing the direct clock enable in pin configuration and introducing a dedicated SYS_INIT-based clock initialization function.

  • Removed inline clock enabling in pin configuration.
  • Added a new clock initialization function that leverages device tree settings.
  • Applied the changes consistently across both CH32V003 and CH32V20x/30x drivers.

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 2 comments.

File Description
drivers/pinctrl/pinctrl_wch_afio.c Removed direct clock enable from pin configuration and added a dedicated clock initialization function with SYS_INIT
drivers/pinctrl/pinctrl_wch_20x_30x_afio.c Applied similar clock initialization changes consistent with the CH32V003 implementation
Files not reviewed (2)
  • dts/riscv/wch/ch32v0/ch32v003.dtsi: Language not supported
  • dts/riscv/wch/ch32v208/ch32v208.dtsi: Language not supported

@kartben kartben merged commit aa469e0 into zephyrproject-rtos:main May 2, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Pinctrl area: RISCV RISCV Architecture (32-bit & 64-bit) platform: WinChipHead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants