Skip to content

Thermal control example (Maaxboard)#670

Draft
omeh-a wants to merge 25 commits into
mainfrom
thermal_control_example
Draft

Thermal control example (Maaxboard)#670
omeh-a wants to merge 25 commits into
mainfrom
thermal_control_example

Conversation

@omeh-a

@omeh-a omeh-a commented Mar 13, 2026

Copy link
Copy Markdown
Member

This is the thermal control example for NCSC phase 5. This adds an example which demonstrates a fully-featured thermal control system, including:

  • A TMU driver supplying access to the core temperature,
  • A PMIC driver allowing us to modify the voltages supplied to the SoC,
  • An I2C driver to let the PMIC driver access the PMIC,
  • A Clock driver allowing us to set the core CPU frequency and the clock state of various peripheral clocks,
  • A PWM driver allowing us to generate a fan-speed control signal,
  • A pinctrl driver allowing us to route the PWM signal to external pins to control the fan,
  • A DVFS driver implementing an operating point table to direct the clock and pmic drivers,
  • A timer driver,
  • And a thermal control client, reading the temperature from the TMU and appropriately setting the DVFS and PWM drivers to control the CPU power state and cooling power level respectively.

Todo for merge:

  • Merge TMU driver
  • Merge I2C driver
  • Merge PMIC driver
  • Merge clock driver
  • Merge DVFS driver
  • Merge pinctrl driver
  • Merge PWM driver
  • Merge SDFgen support for all above drivers
  • Add zig build support
  • Add CI tests

terryzbai and others added 25 commits March 11, 2026 11:13
This implementation includes all clock definitions, basic operations
of clock compoents, as well as interfaces to interact with clicnets
via PPC. Client should be able to enable/disable a specific gate
clock or query the current clock rate by passing the corresponding
clock identifier, which is listed in g12a-bindings.h.

set_rate() assumes that the rate requst is valid and compatible with
the current configurations. Complete implementation that considers
more incompatible requests will come in the future when dynamic
clock configuration is necessary in lionsos

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

add Makefile

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Clock driver for maaxboard

Add clock driver for maaxboard. This commit includes all clock component
definitions, basic operations, and a simple test on maaxboard. Scripts are
added in build systems. A few files are reorganised for reuse

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Clk: fix style

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: modify interfaces and fix issues during initialisation

This commit includes modifiation to the interfaces, primarily for set/get rate, which
return error state as well as final rate.

More tests are conducted to verify the basic operations of types of clock components.
A few bugs are fixed as well.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: fix style and add licenses

This commit fixed style and license issues

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: fix style and data types

This commit replaces all platform-dependent data types with fix-sized
types, and unifies the return values of interfaces as signed integers.
The return value 0 indicates the success on the request to clock driver,
and negative values indicate the failure reasons.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: combine regmap_* and regmap_mux_* operations

Abstract a set of regmap_* operations by combining mux-specific ones and ordinary ones

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: add get/set parent interfaces

Add clk_get_parent() and clk_set_parent() interfaces for the clients.
Fixed several logic issues in related implementations. More clock
component definition checkings and fixup.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: set_rate for maaxboard clocks

This commit adds set_rate() implementations for maaxboard. Now clocks can
be set to target rate at initialisation time and configured dynamically.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: reorganise files

This commit reorgnises source files to allow more code to be shared
for multiple boards.

Refactor makefiles:
- move objectives to clk_driver directory
- use built-in CFLAGS in rules

Temporary fixup for a zig build issue: create_clk_config.py cannot find
the lazypath `zig-out/bin` when executing. The current solution is to
create an install directory in advance, but it would be a bit of trouble
to find the generated header file if someone want to read or modify it.

Moved clock specifier binding files to `include/sddf/clk`, so the clients
will be able to configure clocks with macro constants

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Update clock driver to current sddf build style, added meta.py

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>

Replace setvar constants, move all memory region setup to meta.py

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>

Clock driver for maaxboard

Add clock driver for maaxboard. This commit includes all clock component
definitions, basic operations, and a simple test on maaxboard. Scripts are
added in build systems. A few files are reorganised for reuse

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

examples/clk: remove timer for client

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

examples/clk: remove dts dir

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

drivers/clk: add sddf_clk_set_cpu_freq() interface

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

drivers/clk: add ARM_CLK and remove sddf_clk_set_cpu_freq()

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

clock driver hotfixes

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>

clk driver flake dep

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
…as we think the peripheral clocks are gated

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
add returh of data handler to imx i2c

update i2c imx registers to align with data sheet memory map

update i2c imx init step to use fast-mode divider

add notes on i2c clock calculation

update i2c imx driver to send start when await start

update imx i2c address cycle handling

add transmit successful check

update boards.py to contain i2c region for imx

add read handling in state_cmd_ret for i2c imx

update i2c imx to set TXAK register when reading second to last byte
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
…r why.

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
…orts only the subset of features needed for contract deliverable (DVFS)

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
This implementation includes all clock definitions, basic operations
of clock compoents, as well as interfaces to interact with clicnets
via PPC. Client should be able to enable/disable a specific gate
clock or query the current clock rate by passing the corresponding
clock identifier, which is listed in g12a-bindings.h.

set_rate() assumes that the rate requst is valid and compatible with
the current configurations. Complete implementation that considers
more incompatible requests will come in the future when dynamic
clock configuration is necessary in lionsos

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

add Makefile

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Clock driver for maaxboard

Add clock driver for maaxboard. This commit includes all clock component
definitions, basic operations, and a simple test on maaxboard. Scripts are
added in build systems. A few files are reorganised for reuse

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Clk: fix style

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: modify interfaces and fix issues during initialisation

This commit includes modifiation to the interfaces, primarily for set/get rate, which
return error state as well as final rate.

More tests are conducted to verify the basic operations of types of clock components.
A few bugs are fixed as well.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: fix style and add licenses

This commit fixed style and license issues

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: fix style and data types

This commit replaces all platform-dependent data types with fix-sized
types, and unifies the return values of interfaces as signed integers.
The return value 0 indicates the success on the request to clock driver,
and negative values indicate the failure reasons.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: combine regmap_* and regmap_mux_* operations

Abstract a set of regmap_* operations by combining mux-specific ones and ordinary ones

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: add get/set parent interfaces

Add clk_get_parent() and clk_set_parent() interfaces for the clients.
Fixed several logic issues in related implementations. More clock
component definition checkings and fixup.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: set_rate for maaxboard clocks

This commit adds set_rate() implementations for maaxboard. Now clocks can
be set to target rate at initialisation time and configured dynamically.

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

clk: reorganise files

This commit reorgnises source files to allow more code to be shared
for multiple boards.

Refactor makefiles:
- move objectives to clk_driver directory
- use built-in CFLAGS in rules

Temporary fixup for a zig build issue: create_clk_config.py cannot find
the lazypath `zig-out/bin` when executing. The current solution is to
create an install directory in advance, but it would be a bit of trouble
to find the generated header file if someone want to read or modify it.

Moved clock specifier binding files to `include/sddf/clk`, so the clients
will be able to configure clocks with macro constants

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

Update clock driver to current sddf build style, added meta.py

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>

Replace setvar constants, move all memory region setup to meta.py

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>

Clock driver for maaxboard

Add clock driver for maaxboard. This commit includes all clock component
definitions, basic operations, and a simple test on maaxboard. Scripts are
added in build systems. A few files are reorganised for reuse

Signed-off-by: Terry Bai <terry.z.bai@gmail.com>

examples/clk: remove timer for client

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

examples/clk: remove dts dir

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

drivers/clk: add sddf_clk_set_cpu_freq() interface

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

drivers/clk: add ARM_CLK and remove sddf_clk_set_cpu_freq()

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

clock driver hotfixes

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>

clk driver flake dep

Signed-off-by: Julia Vassiliki <julia.vassiliki@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
… and pmic drivers

Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
@omeh-a omeh-a force-pushed the thermal_control_example branch from 25b8778 to 6cec379 Compare March 16, 2026 02:59
)
from board import BOARDS

assert version("sdfgen").split(".")[1] == "29", "Unexpected sdfgen version"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove: #709

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants