All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tero Kristo <t-kristo@ti.com>
To: linux-omap@vger.kernel.org, paul@pwsan.com, tony@atomide.com,
	nm@ti.com, rnayak@ti.com, bcousson@baylibre.com,
	mturquette@linaro.org
Cc: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org
Subject: [PATCHv10 07/41] CLK: ti: add support for ti divider-clock
Date: Tue, 26 Nov 2013 10:05:48 +0200	[thread overview]
Message-ID: <1385453182-24421-8-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1385453182-24421-1-git-send-email-t-kristo@ti.com>

This patch adds support for TI divider clock binding, which simply uses
the basic clock divider to provide the features needed.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 .../devicetree/bindings/clock/ti/divider.txt       |  114 ++++++++++
 drivers/clk/ti/Makefile                            |    3 +-
 drivers/clk/ti/divider.c                           |  228 ++++++++++++++++++++
 3 files changed, 344 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/divider.txt
 create mode 100644 drivers/clk/ti/divider.c

diff --git a/Documentation/devicetree/bindings/clock/ti/divider.txt b/Documentation/devicetree/bindings/clock/ti/divider.txt
new file mode 100644
index 0000000..35a6f5c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti/divider.txt
@@ -0,0 +1,114 @@
+Binding for TI divider clock
+
+Binding status: Unstable - ABI compatibility may be broken in the future
+
+This binding uses the common clock binding[1].  It assumes a
+register-mapped adjustable clock rate divider that does not gate and has
+only one input clock or parent.  By default the value programmed into
+the register is one less than the actual divisor value.  E.g:
+
+register value		actual divisor value
+0			1
+1			2
+2			3
+
+This assumption may be modified by the following optional properties:
+
+ti,index-starts-at-one - valid divisor values start at 1, not the default
+of 0.  E.g:
+register value		actual divisor value
+1			1
+2			2
+3			3
+
+ti,index-power-of-two - valid divisor values are powers of two.  E.g:
+register value		actual divisor value
+0			1
+1			2
+2			4
+
+Additionally an array of valid dividers may be supplied like so:
+
+	ti,dividers = <4>, <8>, <0>, <16>;
+
+Which will map the resulting values to a divisor table by their index:
+register value		actual divisor value
+0			4
+1			8
+2			<invalid divisor, skipped>
+3			16
+
+Any zero value in this array means the corresponding bit-value is invalid
+and must not be used.
+
+The binding must also provide the register to control the divider and
+unless the divider array is provided, min and max dividers. Optionally
+the number of bits to shift that mask, if necessary. If the shift value
+is missing it is the same as supplying a zero shift.
+
+This binding can also optionally provide support to the hardware autoidle
+feature, see [2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Documentation/devicetree/bindings/clock/ti/autoidle.txt
+
+Required properties:
+- compatible : shall be "ti,divider-clock" or "ti,composite-divider-clock".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : link to phandle of parent clock
+- reg : offset for register controlling adjustable divider
+
+Optional properties:
+- clock-output-names : from common clock binding.
+- ti,dividers : array of integers defining divisors
+- ti,bit-shift : number of bits to shift the divider value, defaults to 0
+- ti,min-div : min divisor for dividing the input clock rate, only
+  needed if the first divisor is offset from the default value (1)
+- ti,max-div : max divisor for dividing the input clock rate, only needed
+  if ti,dividers is not defined.
+- ti,index-starts-at-one : valid divisor programming starts at 1, not zero,
+  only valid if ti,dividers is not defined.
+- ti,index-power-of-two : valid divisor programming must be a power of two,
+  only valid if ti,dividers is not defined.
+- ti,autoidle-shift : bit shift of the autoidle enable bit for the 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
+
+Examples:
+dpll_usb_m2_ck: dpll_usb_m2_ck@4a008190 {
+	#clock-cells = <0>;
+	compatible = "ti,divider-clock";
+	clocks = <&dpll_usb_ck>;
+	ti,max-div = <127>;
+	reg = <0x190>;
+	ti,index-starts-at-one;
+};
+
+aess_fclk: aess_fclk@4a004528 {
+	#clock-cells = <0>;
+	compatible = "ti,divider-clock";
+	clocks = <&abe_clk>;
+	ti,bit-shift = <24>;
+	reg = <0x528>;
+	ti,max-div = <2>;
+};
+
+dpll_core_m3x2_div_ck: dpll_core_m3x2_div_ck {
+	#clock-cells = <0>;
+	compatible = "ti,composite-divider-clock";
+	clocks = <&dpll_core_x2_ck>;
+	ti,max-div = <31>;
+	reg = <0x0134>;
+	ti,index-starts-at-one;
+};
+
+ssi_ssr_div_fck_3430es2: ssi_ssr_div_fck_3430es2 {
+	#clock-cells = <0>;
+	compatible = "ti,composite-divider-clock";
+	clocks = <&corex2_fck>;
+	ti,bit-shift = <8>;
+	reg = <0x0a40>;
+	ti,dividers = <0>, <1>, <2>, <3>, <4>, <0>, <6>, <0>, <8>;
+};
diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile
index a4a7595..640ebf9 100644
--- a/drivers/clk/ti/Makefile
+++ b/drivers/clk/ti/Makefile
@@ -1,3 +1,4 @@
 ifneq ($(CONFIG_OF),)
-obj-y					+= clk.o dpll.o autoidle.o composite.o
+obj-y					+= clk.o dpll.o autoidle.o divider.o \
+					   composite.o
 endif
diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
new file mode 100644
index 0000000..818549f
--- /dev/null
+++ b/drivers/clk/ti/divider.c
@@ -0,0 +1,228 @@
+/*
+ * TI Divider 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__
+
+static struct clk_div_table
+__init *ti_clk_get_div_table(struct device_node *node)
+{
+	struct clk_div_table *table;
+	const __be32 *divspec;
+	u32 val;
+	u32 num_div;
+	u32 valid_div;
+	int i;
+
+	divspec = of_get_property(node, "ti,dividers", &num_div);
+
+	if (!divspec)
+		return NULL;
+
+	num_div /= 4;
+
+	valid_div = 0;
+
+	/* Determine required size for divider table */
+	for (i = 0; i < num_div; i++) {
+		of_property_read_u32_index(node, "ti,dividers", i, &val);
+		if (val)
+			valid_div++;
+	}
+
+	if (!valid_div) {
+		pr_err("no valid dividers for %s table\n", node->name);
+		return ERR_PTR(-EINVAL);
+	}
+
+	table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL);
+
+	if (!table)
+		return ERR_PTR(-ENOMEM);
+
+	valid_div = 0;
+
+	for (i = 0; i < num_div; i++) {
+		of_property_read_u32_index(node, "ti,dividers", i, &val);
+		if (val) {
+			table[valid_div].div = val;
+			table[valid_div].val = i;
+			valid_div++;
+		}
+	}
+
+	return table;
+}
+
+static int _get_divider_width(struct device_node *node,
+			      const struct clk_div_table *table,
+			      u8 flags)
+{
+	u32 min_div;
+	u32 max_div;
+	u32 val = 0;
+	u32 div;
+
+	if (!table) {
+		/* Clk divider table not provided, determine min/max divs */
+		if (of_property_read_u32(node, "ti,min-div", &min_div))
+			min_div = 1;
+
+		if (of_property_read_u32(node, "ti,max-div", &max_div)) {
+			pr_err("no max-div for %s!\n", node->name);
+			return -EINVAL;
+		}
+
+		/* Determine bit width for the field */
+		if (flags & CLK_DIVIDER_ONE_BASED)
+			val = 1;
+
+		div = min_div;
+
+		while (div < max_div) {
+			if (flags & CLK_DIVIDER_POWER_OF_TWO)
+				div <<= 1;
+			else
+				div++;
+			val++;
+		}
+	} else {
+		div = 0;
+
+		while (table[div].div) {
+			val = table[div].val;
+			div++;
+		}
+	}
+
+	return fls(val);
+}
+
+static int __init ti_clk_divider_populate(struct device_node *node,
+	void __iomem **reg, const struct clk_div_table **table, u32 *flags,
+	u8 *div_flags, u8 *width, u8 *shift)
+{
+	u32 val;
+
+	*reg = ti_clk_get_reg_addr(node, 0);
+	if (!*reg)
+		return -EINVAL;
+
+	if (!of_property_read_u32(node, "ti,bit-shift", &val))
+		*shift = val;
+	else
+		*shift = 0;
+
+	*flags = 0;
+	*div_flags = 0;
+
+	if (of_property_read_bool(node, "ti,index-starts-at-one"))
+		*div_flags |= CLK_DIVIDER_ONE_BASED;
+
+	if (of_property_read_bool(node, "ti,index-power-of-two"))
+		*div_flags |= CLK_DIVIDER_POWER_OF_TWO;
+
+	if (of_property_read_bool(node, "ti,set-rate-parent"))
+		*flags |= CLK_SET_RATE_PARENT;
+
+	*table = ti_clk_get_div_table(node);
+
+	if (IS_ERR(*table))
+		return PTR_ERR(*table);
+
+	*width = _get_divider_width(node, *table, *div_flags);
+
+	kfree(*table);
+	*table = NULL;
+
+	return 0;
+}
+
+/**
+ * of_ti_divider_clk_setup - Setup function for simple div rate clock
+ * @node: device node for this clock
+ *
+ * Sets up a basic divider clock.
+ */
+static int __init of_ti_divider_clk_setup(struct device_node *node)
+{
+	struct clk *clk;
+	const char *clk_name = node->name;
+	void __iomem *reg;
+	const char *parent_name;
+	u8 clk_divider_flags = 0;
+	u8 width = 0;
+	u8 shift = 0;
+	const struct clk_div_table *table = NULL;
+	u32 flags = 0;
+	int ret = 0;
+
+	parent_name = of_clk_get_parent_name(node, 0);
+
+	ret = ti_clk_divider_populate(node, &reg, &table, &flags,
+				      &clk_divider_flags, &width, &shift);
+	if (ret < 0)
+		return ret;
+
+	clk = clk_register_divider_table(NULL, clk_name, parent_name,
+					 flags, reg, shift, width,
+					 clk_divider_flags, table, NULL);
+
+	if (!IS_ERR(clk)) {
+		of_clk_add_provider(node, of_clk_src_simple_get, clk);
+		of_ti_clk_autoidle_setup(node);
+		return 0;
+	}
+
+	kfree(table);
+	return PTR_ERR(clk);
+}
+CLK_OF_DECLARE(divider_clk, "ti,divider-clock", of_ti_divider_clk_setup);
+
+static int __init of_ti_composite_divider_clk_setup(struct device_node *node)
+{
+	struct clk_divider *div;
+	u32 val;
+	int ret;
+
+	div = kzalloc(sizeof(*div), GFP_KERNEL);
+	if (!div)
+		return -ENOMEM;
+
+	ret = ti_clk_divider_populate(node, &div->reg, &div->table, &val,
+				      &div->flags, &div->width, &div->shift);
+	if (ret < 0)
+		goto cleanup;
+
+	ret = ti_clk_add_component(node, &div->hw, CLK_COMPONENT_TYPE_DIVIDER);
+	if (!ret)
+		return 0;
+
+cleanup:
+	kfree(div->table);
+	kfree(div);
+	return ret;
+}
+CLK_OF_DECLARE(ti_composite_divider_clk, "ti,composite-divider-clock",
+	       of_ti_composite_divider_clk_setup);
-- 
1.7.9.5


