From: Tero Kristo <t-kristo@ti.com>
To: Nishanth Menon <nm@ti.com>,
linux-omap@vger.kernel.org, paul@pwsan.com, tony@atomide.com,
bcousson@baylibre.com, rnayak@ti.com, mturquette@linaro.org
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCHv9 11/43] CLK: TI: add support for gate clock
Date: Mon, 4 Nov 2013 14:23:06 +0200 [thread overview]
Message-ID: <527791AA.6090908@ti.com> (raw)
In-Reply-To: <52740AFB.5050706@ti.com>
On 11/01/2013 10:11 PM, Nishanth Menon wrote:
> On 10/25/2013 10:57 AM, Tero Kristo wrote:
>> This patch adds support for TI specific gate clocks. These behave as basic
>> gate-clock, but have different ops / hw-ops for controlling the actual
>> gate, for example waiting until the clock is ready. Several sub-types
>> are supported:
>> - ti,gate-clock: basic gate clock with default ops/hwops
>> - ti,clkdm-gate-clock: clockdomain level gate control
>> - ti,dss-gate-clock: gate clock with DSS specific hardware handling
>> - ti,am35xx-gate-clock: gate clock with AM35xx specific hardware handling
>> - ti,hsdiv-gate-clock: gate clock with OMAP36xx hardware errata handling
>>
>> Signed-off-by: Tero Kristo <t-kristo@ti.com>
>> ---
>> .../devicetree/bindings/clock/ti/gate.txt | 77 ++++++
>> arch/arm/mach-omap2/clock.h | 29 ---
>> drivers/clk/ti/Makefile | 2 +-
>> drivers/clk/ti/gate.c | 258 ++++++++++++++++++++
>> include/linux/clk/ti.h | 36 +++
>> 5 files changed, 372 insertions(+), 30 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/clock/ti/gate.txt
>> create mode 100644 drivers/clk/ti/gate.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/ti/gate.txt b/Documentation/devicetree/bindings/clock/ti/gate.txt
>> new file mode 100644
>> index 0000000..18c4d86
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/clock/ti/gate.txt
>> @@ -0,0 +1,77 @@
>> +Binding for Texas Instruments gate clock.
>> +
>> +Binding status: Unstable - ABI compatibility may be broken in the future
>> +
>> +This binding uses the common clock binding[1]. This clock is
>> +quite much similar to the basic gate-clock [2], however,
>> +it supports a number of additional features. If no register
>> +is provided for this clock, the code assumes that a clockdomain
>> +will be controlled instead and the corresponding hw-ops for
>> +that is used.
>> +
>> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +[2] Documentation/devicetree/bindings/clock/gate-clock.txt
>> +[3] Documentation/devicetree/bindings/clock/ti/clockdomain.txt
>
> i think you may want to sequence patch #12 before this if you would
> like to refer to this.
Yea, can re-order based on this. Compiler doesn't really catch issues
like this. :)
>
>> +
>> +Required properties:
>> +- compatible : shall be one of:
>> + "ti,gate-clock" - basic gate clock
>> + "ti,wait-gate-clock" - gate clock which waits until clock is active before
>> + returning from clk_enable()
> an example will be nice for this.
Will add.
>
> [...]
>> diff --git a/drivers/clk/ti/gate.c b/drivers/clk/ti/gate.c
>> new file mode 100644
>> index 0000000..1a201f8
>> --- /dev/null
>> +++ b/drivers/clk/ti/gate.c
>
> [...]
>> +/**
>> + * omap36xx_gate_clk_enable_with_hsdiv_restore - enable clocks suffering
>> + * from HSDivider PWRDN problem Implements Errata ID: i556.
>> + * @clk: DPLL output struct clk
>> + *
>> + * 3630 only: dpll3_m3_ck, dpll4_m2_ck, dpll4_m3_ck, dpll4_m4_ck,
>> + * dpll4_m5_ck & dpll4_m6_ck dividers gets loaded with reset
>> + * valueafter their respective PWRDN bits are set. Any dummy write
>> + * (Any other value different from the Read value) to the
>> + * corresponding CM_CLKSEL register will refresh the dividers.
>> + */
>> +static int omap36xx_gate_clk_enable_with_hsdiv_restore(struct clk_hw *clk)
>> +{
>> + struct clk_divider *parent;
>> + struct clk_hw *parent_hw;
>> + u32 dummy_v, orig_v;
>> + int ret;
>> +
>> + /* Clear PWRDN bit of HSDIVIDER */
>> + ret = omap2_dflt_clk_enable(clk);
>> +
>> + /* Parent is the x2 node, get parent of parent for the m2 div */
>> + parent_hw = __clk_get_hw(__clk_get_parent(__clk_get_parent(clk->clk)));
>> + parent = to_clk_divider(parent_hw);
>> +
>> + /* Restore the dividers */
>> + if (!ret) {
>> + orig_v = __raw_readl(parent->reg);
>> + dummy_v = orig_v;
>> +
>> + /* Write any other value different from the Read value */
>> + dummy_v ^= (1 << parent->shift);
>> + __raw_writel(dummy_v, parent->reg);
>> +
>> + /* Write the original divider */
>> + __raw_writel(orig_v, parent->reg);
>
> i think we already did state that these need to be regmap_updatebits..
Yea.
>
>> + }
>> +
>> + return ret;
>> +}
>> +
>> +static int __init _of_ti_gate_clk_setup(struct device_node *node,
>> + const struct clk_ops *ops,
>> + const struct clk_hw_omap_ops *hw_ops,
>> + struct regmap *regmap)
>> +{
>> + struct clk *clk;
>> + struct clk_init_data init = { NULL };
>> + struct clk_hw_omap *clk_hw;
>> + const char *clk_name = node->name;
>> + const char *parent_name;
>> + u32 val;
>> +
>> + clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
>> + if (!clk_hw) {
>> + pr_err("%s: could not allocate clk_hw_omap\n", __func__);
>> + return -ENOMEM;
>> + }
>> +
>> + clk_hw->hw.init = &init;
>> +
>> + of_property_read_string(node, "clock-output-names", &clk_name);
>> +
>> + init.name = clk_name;
>> + init.ops = ops;
>> +
>> + if (!of_property_read_u32(node, "reg", &val))
>> + clk_hw->enable_reg = (void *)val;
>
> seems reg is a mandatory as per bindings for everything other than
> ti,clkdm-gate-clock.. no error handling?
Will add.
>
>> +
>> + clk_hw->regmap = regmap;
>> +
>> + if (!of_property_read_u32(node, "ti,bit-shift", &val))
>> + clk_hw->enable_bit = val;
>
> Again -> bindings state this is mandatory for non ti,clkdm-gate-clock
> clocks. no error handling?
Will add.
>
>> + clk_hw->ops = hw_ops;
>> +
>> + parent_name = of_clk_get_parent_name(node, 0);
>> + init.parent_names = &parent_name;
>> + init.num_parents = 1;
>
> error checks for parent clk which seems to be mandatory?
Will add.
>
>> +
>> + if (of_property_read_bool(node, "ti,set-rate-parent"))
>> + init.flags |= CLK_SET_RATE_PARENT;
>> +
>> + if (of_property_read_bool(node, "ti,set-bit-to-disable"))
>> + clk_hw->flags |= INVERT_ENABLE;
>> +
>> + clk = clk_register(NULL, &clk_hw->hw);
>> +
>> + if (!IS_ERR(clk)) {
>> + of_clk_add_provider(node, of_clk_src_simple_get, clk);
>> + return 0;
>> + }
>> +
>
> free(clk_hw)?
Hmm yea, missing.
>
>> + return PTR_ERR(clk);
>> +}
>> +
>
>
>
next prev parent reply other threads:[~2013-11-04 12:23 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-25 15:56 [PATCHv9 00/43] ARM: TI SoC clock DT conversion Tero Kristo
2013-10-25 15:56 ` [PATCHv9 01/43] clk: Add support for regmap register read/write Tero Kristo
2013-10-31 14:03 ` Nishanth Menon
2013-10-31 14:40 ` Tero Kristo
2013-10-31 15:46 ` Nishanth Menon
2013-11-01 8:57 ` Tero Kristo
2013-11-05 21:43 ` Gerhard Sittig
2013-11-06 10:54 ` Tero Kristo
2013-11-02 13:26 ` Tomasz Figa
2013-10-25 15:56 ` [PATCHv9 02/43] clk: divider: add init call which supports regmap Tero Kristo
2013-10-25 15:56 ` [PATCHv9 03/43] clk: mux: " Tero Kristo
2013-10-25 15:56 ` [PATCHv9 04/43] CLK: TI: Add DPLL clock support Tero Kristo
2013-10-31 14:19 ` Nishanth Menon
2013-10-31 14:56 ` Tero Kristo
2013-10-31 15:25 ` Nishanth Menon
2013-10-25 15:56 ` [PATCHv9 05/43] CLK: TI: add DT alias clock registration mechanism Tero Kristo
2013-10-29 17:50 ` Matt Sealey
2013-10-30 8:29 ` Tero Kristo
2013-10-30 17:38 ` Matt Sealey
2013-10-31 9:18 ` Tero Kristo
2013-11-02 13:49 ` Tomasz Figa
2013-11-04 22:45 ` Matt Sealey
2013-10-25 15:57 ` [PATCHv9 06/43] CLK: ti: add init support for clock IP blocks Tero Kristo
2013-10-31 15:42 ` Nishanth Menon
2013-11-01 9:12 ` Tero Kristo
2013-11-01 19:13 ` Nishanth Menon
2013-11-04 7:23 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 07/43] CLK: TI: add autoidle support Tero Kristo
2013-10-31 16:05 ` Nishanth Menon
2013-11-01 9:18 ` Tero Kristo
2013-11-01 19:16 ` Nishanth Menon
2013-11-04 10:00 ` Tero Kristo
2013-11-04 14:59 ` Nishanth Menon
2013-11-05 8:10 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 08/43] clk: ti: add composite clock support Tero Kristo
2013-10-31 16:27 ` Nishanth Menon
2013-10-31 16:32 ` Nishanth Menon
2013-11-01 9:40 ` Tero Kristo
2013-11-01 9:35 ` Tero Kristo
2013-11-01 19:24 ` Nishanth Menon
2013-10-25 15:57 ` [PATCHv9 09/43] CLK: ti: add support for ti divider-clock Tero Kristo
2013-10-31 18:02 ` Nishanth Menon
2013-11-01 9:48 ` Tero Kristo
2013-11-01 9:54 ` Tero Kristo
2013-11-01 19:35 ` Nishanth Menon
2013-11-04 10:54 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 10/43] clk: ti: add support for TI fixed factor clock Tero Kristo
2013-10-31 18:12 ` Nishanth Menon
2013-11-01 9:52 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 11/43] CLK: TI: add support for gate clock Tero Kristo
2013-11-01 20:11 ` Nishanth Menon
2013-11-04 12:23 ` Tero Kristo [this message]
2013-10-25 15:57 ` [PATCHv9 12/43] CLK: TI: add support for clockdomain binding Tero Kristo
2013-11-01 20:22 ` Nishanth Menon
[not found] ` <52740D79.3090107-l0cyMroinI0@public.gmane.org>
2013-11-04 14:30 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 13/43] clk: ti: add support for basic mux clock Tero Kristo
2013-11-01 21:01 ` Nishanth Menon
2013-11-05 8:09 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 14/43] CLK: TI: add omap4 clock init file Tero Kristo
2013-10-25 15:57 ` [PATCHv9 15/43] CLK: TI: add omap5 " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 16/43] CLK: TI: omap5: Initialize USB_DPLL at boot Tero Kristo
2013-10-25 15:57 ` [PATCHv9 17/43] CLK: TI: DRA7: Add APLL support Tero Kristo
2013-10-25 15:57 ` [PATCHv9 18/43] CLK: TI: add dra7 clock init file Tero Kristo
2013-10-25 15:57 ` [PATCHv9 19/43] CLK: TI: add am33xx " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 21/43] CLK: TI: add omap3 " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 22/43] CLK: TI: add am43xx " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 23/43] ARM: dts: omap4 clock data Tero Kristo
2013-10-25 15:57 ` [PATCHv9 24/43] ARM: dts: omap5 " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 26/43] ARM: dts: clk: Add apll related clocks Tero Kristo
2013-10-25 15:57 ` [PATCHv9 27/43] ARM: dts: DRA7: Change apll_pcie_m2_ck to fixed factor clock Tero Kristo
2013-10-25 15:57 ` [PATCHv9 28/43] ARM: dts: DRA7: Add PCIe related clock nodes Tero Kristo
2013-10-25 15:57 ` [PATCHv9 29/43] ARM: dts: DRA7: link in clock DT data Tero Kristo
2013-10-25 15:57 ` [PATCHv9 30/43] ARM: dts: am33xx clock data Tero Kristo
2013-10-26 0:36 ` Jan Lübbe
2013-10-26 12:46 ` Tero Kristo
2013-10-28 9:59 ` Jan Lübbe
2013-10-28 10:12 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 31/43] ARM: dts: omap3 " Tero Kristo
2013-10-25 15:57 ` [PATCHv9 32/43] ARM: dts: AM35xx: use DT " Tero Kristo
2013-11-01 21:18 ` Nishanth Menon
2013-11-05 8:12 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 33/43] ARM: dts: am43xx " Tero Kristo
2013-11-01 21:16 ` Nishanth Menon
2013-11-04 14:15 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 34/43] ARM: OMAP2+: clock: add support for regmap Tero Kristo
2013-10-25 15:57 ` [PATCHv9 35/43] ARM: OMAP2+: clock: use driver API instead of direct memory read/write Tero Kristo
[not found] ` <1382716658-6964-1-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2013-10-25 15:57 ` [PATCHv9 20/43] CLK: TI: add interface clock support for OMAP3 Tero Kristo
2013-10-25 15:57 ` [PATCHv9 25/43] ARM: dts: dra7 clock data Tero Kristo
2013-10-25 15:57 ` [PATCHv9 36/43] ARM: OMAP: hwmod: fix an incorrect clk type cast with _get_clkdm Tero Kristo
2013-10-25 15:57 ` [PATCHv9 40/43] ARM: OMAP4: remove old clock data and link in new clock init code Tero Kristo
2013-10-25 15:57 ` [PATCHv9 37/43] ARM: OMAP3: hwmod: initialize clkdm from clkdm_name Tero Kristo
2013-10-25 15:57 ` [PATCHv9 38/43] ARM: OMAP2+: PRM: add support for initializing PRCM clock modules from DT Tero Kristo
2013-11-01 21:07 ` Nishanth Menon
2013-11-05 8:22 ` Tero Kristo
2013-10-25 15:57 ` [PATCHv9 39/43] ARM: OMAP2+: io: use new clock init API Tero Kristo
2013-10-25 15:57 ` [PATCHv9 41/43] ARM: OMAP: DRA7: Enable clock init Tero Kristo
2013-10-25 15:57 ` [PATCHv9 42/43] ARM: AM33xx: remove old clock data and link in new clock init code Tero Kristo
2013-10-25 15:57 ` [PATCHv9 43/43] ARM: OMAP3: use DT clock init if DT data is available Tero Kristo
2013-10-29 16:19 ` [PATCHv9 00/43] ARM: TI SoC clock DT conversion Nishanth Menon
2013-10-30 8:23 ` Tero Kristo
2013-10-30 15:00 ` Nishanth Menon
2013-10-30 20:10 ` Nishanth Menon
2013-10-31 9:10 ` Tero Kristo
2013-10-31 13:55 ` Nishanth Menon
2013-11-01 21:25 ` Nishanth Menon
2013-11-04 7:15 ` Tero Kristo
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=527791AA.6090908@ti.com \
--to=t-kristo@ti.com \
--cc=bcousson@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=nm@ti.com \
--cc=paul@pwsan.com \
--cc=rnayak@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;
as well as URLs for NNTP newsgroup(s).