From: Maxime Ripard <maxime@cerno.tech> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org> Cc: linux-clk@vger.kernel.org, Maxime Ripard <maxime@cerno.tech>, Abel Vesa <abelvesa@kernel.org>, Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>, Sascha Hauer <s.hauer@pengutronix.de>, Shawn Guo <shawnguo@kernel.org>, linux-arm-kernel@lists.infradead.org, NXP Linux Team <linux-imx@nxp.com>, Pengutronix Kernel Team <kernel@pengutronix.de> Subject: [PATCH v4 58/68] clk: imx: scu: Switch to determine_rate Date: Fri, 05 May 2023 13:26:00 +0200 [thread overview] Message-ID: <20221018-clk-range-checks-fixes-v4-58-971d5077e7d2@cerno.tech> (raw) In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> The iMX SCU clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. The round_rate() implementation being shared with other clocks, it's not removed. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Abel Vesa <abelvesa@kernel.org> Cc: Fabio Estevam <festevam@gmail.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawnguo@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team <linux-imx@nxp.com> Cc: Pengutronix Kernel Team <kernel@pengutronix.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/clk/imx/clk-scu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index 417f893f8895..725b7b3edb63 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -250,6 +250,23 @@ static unsigned long clk_scu_recalc_rate(struct clk_hw *hw, return le32_to_cpu(msg.data.resp.rate); } +/* + * clk_scu_determine_rate - Returns the closest rate for a SCU clock + * @hw: clock to round rate for + * @req: clock rate request + * + * Returns 0 on success, a negative error on failure + */ +static int clk_scu_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + /* + * Assume we support all the requested rate and let the SCU firmware + * to handle the left work + */ + return 0; +} + /* * clk_scu_round_rate - Round clock rate for a SCU clock * @hw: clock to round rate for @@ -425,7 +442,7 @@ static void clk_scu_unprepare(struct clk_hw *hw) static const struct clk_ops clk_scu_ops = { .recalc_rate = clk_scu_recalc_rate, - .round_rate = clk_scu_round_rate, + .determine_rate = clk_scu_determine_rate, .set_rate = clk_scu_set_rate, .get_parent = clk_scu_get_parent, .set_parent = clk_scu_set_parent, -- 2.40.0
WARNING: multiple messages have this Message-ID (diff)
From: Maxime Ripard <maxime@cerno.tech> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org> Cc: linux-clk@vger.kernel.org, Maxime Ripard <maxime@cerno.tech>, Abel Vesa <abelvesa@kernel.org>, Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>, Sascha Hauer <s.hauer@pengutronix.de>, Shawn Guo <shawnguo@kernel.org>, linux-arm-kernel@lists.infradead.org, NXP Linux Team <linux-imx@nxp.com>, Pengutronix Kernel Team <kernel@pengutronix.de> Subject: [PATCH v4 58/68] clk: imx: scu: Switch to determine_rate Date: Fri, 05 May 2023 13:26:00 +0200 [thread overview] Message-ID: <20221018-clk-range-checks-fixes-v4-58-971d5077e7d2@cerno.tech> (raw) In-Reply-To: <20221018-clk-range-checks-fixes-v4-0-971d5077e7d2@cerno.tech> The iMX SCU clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. The round_rate() implementation being shared with other clocks, it's not removed. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Abel Vesa <abelvesa@kernel.org> Cc: Fabio Estevam <festevam@gmail.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Shawn Guo <shawnguo@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: NXP Linux Team <linux-imx@nxp.com> Cc: Pengutronix Kernel Team <kernel@pengutronix.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> --- drivers/clk/imx/clk-scu.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/clk/imx/clk-scu.c b/drivers/clk/imx/clk-scu.c index 417f893f8895..725b7b3edb63 100644 --- a/drivers/clk/imx/clk-scu.c +++ b/drivers/clk/imx/clk-scu.c @@ -250,6 +250,23 @@ static unsigned long clk_scu_recalc_rate(struct clk_hw *hw, return le32_to_cpu(msg.data.resp.rate); } +/* + * clk_scu_determine_rate - Returns the closest rate for a SCU clock + * @hw: clock to round rate for + * @req: clock rate request + * + * Returns 0 on success, a negative error on failure + */ +static int clk_scu_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) +{ + /* + * Assume we support all the requested rate and let the SCU firmware + * to handle the left work + */ + return 0; +} + /* * clk_scu_round_rate - Round clock rate for a SCU clock * @hw: clock to round rate for @@ -425,7 +442,7 @@ static void clk_scu_unprepare(struct clk_hw *hw) static const struct clk_ops clk_scu_ops = { .recalc_rate = clk_scu_recalc_rate, - .round_rate = clk_scu_round_rate, + .determine_rate = clk_scu_determine_rate, .set_rate = clk_scu_set_rate, .get_parent = clk_scu_get_parent, .set_parent = clk_scu_set_parent, -- 2.40.0 _______________________________________________ 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:[~2023-05-05 11:28 UTC|newest] Thread overview: 152+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-05 11:25 [PATCH v4 00/68] clk: Make determine_rate mandatory for muxes Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 01/68] clk: Export clk_hw_forward_rate_request() Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 02/68] clk: test: Fix type sign of rounded rate variables Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 03/68] clk: Move no reparent case into a separate function Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard [not found] ` <CGME20230613111502eucas1p2644889c9de1abfe1a14a3b549772f247@eucas1p2.samsung.com> 2023-06-13 11:15 ` Marek Szyprowski 2023-06-13 11:15 ` Marek Szyprowski 2023-06-13 11:15 ` Marek Szyprowski 2023-06-13 11:15 ` Marek Szyprowski [not found] ` <CGME20230613121511eucas1p2595e0de21fadbafc1f6ffdc5636b9271@eucas1p2.samsung.com> 2023-06-13 12:15 ` Marek Szyprowski 2023-06-13 12:15 ` Marek Szyprowski 2023-06-13 12:15 ` Marek Szyprowski 2023-06-13 12:15 ` Marek Szyprowski 2023-06-13 12:29 ` Maxime Ripard 2023-06-13 12:29 ` Maxime Ripard 2023-06-13 12:29 ` Maxime Ripard 2023-06-13 12:29 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 04/68] clk: Introduce clk_hw_determine_rate_no_reparent() Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 17:15 ` kernel test robot 2023-05-05 17:15 ` kernel test robot 2023-05-05 17:15 ` kernel test robot 2023-05-05 11:25 ` [PATCH v4 05/68] clk: lan966x: Remove unused round_rate hook Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 06/68] clk: nodrv: Add a determine_rate hook Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 07/68] clk: test: " Maxime Ripard 2023-06-09 1:41 ` Stephen Boyd 2023-06-13 8:21 ` Maxime Ripard 2023-06-13 18:39 ` Stephen Boyd 2023-06-19 13:20 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 08/68] clk: actions: composite: Add a determine_rate hook for pass clk Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 09/68] clk: at91: main: Add a determine_rate hook Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 10/68] clk: at91: sckc: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 11/68] clk: berlin: div: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 12/68] clk: cdce706: " Maxime Ripard 2023-05-05 21:00 ` kernel test robot 2023-05-05 11:25 ` [PATCH v4 13/68] clk: k210: pll: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 14/68] clk: k210: aclk: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 15/68] clk: k210: mux: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 16/68] clk: lmk04832: clkout: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 17/68] clk: lochnagar: " Maxime Ripard 2023-05-05 17:46 ` kernel test robot 2023-05-05 18:47 ` kernel test robot 2023-05-05 11:25 ` [PATCH v4 18/68] clk: qoriq: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 19/68] clk: si5341: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 20/68] clk: stm32f4: mux: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 21/68] clk: vc5: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 22/68] clk: vc5: clkout: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 23/68] clk: wm831x: " Maxime Ripard 2023-05-05 18:06 ` kernel test robot 2023-05-05 11:25 ` [PATCH v4 24/68] clk: davinci: da8xx-cfgchip: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 25/68] " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 26/68] clk: imx: busy: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 27/68] clk: imx: fixup-mux: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 28/68] clk: imx: scu: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-06 0:37 ` kernel test robot 2023-05-06 0:37 ` kernel test robot 2023-05-05 11:25 ` [PATCH v4 29/68] clk: mediatek: cpumux: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-08 2:36 ` Chen-Yu Tsai 2023-05-08 2:36 ` Chen-Yu Tsai 2023-05-05 11:25 ` [PATCH v4 30/68] clk: pxa: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 31/68] clk: renesas: r9a06g032: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 32/68] clk: socfpga: gate: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 33/68] clk: stm32: core: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 34/68] clk: tegra: bpmp: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 35/68] clk: tegra: super: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 36/68] clk: tegra: periph: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 37/68] clk: ux500: prcmu: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 38/68] clk: ux500: sysctrl: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 39/68] clk: versatile: sp810: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:30 ` Linus Walleij 2023-05-05 11:30 ` Linus Walleij 2023-05-05 19:04 ` Pawel Moll 2023-05-05 19:04 ` Pawel Moll 2023-05-05 11:25 ` [PATCH v4 40/68] drm/tegra: sor: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 41/68] phy: cadence: sierra: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 42/68] phy: cadence: torrent: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 43/68] phy: ti: am654-serdes: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 44/68] phy: ti: j721e-wiz: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 45/68] rtc: sun6i: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 18:46 ` Jernej Škrabec 2023-05-05 18:46 ` Jernej Škrabec 2023-05-05 11:25 ` [PATCH v4 46/68] ASoC: tlv320aic32x4: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 47/68] clk: actions: composite: div: Switch to determine_rate Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 48/68] clk: actions: composite: fact: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 49/68] clk: at91: smd: " Maxime Ripard 2023-05-05 11:25 ` Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 50/68] clk: axi-clkgen: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 51/68] clk: cdce706: divider: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 52/68] clk: cdce706: clkout: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 53/68] clk: si5341: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 54/68] clk: si5351: pll: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 55/68] clk: si5351: msynth: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 56/68] clk: si5351: clkout: " Maxime Ripard 2023-05-05 11:25 ` [PATCH v4 57/68] clk: da8xx: clk48: " Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard [this message] 2023-05-05 11:26 ` [PATCH v4 58/68] clk: imx: scu: " Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 59/68] clk: ingenic: cgu: " Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 60/68] clk: ingenic: tcu: " Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 61/68] clk: sprd: composite: " Maxime Ripard 2023-06-13 17:11 ` Harshit Mogalapalli 2023-06-13 19:21 ` Stephen Boyd 2023-06-13 19:45 ` Harshit Mogalapalli 2023-05-05 11:26 ` [PATCH v4 62/68] clk: st: flexgen: " Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 63/68] clk: stm32: composite: " Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 64/68] clk: tegra: periph: " Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 65/68] clk: tegra: super: " Maxime Ripard 2023-06-18 23:38 ` Dmitry Osipenko 2023-06-19 7:26 ` Maxime Ripard 2023-06-20 19:09 ` Stephen Boyd 2023-06-21 15:35 ` Thierry Reding 2023-06-22 11:24 ` Maxime Ripard 2023-06-23 14:51 ` Thierry Reding 2023-06-23 15:02 ` Maxime Ripard 2023-06-22 11:32 ` Dmitry Osipenko 2023-06-30 4:57 ` Stephen Boyd 2023-05-05 11:26 ` [PATCH v4 66/68] ASoC: tlv320aic32x4: pll: " Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 67/68] ASoC: tlv320aic32x4: div: " Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard 2023-05-05 11:26 ` [PATCH v4 68/68] clk: Forbid to register a mux without determine_rate Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard 2023-05-05 11:26 ` Maxime Ripard 2023-06-09 1:49 ` [PATCH v4 00/68] clk: Make determine_rate mandatory for muxes Stephen Boyd 2023-06-09 1:49 ` Stephen Boyd 2023-06-09 1:49 ` Stephen Boyd
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=20221018-clk-range-checks-fixes-v4-58-971d5077e7d2@cerno.tech \ --to=maxime@cerno.tech \ --cc=abelvesa@kernel.org \ --cc=festevam@gmail.com \ --cc=kernel@pengutronix.de \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-clk@vger.kernel.org \ --cc=linux-imx@nxp.com \ --cc=mturquette@baylibre.com \ --cc=peng.fan@nxp.com \ --cc=s.hauer@pengutronix.de \ --cc=sboyd@kernel.org \ --cc=shawnguo@kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.