WARNING: multiple messages have this Message-ID (diff)
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv10 07/41] CLK: ti: add support for ti divider-clock
Date: Tue, 26 Nov 2013 10:05:48 +0200	[thread overview]
Message-ID: <1385453182-24421-8-git-send-email-t-kristo@ti.com> (raw)
In-Reply-To: <1385453182-24421-1-git-send-email-t-kristo@ti.com>

This patch adds support for TI divider clock binding, which simply uses
the basic clock divider to provide the features needed.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
---
 .../devicetree/bindings/clock/ti/divider.txt       |  114 ++++++++++
 drivers/clk/ti/Makefile                            |    3 +-
 drivers/clk/ti/divider.c                           |  228 ++++++++++++++++++++
 3 files changed, 344 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/clock/ti/divider.txt
 create mode 100644 drivers/clk/ti/divider.c

diff --git a/Documentation/devicetree/bindings/clock/ti/divider.txt b/Documentation/devicetree/bindings/clock/ti/divider.txt
new file mode 100644
index 0000000..35a6f5c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti/divider.txt
@@ -0,0 +1,114 @@
+Binding for TI divider clock
+
+Binding status: Unstable - ABI compatibility may be broken in the future
+
+This binding uses the common clock binding[1].  It assumes a
+register-mapped adjustable clock rate divider that does not gate and has
+only one input clock or parent.  By default the value programmed into
+the register is one less than the actual divisor value.  E.g:
+
+register value		actual divisor value
+0			1
+1			2
+2			3
+
+This assumption may be modified by the following optional properties:
+
+ti,index-starts-at-one - valid divisor values start at 1, not the default
+of 0.  E.g:
+register value		actual divisor value
+1			1
+2			2
+3			3
+
+ti,index-power-of-two - valid divisor values are powers of two.  E.g:
+register value		actual divisor value
+0			1
+1			2
+2			4
+
+Additionally an array of valid dividers may be supplied like so:
+
+	ti,dividers = <4>, <8>, <0>, <16>;
+
+Which will map the resulting values to a divisor table by their index:
+register value		actual divisor value
+0			4
+1			8
+2			<invalid divisor, skipped>
+3			16
+
+Any zero value in this array means the corresponding bit-value is invalid
+and must not be used.
+
+The binding must also provide the register to control the divider and
+unless the divider array is provided, min and max dividers. Optionally
+the number of bits to shift that mask, if necessary. If the shift value
+is missing it is the same as supplying a zero shift.
+
+This binding can also optionally provide support to the hardware autoidle
+feature, see [2].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+[2] Documentation/devicetree/bindings/clock/ti/autoidle.txt
+
+Required properties:
+- compatible : shall be "ti,divider-clock" or "ti,composite-divider-clock".
+- #clock-cells : from common clock binding; shall be set to 0.
+- clocks : link to phandle of parent clock
+- reg : offset for register controlling adjustable divider
+
+Optional properties:
+- clock-output-names : from common clock binding.
+- ti,dividers : array of integers defining divisors
+- ti,bit-shift : number of bits to shift the divider value, defaults to 0
+- ti,min-div : min divisor for dividing the input clock rate, only
+  needed if the first divisor is offset from the default value (1)
+- ti,max-div : max divisor for dividing the input clock rate, only needed
+  if ti,dividers is not defined.
+- ti,index-starts-at-one : valid divisor programming starts at 1, not zero,
+  only valid if ti,dividers is not defined.
+- ti,index-power-of-two : valid divisor programming must be a power of two,
+  only valid if ti,dividers is not defined.
+- ti,autoidle-shift : bit shift of the autoidle enable bit for the 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
+
+Examples:
+dpll_usb_m2_ck: dpll_usb_m2_ck at 4a008190 {
+	#clock-cells = <0>;
+	compatible = "ti,divider-clock";
+	clocks = <&dpll_usb_ck>;
+	ti,max-div = <127>;
+	reg = <0x190>;
+	ti,index-starts-at-one;
+};
+
+aess_fclk: aess_fclk at 4a004528 {
+	#clock-cells = <0>;
+	compatible = "ti,divider-clock";
+	clocks = <&abe_clk>;
+	ti,bit-shift = <24>;
+	reg = <0x528>;
+	ti,max-div = <2>;
+};
+
+dpll_core_m3x2_div_ck: dpll_core_m3x2_div_ck {
+	#clock-cells = <0>;
+	compatible = "ti,composite-divider-clock";
+	clocks = <&dpll_core_x2_ck>;
+	ti,max-div = <31>;
+	reg = <0x0134>;
+	ti,index-starts-at-one;
+};
+
+ssi_ssr_div_fck_3430es2: ssi_ssr_div_fck_3430es2 {
+	#clock-cells = <0>;
+	compatible = "ti,composite-divider-clock";
+	clocks = <&corex2_fck>;
+	ti,bit-shift = <8>;
+	reg = <0x0a40>;
+	ti,dividers = <0>, <1>, <2>, <3>, <4>, <0>, <6>, <0>, <8>;
+};
diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile
index a4a7595..640ebf9 100644
--- a/drivers/clk/ti/Makefile
+++ b/drivers/clk/ti/Makefile
@@ -1,3 +1,4 @@
 ifneq ($(CONFIG_OF),)
