arch/risc-v/k210: Add sysctl driver for clock and reset control.#18540
Open
no1wudi wants to merge 1 commit intoapache:masterfrom
Open
arch/risc-v/k210: Add sysctl driver for clock and reset control.#18540no1wudi wants to merge 1 commit intoapache:masterfrom
no1wudi wants to merge 1 commit intoapache:masterfrom
Conversation
Add sysctl driver for K210 SoC providing clock and reset control: - Clock enable/disable with two-stage APB/peripheral enable pattern - Peripheral reset control with proper timing - Clock frequency query for PLL, CPU, APB buses, and peripherals - PLL frequency calculation and CPU frequency configuration The sysctl driver is built unconditionally for K210 boards as it provides essential clock and reset control functionality. Add Kconfig option: - K210_CPU_FREQ: Target CPU frequency in Hz (default 400MHz) Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
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
This change adds a comprehensive sysctl driver for the Kendryte K210 SoC, providing essential clock and reset control functionality. The driver enables proper clock management, peripheral reset control, and configurable CPU frequency.
Why: The K210 SoC requires proper clock and reset management for peripherals and CPU frequency configuration. Previously, the CPU frequency was hardcoded to 400MHz with limited clock control capabilities. This driver provides:
What:
k210_sysctl.c- Full sysctl implementation with clock/reset controlk210_sysctl.h- Public API for clock and reset operationshardware/k210_sysctl.h- Complete register definitionsK210_CPU_FREQ- Target CPU frequency in Hz (default 400MHz, range 40-600MHz)How:
make menuconfig→ "K210 CPU target frequency (Hz)"Impact
Testing
I confirm that changes are verified on local setup and works as intended:
Build Verification
cmake -S nuttx -B build -DBOARD_CONFIG=boards/risc-v/k210/maix-bit/configs/nsh cmake --build build -j8 # Build successful, nuttx.bin generatedCPU Frequency Testing
Tested CPU frequencies from 40MHz to 590MHz in 50MHz increments using
getprimebenchmark to verify:Testing results:
Results demonstrate:
Runtime Verification
Verified on real K210 hardware (Maix Bit board):
getprimebenchmark runs correctlyFiles Changed
arch/risc-v/src/k210/CMakeLists.txt- Add k210_sysctl.c to buildarch/risc-v/src/k210/Make.defs- Add k210_sysctl.c to buildarch/risc-v/src/k210/Kconfig- Add K210_CPU_FREQ configuration optionarch/risc-v/src/k210/hardware/k210_sysctl.h- Extended register definitionsarch/risc-v/src/k210/k210_clockconfig.c- Use new sysctl driverarch/risc-v/src/k210/k210_sysctl.c- New sysctl driver implementationarch/risc-v/src/k210/k210_sysctl.h- New public API header