[PATCH v2 1/2] clk: samsung: acpm: introduce driver data for SoC-specific clocks
From: Alexey Klimov
Date: Mon Sep 14 2026 - 19:10:56 EST
Currently, the ACPM clock driver hardcodes the GS101 clock variant
arrays and counts directly in probe() routine. To support additional
other SoCs (for instance Exynos850 SoC) that use the same ACPM protocol
but have different clock trees, the driver needs to be more flexible.
Introduce driver data attached to the platform_device_id table.
Update the probe function to dynamically extract the clock lists,
number of clocks, its names and mailbox channel id based on the matching
device ID.
Reviewed-by: Tudor Ambarus <tudor.ambarus@xxxxxxxxxx>
Signed-off-by: Alexey Klimov <alexey.klimov@xxxxxxxxxx>
---
drivers/clk/samsung/clk-acpm.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/samsung/clk-acpm.c b/drivers/clk/samsung/clk-acpm.c
index 7680bc8c5275..4b68b44fe615 100644
--- a/drivers/clk/samsung/clk-acpm.c
+++ b/drivers/clk/samsung/clk-acpm.c
@@ -12,6 +12,7 @@
#include <linux/device.h>
#include <linux/err.h>
#include <linux/firmware/samsung/exynos-acpm-protocol.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/types.h>
@@ -101,6 +102,8 @@ static int acpm_clk_register(struct device *dev, struct acpm_clk *aclk,
static int acpm_clk_probe(struct platform_device *pdev)
{
+ const struct acpm_clk_driver_data *drv_data;
+ const struct platform_device_id *id;
struct acpm_handle *acpm_handle;
struct clk_hw_onecell_data *clk_data;
struct clk_hw **hws;
@@ -114,8 +117,14 @@ static int acpm_clk_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(acpm_handle),
"Failed to get acpm handle\n");
- count = acpm_clk_gs101.nr_clks;
- mbox_chan_id = acpm_clk_gs101.mbox_chan_id;
+ id = platform_get_device_id(pdev);
+ if (!id || !id->driver_data)
+ return -ENODEV;
+
+ drv_data = (const struct acpm_clk_driver_data *)id->driver_data;
+
+ count = drv_data->nr_clks;
+ mbox_chan_id = drv_data->mbox_chan_id;
clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, count),
GFP_KERNEL);
@@ -142,8 +151,7 @@ static int acpm_clk_probe(struct platform_device *pdev)
hws[i] = &aclk->hw;
- err = acpm_clk_register(dev, aclk,
- acpm_clk_gs101.clks[i].name);
+ err = acpm_clk_register(dev, aclk, drv_data->clks[i].name);
if (err)
return dev_err_probe(dev, err,
"Failed to register clock\n");
@@ -154,7 +162,7 @@ static int acpm_clk_probe(struct platform_device *pdev)
}
static const struct platform_device_id acpm_clk_id[] = {
- { .name = "gs101-acpm-clk" },
+ { .name = "gs101-acpm-clk", (kernel_ulong_t)&acpm_clk_gs101 },
{ }
};
MODULE_DEVICE_TABLE(platform, acpm_clk_id);
--
2.51.0