clk: ti: Notify AVS driver upon setting clock rate
Subsystems (2)
PATCH v3 1/1 clk: ti: Notify AVS driver upon setting clock rate
AVS is enabled at R5 SPL stage, on few platforms like J721E and J7200 clk-k3 is used instead if clk-sci driver.
Add support in clk-k3 driver as well to notify AVS driver on setting clock rate so that voltage is changed accordingly.
Also add support in clk-sci driver to do AVS notification before or after clock setting based upon current rate and new clock rate.
---
Boot logs with v3:
https://gist.github.com/uditkumarti/12a753a822c0aec9ca3028648c29dfa8
Change log:
Change in v3:
- Updated AVS notification before/after clock setting based upon new and current rate
- Added modifed notification in clk-sci driver as well
- v2 link
https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Kept clk-sci.c as is because this is used by
AM64 and AM65 platforms
- v1 link
https://lore.kernel.org/all/[email protected]
drivers/clk/ti/clk-k3.c | 11 +++++++++++ drivers/clk/ti/clk-sci.c | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/clk/ti/clk-k3.c +11 -0
@@ -11,6 +11,7 @@#include <errno.h> #include <soc.h> #include <clk-uclass.h> +#include <k3-avs.h> #include "k3-clk.h" #define PLL_MIN_FREQ 800000000
@@ -242,7 +243,13 @@ static ulong ti_clk_set_rate(struct clk *clk, ulong rate)const struct clk_ops *ops;ulong new_rate, rem;ulong diff, new_diff; +int set_avs_after_clock =1 ; +if (rate >=ti_clk_get_rate (clk) &&IS_ENABLED (CONFIG_K3_AVS0 )) { +k3_avs_notify_freq (data->map[clk->id].dev_id, + data->map[clk->id].clk_id, rate); + set_avs_after_clock =0 ; + }/* * We must propagate rate change to parent if current clock type * does not allow setting it.
@@ -339,6 +346,10 @@ static ulong ti_clk_set_rate(struct clk *clk, ulong rate) } } +if (set_avs_after_clock &&IS_ENABLED (CONFIG_K3_AVS0 )) +k3_avs_notify_freq (data->map[clk->id].dev_id, + data->map[clk->id].clk_id, rate); +return new_rate; }
drivers/clk/ti/clk-sci.c +8 -3
@@ -91,12 +91,14 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)const struct ti_sci_handle *sci = data->sci;const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops;int ret; +u8 set_avs_after_clock =1 ;debug ("%s(clk=%p, rate=%lu)\n" , __func__, clk, rate); -#ifdef CONFIG_K3_AVS0 -k3_avs_notify_freq (clk->id, clk->data, rate); -#endif +if (rate >=ti_sci_clk_get_rate (clk) &&IS_ENABLED (CONFIG_K3_AVS0 )) { +k3_avs_notify_freq (clk->id, clk->data, rate); + set_avs_after_clock =0 ; + } ret = cops->set_freq (sci, clk->id, clk->data,0 , rate,ULONG_MAX );if (ret) {
@@ -104,6 +106,9 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)return ret; } +if (set_avs_after_clock &&IS_ENABLED (CONFIG_K3_AVS0 )) +k3_avs_notify_freq (clk->id, clk->data, rate); +return rate; }
Signature · 1 line
2.34.1
Quoted 47 lines · Udit Kumar
AVS is enabled at R5 SPL stage, on few platforms like J721E and J7200 clk-k3 is used instead if clk-sci driver.
Add support in clk-k3 driver as well to notify AVS driver on setting clock rate so that voltage is changed accordingly.
Also add support in clk-sci driver to do AVS notification before or after clock setting based upon current rate and new clock rate.
Cc Keerthy <[email protected]>Signed-off-by Udit Kumar <[email protected]>---
Boot logs with v3:
https://gist.github.com/uditkumarti/12a753a822c0aec9ca3028648c29dfa8Change log:
Change in v3:
- Updated AVS notification before/after clock setting based upon new and current rate
- Added modifed notification in clk-sci driver as well
- v2 link
https://lore.kernel.org/all/[email protected]/Changes in v2:
- Keptclk-sci.cas is because this is used by
AM64 and AM65 platforms
- v1 link
https://lore.kernel.org/all/[email protected]drivers/clk/ti/clk-k3.c | 11 +++++++++++ drivers/clk/ti/clk-sci.c | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-)drivers/clk/ti/clk-k3.c +1
-0@@ -11,6 +11,7 @@#include <errno.h> #include <soc.h> #include <clk-uclass.h> +#include <k3-avs.h> #include "k3-clk.h" #define PLL_MIN_FREQ 800000000
drivers/clk/ti/clk-k3.c static ulong ti_clk_set_rate(struct clk *clk, ulong rate) · line 246
Quoted 4 lines
drivers/clk/ti/clk-k3.c +1
-0@@ -242,7 +243,13 @@ static ulong ti_clk_set_rate(struct clk *clk, ulong rate)const struct clk_ops *ops;ulong new_rate, rem;ulong diff, new_diff; +int set_avs_after_clock =1 ;
int freq_scale_up = rate >= ti_clk_get_rate(clk) ? 1 : 0;
drivers/clk/ti/clk-k3.c static ulong ti_clk_set_rate(struct clk *clk, ulong rate) · line 248
Quoted 2 lines
drivers/clk/ti/clk-k3.c +1
-0+if (rate >=ti_clk_get_rate (clk) &&IS_ENABLED (CONFIG_K3_AVS0 )) {
I think it is better to put IS_ENABLED() as the first check. See other usage:
$ git grep IS_ENABLED . |grep if|grep '&&'
Quoted 53 lines
drivers/clk/ti/clk-k3.c +8
-0+k3_avs_notify_freq (data->map[clk->id].dev_id, + data->map[clk->id].clk_id, rate); + set_avs_after_clock =0 ; + }/* * We must propagate rate change to parent if current clock type * does not allow setting it. @@ -339,6 +346,10 @@ static ulong ti_clk_set_rate(struct clk *clk, ulong rate) } } +if (set_avs_after_clock &&IS_ENABLED (CONFIG_K3_AVS0 )) +k3_avs_notify_freq (data->map[clk->id].dev_id, + data->map[clk->id].clk_id, rate); +return new_rate; }drivers/clk/ti/clk-sci.c +8
-3@@ -91,12 +91,14 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)const struct ti_sci_handle *sci = data->sci;const struct ti_sci_clk_ops *cops = &sci->ops.clk_ops;int ret; +u8 set_avs_after_clock =1 ;debug ("%s(clk=%p, rate=%lu)\n" , __func__, clk, rate); -#ifdef CONFIG_K3_AVS0 -k3_avs_notify_freq (clk->id, clk->data, rate); -#endif +if (rate >=ti_sci_clk_get_rate (clk) &&IS_ENABLED (CONFIG_K3_AVS0 )) { +k3_avs_notify_freq (clk->id, clk->data, rate); + set_avs_after_clock =0 ; + } ret = cops->set_freq (sci, clk->id, clk->data,0 , rate,ULONG_MAX );if (ret) {@@ -104,6 +106,9 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)return ret; } +if (set_avs_after_clock &&IS_ENABLED (CONFIG_K3_AVS0 )) +k3_avs_notify_freq (clk->id, clk->data, rate); +return rate; }Signature · 1 line
2.34.1
First look - it looks fine, but note: these are two different patches. the clk-sci.c is a fix for an existing implementation and clk-k3.c is a new feature addition. please don't mix the two.
Signature · 3 lines
Regards, Nishanth Menon Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
Thanks Nishanth
Quoted 7 lines · Nishanth Menon
Quoted 6 lines · Udit Kumar
AVS is enabled at R5 SPL stage, on few platforms like J721E and J7200 clk-k3 is used instead if clk-sci driver. [...]
I think it is better to putIS_ENABLED()as the first check. See other usage:$ git grep IS_ENABLED . |grep if|grep '&&'
will address in next version
Quoted 5 lines
Quoted 2 lines
[..]
First look - it looks fine, but note: these are two different patches. the
clk-sci.cis a fix for an existing implementation andclk-k3.cis a new feature addition. please don't mix the two.
Sure, Let me send two patches then,
One for new implementation clk-k3.c version v4.
and another for clk-sci.c with Fixes tag.