diff options
author | Stephen Boyd <sboyd@kernel.org> | 2019-04-12 14:31:48 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2019-04-19 17:53:00 -0400 |
commit | dde4eff47c82c52a72af333d9e55370eee6d95d6 (patch) | |
tree | 04a196fc1c5f28c1c8808060a6d730d6386d40d5 | |
parent | fc0c209c147f35ed2648adda09db39fcad89e334 (diff) |
clk: Look for parents with clkdev based clk_lookups
In addition to looking for DT based parents, support clkdev based
clk_lookups. This should allow non-DT based clk drivers to participate
in the parent lookup process.
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Jerome Brunet <jbrunet@baylibre.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Michael Turquette <mturquette@baylibre.com>
Cc: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: Chen-Yu Tsai <wens@csie.org>
Tested-by: Jeffrey Hugo <jhugo@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
-rw-r--r-- | drivers/clk/clk.c | 27 | ||||
-rw-r--r-- | drivers/clk/clk.h | 2 | ||||
-rw-r--r-- | drivers/clk/clkdev.c | 2 |
3 files changed, 21 insertions, 10 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index ffd33b63c37e..50f5c73de688 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -324,14 +324,15 @@ static struct clk_core *clk_core_lookup(const char *name) | |||
324 | } | 324 | } |
325 | 325 | ||
326 | /** | 326 | /** |
327 | * clk_core_get - Find the parent of a clk using a clock specifier in DT | 327 | * clk_core_get - Find the clk_core parent of a clk |
328 | * @core: clk to find parent of | 328 | * @core: clk to find parent of |
329 | * @name: name to search for in 'clock-names' of device providing clk | 329 | * @name: name to search for |
330 | * | 330 | * |
331 | * This is the preferred method for clk providers to find the parent of a | 331 | * This is the preferred method for clk providers to find the parent of a |
332 | * clk when that parent is external to the clk controller. The parent_names | 332 | * clk when that parent is external to the clk controller. The parent_names |
333 | * array is indexed and treated as a local name matching a string in the device | 333 | * array is indexed and treated as a local name matching a string in the device |
334 | * node's 'clock-names' property. This allows clk providers to use their own | 334 | * node's 'clock-names' property or as the 'con_id' matching the device's |
335 | * dev_name() in a clk_lookup. This allows clk providers to use their own | ||
335 | * namespace instead of looking for a globally unique parent string. | 336 | * namespace instead of looking for a globally unique parent string. |
336 | * | 337 | * |
337 | * For example the following DT snippet would allow a clock registered by the | 338 | * For example the following DT snippet would allow a clock registered by the |
@@ -359,15 +360,23 @@ static struct clk_core *clk_core_lookup(const char *name) | |||
359 | */ | 360 | */ |
360 | static struct clk_core *clk_core_get(struct clk_core *core, const char *name) | 361 | static struct clk_core *clk_core_get(struct clk_core *core, const char *name) |
361 | { | 362 | { |
362 | struct clk_hw *hw; | 363 | struct clk_hw *hw = ERR_PTR(-ENOENT); |
364 | struct device *dev = core->dev; | ||
365 | const char *dev_id = dev ? dev_name(dev) : NULL; | ||
363 | struct device_node *np = core->of_node; | 366 | struct device_node *np = core->of_node; |
364 | 367 | ||
365 | if (!np) | 368 | if (np) |
366 | return ERR_PTR(-ENOENT); | 369 | hw = of_clk_get_hw(np, -1, name); |
367 | 370 | ||
368 | /* TODO: Support clkdev clk_lookups */ | 371 | /* |
369 | hw = of_clk_get_hw(np, -1, name); | 372 | * If the DT search above couldn't find the provider or the provider |
370 | if (IS_ERR_OR_NULL(hw)) | 373 | * didn't know about this clk, fallback to looking up via clkdev based |
374 | * clk_lookups | ||
375 | */ | ||
376 | if (PTR_ERR(hw) == -ENOENT) | ||
377 | hw = clk_find_hw(dev_id, name); | ||
378 | |||
379 | if (IS_ERR(hw)) | ||
371 | return ERR_CAST(hw); | 380 | return ERR_CAST(hw); |
372 | 381 | ||
373 | return hw->core; | 382 | return hw->core; |
diff --git a/drivers/clk/clk.h b/drivers/clk/clk.h index 553f531cc232..d8400d623b34 100644 --- a/drivers/clk/clk.h +++ b/drivers/clk/clk.h | |||
@@ -19,6 +19,8 @@ static inline struct clk_hw *of_clk_get_hw(struct device_node *np, | |||
19 | } | 19 | } |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id); | ||
23 | |||
22 | #ifdef CONFIG_COMMON_CLK | 24 | #ifdef CONFIG_COMMON_CLK |
23 | struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, | 25 | struct clk *clk_hw_create_clk(struct device *dev, struct clk_hw *hw, |
24 | const char *dev_id, const char *con_id); | 26 | const char *dev_id, const char *con_id); |
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c index 6f65bde696da..2afc8df8acff 100644 --- a/drivers/clk/clkdev.c +++ b/drivers/clk/clkdev.c | |||
@@ -72,7 +72,7 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) | |||
72 | return cl; | 72 | return cl; |
73 | } | 73 | } |
74 | 74 | ||
75 | static struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id) | 75 | struct clk_hw *clk_find_hw(const char *dev_id, const char *con_id) |
76 | { | 76 | { |
77 | struct clk_lookup *cl; | 77 | struct clk_lookup *cl; |
78 | struct clk_hw *hw = ERR_PTR(-ENOENT); | 78 | struct clk_hw *hw = ERR_PTR(-ENOENT); |