-obj-y					+= clk.o dpll.o autoidle.o composite.o
+obj-y					+= clk.o dpll.o autoidle.o divider.o \
+					   composite.o
 endif
diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
new file mode 100644
index 0000000..818549f
--- /dev/null
+++ b/drivers/clk/ti/divider.c
@@ -0,0 +1,228 @@
+/*
+ * TI Divider 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__
+
+static struct clk_div_table
+__init *ti_clk_get_div_table(struct device_node *node)
+{
+	struct clk_div_table *table;
+	const __be32 *divspec;
+	u32 val;
+	u32 num_div;
+	u32 valid_div;
+	int i;
+
+	divspec = of_get_property(node, "ti,dividers", &num_div);
+
+	if (!divspec)
+		return NULL;
+
+	num_div /= 4;
+
+	valid_div = 0;
+
+	/* Determine required size for divider table */
+	for (i = 0; i < num_div; i++) {
+		of_property_read_u32_index(node, "ti,dividers", i, &val);
+		if (val)
+			valid_div++;
+	}
+
+	if (!valid_div) {
+		pr_err("no valid dividers for %s table\n", node->name);
+		return ERR_PTR(-EINVAL);
+	}
+
+	table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL);
+
+	if (!table)
+		return ERR_PTR(-ENOMEM);
+
+	valid_div = 0;
+
+	for (i = 0; i < num_div; i++) {
+		of_property_read_u32_index(node, "ti,dividers", i, &val);
+		if (val) {
+			table[valid_div].div = val;
+			table[valid_div].val = i;
+			valid_div++;
+		}
+	}
+
+	return table;
+}
+
+static int _get_divider_width(struct device_node *node,
+			      const struct clk_div_table *table,
+			      u8 flags)
+{
+	u32 min_div;
+	u32 max_div;
+	u32 val = 0;
+	u32 div;
+
+	if (!table) {
+		/* Clk divider table not provided, determine min/max divs */
+		if (of_property_read_u32(node, "ti,min-div", &min_div))
+			min_div = 1;
+
+		if (of_property_read_u32(node, "ti,max-div", &max_div)) {
+			pr_err("no max-div for %s!\n", node->name);
+			return -EINVAL;
+		}
+
+		/* Determine bit width for the field */
+		if (flags & CLK_DIVIDER_ONE_BASED)
+			val = 1;
+
+		div = min_div;
+
+		while (div < max_div) {
+			if (flags & CLK_DIVIDER_POWER_OF_TWO)
+				div <<= 1;
+			else
+				div++;
+			val++;
+		}
+	} else {
+		div = 0;
+
+		while (table[div].div) {
+			val = table[div].val;
+			div++;
+		}
+	}
+
+	return fls(val);
+}
+
+static int __init ti_clk_divider_populate(struct device_node *node,
+	void __iomem **reg, const struct clk_div_table **table, u32 *flags,
+	u8 *div_flags, u8 *width, u8 *shift)
+{
+	u32 val;
+
+	*reg = ti_clk_get_reg_addr(node, 0);
+	if (!*reg)
+		return -EINVAL;
+
+	if (!of_property_read_u32(node, "ti,bit-shift", &val))
+		*shift = val;
+	else
+		*shift = 0;
+
+	*flags = 0;
+	*div_flags = 0;
+
+	if (of_property_read_bool(node, "ti,index-starts-at-one"))
+		*div_flags |= CLK_DIVIDER_ONE_BASED;
+
+	if (of_property_read_bool(node, "ti,index-power-of-two"))
+		*div_flags |= CLK_DIVIDER_POWER_OF_TWO;
+
+	if (of_property_read_bool(node, "ti,set-rate-parent"))
+		*flags |= CLK_SET_RATE_PARENT;
+
+	*table = ti_clk_get_div_table(node);
+
+	if (IS_ERR(*table))
+		return PTR_ERR(*table);
+
+	*width = _get_divider_width(node, *table, *div_flags);
+
+	kfree(*table);
+	*table = NULL;
+
+	return 0;
+}
+
+/**
+ * of_ti_divider_clk_setup - Setup function for simple div rate clock
+ * @node: device node for this clock
+ *
+ * Sets up a basic divider clock.
+ */
+static int __init of_ti_divider_clk_setup(struct device_node *node)
+{
+	struct clk *clk;
+	const char *clk_name = node->name;
+	void __iomem *reg;
+	const char *parent_name;
+	u8 clk_divider_flags = 0;
+	u8 width = 0;
+	u8 shift = 0;
+	const struct clk_div_table *table = NULL;
+	u32 flags = 0;
+	int ret = 0;
+
+	parent_name = of_clk_get_parent_name(node, 0);
+
+	ret = ti_clk_divider_populate(node, &reg, &table, &flags,
+				      &clk_divider_flags, &width, &shift);
+	if (ret < 0)
+		return ret;
+
+	clk = clk_register_divider_table(NULL, clk_name, parent_name,
+					 flags, reg, shift, width,
+					 clk_divider_flags, table, NULL);
+
+	if (!IS_ERR(clk)) {
+		of_clk_add_provider(node, of_clk_src_simple_get, clk);
+		of_ti_clk_autoidle_setup(node);
+		return 0;
+	}
+
+	kfree(table);
+	return PTR_ERR(clk);
+}
+CLK_OF_DECLARE(divider_clk, "ti,divider-clock", of_ti_divider_clk_setup);
+
+static int __init of_ti_composite_divider_clk_setup(struct device_node *node)
+{
+	struct clk_divider *div;
+	u32 val;
+	int ret;
+
+	div = kzalloc(sizeof(*div), GFP_KERNEL);
+	if (!div)
+		return -ENOMEM;
+
+	ret = ti_clk_divider_populate(node, &div->reg, &div->table, &val,
+				      &div->flags, &div->width, &div->shift);
+	if (ret < 0)
+		goto cleanup;
+
+	ret = ti_clk_add_component(node, &div->hw, CLK_COMPONENT_TYPE_DIVIDER);
+	if (!ret)
+		return 0;
+
+cleanup:
+	kfree(div->table);
+	kfree(div);
+	return ret;
+}
+CLK_OF_DECLARE(ti_composite_divider_clk, "ti,composite-divider-clock",
+	       of_ti_composite_divider_clk_setup);
-- 
1.7.9.5

  parent reply	other threads:[~2013-11-26  8:05 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-26  8:05 [PATCHv10 00/41] ARM: TI SoC clock DT conversion Tero Kristo
2013-11-26  8:05 ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 01/41] clk: add support for platform specific clock I/O wrapper functions Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-12-15  0:48   ` Mike Turquette
2013-12-15  0:48     ` Mike Turquette
2013-12-16  8:06     ` Tero Kristo
2013-12-16  8:06       ` Tero Kristo
2013-12-17 12:34   ` Paul Walmsley
2013-12-17 12:34     ` Paul Walmsley
2013-12-18  3:33     ` Paul Walmsley
2013-12-18  3:33       ` Paul Walmsley
2013-11-26  8:05 ` [PATCHv10 02/41] CLK: TI: add DT alias clock registration mechanism Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 03/41] CLK: ti: add init support for clock IP blocks Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-12-17  8:14   ` Paul Walmsley
2013-12-17  8:14     ` Paul Walmsley
2013-12-17  8:21     ` Tero Kristo
2013-12-17  8:21       ` Tero Kristo
2013-12-17  8:32       ` Paul Walmsley
2013-12-17  8:32         ` Paul Walmsley
2013-11-26  8:05 ` [PATCHv10 04/41] CLK: TI: Add DPLL clock support Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-12-17  8:37   ` Paul Walmsley
2013-12-17  8:37     ` Paul Walmsley
2013-12-17  8:40   ` Paul Walmsley
2013-12-17  8:40     ` Paul Walmsley
2013-11-26  8:05 ` [PATCHv10 05/41] CLK: TI: add autoidle support Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 06/41] clk: ti: add composite clock support Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` Tero Kristo [this message]
2013-11-26  8:05   ` [PATCHv10 07/41] CLK: ti: add support for ti divider-clock Tero Kristo
2013-11-26  8:05 ` [PATCHv10 08/41] clk: ti: add support for TI fixed factor clock Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 09/41] CLK: TI: add support for gate clock Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 11/41] clk: ti: add support for basic mux clock Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 12/41] CLK: TI: add omap4 clock init file Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-12-17  9:30   ` Paul Walmsley
2013-12-17  9:30     ` Paul Walmsley
2013-11-26  8:05 ` [PATCHv10 14/41] CLK: TI: omap5: Initialize USB_DPLL at boot Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 15/41] CLK: TI: DRA7: Add APLL support Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:51   ` Alexander Aring
2013-11-26  8:51     ` Alexander Aring
2013-11-29 19:00     ` Tero Kristo
2013-11-29 19:00       ` Tero Kristo
2013-11-29 20:52       ` Alexander Aring
2013-11-29 20:52         ` Alexander Aring
2013-11-26  8:05 ` [PATCHv10 16/41] CLK: TI: add dra7 clock init file Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:05 ` [PATCHv10 17/41] CLK: TI: add am33xx " Tero Kristo
2013-11-26  8:05   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 19/41] CLK: TI: add omap3 " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 20/41] CLK: TI: add am43xx " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 21/41] ARM: dts: omap4 clock data Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-12-17  9:44   ` Paul Walmsley
2013-12-17  9:44     ` Paul Walmsley
2013-12-17  9:57     ` Tero Kristo
2013-12-17  9:57       ` Tero Kristo
2013-12-20 11:15       ` Paul Walmsley
2013-12-20 11:15         ` Paul Walmsley
2013-11-26  8:06 ` [PATCHv10 23/41] ARM: dts: dra7 " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-12-17  9:46   ` Paul Walmsley
2013-12-17  9:46     ` Paul Walmsley
2013-11-26  8:06 ` [PATCHv10 24/41] ARM: dts: clk: Add apll related clocks Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 26/41] ARM: dts: DRA7: Add PCIe related clock nodes Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 27/41] ARM: dts: am33xx clock data Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-12-17  9:48   ` Paul Walmsley
2013-12-17  9:48     ` Paul Walmsley
2013-11-26  8:06 ` [PATCHv10 28/41] ARM: dts: omap3 " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-12-17  9:50   ` Paul Walmsley
2013-12-17  9:50     ` Paul Walmsley
2013-11-26  8:06 ` [PATCHv10 29/41] ARM: dts: AM35xx: use DT " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 30/41] ARM: dts: am43xx " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-12-17  9:52   ` Paul Walmsley
2013-12-17  9:52     ` Paul Walmsley
2013-11-26  8:06 ` [PATCHv10 31/41] ARM: OMAP2+: clock: add support for regmap Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26 17:40   ` Tony Lindgren
2013-11-26 17:40     ` Tony Lindgren
2013-11-27  9:08     ` Tero Kristo
2013-11-27  9:08       ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 32/41] ARM: OMAP2+: clock: use driver API instead of direct memory read/write Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 33/41] ARM: OMAP: hwmod: fix an incorrect clk type cast with _get_clkdm Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 34/41] ARM: OMAP3: hwmod: initialize clkdm from clkdm_name Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 35/41] ARM: OMAP2+: PRM: add support for initializing PRCM clock modules from DT Tero Kristo
2013-11-26  8:06   ` Tero Kristo
     [not found] ` <1385453182-24421-1-git-send-email-t-kristo-l0cyMroinI0@public.gmane.org>
