From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: Rob Herring <robh+dt@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Adrian Hunter <adrian.hunter@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Philipp Zabel <p.zabel@pengutronix.de>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
linux-clk@vger.kernel.org, linux-mmc@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel@lists.collabora.co.uk,
Elaine Zhang <zhangqing@rock-chips.com>,
kernel@collabora.com,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCHv2 06/21] clk: rockchip: clk-cpu: add mux setting for cpu change frequency
Date: Wed, 4 May 2022 23:32:36 +0200 [thread overview]
Message-ID: <20220504213251.264819-7-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20220504213251.264819-1-sebastian.reichel@collabora.com>
From: Elaine Zhang <zhangqing@rock-chips.com>
In order to improve the main frequency of CPU, the clock path of CPU is
simplified as follows:
|--\
| \ |--\
--apll--|\ | \ | \
| |--apll_core--| \ | \
--24M---|/ |mux1 |--[gate]--|mux2|---clk_core
| / | /
--gpll--|\ | / |------| /
| |--gpll_core--| / | |--/
--24M---|/ |--/ |
|
-------apll_directly--------------|
When the CPU requests high frequency, we want to use MUX2 select the
"apll_directly".
At low frequencies use MUX1 to select “apll_core" and then MUX2 to
select "apll_core_gate".
However, in this way, the CPU frequency conversion needs to be
in the following order:
1. MUX2 select to "apll_core_gate", MUX1 select "gpll_core"
2. Apll sets slow_mode, sets APLL parameters, locks APLL, and then APLL
sets normal_mode
3. MUX1 select "apll_core", MUX2 select "apll_directly"
So add pre_muxs and post_muxs to cover this special requirements.
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
[rebase]
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/clk/rockchip/clk-cpu.c | 41 ++++++++++++++++++++++++++++++++++
drivers/clk/rockchip/clk.h | 2 ++
2 files changed, 43 insertions(+)
diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
index 11aa2259b532..6ea7fba9f9e5 100644
--- a/drivers/clk/rockchip/clk-cpu.c
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -113,6 +113,42 @@ static void rockchip_cpuclk_set_dividers(struct rockchip_cpuclk *cpuclk,
}
}
+static void rockchip_cpuclk_set_pre_muxs(struct rockchip_cpuclk *cpuclk,
+ const struct rockchip_cpuclk_rate_table *rate)
+{
+ int i;
+
+ /* alternate parent is active now. set the pre_muxs */
+ for (i = 0; i < ARRAY_SIZE(rate->pre_muxs); i++) {
+ const struct rockchip_cpuclk_clksel *clksel = &rate->pre_muxs[i];
+
+ if (!clksel->reg)
+ break;
+
+ pr_debug("%s: setting reg 0x%x to 0x%x\n",
+ __func__, clksel->reg, clksel->val);
+ writel(clksel->val, cpuclk->reg_base + clksel->reg);
+ }
+}
+
+static void rockchip_cpuclk_set_post_muxs(struct rockchip_cpuclk *cpuclk,
+ const struct rockchip_cpuclk_rate_table *rate)
+{
+ int i;
+
+ /* alternate parent is active now. set the muxs */
+ for (i = 0; i < ARRAY_SIZE(rate->post_muxs); i++) {
+ const struct rockchip_cpuclk_clksel *clksel = &rate->post_muxs[i];
+
+ if (!clksel->reg)
+ break;
+
+ pr_debug("%s: setting reg 0x%x to 0x%x\n",
+ __func__, clksel->reg, clksel->val);
+ writel(clksel->val, cpuclk->reg_base + clksel->reg);
+ }
+}
+
static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
struct clk_notifier_data *ndata)
{
@@ -165,6 +201,9 @@ static int rockchip_cpuclk_pre_rate_change(struct rockchip_cpuclk *cpuclk,
cpuclk->reg_base + reg_data->core_reg[i]);
}
}
+
+ rockchip_cpuclk_set_pre_muxs(cpuclk, rate);
+
/* select alternate parent */
if (reg_data->mux_core_reg)
writel(HIWORD_UPDATE(reg_data->mux_core_alt,
@@ -219,6 +258,8 @@ static int rockchip_cpuclk_post_rate_change(struct rockchip_cpuclk *cpuclk,
reg_data->mux_core_shift),
cpuclk->reg_base + reg_data->core_reg[0]);
+ rockchip_cpuclk_set_post_muxs(cpuclk, rate);
+
/* remove dividers */
for (i = 0; i < reg_data->num_cores; i++) {
writel(HIWORD_UPDATE(0, reg_data->div_core_mask[i],
diff --git a/drivers/clk/rockchip/clk.h b/drivers/clk/rockchip/clk.h
index bf7c8d082fde..2bd1863a7418 100644
--- a/drivers/clk/rockchip/clk.h
+++ b/drivers/clk/rockchip/clk.h
@@ -380,6 +380,8 @@ struct rockchip_cpuclk_clksel {
struct rockchip_cpuclk_rate_table {
unsigned long prate;
struct rockchip_cpuclk_clksel divs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
+ struct rockchip_cpuclk_clksel pre_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
+ struct rockchip_cpuclk_clksel post_muxs[ROCKCHIP_CPUCLK_NUM_DIVIDERS];
};
/**
--
2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-04 21:35 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-04 21:32 [PATCHv2 00/21] Basic RK3588 Support Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 01/21] dt-bindings: pinctrl: rockchip: add rk3588 Sebastian Reichel
2022-05-05 14:14 ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 02/21] dt-bindings: mmc: sdhci-of-dwcmhsc: Add rk3588 Sebastian Reichel
2022-05-05 14:15 ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 03/21] dt-binding: clock: Document rockchip, rk3588-cru bindings Sebastian Reichel
2022-05-17 0:01 ` [PATCHv2 03/21] dt-binding: clock: Document rockchip,rk3588-cru bindings Rob Herring
2022-05-04 21:32 ` [PATCHv2 04/21] clk: rockchip: add register offset of the cores select parent Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 05/21] clk: rockchip: add pll type for RK3588 Sebastian Reichel
2022-05-04 21:32 ` Sebastian Reichel [this message]
2022-05-04 21:32 ` [PATCHv2 07/21] clk: rockchip: add dt-binding header for rk3588 Sebastian Reichel
2022-05-17 0:03 ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 09/21] mmc: sdhci-of-dwcmshc: add reset call back for rockchip Socs Sebastian Reichel
2022-05-06 8:52 ` Ulf Hansson
2022-05-06 9:18 ` Sebastian Reichel
2022-05-06 12:37 ` Ulf Hansson
2022-05-31 13:38 ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 10/21] mmc: sdhci-of-dwcmshc: rename rk3568 to rk35xx Sebastian Reichel
2022-05-31 13:38 ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 11/21] mmc: sdhci-of-dwcmshc: add support for rk3588 Sebastian Reichel
2022-05-31 13:38 ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 12/21] pinctrl/rockchip: add error handling for pull/drive register getters Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 13/21] pinctrl/rockchip: add rk3588 support Sebastian Reichel
2022-05-05 13:51 ` Nicolas Frattaroli
2022-05-05 14:11 ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 14/21] gpio: rockchip: add support for rk3588 Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 15/21] dt-bindings: serial: snps-dw-apb-uart: Add Rockchip RK3588 Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 16/21] dt-bindings: soc: rockchip: add initial rk3588 syscon compatibles Sebastian Reichel
2022-05-17 0:04 ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 17/21] dt-bindings: gpio: rockchip: add gpio-ranges Sebastian Reichel
2022-05-17 0:04 ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 18/21] dt-bindings: pinctrl: rockchip: increase max amount of device functions Sebastian Reichel
2022-05-17 0:05 ` Rob Herring
2022-05-19 13:04 ` Linus Walleij
2022-05-04 21:32 ` [PATCHv2 19/21] arm64: dts: rockchip: Add rk3588s pinctrl data Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 20/21] arm64: dts: rockchip: Add base DT for rk3588 SoC Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 21/21] arm64: dts: rockchip: Add rk3588-evb1 board Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220504213251.264819-7-sebastian.reichel@collabora.com \
--to=sebastian.reichel@collabora.com \
--cc=adrian.hunter@intel.com \
--cc=brgl@bgdev.pl \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=kernel@collabora.com \
--cc=kernel@lists.collabora.co.uk \
--cc=krzk+dt@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=zhangqing@rock-chips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).