summaryrefslogtreecommitdiff
path: root/drivers/clk
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2016-02-11 13:19:11 -0800
committerTaniya Das <tdas@codeaurora.org>2016-11-28 10:17:41 +0530
commit077d50e6f6edc8ae06c5f0d11e795901218ac534 (patch)
treeeafff0ed1a838b29c17b1588a912d3d37d13fa09 /drivers/clk
parenta2c13a4cc29640ab823a1e949b533385aeb7746b (diff)
clk: Provide OF helper to mark clocks as CRITICAL
This call matches clocks which have been marked as critical in DT and sets the appropriate flag. These flags can then be used to mark the clock core flags appropriately prior to registration. Legacy bindings requiring this feature must add the clock-critical property to their binding descriptions, as it is not a part of common-clock binding. Cc: devicetree@vger.kernel.org Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Michael Turquette <mturquette@baylibre.com> Link: lkml.kernel.org/r/1455225554-13267-4-git-send-email-mturquette@baylibre.com (cherry picked from commit d56f8994b6fb928f59481fabc25bcd1c2f9bd06d) [tdas@codeaurora.org: resolve trivial conflict] Git-commit: d56f8994b6fb928f59481fabc25bcd1c2f9bd06d Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git Change-Id: I2bf824bd2446ca87baabd31c166119d6c5c90643 Signed-off-by: Taniya Das <tdas@codeaurora.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r--drivers/clk/clk.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index b42b68482279..910c168bcbc1 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3864,6 +3864,41 @@ static int parent_ready(struct device_node *np)
}
/**
+ * of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree
+ * @np: Device node pointer associated with clock provider
+ * @index: clock index
+ * @flags: pointer to clk_core->flags
+ *
+ * Detects if the clock-critical property exists and, if so, sets the
+ * corresponding CLK_IS_CRITICAL flag.
+ *
+ * Do not use this function. It exists only for legacy Device Tree
+ * bindings, such as the one-clock-per-node style that are outdated.
+ * Those bindings typically put all clock data into .dts and the Linux
+ * driver has no clock data, thus making it impossible to set this flag
+ * correctly from the driver. Only those drivers may call
+ * of_clk_detect_critical from their setup functions.
+ *
+ * Return: error code or zero on success
+ */
+int of_clk_detect_critical(struct device_node *np,
+ int index, unsigned long *flags)
+{
+ struct property *prop;
+ const __be32 *cur;
+ uint32_t idx;
+
+ if (!np || !flags)
+ return -EINVAL;
+
+ of_property_for_each_u32(np, "clock-critical", prop, cur, idx)
+ if (index == idx)
+ *flags |= CLK_IS_CRITICAL;
+
+ return 0;
+}
+
+/**
* of_clk_init() - Scan and init clock providers from the DT
* @matches: array of compatible values and init functions for providers.
*