clk: imx: imx8mm: add set_parent callback
authorPeng Fan <peng.fan@nxp.com>
Tue, 22 Oct 2019 03:29:51 +0000 (03:29 +0000)
committerStefano Babic <sbabic@denx.de>
Tue, 5 Nov 2019 09:27:18 +0000 (10:27 +0100)
Add set_parent callback, then assigned-clock-parents in dts could
be work.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Tested-by: Frieder Schrempf <frieder.schrempf@kontron.de>
drivers/clk/imx/clk-imx8mm.c

index 4911345fd908245c6bd79e818cc2677eb8da326d..091b092bbb32763626cf1c0cbeb1631149df645f 100644 (file)
@@ -175,11 +175,30 @@ static int imx8mm_clk_enable(struct clk *clk)
        return __imx8mm_clk_enable(clk, 1);
 }
 
+static int imx8mm_clk_set_parent(struct clk *clk, struct clk *parent)
+{
+       struct clk *c, *cp;
+       int ret;
+
+       debug("%s(#%lu), parent: %lu\n", __func__, clk->id, parent->id);
+
+       ret = clk_get_by_id(clk->id, &c);
+       if (ret)
+               return ret;
+
+       ret = clk_get_by_id(parent->id, &cp);
+       if (ret)
+               return ret;
+
+       return clk_set_parent(c, cp);
+}
+
 static struct clk_ops imx8mm_clk_ops = {
        .set_rate = imx8mm_clk_set_rate,
        .get_rate = imx8mm_clk_get_rate,
        .enable = imx8mm_clk_enable,
        .disable = imx8mm_clk_disable,
+       .set_parent = imx8mm_clk_set_parent,
 };
 
 static int imx8mm_clk_probe(struct udevice *dev)