2013-11-26  8:05   ` [PATCHv10 10/41] CLK: TI: add support for clockdomain binding Tero Kristo
2013-11-26  8:05     ` Tero Kristo
2013-12-15  4:23     ` Mike Turquette
2013-12-15  4:23       ` Mike Turquette
2013-12-16  8:13       ` Tero Kristo
2013-12-16  8:13         ` Tero Kristo
2013-12-18  3:07         ` Mike Turquette
2013-12-18  3:07           ` Mike Turquette
2013-11-26  8:05   ` [PATCHv10 13/41] CLK: TI: add omap5 clock init file Tero Kristo
2013-11-26  8:05     ` Tero Kristo
2013-11-26  8:05   ` [PATCHv10 18/41] CLK: TI: add interface clock support for OMAP3 Tero Kristo
2013-11-26  8:05     ` Tero Kristo
2013-11-26  8:06   ` [PATCHv10 22/41] ARM: dts: omap5 clock data Tero Kristo
2013-11-26  8:06     ` Tero Kristo
2013-12-16 10:51     ` Paul Walmsley
2013-12-16 10:51       ` Paul Walmsley
2013-12-16 10:57       ` Tero Kristo
2013-12-16 10:57         ` Tero Kristo
2013-12-17  9:46     ` Paul Walmsley
2013-12-17  9:46       ` Paul Walmsley
2013-11-26  8:06   ` [PATCHv10 25/41] ARM: dts: DRA7: Change apll_pcie_m2_ck to fixed factor clock Tero Kristo
2013-11-26  8:06     ` Tero Kristo
2013-11-26  8:06   ` [PATCHv10 36/41] ARM: OMAP2+: io: use new clock init API Tero Kristo
2013-11-26  8:06     ` Tero Kristo
2013-11-28  0:49   ` [PATCHv10 00/41] ARM: TI SoC clock DT conversion Nishanth Menon
2013-11-28  0:49     ` Nishanth Menon
     [not found]     ` <52969313.6090207-l0cyMroinI0@public.gmane.org>
2013-11-28 18:58       ` Paul Walmsley
2013-11-28 18:58         ` Paul Walmsley
2013-11-29 17:12         ` Tony Lindgren
2013-11-29 17:12           ` Tony Lindgren
2013-11-29 18:59           ` Tero Kristo
2013-11-29 18:59             ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 37/41] ARM: OMAP4: remove old clock data and link in new clock init code Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 38/41] ARM: OMAP: DRA7: Enable clock init Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 39/41] ARM: AM43xx: " Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 40/41] ARM: AM33xx: remove old clock data and link in new clock init code Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26  8:06 ` [PATCHv10 41/41] ARM: OMAP3: use DT clock init if DT data is available Tero Kristo
2013-11-26  8:06   ` Tero Kristo
2013-11-26 17:44   ` Tony Lindgren
2013-11-26 17:44     ` Tony Lindgren
2013-11-27  9:06     ` Tero Kristo
2013-11-27  9:06       ` Tero Kristo
2013-11-26 17:57 ` [PATCHv10 00/41] ARM: TI SoC clock DT conversion Tony Lindgren
2013-11-26 17:57   ` Tony Lindgren
2013-12-15  0:51 ` Mike Turquette
2013-12-15  0:51   ` Mike Turquette
2013-12-15  4:35 ` Mike Turquette
2013-12-15  4:35   ` Mike Turquette
2013-12-16  8:12   ` Tero Kristo
2013-12-16  8:12     ` Tero Kristo
2013-12-20 16:10 ` Felipe Balbi
2013-12-20 16:10   ` Felipe Balbi

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=1385453182-24421-8-git-send-email-t-kristo@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.