diff options
-rw-r--r-- | Documentation/devicetree/bindings/clock/ti/fixed-factor-clock.txt | 43 | ||||
-rw-r--r-- | drivers/clk/ti/Makefile | 3 | ||||
-rw-r--r-- | drivers/clk/ti/fixed-factor.c | 66 |
3 files changed, 111 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/clock/ti/fixed-factor-clock.txt b/Documentation/devicetree/bindings/clock/ti/fixed-factor-clock.txt new file mode 100644 index 000000000000..662b36d53bf0 --- /dev/null +++ b/Documentation/devicetree/bindings/clock/ti/fixed-factor-clock.txt | |||
@@ -0,0 +1,43 @@ | |||
1 | Binding for TI fixed factor rate clock sources. | ||
2 | |||
3 | Binding status: Unstable - ABI compatibility may be broken in the future | ||
4 | |||
5 | This binding uses the common clock binding[1], and also uses the autoidle | ||
6 | support from TI autoidle clock [2]. | ||
7 | |||
8 | [1] Documentation/devicetree/bindings/clock/clock-bindings.txt | ||
9 | [2] Documentation/devicetree/bindings/clock/ti/autoidle.txt | ||
10 | |||
11 | Required properties: | ||
12 | - compatible : shall be "ti,fixed-factor-clock". | ||
13 | - #clock-cells : from common clock binding; shall be set to 0. | ||
14 | - ti,clock-div: fixed divider. | ||
15 | - ti,clock-mult: fixed multiplier. | ||
16 | - clocks: parent clock. | ||
17 | |||
18 | Optional properties: | ||
19 | - ti,autoidle-shift: bit shift of the autoidle enable bit for the clock, | ||
20 | see [2] | ||
21 | - reg: offset for the autoidle register of this clock, see [2] | ||
22 | - ti,invert-autoidle-bit: autoidle is enabled by setting the bit to 0, see [2] | ||
23 | - ti,set-rate-parent: clk_set_rate is propagated to parent | ||
24 | |||
25 | Example: | ||
26 | clock { | ||
27 | compatible = "ti,fixed-factor-clock"; | ||
28 | clocks = <&parentclk>; | ||
29 | #clock-cells = <0>; | ||
30 | ti,clock-div = <2>; | ||
31 | ti,clock-mult = <1>; | ||
32 | }; | ||
33 | |||
34 | dpll_usb_clkdcoldo_ck: dpll_usb_clkdcoldo_ck { | ||
35 | #clock-cells = <0>; | ||
36 | compatible = "ti,fixed-factor-clock"; | ||
37 | clocks = <&dpll_usb_ck>; | ||
38 | ti,clock-div = <1>; | ||
39 | ti,autoidle-shift = <8>; | ||
40 | reg = <0x01b4>; | ||
41 | ti,clock-mult = <1>; | ||
42 | ti,invert-autoidle-bit; | ||
43 | }; | ||
diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile index 8690b0b442c0..d3586252a391 100644 --- a/drivers/clk/ti/Makefile +++ b/drivers/clk/ti/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | ifneq ($(CONFIG_OF),) | 1 | ifneq ($(CONFIG_OF),) |
2 | obj-y += clk.o autoidle.o | 2 | obj-y += clk.o autoidle.o |
3 | clk-common = dpll.o composite.o divider.o | 3 | clk-common = dpll.o composite.o divider.o \ |
4 | fixed-factor.o | ||
4 | endif | 5 | endif |
diff --git a/drivers/clk/ti/fixed-factor.c b/drivers/clk/ti/fixed-factor.c new file mode 100644 index 000000000000..c2c8a287408c --- /dev/null +++ b/drivers/clk/ti/fixed-factor.c | |||
@@ -0,0 +1,66 @@ | |||
1 | /* | ||
2 | * TI Fixed Factor Clock | ||
3 | * | ||
4 | * Copyright (C) 2013 Texas Instruments, Inc. | ||
5 | * | ||
6 | * Tero Kristo <t-kristo@ti.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
13 | * kind, whether express or implied; without even the implied warranty | ||
14 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/clk-provider.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/err.h> | ||
21 | #include <linux/of.h> | ||
22 | #include <linux/of_address.h> | ||
23 | #include <linux/clk/ti.h> | ||
24 | |||
25 | #undef pr_fmt | ||
26 | #define pr_fmt(fmt) "%s: " fmt, __func__ | ||
27 | |||
28 | /** | ||
29 | * of_ti_fixed_factor_clk_setup - Setup function for TI fixed factor clock | ||
30 | * @node: device node for this clock | ||
31 | * | ||
32 | * Sets up a simple fixed factor clock based on device tree info. | ||
33 | */ | ||
34 | static void __init of_ti_fixed_factor_clk_setup(struct device_node *node) | ||
35 | { | ||
36 | struct clk *clk; | ||
37 | const char *clk_name = node->name; | ||
38 | const char *parent_name; | ||
39 | u32 div, mult; | ||
40 | u32 flags = 0; | ||
41 | |||
42 | if (of_property_read_u32(node, "ti,clock-div", &div)) { | ||
43 | pr_err("%s must have a clock-div property\n", node->name); | ||
44 | return; | ||
45 | } | ||
46 | |||
47 | if (of_property_read_u32(node, "ti,clock-mult", &mult)) { | ||
48 | pr_err("%s must have a clock-mult property\n", node->name); | ||
49 | return; | ||
50 | } | ||
51 | |||
52 | if (of_property_read_bool(node, "ti,set-rate-parent")) | ||
53 | flags |= CLK_SET_RATE_PARENT; | ||
54 | |||
55 | parent_name = of_clk_get_parent_name(node, 0); | ||
56 | |||
57 | clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags, | ||
58 | mult, div); | ||
59 | |||
60 | if (!IS_ERR(clk)) { | ||
61 | of_clk_add_provider(node, of_clk_src_simple_get, clk); | ||
62 | of_ti_clk_autoidle_setup(node); | ||
63 | } | ||
64 | } | ||
65 | CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock", | ||
66 | of_ti_fixed_factor_clk_setup); | ||