[U-Boot,i.MX8MM+CCF,04/41] clk: use clk_dev_binded
diff mbox series

Message ID 20190430103056.32537-5-peng.fan@nxp.com
State Needs Review / ACK
Delegated to: Stefano Babic
Headers show
Series
  • i.MX8MM + CCF
Related show

Commit Message

Peng Fan April 30, 2019, 10:17 a.m. UTC
Preparing to support composite clk.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 drivers/clk/clk-divider.c | 4 ++--
 drivers/clk/clk-mux.c     | 6 ++++--
 2 files changed, 6 insertions(+), 4 deletions(-)

Comments

Lukasz Majewski May 6, 2019, 9:59 p.m. UTC | #1
On Tue, 30 Apr 2019 10:17:43 +0000
Peng Fan <peng.fan@nxp.com> wrote:

> Preparing to support composite clk.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/clk/clk-divider.c | 4 ++--
>  drivers/clk/clk-mux.c     | 6 ++++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index 1d2c1b1ec4..2f09e0bb58 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -69,8 +69,8 @@ unsigned long divider_recalc_rate(struct clk *hw,
> unsigned long parent_rate, 
>  static ulong clk_divider_recalc_rate(struct clk *clk)
>  {
> -	struct clk_divider *divider =
> -		to_clk_divider((struct clk
> *)dev_get_driver_data(clk->dev));
> +	struct clk_divider *divider =
> to_clk_divider(clk_dev_binded(clk) ?
> +			(struct clk

As I've wrote in the previous mail - in iMX6Q there was no issues.
Could you provide an explanation in what respect the iMX8MM is
different ?

What exactly is missing?

> *)dev_get_driver_data(clk->dev) : clk); unsigned long parent_rate =
> clk_get_parent_rate(clk); unsigned int val;
>  
> diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
> index 2c85f2052c..55fc97367a 100644
> --- a/drivers/clk/clk-mux.c
> +++ b/drivers/clk/clk-mux.c
> @@ -35,7 +35,8 @@
>  int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int
> flags, unsigned int val)
>  {
> -	struct clk_mux *mux = to_clk_mux(clk);
> +	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
> +			(struct clk
> *)dev_get_driver_data(clk->dev) : clk); int num_parents =
> mux->num_parents; 
>  	if (table) {
> @@ -61,7 +62,8 @@ int clk_mux_val_to_index(struct clk *clk, u32
> *table, unsigned int flags, 
>  static u8 clk_mux_get_parent(struct clk *clk)
>  {
> -	struct clk_mux *mux = to_clk_mux(clk);
> +	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
> +			(struct clk
> *)dev_get_driver_data(clk->dev) : clk); u32 val;
>  
>  	val = readl(mux->reg) >> mux->shift;




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Lukasz Majewski May 8, 2019, 7:27 a.m. UTC | #2
On Tue, 30 Apr 2019 10:17:43 +0000
Peng Fan <peng.fan@nxp.com> wrote:

> Preparing to support composite clk.
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
>  drivers/clk/clk-divider.c | 4 ++--
>  drivers/clk/clk-mux.c     | 6 ++++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
> index 1d2c1b1ec4..2f09e0bb58 100644
> --- a/drivers/clk/clk-divider.c
> +++ b/drivers/clk/clk-divider.c
> @@ -69,8 +69,8 @@ unsigned long divider_recalc_rate(struct clk *hw,
> unsigned long parent_rate, 
>  static ulong clk_divider_recalc_rate(struct clk *clk)
>  {
> -	struct clk_divider *divider =
> -		to_clk_divider((struct clk
> *)dev_get_driver_data(clk->dev));
> +	struct clk_divider *divider =
> to_clk_divider(clk_dev_binded(clk) ?
> +			(struct clk
> *)dev_get_driver_data(clk->dev) : clk); unsigned long parent_rate =
> clk_get_parent_rate(clk); unsigned int val;
>  
> diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
> index 2c85f2052c..55fc97367a 100644
> --- a/drivers/clk/clk-mux.c
> +++ b/drivers/clk/clk-mux.c
> @@ -35,7 +35,8 @@
>  int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int
> flags, unsigned int val)
>  {
> -	struct clk_mux *mux = to_clk_mux(clk);
> +	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
> +			(struct clk
> *)dev_get_driver_data(clk->dev) : clk); int num_parents =
> mux->num_parents; 
>  	if (table) {
> @@ -61,7 +62,8 @@ int clk_mux_val_to_index(struct clk *clk, u32
> *table, unsigned int flags, 
>  static u8 clk_mux_get_parent(struct clk *clk)
>  {
> -	struct clk_mux *mux = to_clk_mux(clk);
> +	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
> +			(struct clk
> *)dev_get_driver_data(clk->dev) : clk); u32 val;

Maybe the 

(clk_dev_binded(clk) ? (struct clk *)dev_get_driver_data(clk->dev) :
clk)

Could be an inline function or macro?

>  
>  	val = readl(mux->reg) >> mux->shift;




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

Patch
diff mbox series

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 1d2c1b1ec4..2f09e0bb58 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -69,8 +69,8 @@  unsigned long divider_recalc_rate(struct clk *hw, unsigned long parent_rate,
 
 static ulong clk_divider_recalc_rate(struct clk *clk)
 {
-	struct clk_divider *divider =
-		to_clk_divider((struct clk *)dev_get_driver_data(clk->dev));
+	struct clk_divider *divider = to_clk_divider(clk_dev_binded(clk) ?
+			(struct clk *)dev_get_driver_data(clk->dev) : clk);
 	unsigned long parent_rate = clk_get_parent_rate(clk);
 	unsigned int val;
 
diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 2c85f2052c..55fc97367a 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -35,7 +35,8 @@ 
 int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int flags,
 			 unsigned int val)
 {
-	struct clk_mux *mux = to_clk_mux(clk);
+	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
+			(struct clk *)dev_get_driver_data(clk->dev) : clk);
 	int num_parents = mux->num_parents;
 
 	if (table) {
@@ -61,7 +62,8 @@  int clk_mux_val_to_index(struct clk *clk, u32 *table, unsigned int flags,
 
 static u8 clk_mux_get_parent(struct clk *clk)
 {
-	struct clk_mux *mux = to_clk_mux(clk);
+	struct clk_mux *mux = to_clk_mux(clk_dev_binded(clk) ?
+			(struct clk *)dev_get_driver_data(clk->dev) : clk);
 	u32 val;
 
 	val = readl(mux->reg) >> mux->shift;