81 lines
2.7 KiB
Diff
81 lines
2.7 KiB
Diff
From d2225c1ed8259c5958b1999306abdc0341688733 Mon Sep 17 00:00:00 2001
|
|
From: Icenowy Zheng <icenowy@aosc.io>
|
|
Date: Wed, 17 Jun 2020 08:39:18 +0800
|
|
Subject: [PATCH 221/351] clk: sunxi-ng: add support for rate resetting
|
|
notifier
|
|
|
|
In some situaitons, we will want a clock rate be kept while its parent
|
|
can change, for example, to make dual-head work on A64, TCON0 clock
|
|
needs to be kept for LCD display and its parent (or grandparent)
|
|
PLL-Video0 need to be changed for HDMI display. (There's a quirk on A64
|
|
that HDMI PHY can only use PLL-Video0, not PLL-Video1).
|
|
|
|
Add a notifier helper to create such kind of rate keeping notifier by
|
|
reset the rate after the parent changed.
|
|
|
|
Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
|
|
---
|
|
drivers/clk/sunxi-ng/ccu_common.c | 22 ++++++++++++++++++++++
|
|
drivers/clk/sunxi-ng/ccu_common.h | 12 ++++++++++++
|
|
2 files changed, 34 insertions(+)
|
|
|
|
diff --git a/drivers/clk/sunxi-ng/ccu_common.c b/drivers/clk/sunxi-ng/ccu_common.c
|
|
index 2e20e650b6c0..c33d2de4569d 100644
|
|
--- a/drivers/clk/sunxi-ng/ccu_common.c
|
|
+++ b/drivers/clk/sunxi-ng/ccu_common.c
|
|
@@ -79,6 +79,28 @@ int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb)
|
|
&pll_nb->clk_nb);
|
|
}
|
|
|
|
+static int ccu_rate_reset_notifier_cb(struct notifier_block *nb,
|
|
+ unsigned long event, void *data)
|
|
+{
|
|
+ struct ccu_rate_reset_nb *rate_reset = to_ccu_rate_reset_nb(nb);
|
|
+
|
|
+ if (event == PRE_RATE_CHANGE) {
|
|
+ rate_reset->saved_rate = clk_get_rate(rate_reset->target_clk);
|
|
+ } else if (event == POST_RATE_CHANGE) {
|
|
+ clk_set_rate(rate_reset->target_clk, rate_reset->saved_rate);
|
|
+ }
|
|
+
|
|
+ return NOTIFY_DONE;
|
|
+}
|
|
+
|
|
+int ccu_rate_reset_notifier_register(struct ccu_rate_reset_nb *rate_reset_nb)
|
|
+{
|
|
+ rate_reset_nb->clk_nb.notifier_call = ccu_rate_reset_notifier_cb;
|
|
+
|
|
+ return clk_notifier_register(rate_reset_nb->common->hw.clk,
|
|
+ &rate_reset_nb->clk_nb);
|
|
+}
|
|
+
|
|
int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
|
|
const struct sunxi_ccu_desc *desc)
|
|
{
|
|
diff --git a/drivers/clk/sunxi-ng/ccu_common.h b/drivers/clk/sunxi-ng/ccu_common.h
|
|
index 04e7a12200a2..09a468c2ab9b 100644
|
|
--- a/drivers/clk/sunxi-ng/ccu_common.h
|
|
+++ b/drivers/clk/sunxi-ng/ccu_common.h
|
|
@@ -63,6 +63,18 @@ struct ccu_pll_nb {
|
|
|
|
int ccu_pll_notifier_register(struct ccu_pll_nb *pll_nb);
|
|
|
|
+struct ccu_rate_reset_nb {
|
|
+ struct notifier_block clk_nb;
|
|
+ struct ccu_common *common;
|
|
+
|
|
+ struct clk *target_clk;
|
|
+ unsigned long saved_rate;
|
|
+};
|
|
+
|
|
+#define to_ccu_rate_reset_nb(_nb) container_of(_nb, struct ccu_rate_reset_nb, clk_nb)
|
|
+
|
|
+int ccu_rate_reset_notifier_register(struct ccu_rate_reset_nb *rate_reset_nb);
|
|
+
|
|
int sunxi_ccu_probe(struct device_node *node, void __iomem *reg,
|
|
const struct sunxi_ccu_desc *desc);
|
|
|
|
--
|
|
2.34.0
|
|
|