* [PATCH v5 0/4] clk: Provide support for always-on clocks
@ 2015-04-01 12:28 Lee Jones
2015-04-01 12:28 ` [PATCH v5 1/4] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0 Lee Jones
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Lee Jones @ 2015-04-01 12:28 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: lee.jones, kernel, mturquette, sboyd, devicetree
Lots of platforms contain clocks which if turned off would prove fatal.
The only way to recover from these catastrophic failures is to restart
the board(s). Now, when a clock provider is registered with the
framework it is possible for a list of always-on clocks to be supplied
which must be kept ungated. Each clock mentioned in the newly
introduced 'clock-always-on' will be clk_prepare_enable()d where the
normal references will be taken. This will prevent the common clk
framework from attempting to gate them during the clk_disable_unused()
and disable_clock() procedures.
Changelog:
Implementations have changed drastically between versions, thus I
would like for this set to be thought of independently from its
predecessors. The only reason for identifying as 'v5' is ease of
differentiation on the list, which stems from the confusion caused
by submitting 'v4' as a separate entity.
Lee Jones (4):
ARM: sti: stih407-family: Supply defines for CLOCKGEN A0
ARM: sti: stih410-clocks: Identify critical clocks as always-on
clk: Provide always-on clock support
clk: dt: Introduce binding for always-on clock support
.../devicetree/bindings/clock/clock-bindings.txt | 31 ++++++++++++++++
arch/arm/boot/dts/stih410-clock.dtsi | 10 +++++
drivers/clk/clk-conf.c | 43 +++++++++++++++++++++-
include/dt-bindings/clock/stih407-clks.h | 4 ++
4 files changed, 87 insertions(+), 1 deletion(-)
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v5 1/4] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0
2015-04-01 12:28 [PATCH v5 0/4] clk: Provide support for always-on clocks Lee Jones
@ 2015-04-01 12:28 ` Lee Jones
2015-04-01 12:28 ` [PATCH v5 2/4] ARM: sti: stih410-clocks: Identify critical clocks as always-on Lee Jones
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2015-04-01 12:28 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: lee.jones, kernel, mturquette, sboyd, devicetree
There are 2 LMI clocks generated by CLOCKGEN A0. We wish to control
them individually and need to use these indexes to do so.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
include/dt-bindings/clock/stih407-clks.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/dt-bindings/clock/stih407-clks.h b/include/dt-bindings/clock/stih407-clks.h
index 7af2b71..082edd9 100644
--- a/include/dt-bindings/clock/stih407-clks.h
+++ b/include/dt-bindings/clock/stih407-clks.h
@@ -5,6 +5,10 @@
#ifndef _DT_BINDINGS_CLK_STIH407
#define _DT_BINDINGS_CLK_STIH407
+/* CLOCKGEN A0 */
+#define CLK_IC_LMI0 0
+#define CLK_IC_LMI1 1
+
/* CLOCKGEN C0 */
#define CLK_ICN_GPU 0
#define CLK_FDMA 1
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 2/4] ARM: sti: stih410-clocks: Identify critical clocks as always-on
2015-04-01 12:28 [PATCH v5 0/4] clk: Provide support for always-on clocks Lee Jones
2015-04-01 12:28 ` [PATCH v5 1/4] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0 Lee Jones
@ 2015-04-01 12:28 ` Lee Jones
2015-04-01 12:28 ` [PATCH v5 3/4] clk: Provide always-on clock support Lee Jones
2015-04-01 12:28 ` [PATCH v5 4/4] clk: dt: Introduce binding for " Lee Jones
3 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2015-04-01 12:28 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: lee.jones, kernel, mturquette, sboyd, devicetree
Lots of platforms contain clocks which if turned off would prove fatal.
The only way to recover is to restart the board(s). This driver takes
references to clocks which are required to be always-on. The common
clk framework will then take references to them. This way they will
not be turned off during the clk_disabled_unused() procedure.
In this patch we are identifying clocks, which if gated would render
the STiH410 development board unserviceable.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
arch/arm/boot/dts/stih410-clock.dtsi | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/arm/boot/dts/stih410-clock.dtsi b/arch/arm/boot/dts/stih410-clock.dtsi
index 6b5803a..e1dd9b2 100644
--- a/arch/arm/boot/dts/stih410-clock.dtsi
+++ b/arch/arm/boot/dts/stih410-clock.dtsi
@@ -103,6 +103,7 @@
clocks = <&clk_sysin>;
clock-output-names = "clk-s-a0-pll-ofd-0";
+ clock-always-on = <0>; /* clk-s-a0-pll-ofd-0 */
};
clk_s_a0_flexgen: clk-s-a0-flexgen {
@@ -115,6 +116,8 @@
clock-output-names = "clk-ic-lmi0",
"clk-ic-lmi1";
+
+ clock-always-on = <CLK_IC_LMI0>;
};
};
@@ -142,6 +145,7 @@
clocks = <&clk_sysin>;
clock-output-names = "clk-s-c0-pll0-odf-0";
+ clock-always-on = <0>; /* clk-s-c0-pll0-odf-0 */
};
clk_s_c0_pll1: clk-s-c0-pll1 {
@@ -204,6 +208,12 @@
"clk-clust-hades",
"clk-hwpe-hades",
"clk-fc-hades";
+
+ clock-always-on = <CLK_ICN_CPU>,
+ <CLK_TX_ICN_DMU>,
+ <CLK_EXT2F_A9>,
+ <CLK_ICN_LMI>,
+ <CLK_ICN_SBC>;
};
};
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 3/4] clk: Provide always-on clock support
2015-04-01 12:28 [PATCH v5 0/4] clk: Provide support for always-on clocks Lee Jones
2015-04-01 12:28 ` [PATCH v5 1/4] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0 Lee Jones
2015-04-01 12:28 ` [PATCH v5 2/4] ARM: sti: stih410-clocks: Identify critical clocks as always-on Lee Jones
@ 2015-04-01 12:28 ` Lee Jones
2015-04-02 18:40 ` Geert Uytterhoeven
2015-04-01 12:28 ` [PATCH v5 4/4] clk: dt: Introduce binding for " Lee Jones
3 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2015-04-01 12:28 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: lee.jones, kernel, mturquette, sboyd, devicetree
Lots of platforms contain clocks which if turned off would prove fatal.
The only way to recover from these catastrophic failures is to restart
the board(s). Now, when a clock provider is registered with the
framework it is possible for a list of always-on clocks to be supplied
which must be kept ungated. Each clock mentioned in the newly
introduced 'clock-always-on' will be clk_prepare_enable()d where the
normal references will be taken. This will prevent the common clk
framework from attempting to gate them during the clk_disable_unused()
and disable_clock() procedures.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
drivers/clk/clk-conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c
index aad4796..22b8fdd 100644
--- a/drivers/clk/clk-conf.c
+++ b/drivers/clk/clk-conf.c
@@ -116,6 +116,43 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
return 0;
}
+static int __set_clk_always_on(struct device_node *node, bool clk_supplier)
+{
+ struct of_phandle_args clkspec;
+ struct clk *clk;
+ struct property *prop;
+ const __be32 *cur;
+ uint32_t index;
+ int ret;
+
+ if (!clk_supplier)
+ return 0;
+
+ of_property_for_each_u32(node, "clock-always-on", prop, cur, index) {
+ clkspec.np = node;
+ clkspec.args_count = 1;
+ clkspec.args[0] = index;
+
+ clk = of_clk_get_by_clkspec(&clkspec);
+ if (IS_ERR(clk)) {
+ pr_err("clk: couldn't get clock %d for %s\n",
+ index, node->full_name);
+ return PTR_ERR(clk);
+ }
+
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ pr_err("Failed to enable clock %d for %s: %d\n",
+ index, node->full_name, ret);
+ return ret;
+ }
+
+ pr_debug("Set clock %s as always-on\n", __clk_get_name(clk));
+ }
+
+ return 0;
+}
+
/**
* of_clk_set_defaults() - parse and set assigned clocks configuration
* @node: device node to apply clock settings for
@@ -139,6 +176,10 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier)
if (rc < 0)
return rc;
- return __set_clk_rates(node, clk_supplier);
+ rc = __set_clk_rates(node, clk_supplier);
+ if (rc < 0)
+ return rc;
+
+ return __set_clk_always_on(node, clk_supplier);
}
EXPORT_SYMBOL_GPL(of_clk_set_defaults);
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v5 4/4] clk: dt: Introduce binding for always-on clock support
2015-04-01 12:28 [PATCH v5 0/4] clk: Provide support for always-on clocks Lee Jones
` (2 preceding siblings ...)
2015-04-01 12:28 ` [PATCH v5 3/4] clk: Provide always-on clock support Lee Jones
@ 2015-04-01 12:28 ` Lee Jones
2015-04-02 18:46 ` Geert Uytterhoeven
3 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2015-04-01 12:28 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel
Cc: lee.jones, kernel, mturquette, sboyd, devicetree
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
.../devicetree/bindings/clock/clock-bindings.txt | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/clock-bindings.txt b/Documentation/devicetree/bindings/clock/clock-bindings.txt
index 06fc6d5..94cdda2 100644
--- a/Documentation/devicetree/bindings/clock/clock-bindings.txt
+++ b/Documentation/devicetree/bindings/clock/clock-bindings.txt
@@ -44,6 +44,37 @@ For example:
clocks by index. The names should reflect the clock output signal
names for the device.
+clock-always-on: Some hardware contains bunches of clocks which must never be
+ turned off. If drivers a) fail to obtain a reference to any
+ of these or b) give up a previously obtained reference
+ during suspend, the common clk framework will attempt to
+ disable them and a platform can fail irrecoverably as a
+ result. Usually the only way to recover from these failures
+ is to reboot.
+
+ To avoid either of these two scenarios from catastrophically
+ disabling an otherwise perfectly healthy running system,
+ clocks can be identified as always-on using this property
+ from inside a clocksource's node.
+
+ This property is not to be abused. It is only to be used to
+ protect platforms from being crippled by gated clocks, not
+ as a convenience function to avoid using the framework
+ correctly inside device drivers.
+
+For example:
+
+ oscillator {
+ #clock-cells = <1>;
+ clock-output-names = "ckil", "ckih";
+ clock-always-on = <0>, <1>;
+ };
+
+- this node defines a device with two clock outputs, just as in the
+ example above. The only difference being that 'ckil' and 'ckih'
+ are now identified as an always-on clocks, so the framework will
+ know to never attempt to gate them.
+
clock-indices: If the identifying number for the clocks in the node
is not linear from zero, then this allows the mapping of
identifiers into the clock-output-names array.
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v5 3/4] clk: Provide always-on clock support
2015-04-01 12:28 ` [PATCH v5 3/4] clk: Provide always-on clock support Lee Jones
@ 2015-04-02 18:40 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2015-04-02 18:40 UTC (permalink / raw)
To: Lee Jones
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel, Mike Turquette,
Stephen Boyd, devicetree@vger.kernel.org
On Wed, Apr 1, 2015 at 2:28 PM, Lee Jones <lee.jones@linaro.org> wrote:
> --- a/drivers/clk/clk-conf.c
> +++ b/drivers/clk/clk-conf.c
> @@ -116,6 +116,43 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
> return 0;
> }
>
> +static int __set_clk_always_on(struct device_node *node, bool clk_supplier)
> +{
> + struct of_phandle_args clkspec;
> + struct clk *clk;
> + struct property *prop;
> + const __be32 *cur;
> + uint32_t index;
> + int ret;
> +
> + if (!clk_supplier)
> + return 0;
> +
> + of_property_for_each_u32(node, "clock-always-on", prop, cur, index) {
> + clkspec.np = node;
> + clkspec.args_count = 1;
> + clkspec.args[0] = index;
> +
> + clk = of_clk_get_by_clkspec(&clkspec);
As of commit 306c342f9cb1 ("clk: Replace of_clk_get_by_clkspec() with
of_clk_get_from_provider()") in -next, you must use of_clk_get_from_provider()
instead.
> + if (IS_ERR(clk)) {
> + pr_err("clk: couldn't get clock %d for %s\n",
"%u" (index is uint32_t)
> + index, node->full_name);
> + return PTR_ERR(clk);
> + }
> +
> + ret = clk_prepare_enable(clk);
> + if (ret) {
> + pr_err("Failed to enable clock %d for %s: %d\n",
%u
> + index, node->full_name, ret);
> + return ret;
> + }
> +
> + pr_debug("Set clock %s as always-on\n", __clk_get_name(clk));
As of commit 4716bafa1f63 ("lib/vsprintf: Add %pC{,n,r} format specifiers
for clocks") in -next, you can use "%pC" to print the clock's name.
> + }
> +
> + return 0;
> +}
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v5 4/4] clk: dt: Introduce binding for always-on clock support
2015-04-01 12:28 ` [PATCH v5 4/4] clk: dt: Introduce binding for " Lee Jones
@ 2015-04-02 18:46 ` Geert Uytterhoeven
2015-04-07 9:42 ` Lee Jones
0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2015-04-02 18:46 UTC (permalink / raw)
To: Lee Jones
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel, Mike Turquette,
Stephen Boyd, devicetree@vger.kernel.org
On Wed, Apr 1, 2015 at 2:28 PM, Lee Jones <lee.jones@linaro.org> wrote:
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
> .../devicetree/bindings/clock/clock-bindings.txt | 31 ++++++++++++++++++++++
> 1 file changed, 31 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/clock/clock-bindings.txt b/Documentation/devicetree/bindings/clock/clock-bindings.txt
> index 06fc6d5..94cdda2 100644
> --- a/Documentation/devicetree/bindings/clock/clock-bindings.txt
> +++ b/Documentation/devicetree/bindings/clock/clock-bindings.txt
> @@ -44,6 +44,37 @@ For example:
> clocks by index. The names should reflect the clock output signal
> names for the device.
>
> +clock-always-on: Some hardware contains bunches of clocks which must never be
> + turned off. If drivers a) fail to obtain a reference to any
> + of these or b) give up a previously obtained reference
> + during suspend, the common clk framework will attempt to
> + disable them and a platform can fail irrecoverably as a
> + result. Usually the only way to recover from these failures
> + is to reboot.
> +
> + To avoid either of these two scenarios from catastrophically
> + disabling an otherwise perfectly healthy running system,
> + clocks can be identified as always-on using this property
> + from inside a clocksource's node.
> +
> + This property is not to be abused. It is only to be used to
> + protect platforms from being crippled by gated clocks, not
> + as a convenience function to avoid using the framework
> + correctly inside device drivers.
Please document what are the expected value(s) for this property.
I assume these are clock indices into the array of hardware clocks?
Do they take into account sparse hardware clocks, cfr. the "clock-indices"
property below (I didn't check)?
> +For example:
> +
> + oscillator {
> + #clock-cells = <1>;
> + clock-output-names = "ckil", "ckih";
> + clock-always-on = <0>, <1>;
> + };
> +
> +- this node defines a device with two clock outputs, just as in the
> + example above. The only difference being that 'ckil' and 'ckih'
> + are now identified as an always-on clocks, so the framework will
> + know to never attempt to gate them.
> +
> clock-indices: If the identifying number for the clocks in the node
> is not linear from zero, then this allows the mapping of
> identifiers into the clock-output-names array.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v5 4/4] clk: dt: Introduce binding for always-on clock support
2015-04-02 18:46 ` Geert Uytterhoeven
@ 2015-04-07 9:42 ` Lee Jones
0 siblings, 0 replies; 8+ messages in thread
From: Lee Jones @ 2015-04-07 9:42 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, kernel, Mike Turquette,
Stephen Boyd, devicetree@vger.kernel.org
On Thu, 02 Apr 2015, Geert Uytterhoeven wrote:
> On Wed, Apr 1, 2015 at 2:28 PM, Lee Jones <lee.jones@linaro.org> wrote:
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> > .../devicetree/bindings/clock/clock-bindings.txt | 31 ++++++++++++++++++++++
> > 1 file changed, 31 insertions(+)
> >
> > diff --git a/Documentation/devicetree/bindings/clock/clock-bindings.txt b/Documentation/devicetree/bindings/clock/clock-bindings.txt
> > index 06fc6d5..94cdda2 100644
> > --- a/Documentation/devicetree/bindings/clock/clock-bindings.txt
> > +++ b/Documentation/devicetree/bindings/clock/clock-bindings.txt
> > @@ -44,6 +44,37 @@ For example:
> > clocks by index. The names should reflect the clock output signal
> > names for the device.
> >
> > +clock-always-on: Some hardware contains bunches of clocks which must never be
> > + turned off. If drivers a) fail to obtain a reference to any
> > + of these or b) give up a previously obtained reference
> > + during suspend, the common clk framework will attempt to
> > + disable them and a platform can fail irrecoverably as a
> > + result. Usually the only way to recover from these failures
> > + is to reboot.
> > +
> > + To avoid either of these two scenarios from catastrophically
> > + disabling an otherwise perfectly healthy running system,
> > + clocks can be identified as always-on using this property
> > + from inside a clocksource's node.
> > +
> > + This property is not to be abused. It is only to be used to
> > + protect platforms from being crippled by gated clocks, not
> > + as a convenience function to avoid using the framework
> > + correctly inside device drivers.
>
> Please document what are the expected value(s) for this property.
> I assume these are clock indices into the array of hardware clocks?
>
> Do they take into account sparse hardware clocks, cfr. the "clock-indices"
> property below (I didn't check)?
They must match a valid indices. If the clock-indices property is
present, the value identified as always-on must match one of the
clocks listed.
I'll mention that.
> > +For example:
> > +
> > + oscillator {
> > + #clock-cells = <1>;
> > + clock-output-names = "ckil", "ckih";
> > + clock-always-on = <0>, <1>;
> > + };
> > +
> > +- this node defines a device with two clock outputs, just as in the
> > + example above. The only difference being that 'ckil' and 'ckih'
> > + are now identified as an always-on clocks, so the framework will
> > + know to never attempt to gate them.
> > +
> > clock-indices: If the identifying number for the clocks in the node
> > is not linear from zero, then this allows the mapping of
> > identifiers into the clock-output-names array.
>
> Gr{oetje,eeting}s,
>
> Geert
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-04-07 9:42 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-01 12:28 [PATCH v5 0/4] clk: Provide support for always-on clocks Lee Jones
2015-04-01 12:28 ` [PATCH v5 1/4] ARM: sti: stih407-family: Supply defines for CLOCKGEN A0 Lee Jones
2015-04-01 12:28 ` [PATCH v5 2/4] ARM: sti: stih410-clocks: Identify critical clocks as always-on Lee Jones
2015-04-01 12:28 ` [PATCH v5 3/4] clk: Provide always-on clock support Lee Jones
2015-04-02 18:40 ` Geert Uytterhoeven
2015-04-01 12:28 ` [PATCH v5 4/4] clk: dt: Introduce binding for " Lee Jones
2015-04-02 18:46 ` Geert Uytterhoeven
2015-04-07 9:42 ` Lee Jones
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).