clk: ti: add support for TI fixed factor clock
This behaves exactly in similar manner to basic fixed-factor-clock, but adds a few properties on top for handling clock hardware autoidling. Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
This commit is contained in:
Родитель
b4761198bf
Коммит
1f847c65fd
|
@ -0,0 +1,43 @@
|
|||
Binding for TI fixed factor rate clock sources.
|
||||
|
||||
Binding status: Unstable - ABI compatibility may be broken in the future
|
||||
|
||||
This binding uses the common clock binding[1], and also uses the autoidle
|
||||
support from TI autoidle clock [2].
|
||||
|
||||
[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
|
||||
[2] Documentation/devicetree/bindings/clock/ti/autoidle.txt
|
||||
|
||||
Required properties:
|
||||
- compatible : shall be "ti,fixed-factor-clock".
|
||||
- #clock-cells : from common clock binding; shall be set to 0.
|
||||
- ti,clock-div: fixed divider.
|
||||
- ti,clock-mult: fixed multiplier.
|
||||
- clocks: parent clock.
|
||||
|
||||
Optional properties:
|
||||
- ti,autoidle-shift: bit shift of the autoidle enable bit for the clock,
|
||||
see [2]
|
||||
- reg: offset for the autoidle register of this clock, see [2]
|
||||
- ti,invert-autoidle-bit: autoidle is enabled by setting the bit to 0, see [2]
|
||||
- ti,set-rate-parent: clk_set_rate is propagated to parent
|
||||
|
||||
Example:
|
||||
clock {
|
||||
compatible = "ti,fixed-factor-clock";
|
||||
clocks = <&parentclk>;
|
||||
#clock-cells = <0>;
|
||||
ti,clock-div = <2>;
|
||||
ti,clock-mult = <1>;
|
||||
};
|
||||
|
||||
dpll_usb_clkdcoldo_ck: dpll_usb_clkdcoldo_ck {
|
||||
#clock-cells = <0>;
|
||||
compatible = "ti,fixed-factor-clock";
|
||||
clocks = <&dpll_usb_ck>;
|
||||
ti,clock-div = <1>;
|
||||
ti,autoidle-shift = <8>;
|
||||
reg = <0x01b4>;
|
||||
ti,clock-mult = <1>;
|
||||
ti,invert-autoidle-bit;
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
ifneq ($(CONFIG_OF),)
|
||||
obj-y += clk.o autoidle.o
|
||||
clk-common = dpll.o composite.o divider.o
|
||||
clk-common = dpll.o composite.o divider.o \
|
||||
fixed-factor.o
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* TI Fixed Factor Clock
|
||||
*
|
||||
* Copyright (C) 2013 Texas Instruments, Inc.
|
||||
*
|
||||
* Tero Kristo <t-kristo@ti.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
|
||||
* kind, whether express or implied; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_address.h>
|
||||
#include <linux/clk/ti.h>
|
||||
|
||||
#undef pr_fmt
|
||||
#define pr_fmt(fmt) "%s: " fmt, __func__
|
||||
|
||||
/**
|
||||
* of_ti_fixed_factor_clk_setup - Setup function for TI fixed factor clock
|
||||
* @node: device node for this clock
|
||||
*
|
||||
* Sets up a simple fixed factor clock based on device tree info.
|
||||
*/
|
||||
static void __init of_ti_fixed_factor_clk_setup(struct device_node *node)
|
||||
{
|
||||
struct clk *clk;
|
||||
const char *clk_name = node->name;
|
||||
const char *parent_name;
|
||||
u32 div, mult;
|
||||
u32 flags = 0;
|
||||
|
||||
if (of_property_read_u32(node, "ti,clock-div", &div)) {
|
||||
pr_err("%s must have a clock-div property\n", node->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (of_property_read_u32(node, "ti,clock-mult", &mult)) {
|
||||
pr_err("%s must have a clock-mult property\n", node->name);
|
||||
return;
|
||||
}
|
||||
|
||||
if (of_property_read_bool(node, "ti,set-rate-parent"))
|
||||
flags |= CLK_SET_RATE_PARENT;
|
||||
|
||||
parent_name = of_clk_get_parent_name(node, 0);
|
||||
|
||||
clk = clk_register_fixed_factor(NULL, clk_name, parent_name, flags,
|
||||
mult, div);
|
||||
|
||||
if (!IS_ERR(clk)) {
|
||||
of_clk_add_provider(node, of_clk_src_simple_get, clk);
|
||||
of_ti_clk_autoidle_setup(node);
|
||||
}
|
||||
}
|
||||
CLK_OF_DECLARE(ti_fixed_factor_clk, "ti,fixed-factor-clock",
|
||||
of_ti_fixed_factor_clk_setup);
|
Загрузка…
Ссылка в новой задаче