[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230117135459.16868-4-ansuelsmth@gmail.com>
Date: Tue, 17 Jan 2023 14:54:56 +0100
From: Christian Marangi <ansuelsmth@...il.com>
To: Bjorn Andersson <andersson@...nel.org>,
Andy Gross <agross@...nel.org>,
Konrad Dybcio <konrad.dybcio@...ainline.org>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, linux-arm-msm@...r.kernel.org,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Christian Marangi <ansuelsmth@...il.com>
Subject: [PATCH v3 3/6] clk: qcom: common: add qcom_find_freq_exact
Currently qcom_find_freq will always find a freq following a CEIL logic
but we may need to find the exact requesting frequency or return NULL.
Add qcom_find_freq_exact to perform a search of the exact requested
frequency.
Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
---
drivers/clk/qcom/common.c | 17 +++++++++++++++++
drivers/clk/qcom/common.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index 75f09e6e057e..ffa91bcc0b0a 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -57,6 +57,23 @@ const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
}
EXPORT_SYMBOL_GPL(qcom_find_freq_floor);
+const
+struct freq_tbl *qcom_find_freq_exact(const struct freq_tbl *f, unsigned long rate)
+{
+ if (!f)
+ return NULL;
+
+ if (!f->freq)
+ return f;
+
+ for (; f->freq; f++)
+ if (rate == f->freq)
+ return f;
+
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(qcom_find_freq_exact);
+
int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src)
{
int i, num_parents = clk_hw_get_num_parents(hw);
diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h
index 9c8f7b798d9f..7bd935332634 100644
--- a/drivers/clk/qcom/common.h
+++ b/drivers/clk/qcom/common.h
@@ -45,6 +45,8 @@ extern const struct freq_tbl *qcom_find_freq(const struct freq_tbl *f,
unsigned long rate);
extern const struct freq_tbl *qcom_find_freq_floor(const struct freq_tbl *f,
unsigned long rate);
+extern const struct freq_tbl *qcom_find_freq_exact(const struct freq_tbl *f,
+ unsigned long rate);
extern void
qcom_pll_set_fsm_mode(struct regmap *m, u32 reg, u8 bias_count, u8 lock_count);
extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map,
--
2.38.1
Powered by blists - more mailing lists