Use clock-names property which is accessible via parent clock OF node
to look up the parent clock by name instead of depending on unreliable
global clock name to perform look up.

Signed-off-by: Marek Vasut <[email protected]>
---
Cc: Adam Ford <[email protected]>
Cc: Christoph Niedermaier <[email protected]>
Cc: Dong Aisheng <[email protected]>
Cc: Fabio Estevam <[email protected]>
Cc: Hou Zhiqiang <[email protected]>
Cc: Michael Trimarchi <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Tim Harvey <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
V2: Rebase on u-boot/next with additional clock patches
---
 drivers/clk/clk-mux.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index e2331a07840..d7411f8f282 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -113,6 +113,11 @@ int clk_mux_fetch_parent_index(struct clk *clk, struct clk 
*parent)
        for (i = 0; i < mux->num_parents; i++) {
                if (!strcmp(parent->dev->name, mux->parent_names[i]))
                        return i;
+               if (!strcmp(parent->dev->name,
+                           clk_resolve_parent_clk(clk->dev,
+                                                  mux->parent_names[i])))
+                       return i;
+
        }
 
        return -EINVAL;
@@ -207,7 +212,8 @@ struct clk *clk_register_mux(struct udevice *dev, const 
char *name,
         * for the corresponding clock (to do that define .set_parent() method).
         */
        ret = clk_register(clk, UBOOT_DM_CLK_CCF_MUX, name,
-                          parent_names[clk_mux_get_parent(clk)]);
+                          clk_resolve_parent_clk(dev,
+                               parent_names[clk_mux_get_parent(clk)]));
        if (ret) {
                kfree(mux);
                return ERR_PTR(ret);
-- 
2.47.2

Reply via email to