diff mbox series

[1/2] clk: Add initialize the rate boundaries of the clk provider

Message ID 20250110-limit-rate-range-of-clk-v1-1-dd618adc4aa8@amlogic.com (mailing list archive)
State New
Headers show
Series clk: amlogic: Limit the rate boundaries of clk_hw | expand

Commit Message

Chuan Liu via B4 Relay Jan. 10, 2025, 11:47 a.m. UTC
From: Chuan Liu <chuan.liu@amlogic.com>

The rate boundaries output by different clk providers vary due to
hardware limitations.

When registering the clk, limit the rate boundaries of the clk provider
to prevent setting the rate of the clk provider beyond the design
specifications and causing abnormal conditions.

Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
 drivers/clk/clk.c            | 4 ++--
 include/linux/clk-provider.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 9b45fa005030..36e4b4f16f1d 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -4359,8 +4359,8 @@  __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
 	core->hw = hw;
 	core->flags = init->flags;
 	core->num_parents = init->num_parents;
-	core->min_rate = 0;
-	core->max_rate = ULONG_MAX;
+	core->min_rate = init->min_rate ? init->min_rate : 0;
+	core->max_rate = init->max_rate ? init->max_rate : ULONG_MAX;
 
 	ret = clk_core_populate_parent_map(core, init);
 	if (ret)
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 2e6e603b7493..46cfc342819e 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -294,6 +294,8 @@  struct clk_parent_data {
  * @parent_hws: array of pointers to all possible parents (when all parents
  *              are internal to the clk controller)
  * @num_parents: number of possible parents
+ * @min_rate: min rate provided by the clk provider
+ * @max_rate: max rate provided by the clk provider
  * @flags: framework-level hints and quirks
  */
 struct clk_init_data {
@@ -304,6 +306,8 @@  struct clk_init_data {
 	const struct clk_parent_data	*parent_data;
 	const struct clk_hw		**parent_hws;
 	u8			num_parents;
+	unsigned long		min_rate;
+	unsigned long		max_rate;
 	unsigned long		flags;
 };