clk: ti: Add ti_dt_clk_name() helper to use clock-output-names
authorTony Lindgren <tony@atomide.com>
Fri, 4 Feb 2022 07:14:47 +0000 (09:14 +0200)
committerStephen Boyd <sboyd@kernel.org>
Fri, 11 Mar 2022 02:55:59 +0000 (18:55 -0800)
Let's create the clock alias based on the clock-output-names property if
available. Also the component clock drivers can use ti_dt_clk_name() in
the following patches.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/r/20220204071449.16762-7-tony@atomide.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/ti/clk.c
drivers/clk/ti/clock.h

index 6fcbd80..3463579 100644 (file)
@@ -448,6 +448,24 @@ static const struct of_device_id simple_clk_match_table[] __initconst = {
 };
 
 /**
+ * ti_dt_clk_name - init clock name from first output name or node name
+ * @np: device node
+ *
+ * Use the first clock-output-name for the clock name if found. Fall back
+ * to legacy naming based on node name.
+ */
+const char *ti_dt_clk_name(struct device_node *np)
+{
+       const char *name;
+
+       if (!of_property_read_string_index(np, "clock-output-names", 0,
+                                          &name))
+               return name;
+
+       return np->name;
+}
+
+/**
  * ti_clk_add_aliases - setup clock aliases
  *
  * Sets up any missing clock aliases. No return value.
@@ -463,7 +481,7 @@ void __init ti_clk_add_aliases(void)
                clkspec.np = np;
                clk = of_clk_get_from_provider(&clkspec);
 
-               ti_clk_add_alias(NULL, clk, np->name);
+               ti_clk_add_alias(NULL, clk, ti_dt_clk_name(np));
        }
 }
 
index f1dd62d..938f34e 100644 (file)
@@ -214,6 +214,7 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
                            const char *con);
 struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
                                    const char *con);
+const char *ti_dt_clk_name(struct device_node *np);
 int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
 void ti_clk_add_aliases(void);