Skip to contentSkip to conversation

clk: fixed-factor: add DT init function

PATCH Applied Antony Pavlov 2 participants 4 messages Apr 25, 2014 – Apr 26, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover clk: fixed-factor: add DT init function

This short patchseries imports DT init function for fixed-factor clocks from linux kernel.

Antony Pavlov (2):
clk: move of_clk_get_parent_name() to common clk code
clk: fixed-factor: add DT init function

 drivers/clk/clk-fixed-factor.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/clk/clk.c              | 20 ++++++++++++++++++++
 drivers/clk/socfpga.c          | 19 -------------------
 include/linux/clk.h            |  1 +
 4 files changed, 57 insertions(+), 19 deletions(-)
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/2 clk: move of_clk_get_parent_name() to common clk code

---
 drivers/clk/clk.c     | 20 ++++++++++++++++++++
 drivers/clk/socfpga.c | 19 -------------------
 include/linux/clk.h   |  1 +
 3 files changed, 21 insertions(+), 19 deletions(-)
drivers/clk/clk.c +20 -0
index 23b1a7a..584e2f3 100644
@@ -390,6 +390,26 @@ struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec)
 	return clk;
 }
 
+char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
+{
+	struct of_phandle_args clkspec;
+	const char *clk_name;
+	int rc;
+
+	rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
+			&clkspec);
+	if (rc)
+		return NULL;
+
+	if (of_property_read_string_index(clkspec.np, "clock-output-names",
+				clkspec.args_count ? clkspec.args[0] : 0,
+				&clk_name) < 0)
+		clk_name = clkspec.np->name;
+
+	return xstrdup(clk_name);
+}
+EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
+
 /**
  * of_clk_init() - Scan and init clock providers from the DT
  * @root: parent of the first level to probe or NULL for the root of the tree
drivers/clk/socfpga.c +0 -19
index 33a55cb..f4257fd 100644
@@ -49,25 +49,6 @@
 
 static void __iomem *clk_mgr_base_addr;
 
-char *of_clk_get_parent_name(struct device_node *np, unsigned int index)
-{
-	struct of_phandle_args clkspec;
-	const char *clk_name;
-	int rc;
-
-	rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index,
-			&clkspec);
-	if (rc)
-		return NULL;
-
-	if (of_property_read_string_index(clkspec.np, "clock-output-names",
-				clkspec.args_count ? clkspec.args[0] : 0,
-				&clk_name) < 0)
-		clk_name = clkspec.np->name;
-
-	return xstrdup(clk_name);
-}
-
 static struct clk *socfpga_fixed_clk(struct device_node *node)
 {
 	uint32_t f = 0;
include/linux/clk.h +1 -0
index 07b27cf..dd9fab7 100644
@@ -316,6 +316,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, void *data);
 struct clk *of_clk_get(struct device_node *np, int index);
 struct clk *of_clk_get_by_name(struct device_node *np, const char *name);
 struct clk *of_clk_get_from_provider(struct of_phandle_args *clkspec);
+char *of_clk_get_parent_name(struct device_node *np, unsigned int index);
 int of_clk_init(struct device_node *root, const struct of_device_id *matches);
 #else
 static inline struct clk *of_clk_get(struct device_node *np, int index)
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/2 clk: fixed-factor: add DT init function

In reply to Antony Pavlov
---
 drivers/clk/clk-fixed-factor.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
drivers/clk/clk-fixed-factor.c +36 -0
index cb531b1..40b63d6 100644
@@ -92,3 +92,39 @@ struct clk *clk_fixed_factor(const char *name,
 
 	return &f->clk;
 }
+
+#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK_OF_PROVIDER)
+/**
+ * of_fixed_factor_clk_setup() - Setup function for simple fixed factor clock
+ */
+static int of_fixed_factor_clk_setup(struct device_node *node)
+{
+	struct clk *clk;
+	const char *clk_name = node->name;
+	const char *parent_name;
+	u32 div, mult;
+
+	if (of_property_read_u32(node, "clock-div", &div)) {
+		pr_err("%s Fixed factor clock <%s> must have a clock-div property\n",
+			__func__, node->name);
+		return -EINVAL;
+	}
+
+	if (of_property_read_u32(node, "clock-mult", &mult)) {
+		pr_err("%s Fixed factor clock <%s> must have a clock-mult property\n",
+			__func__, node->name);
+		return -EINVAL;
+	}
+
+	of_property_read_string(node, "clock-output-names", &clk_name);
+	parent_name = of_clk_get_parent_name(node, 0);
+
+	clk = clk_fixed_factor(clk_name, parent_name, mult, div, 0);
+	if (IS_ERR(clk))
+		return IS_ERR(clk);
+
+	return of_clk_add_provider(node, of_clk_src_simple_get, clk);
+}
+CLK_OF_DECLARE(fixed_factor_clk, "fixed-factor-clock",
+		of_fixed_factor_clk_setup);
+#endif
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Antony Pavlov
Quoted 6 lines · Antony Pavlov

This short patchseries imports DT init function for fixed-factor clocks from linux kernel.

Antony Pavlov (2):
clk: move of_clk_get_parent_name() to common clk code
clk: fixed-factor: add DT init function

Applied, thanks

Sascha

Quoted 16 lines
 drivers/clk/clk-fixed-factor.c | 36 ++++++++++++++++++++++++++++++++++++
 drivers/clk/clk.c              | 20 ++++++++++++++++++++
 drivers/clk/socfpga.c          | 19 -------------------
 include/linux/clk.h            |  1 +
 4 files changed, 57 insertions(+), 19 deletions(-)
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox