summaryrefslogtreecommitdiff
path: root/drivers/clk/clk_scmi.c
AgeCommit message (Collapse)Author
3 daysclk: scmi: Fix protocol version fetch for non-CCF platformsKamlesh Gurudasani
The SCMI clock protocol version was only being fetched when CLK_CCF was enabled. On non-CCF platforms, the probe function returned early without fetching the version, leaving priv->version as 0. This caused issues because code paths like scmi_clk_gate() and scmi_clk_get_permissions() depend on priv->version to determine which protocol message format to use, even in non-CCF mode. Fix this by moving the scmi_generic_protocol_version() call before the CLK_CCF check, ensuring the version is fetched for both CCF and non-CCF platforms. Tested on am62lx_evm. Fixes: ae7e0330ce22 ("clk: scmi: add compatibility with clock protocol 2.0") Signed-off-by: Kamlesh Gurudasani <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2026-01-05clk: scmi: Remove duplicated scmi_generic_protocol_version() requestPatrice Chotard
scmi_generic_protocol_version() request is done twice in scmi_clk_probe(). Remove first call which is useless. Fixes: ae7e0330ce22 ("clk: scmi: add compatibility with clock protocol 2.0") Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2026-01-05clk: scmi: Fix priv initialization in scmi_clk_gate()Patrice Chotard
In scmi_clk_probe(), in case of CLK_CCF is not enabled, parent private data is not set, so in scmi_clk_gate(), an uninitialized priv struct is retrieved. SCMI request is performed either using scmi_clk_state_in_v1 or scmi_clk_state_in_v2 struct depending of the unpredictable value of priv->version which leads to error during SCMI clock enable. Issue detected on STM32MP157C-DK2 board using the SCMI device tree stm32mp157c-dk2-scmi.dts. Fixes: 0619cb32030b ("firmware: scmi: Add clock v3.2 CONFIG_SET support") Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2026-01-05clk: scmi: Fix typo scmi_clk_get_attibutePatrice Chotard
Fix typo attibute, rename scmi_clk_get_attibute() to scmi_clk_get_attribute(). Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Marek Vasut <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10clk: scmi: Defer issue of SCMI_CLOCK_ATTRIBUTESMarek Vasut
Instead of resolving clock control flags using SCMI_CLOCK_ATTRIBUTES during probe for each and every clock, resolve the clock control flags using SCMI_CLOCK_ATTRIBUTES when the clock control flags are first used. Because most clock are never used by U-Boot, this allows reducing the amount of SCMI_CLOCK_ATTRIBUTES considerably, and this improve probe time of the scmi clock driver and U-Boot start up time. On Renesas X5H, with 1700+ SCMI clock, the boot time improved by 1.7s . Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10clk: scmi: Postpone clock name resolutionMarek Vasut
The clock names are retrived via SCMI_CLOCK_ATTRIBUTES, called for each clock ID. This may take a lot of time to complete and is not strictly necessary. Register each clock as "scmi-%zu" instead, and let the first call of SCMI_CLOCK_ATTRIBUTES fill in the actual clock name. This has a side effect, which can be considered both an upside and also a downside. Unused clock are never renamed and retain their placeholder "scmi-%zu" name, which avoids empty clock names for nameless SCMI clock, and avoids the name resolution and improves boot time. But for those SCMI clock which do have name, that name is not listed until the clock are used. This is a preparatory patch for deferred issue of SCMI_CLOCK_ATTRIBUTES. Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10clk: scmi: Factor out clock control flags resolutionMarek Vasut
Pull clock control flags resolution into dedicated function and call it from each site that does access clock control flags. No functional change. This is a preparatory patch for deferred issue of SCMI_CLOCK_ATTRIBUTES. Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10clk: scmi: Bulk allocate all sub-driver instance dataMarek Vasut
Allocate all sub-driver instance data at once. The amount of data that have to be allocated is known up front, so is the size of the data, so there is no need to call malloc() in a loop, mallocate all data at once. The upside is, less heap fragmentation and fewer malloc() calls overall, and a faster boot time. The downside is, if some of the clock fail to register, then the clock driver cannot free parts of the bulk allocated sub-driver instance data. Such a failure can only occur if clk_register() were to fail, and if that happens, the system has more significant problems. Worse, if a core clock driver fails to probe, the system has even bigger problem. Reviewed-by: Peng Fan <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10clk: scmi: fix set_parent support when CCF is not being usedKamlesh Gurudasani
When not using Common clock framework(CCF), calls to scmi_clk_set_parent returns -ENOTSUPP, which should not be the case. Fix that. Fixes: 15fdfef6642c ("clk: scmi: check the clock state/parent/rate control permissions) Signed-off-by: Kamlesh Gurudasani <[email protected]> Reviewed-by: Dhruva Gole <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-11-10firmware: scmi: Add clock v3.2 CONFIG_SET supportVinh Nguyen
SCMI v3.2 introduces a new clock CONFIG_SET message format that can optionally carry also OEM specific configuration values beside the usual clock enable/disable requests. Add support to use such new format when talking to a v3.2 compliant SCMI platform. Support existing enable/disable operations across different clock protocol versions: this patch still does not add protocol operations to support the new OEM specific optional configuration capabilities. No functional change for the SCMI drivers users of the related enable and disable clock operations. [Marek: Remodel after Linux e49e314a2cf7 ("firmware: arm_scmi: Add clock v3.2 CONFIG_SET support") Support both old < 2.1 and new >= 2.1 protocol versions. Update commit message based on Linux one] Signed-off-by: Vinh Nguyen <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Alice Guo <[email protected]> Signed-off-by: Peng Fan <[email protected]>
2025-10-09clk: scmi: Replace log_debug with dev_dbgPeng Fan
Use dev_dbg to dump device name, dev_dbg also a encapsulation call to log() and print(). So it is ok to use dev_dbg. Signed-off-by: Peng Fan <[email protected]>
2025-07-29clk: scmi: Fix clock identifier passed to struct scmi_clk_parent_set_inAlice Guo
Commit aa7bdc1af505 ("clk: scmi: manage properly the clk identifier with CFF") enables CONFIG_CLK_AUTO_ID, so need to use clk_get_id() to get the real SCMI CLK ID, otherwise wrong ID is used when set clk parent. Fixes: aa7bdc1af505 ("clk: scmi: manage properly the clk identifier with CCF") Signed-off-by: Alice Guo <[email protected]> Reviewed-by: Peng Fan <[email protected]>
2025-06-11clk: scmi: manage properly the clk identifier with CCFPatrick Delaunay
Each clock identifier needs to be unique when CCF is activated, and it is not respected today by SCMI clock driver. This patch supports a unique clk id by using the uclass API clk_get_id() / dev_clk_dm() and by activating by default CONFIG_CLK_AUTO_ID with CCF which adds an offset to the SCMI clock identifiers. After this patch, the SCMI clock driver can coexist with other clock provider without conflict, they can share internal identifier [0..N] defined in their binding and the clock ID = 0 (reserved for dummy clock) is no more used. Signed-off-by: Patrick Delaunay <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-06-11clk: scmi: add compatibility with clock protocol 2.0Valentin Caron
Since clock protocol 2.0, SCMI specification add an option field "clock_enable_delay" to CLOCK_ATTRIBUTES command. scmi_read_resp_from_smt() will return an error ("Buffer too small") as the message length coming from the SCMI server is not the same as expected. So implement a condition to SCMI clock protocol version to change the length of the expected message. Signed-off-by: Valentin Caron <[email protected]> Signed-off-by: Patrice Chotard <[email protected]> Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Reviewed-by: Patrice Chotard <[email protected]>
2025-05-03clk: scmi: check the clock state/parent/rate control permissionsAlice Guo
Clock driver based on SCMI clock management protocol in Linux checks clock state, parent and rate control permissions. To be consistent with the kernel driver, add this check here. CLOCK_GET_PERMISSIONS is from ARM System Control and Management Interface Platform Design Document 3.2. When using common clock framework (CCF), use the clock signal ID to get the clock registered by clk_register() in scmi_clk_probe(), and then obatin the struct clk_scmi variable with container_of(). Signed-off-by: Alice Guo <[email protected]> Signed-off-by: Ye Li <[email protected]> Reviewed-by: Peng Fan <[email protected]>
2025-05-03clk: scmi: add the command CLOCK_PARENT_SETPeng Fan
This patch adds the command CLOCK_PARENT_SET that can be used to set the parent of a clock. ARM SCMI Version 3.2 supports to change the parent of a clock device. Signed-off-by: Peng Fan <[email protected]> Signed-off-by: Alice Guo <[email protected]> Reviewed-by: Ye Li <[email protected]> Reviewed-by: Marek Vasut <[email protected]>
2025-05-03firmware: scmi: use scmi_proto_driver_get() function to get SCMI protocol driverAlice Guo
If there is a SoC specific SCMI protocol driver, using scmi_proto_driver_get() function can avoid to add SoC specific code to scmi_agent-uclass.c. Signed-off-by: Alice Guo <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-07clk: Remove <common.h> and add needed includesTom Rini
Remove <common.h> from this driver directory and when needed add missing include files directly. Signed-off-by: Tom Rini <[email protected]>
2023-10-13scmi: refactor the code to hide a channel from devicesAKASHI Takahiro
The commit 85dc58289238 ("firmware: scmi: prepare uclass to pass channel reference") added an explicit parameter, channel, but it seems to make the code complex. Hiding this parameter will allow for adding a generic (protocol-agnostic) helper function, i.e. for PROTOCOL_VERSION, in a later patch. Signed-off-by: AKASHI Takahiro <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Etienne Carriere <[email protected]>
2022-06-23clk: scmi: support SCMI multi-channelEtienne Carriere
Update SCMI clock driver to get its assigned SCMI channel during initialization. This change allows SCMI clock protocol to use a dedicated channel when defined in the DT. The reference is saved in SCMI clock driver private data. Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Signed-off-by: Etienne Carriere <[email protected]>
2022-06-23firmware: scmi: prepare scmi uclass API to multi-channelEtienne Carriere
Changes SCMI driver API function devm_scmi_process_msg() to add an SCMI channel reference argument for when SCMI agent supports SCMI protocol specific channels. First argument of devm_scmi_process_msg() is also change to point to the caller SCMI protocol device rather than its parent device (the SCMI agent device). The argument is a pointer to opaque struct scmi_channel known from the SCMI transport drivers. It is currently unused and caller a pass NULL value. A later change will enable such support once SCMI protocol drivers have means to get the channel reference during initialization. Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Cc: Jaehoon Chung <[email protected]> Signed-off-by: Etienne Carriere <[email protected]>
2022-05-05clk: scmi: fix scmi_clk_get_attibute()Heinrich Schuchardt
Local variable out.name lives on the stack and therefore cannot be returned directly. Move the strdup() call into the function. (Coverity 352460) Fixes: 7c33f78983c3 ("clk: scmi: register scmi clocks with CCF") Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Sean Anderson <[email protected]>
2022-03-02clk: scmi: register scmi clocks with CCFEtienne Carriere
Implements SCMI APIs to retrieve the number exposed SCMI clocks using SCMI_PROTOCOL_ATTRIBUTES messages and the names of the clocks using SCMI_CLOCK_ATTRIBUTES messages. This change updates sandbox SCMI clock test driver to manage these 2 new message IDs. Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Cc: Clement Leger <[email protected]> Cc: Patrick Delaunay <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Signed-off-by: Gabriel Fernandez <[email protected]> Signed-off-by: Etienne Carriere <[email protected]>
2022-03-02scmi: change parameter dev in devm_scmi_process_msgEtienne Carriere
Changes devm_scmi_process_msg() first argument from target parent device to current SCMI device and lookup the SCMI agent device among SCMI device parents for find the SCMI agent operator needed for communication with the firmware. This change is needed in order to support CCF in clk_scmi driver unless what CCF will fail to find the right udevice related to exposed SCMI clocks. This patch allows to simplify the caller sequence, using SCMI device reference as parameter instead of knowing SCMI uclass topology. This change also adds some protection in case devm_scmi_process_msg() API function is called for an invalid device type. Cc: Lukasz Majewski <[email protected]> Cc: Sean Anderson <[email protected]> Cc: Jaehoon Chung <[email protected]> Cc: Patrick Delaunay <[email protected]> Reviewed-by: Patrick Delaunay <[email protected]> Signed-off-by: Etienne Carriere <[email protected]>
2021-11-23clk: scmi: define LOG_CATEGORYPatrick Delaunay
Define LOG_CATEGORY to allow filtering with log command. Signed-off-by: Patrick Delaunay <[email protected]> Acked-by: Etienne Carriere <[email protected]>
2020-09-30clk: add clock driver for SCMI agentsEtienne Carriere
This change introduces a clock driver for SCMI agent devices. When SCMI agent and SCMI clock drivers are enabled, SCMI agent binds a clock device for each SCMI clock protocol devices enabled in the FDT. SCMI clock driver is embedded upon CONFIG_CLK_SCMI=y. If enabled, CONFIG_SCMI_AGENT is also enabled. SCMI Clock protocol is defined in the SCMI specification [1]. Links: [1] https://developer.arm.com/architectures/system-architectures/software-standards/scmi Signed-off-by: Etienne Carriere <[email protected]> Cc: Lukasz Majewski <[email protected]> Cc: Simon Glass <[email protected]> Cc: Peng Fan <[email protected]> Cc: Sudeep Holla <[email protected]> Reviewed-by: Simon Glass <[email protected]>