[U-Boot,V1,2/6] clk: imx: imx8mm: add set_parent callback
diff mbox series

Message ID 20191022034714.27781-3-peng.fan@nxp.com
State Accepted
Commit ddf66d2159e0cd7486c70a0983cd321798f72d55
Delegated to: Stefano Babic
Headers show
Series
  • imx: imx8mm-evk: support eth
Related show

Commit Message

Peng Fan Oct. 22, 2019, 3:29 a.m. UTC
Add set_parent callback, then assigned-clock-parents in dts could
be work.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/imx/clk-imx8mm.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Schrempf Frieder Oct. 23, 2019, 4:31 p.m. UTC | #1
On 22.10.19 05:29, Peng Fan wrote:
> 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 | 19 +++++++++++++++++++
>   1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
> index 4911345fd9..091b092bbb 100644
> --- a/drivers/clk/imx/clk-imx8mm.c
> +++ b/drivers/clk/imx/clk-imx8mm.c
> @@ -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)
>

Patch
diff mbox series

diff --git a/drivers/clk/imx/clk-imx8mm.c b/drivers/clk/imx/clk-imx8mm.c
index 4911345fd9..091b092bbb 100644
--- a/drivers/clk/imx/clk-imx8mm.c
+++ b/drivers/clk/imx/clk-imx8mm.c
@@ -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)