Skip to content

arch/risc-v/eic7700x: Add CPU core clock control. - #20065

Merged
acassis merged 1 commit into
apache:masterfrom
Fishwaldo:eic7700x-feature-cpuclk-pr
Sep 7, 2026
Merged

arch/risc-v/eic7700x: Add CPU core clock control.#20065
acassis merged 1 commit into
apache:masterfrom
Fishwaldo:eic7700x-feature-cpuclk-pr

Conversation

@Fishwaldo

Copy link
Copy Markdown
Contributor

Summary

A driver for the speed of the four application cores. It sets the rate to any
of the operating points the vendor validates, and reports the rate at start up:

[CPU0] cpu: measured 1399 MHz, clock tree says 1400 MHz

Every operating point shares a core voltage, so this touches no regulator.

How the rate is set

The cores run from the PLL being reprogrammed, so they park on a slower clock
first, through a selector the vendor names as glitch free. While parked the PLL
is stopped, given new dividers, restarted and watched until it locks. If it
never locks the cores stay parked: returning them to an unlocked PLL does not
fail safely.

Above a gigahertz the bus ratio must be two to one before the cores return,
because the bus fabric does not reach beyond about eight hundred megahertz. The
mux is therefore moved before the ratio. That ordering is the one step in the
sequence software cannot recover from, and it is commented as such at the site.

How the rate is read

Measured, not derived: the cores are counted against the crystal derived time
counter, because the manual and the vendor's code number the CPU PLL's outputs
differently. The measurement is reported beside what the clock tree computes so
the two can be compared on any board.

Two consequences for eic7700x_clk.c: the core selector's parent is
cpupll_fout1, and the three CPU PLL outputs are CLK_GET_RATE_NOCACHE, since
this driver reprograms that PLL at run time and the framework computes rates
from the registers.

Testing

Built with -Wno-cpp -Werror for eic7700-evb:nsh, and booted on the ESWIN
EIC7700 EVB, where the measurement reads 1399 to 1400 MHz against a tree that
computes 1400.

tools/checkpatch.sh -c -u -m -g master..HEAD passes.

Depends on nothing; the clock tree merged as #19865.

It is a prerequisite for the EIC7700X devfreq driver, which follows in its
own PR and calls eic7700x_cpuclk_setrate() to give the thermal governor
something to slow down.

Drives the speed of the four application cores.  The rate is set to any
of the operating points the vendor validates, all of which share a core
voltage, so this touches no regulator.

The cores run from the PLL being reprogrammed, so they park on a slower
clock first, through a selector the vendor names as glitch free.  While
parked the PLL is stopped, given new dividers, restarted and watched
until it locks; if it never locks the cores stay parked, since returning
them to an unlocked PLL does not fail safely.

Above a gigahertz the bus ratio must be two to one before the cores
return: the bus fabric does not reach beyond about eight hundred
megahertz.  That is the one step in the sequence software cannot recover
from, so the mux is moved before the ratio.

The rate is measured rather than derived.  The cores are counted against
the crystal derived time counter and the result reported beside what the
clock tree computes, because the manual and the vendor's code number the
CPU PLL's outputs differently.  The core selector's parent is
cpupll_fout1, and the three CPU PLL outputs are marked
CLK_GET_RATE_NOCACHE since this driver reprograms that PLL at run time.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Justin Hammond <justin@dynam.ac>
@Fishwaldo
Fishwaldo requested a review from lupyuen as a code owner September 6, 2026 13:02
@github-actions github-actions Bot added Area: Documentation Improvements or additions to documentation Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Size: L The size of the change in this PR is large Board: risc-v labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@acassis
acassis merged commit 1686bb6 into apache:master Sep 7, 2026
31 checks passed
@FelipeMdeO

Copy link
Copy Markdown
Contributor

Hello @acassis , can you revert this PR temporarily, please?

Please check file arch/risc-v/src/eic7700x/Kconfig, it missed endline. Now I am facing issue to build:

$ git clone https://github.com/apache/nuttx.git
$ git clone https://github.com/apache/nuttx-apps.git apps
$ cd nuttx
$ git log --oneline -1
f17c6552 Documentation/rp2040: document fastboot_usb config for waveshare boards

$ ./tools/configure.sh sim:nsh
...
arch/risc-v/src/eic7700x/Kconfig:50: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/risc-v/Kconfig:956: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/risc-v/Kconfig:961: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/Kconfig:257: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
Kconfig:2996: 'endmenu' in different file than 'menu'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'menu'
make: *** [tools/Unix.mk:756: olddefconfig] Error 1
ERROR: failed to refresh

@acassis

acassis commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Hello @acassis , can you revert this PR temporarily, please?

Please check file arch/risc-v/src/eic7700x/Kconfig, it missed endline. Now I am facing issue to build:

$ git clone https://github.com/apache/nuttx.git
$ git clone https://github.com/apache/nuttx-apps.git apps
$ cd nuttx
$ git log --oneline -1
f17c6552 Documentation/rp2040: document fastboot_usb config for waveshare boards

$ ./tools/configure.sh sim:nsh
...
arch/risc-v/src/eic7700x/Kconfig:50: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/risc-v/Kconfig:956: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/risc-v/Kconfig:961: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
arch/Kconfig:257: 'endif' in different file than 'if'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'if'
Kconfig:2996: 'endmenu' in different file than 'menu'
arch/risc-v/src/eic7700x/Kconfig:39: location of the 'menu'
make: *** [tools/Unix.mk:756: olddefconfig] Error 1
ERROR: failed to refresh

but the added Kconfig seems fine:

image

Probably the unpaired Kconfig is commit from other Kconfig, let's find it

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

Labels

Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Area: Documentation Improvements or additions to documentation Board: risc-v Size: L The size of the change in this PR is large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants