Add clock driver for meson - #278
Conversation
642cb84 to
d53cb39
Compare
wom-bat
left a comment
There was a problem hiding this comment.
These are too close to the Linux drivers. We don't need to provide a run-time interface for different clocks, as any sDDF system runs only on a single SoC --- so get rid of all the ..._ops structures and call the functions directly.
Plus please make sure all lines are under 80 chars wide, and add copyright and SPDX Licence tags where they;re missing. Also remember to sign-off your commit messages.
| int i; | ||
| for (i = 0; i < num_regs; i++) { | ||
| reg_write(base, regs[i].reg, regs[i].def); | ||
| /* TODO: delay is needed */ |
There was a problem hiding this comment.
Is this TODO not already done?
2007cd7 to
0a6c664
Compare
|
Please consider rebasing to squash down some of these commits, it's a bit tricky to handle in git when this feature is broken into 11 |
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>
Signed-off-by: Terry Bai <terry.z.bai@gmail.com>
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>
Signed-off-by: Terry Bai <terry.z.bai@gmail.com>
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>
This commit fixed style and license issues Signed-off-by: Terry Bai <terry.z.bai@gmail.com>
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>
Abstract a set of regmap_* operations by combining mux-specific ones and ordinary ones Signed-off-by: Terry Bai <terry.z.bai@gmail.com>
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>
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>
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>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
Signed-off-by: Lesley Rossouw <lesley.rossouw@unsw.edu.au>
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>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
| }, \ | ||
| .hw.init = &(struct clk_init_data) { \ | ||
| .name = #_name, \ | ||
| .ops = &clk_divider_ops, \ |
There was a problem hiding this comment.
I'm copying @wom-bat comment here btw from his original review, because it was never addressed.
These are too close to the Linux drivers. We don't need to provide a run-time interface for different clocks, as any sDDF system runs only on a single SoC --- so get rid of all the
..._opsstructures and call the functions directly.
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
| ) | ||
| from board import BOARDS | ||
|
|
||
| assert version("sdfgen").split(".")[1] == "28", "Unexpected sdfgen version" |
This clock driver configures all clocks as needed at boot time. The initial configurations are parsed from device tree with a python script (which will replaced with either Zig or Rust) and saved as a C header file to be accessed by clock driver.
The design of clock driver is derived from Linux Common Clock Framework (CCF) that unifies client interfaces and key data structures but simplified for modularity and maintainability. Additionally, clock definitions and operations are implemented as static to avoid dynamic memory allocation and other dangerous behaviours.
The current implementation assumes that all client requests are safe and compatible with the existing configurations, especially for
clk_set_rate(), which simply adjust clock rates or propagate one level up to parent clock without any checking. A virtualiser is probably needed to manage requests according to the safety policy.determine_rate()andround_rate()need to be implemented to consider more complicated cases, such as multiple clock consumers requesting different frequencies, and dynamically clock scaling for power management.Linux clock driver is the main reference but it is not always compatible with what described in the datasheet, and it could go through some obscure code somewhere, so there might be some unknown errors in my code.
The clock driver for maaxboard is in progress and coming soon.The implementation for maaxboard is also ready.