[PATCH v4 0/2] cpufreq: spacemit: Add cpufreq support for K1 SoC
Shuwei Wu <[email protected]>
| Newsgroups | dev.linux.lists.spacemit,org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <[email protected]> |
This series enables CPU DVFS for the SpacemiT K1 SoC using the generic cpufreq-dt driver. K1 has two CPU clock clusters. The two clusters have separate CPU clocks, so they are represented as two cpufreq policies: policy0 for CPUs 0-3 and policy4 for CPUs 4-7. The CPU voltage rail is shared between the clusters. To model this with two policies, the OPP entries describe voltage ranges instead of a single fixed voltage, so the shared regulator can keep the rail within a range acceptable for the active OPP constraints. Tested on Banana Pi BPI-F3: ~ # cat /sys/devices/system/cpu/online 0-7 ~ # ls /sys/devices/system/cpu/cpufreq/ policy0 policy4 ~ # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_driver cpufreq-dt ~ # cat /sys/devices/system/cpu/cpufreq/policy0/affected_cpus 0 1 2 3 ~ # cat /sys/devices/system/cpu/cpufreq/policy4/scaling_driver cpufreq-dt ~ # cat /sys/devices/system/cpu/cpufreq/policy4/affected_cpus 4 5 6 7 Both policies expose the same OPP frequencies: ~ # cat /sys/devices/system/cpu/cpufreq/policy0/scaling_available_frequencies 614400 819000 1000000 1228800 1600000 ~ # cat /sys/devices/system/cpu/cpufreq/policy4/scaling_available_frequencies 614400 819000 1000000 1228800 1600000 For each policy, scaling_setspeed was set to each supported OPP and the workload was pinned to one CPU covered by that policy with taskset. CPU0 was used for policy0, and CPU4 was used for policy4. The clock rates below are from /sys/kernel/debug/clk/clk_summary. policy0 / CPU0: ---------------------------------------------------------- Frequency | cpu_c0_core_clk | Real (s) | User (s) (kHz) | (Hz) | | -------------+-------------------+------------+----------- 1,600,000 | 1,600,000,000 | 1.81 | 1.80 1,228,800 | 1,228,800,000 | 2.37 | 2.37 1,000,000 | 1,000,000,000 | 2.89 | 2.89 819,000 | 819,200,000 | 3.56 | 3.55 614,400 | 614,400,000 | 4.71 | 4.71 ---------------------------------------------------------- policy4 / CPU4: ---------------------------------------------------------- Frequency | cpu_c1_core_clk | Real (s) | User (s) (kHz) | (Hz) | | -------------+-------------------+------------+----------- 1,600,000 | 1,600,000,000 | 1.81 | 1.80 1,228,800 | 1,228,800,000 | 2.36 | 2.36 1,000,000 | 1,000,000,000 | 2.89 | 2.89 819,000 | 819,200,000 | 3.55 | 3.55 614,400 | 614,400,000 | 4.71 | 4.70 ---------------------------------------------------------- Signed-off-by: Shuwei Wu <[email protected]> --- Changes in v4: - Represent K1 as two cpufreq-dt policies, one per CPU clock cluster - Use OPP voltage ranges for the shared CPU supply - Link to v3: https://lore.kernel.org/r/[email protected] Changes in v3: - Add a K1-specific cpufreq driver for the shared-rail, dual-clock topology - Use one shared CPU OPP table and one cpufreq policy for all CPUs - Link to v2: https://lore.kernel.org/r/[email protected] Changes in v2: - Move OPP tables to dedicated k1-opp.dtsi - Enable OPP only on BPI-F3 with cpu-supply present - Link to v1: https://lore.kernel.org/r/[email protected] --- Shuwei Wu (2): cpufreq: dt-platdev: Add SpacemiT K1 SoC to the allowlist riscv: dts: spacemit: Add cpu scaling for K1 SoC arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 35 +++++++- arch/riscv/boot/dts/spacemit/k1-opp.dtsi | 105 ++++++++++++++++++++++++ arch/riscv/boot/dts/spacemit/k1.dtsi | 8 ++ drivers/cpufreq/cpufreq-dt-platdev.c | 2 + 4 files changed, 149 insertions(+), 1 deletion(-) --- base-commit: 5164e95565d3fd508ca8a95351323f5716dfb695 change-id: 20260307-shadow-deps-3582a78aa756 prerequisite-patch-id: 154bd4f720ce5065d58b988de8f273207b44572e prerequisite-message-id: <[email protected]> prerequisite-patch-id: 5da3e75b18291a5540d4f66d7a0600fb8975ef62 prerequisite-patch-id: bcf41917414ecef8cf743095d130f6004c32f6a5 prerequisite-patch-id: cfe3800f8c791ec4c63e070af9628e88e0fc31b9 prerequisite-message-id: <[email protected]> prerequisite-patch-id: 7c7fb9f87dba019ece4c97c45750349a7cd28f3a Best regards, -- Shuwei Wu <[email protected]>