Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ci_logs/
zig-out/
.zig-cache/
venv/
target/
__pycache__
.*.sw*
*.dtb
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Files:
drivers/timer/cdns/config.json
drivers/timer/bcm2835/config.json
drivers/timer/apb_timer/config.json
drivers/dvfs/Cargo.lock
Copyright: UNSW
License: BSD-2-Clause

Expand All @@ -52,3 +53,7 @@ License: ISC
Files: network/ipstacks/lwip/*
Copyright: Copyright (c) 2001-2004 Swedish Institute of Computer Science
License: LicenseRef-BSD-LWIP

Files: support/targets/aarch64-sel4-microkit-minimal.json
Copyright: Copyright 2023, Colias Group, LLC
License: BSD-2-Clause
85 changes: 84 additions & 1 deletion docs/design/design.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2542,9 +2542,92 @@ \subsection{Status}

This device-class specification is \textbf{subject to change}.

\section{Dynamic Voltage and Frequency Scaling}\label{s:DVFS}
Dynamic Voltage and Frequency Scaling(DVFS) is a power management technology
to adjust the frequency and the voltage applied on the processing units in runtime
depending on the actual needs.

\subsection{Principle of the operation}
The power consumption of CMOS(Complementary Metal-Oxide-Semiconductor) circuits can
be defined by the following formula:

\begin{equation}
P_{total} = P_{dynamic} + P_{static}
\end{equation}

Where dynamic power can be roughly defined as:

\begin{equation}
P_{dynamic} \approx C \cdot V^2 \cdot f
\end{equation}

\begin{itemize}
\item \textbf{C}: Capacitance (fixed by hardware design).
\item \textbf{V}: Supply Voltage.
\item \textbf{f}: Clock Frequency.
\end{itemize}

The power scales linearly with the frequency and quadratically with voltage. Lowering
the frequency, which usually allows a lower supply voltage, can dramatically lower
the power consumption as well as the generated heat.

\subsection{Implementing DVFS on different platforms}
There are generally two ways to implement DVFS, and which one to use is heavily depended
on the hardware platform.

\paragraph{Direct interact with the clock/regulator:} The DVFS driver directly interacts
with the clock and the regulator that control the frequency and the voltage the processing
units are operating on. This approach is used on most of the ARM or RISC-V platforms.

\paragraph{Firmware Abstraction:} For some very new ARM platforms, System Control and
Management Interface (SCMI) is supported, providing a unified framework to manage the
the power state of the processing units. For x86 platforms, ACPI and HWP are the common
framework to provide platform agnostic power management interfaces.

\subsection{Data Structures and Interface Specification}
The interface contains static configuration tables to describe the hardware. These are
exposed to the client at compile time.

\paragraph{Operating Performance Point}
Describes a valid discrete state the processing unit can operate on.
\begin{lstlisting}
typedef struct {
uint64_t freq_hz; // Target Frequency in Hertz
uint64_t voltage_uv; // Target Voltage in Microvolts
uint64_t latency_ns; // Transition latency in Nanoseconds
} OppEntry;
\end{lstlisting}

\paragraph{Core Configuration (CoreInfo)}
Describes the topology of the processor. The configuration describes
the number of the processing units, the clock source they are operating under
(one clock source may provide clock for multiple processing units, which means
changing the frequency for one unit would change the frequency of all the units
which has the same clock source), and the Operating Performance Point table.

\begin{lstlisting}
typedef struct {
uint64_t core_ident; // Logical Core ID
uint64_t clock_source_ident; // ID of the clock source
const OppEntry *opptable; // Pointer to valid OPPs for this core
size_t opptable_len; // Number of OPPs
} CoreInfo;
\end{lstlisting}

The interface for DVFS uses \gls{ppc}, and has the following
procedures that can be called:
\begin{description}
\item[\texttt{get\_freq(core\_identifier)}]
Retrieves the current actual frequency of a specific processing unit.
\item[\texttt{set\_freq(core\_identifier, frequency)}]
Sets the designated processing unit to a specific target frequency. The frequency
must be a valid value from the opp table for that specific core or the request
will be rejected.
\end{description}

\section{Sensors, PWM, GPIO, etc}\label{s:sensors}

These device classes are all very similar, and tend tend to be low
These device classes are all very similar, and tend to be low
bandwidth --- transferring one bit to a few bytes at a time. They
fall into the ``simple device'' category introduced in
\autoref{s:dr-overview}; rather than
Expand Down
14 changes: 14 additions & 0 deletions drivers/dvfs/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2025, UNSW
# SPDX-License-Identifier: BSD-2-Clause

[build]
target = "../../support/targets/aarch64-sel4-microkit-minimal.json"

[unstable]
build-std = ["core", "compiler_builtins", "alloc"]
build-std-features = ["compiler-builtins-mem"]

[net]
git-fetch-with-cli = true

[target."aarch64-sel4-microkit-minimal"]
Loading