@@ -76,6 +76,27 @@ void imx_check_clk_hws(struct clk_hw *clks[], unsigned int count)
}
EXPORT_SYMBOL_GPL(imx_check_clk_hws);
+struct clk_hw *imx_get_clk_hw_from_dt(struct device_node *np,
+ const char *name)
+{
+ struct of_phandle_args clkspec;
+ struct clk *clk;
+
+ clkspec.np = of_find_node_by_name(np, name);
+ if (clkspec.np) {
+ clk = of_clk_get_from_provider(&clkspec);
+ if (!IS_ERR(clk)) {
+ pr_debug("%s: got %s clock\n", __func__, name);
+ of_node_put(clkspec.np);
+ return __clk_get_hw(clk);
+ }
+ }
+
+ pr_err("%s: failed to %s clock\n", __func__, name);
+ return ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(imx_get_clk_hw_from_dt);
+
static struct clk *imx_obtain_fixed_clock_from_dt(const char *name)
{
struct of_phandle_args phandle;
@@ -294,6 +294,9 @@ struct clk_hw *clk_hw_register_gate2(struct device *dev, const char *name,
u8 clk_gate_flags, spinlock_t *lock,
unsigned int *share_count);
+struct clk_hw *imx_get_clk_hw_from_dt(struct device_node *np,
+ const char *name);
+
struct clk * imx_obtain_fixed_clock(
const char *name, unsigned long rate);
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- drivers/clk/imx/clk.c | 21 +++++++++++++++++++++ drivers/clk/imx/clk.h | 3 +++ 2 files changed, 24 insertions(+)