diff mbox series

[01/11] clk: renesas: cpg-mssr: add support for ignore-unused clocks

Message ID 1582748897-17374-2-git-send-email-uli+renesas@fpond.eu (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series clk: renesas: cpg-mssr: add ignore-unused option | expand

Commit Message

Ulrich Hecht Feb. 26, 2020, 8:28 p.m. UTC
This adds facilities to mark clocks as "ignore used", i.e. never to be
turned off. The primary application is the RWDT clock, which needs to
remain on throughout the boot process if enabled by the bootloader.

Signed-off-by: Ulrich Hecht <uli+renesas@fpond.eu>
---
 drivers/clk/renesas/renesas-cpg-mssr.c | 7 +++++++
 drivers/clk/renesas/renesas-cpg-mssr.h | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Wolfram Sang March 3, 2020, 4:13 p.m. UTC | #1
> +	for (i = 0; i < info->num_used_mod_clks; i++)

I think the naming of 'used' is a bit unfortunate because the flag is
'unused'. The most readable would be 'ignore_unused_mod_clks' probably?
But this is kinda long. 'kept_mod_clks'? I really don't want to
bikeshed over this, but maybe we can lower the potential confusion here?

> +		if (id == info->used_mod_clks[i]) {
> +			dev_dbg(dev, "MSTP %s setting CLK_IGNORE_UNUSED\n",
> +				mod->name);

Can we remove this? We can check this easily in debugfs/clk. Yes, I know
CLK_CRITICAL has it, too. Maybe we can remove it there, too. Or just
move it to the final dev_dbg before the function leaves?
diff mbox series

Patch

diff --git a/drivers/clk/renesas/renesas-cpg-mssr.c b/drivers/clk/renesas/renesas-cpg-mssr.c
index a2663fb..31115c7 100644
--- a/drivers/clk/renesas/renesas-cpg-mssr.c
+++ b/drivers/clk/renesas/renesas-cpg-mssr.c
@@ -423,6 +423,13 @@  static void __init cpg_mssr_register_mod_clk(const struct mssr_mod_clk *mod,
 			init.flags |= CLK_IS_CRITICAL;
 			break;
 		}
+	for (i = 0; i < info->num_used_mod_clks; i++)
+		if (id == info->used_mod_clks[i]) {
+			dev_dbg(dev, "MSTP %s setting CLK_IGNORE_UNUSED\n",
+				mod->name);
+			init.flags |= CLK_IGNORE_UNUSED;
+			break;
+		}
 
 	parent_name = __clk_get_name(parent);
 	init.parent_names = &parent_name;
diff --git a/drivers/clk/renesas/renesas-cpg-mssr.h b/drivers/clk/renesas/renesas-cpg-mssr.h
index 3b852ba..c76335c 100644
--- a/drivers/clk/renesas/renesas-cpg-mssr.h
+++ b/drivers/clk/renesas/renesas-cpg-mssr.h
@@ -105,6 +105,9 @@  struct device_node;
      * @crit_mod_clks: Array with Module Clock IDs of critical clocks that
      *                 should not be disabled without a knowledgeable driver
      * @num_crit_mod_clks: Number of entries in crit_mod_clks[]
+     * @used_mod_clks: Array with Module Clock IDs of clocks that should not
+     *                 be disabled even if they seem to be unused
+     * @num_used_mod_clks: Number of entries in used_mod_clks[]
      *
      * @core_pm_clks: Array with IDs of Core Clocks that are suitable for Power
      *                Management, in addition to Module Clocks
@@ -141,6 +144,10 @@  struct cpg_mssr_info {
 	const unsigned int *crit_mod_clks;
 	unsigned int num_crit_mod_clks;
 
+	/* Module Clocks that should not be disabled even if unused */
+	const unsigned int *used_mod_clks;
+	unsigned int num_used_mod_clks;
+
 	/* Core Clocks suitable for PM, in addition to the Module Clocks */
 	const unsigned int *core_pm_clks;
 	unsigned int num_core_pm_clks;