mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keerthy <j-keerthy@ti.com>
To: <t-kristo@ti.com>, <sboyd@kernel.org>, <tony@atomide.com>
Cc: <linux-omap@vger.kernel.org>, <linux-clk@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <mturquette@baylibre.com>,
	<d-gerlach@ti.com>, <j-keerthy@ti.com>
Subject: [PATCH 2/4] clk: clk: Add clk_dflt_restore
Date: Tue, 19 Jun 2018 09:58:23 +0530	[thread overview]
Message-ID: <1529382505-3069-3-git-send-email-j-keerthy@ti.com> (raw)
In-Reply-To: <1529382505-3069-1-git-send-email-j-keerthy@ti.com>

The default restore context function enables or disables
the clock based on the enable_count. This is done in cases
where the clock context is lost and based on the enable_count
the clock either needs to be enabled/disabled. This particularly
helps restore the state of gate clocks.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 drivers/clk/clk.c            | 19 +++++++++++++++++++
 include/linux/clk-provider.h |  2 ++
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7347e06..c201b8b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -910,6 +910,25 @@ static int clk_core_enable_lock(struct clk_core *core)
 	return ret;
 }
 
+/**
+ * clk_dflt_restore_context - restore context for poweroff
+ * @hw: the clk_hw pointer of clock whose state is to be restored
+ *
+ * The default restore context function enables or disables
+ * the clock based on the enable_count. This is done in cases
+ * where the clock context is lost and based on the enable_count
+ * the clock either needs to be enabled/disabled. This particularly
+ * helps restore the state of gate clocks.
+ */
+void clk_dflt_restore_context(struct clk_hw *hw)
+{
+	if (hw->clk->core->enable_count)
+		hw->clk->core->ops->enable(hw);
+	else
+		hw->clk->core->ops->disable(hw);
+}
+EXPORT_SYMBOL_GPL(clk_dflt_restore_context);
+
 static int _clk_save_context(struct clk_core *clk)
 {
 	struct clk_core *child;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index 7f30d62..3e0c61a 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -992,5 +992,7 @@ static inline void clk_writel(u32 val, u32 __iomem *reg)
 
 #endif	/* platform dependent I/O accessors */
 
+void clk_dflt_restore_context(struct clk_hw *hw);
+
 #endif /* CONFIG_COMMON_CLK */
 #endif /* CLK_PROVIDER_H */
-- 
1.9.1


  parent reply	other threads:[~2018-06-19  4:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19  4:28 [PATCH 0/4] clk: clk: Add functions to save/restore clock context en-masse Keerthy
2018-06-19  4:28 ` [PATCH 1/4] " Keerthy
2018-06-19  4:28 ` Keerthy [this message]
2018-06-19  6:06   ` [PATCH 2/4] clk: clk: Add clk_dflt_restore Tero Kristo
2018-06-19 11:13     ` J, KEERTHY
2018-06-19  4:28 ` [PATCH 3/4] clk: ti: Add functions to save/restore clk context Keerthy
2018-06-19  4:28 ` [PATCH 4/4] soc: ti: pm33xx: Save/restore clk context based on enable_off_mode setting Keerthy

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=1529382505-3069-3-git-send-email-j-keerthy@ti.com \
    --to=j-keerthy@ti.com \
    --cc=d-gerlach@ti.com \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=t-kristo@ti.com \
    --cc=tony@atomide.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

all inboxes | Powered by JetHome®