[PATCH v6 2/2] clk: Search clocks of ACPI device with its companion device

From: Paul Cercueil

Date: Mon Nov 30 2026 - 07:29:09 EST


If the device passed as argument to clk_get() has a companion ACPI
device, use it to search the clocks. If we can't find our clock there,
fall back to the regular path.

The argument for this, is that ACPI clocks are registered to clkdev
using the companion ACPI device's name, before the regular device object
is created.

Signed-off-by: Paul Cercueil <paul.cercueil@xxxxxxxxxxx>
---

v6: New patch
---
drivers/clk/clkdev.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 919fc680ae4d..396715f30ff0 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -6,6 +6,7 @@
*
* Helper for the clk API to assist looking up a struct clk.
*/
+#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
@@ -100,7 +101,9 @@ EXPORT_SYMBOL(clk_get_sys);
struct clk *clk_get(struct device *dev, const char *con_id)
{
const char *dev_id = dev ? dev_name(dev) : NULL;
+ struct acpi_device *adev;
struct clk_hw *hw;
+ struct clk *clk;

if (dev && dev->of_node) {
hw = of_clk_get_hw(dev->of_node, 0, con_id);
@@ -108,6 +111,13 @@ struct clk *clk_get(struct device *dev, const char *con_id)
return clk_hw_create_clk(dev, hw, dev_id, con_id, NULL);
}

+ if (dev && has_acpi_companion(dev)) {
+ adev = ACPI_COMPANION(dev);
+ clk = clk_get(&adev->dev, con_id);
+ if (!IS_ERR(clk) || PTR_ERR(clk) != -ENOENT)
+ return clk;
+ }
+
return __clk_get_sys(dev, dev_id, con_id);
}
EXPORT_SYMBOL(clk_get);
--
2.47.3