Skip to content

Commit 2c15933

Browse files
tmlindbebarino
authored andcommitted
clk: ti: Add ti_dt_clk_name() helper to use clock-output-names
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>
1 parent d02747e commit 2c15933

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

drivers/clk/ti/clk.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,24 @@ static const struct of_device_id simple_clk_match_table[] __initconst = {
447447
{ }
448448
};
449449

450+
/**
451+
* ti_dt_clk_name - init clock name from first output name or node name
452+
* @np: device node
453+
*
454+
* Use the first clock-output-name for the clock name if found. Fall back
455+
* to legacy naming based on node name.
456+
*/
457+
const char *ti_dt_clk_name(struct device_node *np)
458+
{
459+
const char *name;
460+
461+
if (!of_property_read_string_index(np, "clock-output-names", 0,
462+
&name))
463+
return name;
464+
465+
return np->name;
466+
}
467+
450468
/**
451469
* ti_clk_add_aliases - setup clock aliases
452470
*
@@ -463,7 +481,7 @@ void __init ti_clk_add_aliases(void)
463481
clkspec.np = np;
464482
clk = of_clk_get_from_provider(&clkspec);
465483

466-
ti_clk_add_alias(NULL, clk, np->name);
484+
ti_clk_add_alias(NULL, clk, ti_dt_clk_name(np));
467485
}
468486
}
469487

drivers/clk/ti/clock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
214214
const char *con);
215215
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
216216
const char *con);
217+
const char *ti_dt_clk_name(struct device_node *np);
217218
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
218219
void ti_clk_add_aliases(void);
219220

0 commit comments

Comments
 (0)