Skip to contentSkip to conversation

clk: ti: clk-k3: Notify AVS driver upon setting clock rate

PATCH In review Udit Kumar 2 participants 2 messages Sep 21, 2023 – Oct 12, 2023

Subsystems (2)
lore
Share & tools
lore

Udit Kumar

author
#0 lore raw

PATCH v4 1/1 clk: ti: clk-k3: 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.

---
Boot logs with v4:
https://gist.github.com/uditkumarti/bab0ec09eadb4b167ec1ab93e08637a8

Change log:
Change in v4:
- changed if condition order as per review feedback
- splitted patch into two
- v3 link
https://lore.kernel.org/all/[email protected]/

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 | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/clk/ti/clk-k3.c +9 -0
index ba925fa3c4..10f7240f77 100644
@@ -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,11 @@ 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 freq_scale_up = rate >= ti_clk_get_rate(clk) ? 1 : 0;
 
+	if (IS_ENABLED(CONFIG_K3_AVS0) && freq_scale_up)
+		k3_avs_notify_freq(data->map[clk->id].dev_id,
+				   data->map[clk->id].clk_id, rate);
 	/*
 	 * We must propagate rate change to parent if current clock type
 	 * does not allow setting it.
@@ -339,6 +344,10 @@ static ulong ti_clk_set_rate(struct clk *clk, ulong rate)
 		}
 	}
 
+	if (IS_ENABLED(CONFIG_K3_AVS0) && !freq_scale_up)
+		k3_avs_notify_freq(data->map[clk->id].dev_id,
+				   data->map[clk->id].clk_id, rate);
+
 	return new_rate;
 }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 8 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.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom