* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-09 20:49 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-09 20:49 UTC (permalink / raw)
To: Tony Lindgren
Cc: Roger Quadros, linux-usb, linux, devicetree-discuss, linux-kernel,
balbi, grygorii.strashko, linux-omap, linux-arm-kernel
On 10:43-20130409, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > >
> > > > Can't you just use the clock name there to get it?
> > >
> > > In device tree we don't pass around clock names. You can either get
> > > a phandle or an index to the clock.
> > >
> > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> >
> > Yes I understand that. But the driver/clock/omap driver can just
> > remap the DT device initially so the board specific clock is
> > found from the clock alias table. Basically initially a passthrough
> > driver that can be enhanced to parse DT clock bindings and load
> > data from /lib/firmware.
>
> Actually probably the driver/clock/omap can even do even less
> initially. There probably even no need to remap clocks there.
>
> As long as the DT clock driver understands that a board specific
> auxclk is specified in the DT it can just call clk_add_alias() so
> the driver will get the right auxclk from cclock44xx_data.c.
>
> Then other features can be added later on like to allocate a
> clock entirely based on the binding etc.
I did try to have an implementation for cpufreq using clock nodes.
unfortunately, device tree wont let me have arguments of strings :(
So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;
Here is an attempt on beagleXM - adds every clock node to the list.
Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr
Would an cleaned up version be good enough as a step #1 of transition?
>From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [PATCH] OMAP: add devicetree support for clock nodes.
Dummy patch based on Roger's original idea
Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap3.dtsi | 5 ++
arch/arm/boot/dts/omap34xx.dtsi | 2 +
arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
arch/arm/mach-omap2/pm.c | 11 +++-
drivers/clk/Kconfig | 6 ++
drivers/clk/Makefile | 2 +
drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
include/linux/clk/ti.h | 30 ++++++++++
9 files changed, 157 insertions(+), 5 deletions(-)
create mode 100644 drivers/clk/ti.c
create mode 100644 include/linux/clk/ti.h
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3344f05..a08990d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -73,6 +73,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
intc: interrupt-controller@48200000 {
compatible = "ti,omap2-intc";
interrupt-controller;
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 75ed4ae..93c2621 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -23,6 +23,8 @@
600000 1350000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 249>; /* index to cpufreq_ck */
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
index 4579c3c..d5d5ef5 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -22,6 +22,7 @@
#include <linux/clk-private.h>
#include <linux/list.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
c++)
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
index 0c6834a..338ef64 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
#include <linux/clk-private.h>
#include <linux/clkdev.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
c++) {
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8d15f9a..6cf95160 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
static inline void omap_init_cpufreq(void)
{
- struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+ struct platform_device_info devinfo = { };
+
+ if (!of_have_populated_dt())
+ devinfo.name = "omap-cpufreq";
+ else
+ devinfo.name = "cpufreq-cpu0";
platform_device_register_full(&devinfo);
}
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */
omap_devinit_smartreflex();
- /* cpufreq dummy device instantiation */
- omap_init_cpufreq();
}
+ /* cpufreq dummy device instantiation */
+ omap_init_cpufreq();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a47e6ee..03c6e48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
---help---
This driver supports Maxim 77686 crystal oscillator clock.
+config COMMON_CLK_TI
+ tristate "Clock driver for TI SoCs"
+ depends on ARCH_OMAP && OF
+ ---help---
+ Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
config CLK_TWL6040
tristate "External McPDM functional clock from twl6040"
depends on TWL6040_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..9621815 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_X86) += x86/
+obj-$(CONFIG_COMMON_CLK_TI) += ti.o
+
# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
new file mode 100644
index 0000000..c747381
--- /dev/null
+++ b/drivers/clk/ti.c
@@ -0,0 +1,100 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+ struct clk_lookup *lk;
+ struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+ void *data)
+{
+ struct ti_clk *c;
+#if 0
+ /* Eww.. IF ONLY phandle arguments could be string */
+ char clk_name[32]; /* 32 is max size of property name */
+
+ char *name = clkspec->args[0];
+
+ snprintf(clk_name, 32, "%s_ck", name);
+ list_for_each_entry(c, &ti_clk_list, node) {
+ int r = strncmp(c->lk->conn_id, clk_name, 32);
+ pr_err("%s: searching %s in %s - %d\n",
+ __func__, clk_name, c->lk->con_id, r);
+ if (!r) {
+ pr_err("%s: found it!\n", __func__);
+ return c->lk.clk;
+ }
+ }
+#else
+ /* Use integer indexing into clkdev list! Sigh.. */
+ int idx = clkspec->args[0];
+ int cindex = 1;
+
+ list_for_each_entry(c, &ti_clk_list, node) {
+ int r = (idx == cindex) ? 0 : 1;
+ pr_err("%s: searching index search = %d in %d in %s - %d\n",
+ __func__, idx, cindex, c->lk->con_id, r);
+ if (!r) {
+ pr_err("%s: found it!\n", __func__);
+ return c->lk->clk;
+ }
+ cindex++;
+ }
+#endif
+
+ pr_err("%s: ran out of options\n", __func__);
+ return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+ pr_err("%s: START\n", __func__);
+ of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+ pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk)
+{
+ struct ti_clk *c;
+ static bool of_added;
+
+ c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+ if (!c) {
+ pr_err("%s: No memory!! cannot add clk node!\n", __func__);
+ return;
+ }
+ clkdev_add(lk);
+ c->lk = lk;
+ list_add_tail(&c->node, &ti_clk_list);
+ pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+ if (!of_added) {
+ of_clk_init(NULL);
+ of_added = true;
+ }
+};
+
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 0000000..eb502a8
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk)
+{
+ clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-09 20:49 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-09 20:49 UTC (permalink / raw)
To: linux-arm-kernel
On 10:43-20130409, Tony Lindgren wrote:
> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > >
> > > > Can't you just use the clock name there to get it?
> > >
> > > In device tree we don't pass around clock names. You can either get
> > > a phandle or an index to the clock.
> > >
> > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> >
> > Yes I understand that. But the driver/clock/omap driver can just
> > remap the DT device initially so the board specific clock is
> > found from the clock alias table. Basically initially a passthrough
> > driver that can be enhanced to parse DT clock bindings and load
> > data from /lib/firmware.
>
> Actually probably the driver/clock/omap can even do even less
> initially. There probably even no need to remap clocks there.
>
> As long as the DT clock driver understands that a board specific
> auxclk is specified in the DT it can just call clk_add_alias() so
> the driver will get the right auxclk from cclock44xx_data.c.
>
> Then other features can be added later on like to allocate a
> clock entirely based on the binding etc.
I did try to have an implementation for cpufreq using clock nodes.
unfortunately, device tree wont let me have arguments of strings :(
So, I am unable to do clock = <&clk mpu_dpll>;
instead, I am forced to do clock = <&clk 249>;
Here is an attempt on beagleXM - adds every clock node to the list.
Tons of un-necessary prints added to give an idea - see log:
http://pastebin.com/F9A2zSTr
Would an cleaned up version be good enough as a step #1 of transition?
>From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [PATCH] OMAP: add devicetree support for clock nodes.
Dummy patch based on Roger's original idea
Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
---
arch/arm/boot/dts/omap3.dtsi | 5 ++
arch/arm/boot/dts/omap34xx.dtsi | 2 +
arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
arch/arm/mach-omap2/pm.c | 11 +++-
drivers/clk/Kconfig | 6 ++
drivers/clk/Makefile | 2 +
drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
include/linux/clk/ti.h | 30 ++++++++++
9 files changed, 157 insertions(+), 5 deletions(-)
create mode 100644 drivers/clk/ti.c
create mode 100644 include/linux/clk/ti.h
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3344f05..a08990d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -73,6 +73,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
intc: interrupt-controller at 48200000 {
compatible = "ti,omap2-intc";
interrupt-controller;
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 75ed4ae..93c2621 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -23,6 +23,8 @@
600000 1350000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 249>; /* index to cpufreq_ck */
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
index 4579c3c..d5d5ef5 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -22,6 +22,7 @@
#include <linux/clk-private.h>
#include <linux/list.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
c++)
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
index 0c6834a..338ef64 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
#include <linux/clk-private.h>
#include <linux/clkdev.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
c++) {
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8d15f9a..6cf95160 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
static inline void omap_init_cpufreq(void)
{
- struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+ struct platform_device_info devinfo = { };
+
+ if (!of_have_populated_dt())
+ devinfo.name = "omap-cpufreq";
+ else
+ devinfo.name = "cpufreq-cpu0";
platform_device_register_full(&devinfo);
}
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */
omap_devinit_smartreflex();
- /* cpufreq dummy device instantiation */
- omap_init_cpufreq();
}
+ /* cpufreq dummy device instantiation */
+ omap_init_cpufreq();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a47e6ee..03c6e48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
---help---
This driver supports Maxim 77686 crystal oscillator clock.
+config COMMON_CLK_TI
+ tristate "Clock driver for TI SoCs"
+ depends on ARCH_OMAP && OF
+ ---help---
+ Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
config CLK_TWL6040
tristate "External McPDM functional clock from twl6040"
depends on TWL6040_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..9621815 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_X86) += x86/
+obj-$(CONFIG_COMMON_CLK_TI) += ti.o
+
# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
new file mode 100644
index 0000000..c747381
--- /dev/null
+++ b/drivers/clk/ti.c
@@ -0,0 +1,100 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+ struct clk_lookup *lk;
+ struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+ void *data)
+{
+ struct ti_clk *c;
+#if 0
+ /* Eww.. IF ONLY phandle arguments could be string */
+ char clk_name[32]; /* 32 is max size of property name */
+
+ char *name = clkspec->args[0];
+
+ snprintf(clk_name, 32, "%s_ck", name);
+ list_for_each_entry(c, &ti_clk_list, node) {
+ int r = strncmp(c->lk->conn_id, clk_name, 32);
+ pr_err("%s: searching %s in %s - %d\n",
+ __func__, clk_name, c->lk->con_id, r);
+ if (!r) {
+ pr_err("%s: found it!\n", __func__);
+ return c->lk.clk;
+ }
+ }
+#else
+ /* Use integer indexing into clkdev list! Sigh.. */
+ int idx = clkspec->args[0];
+ int cindex = 1;
+
+ list_for_each_entry(c, &ti_clk_list, node) {
+ int r = (idx == cindex) ? 0 : 1;
+ pr_err("%s: searching index search = %d in %d in %s - %d\n",
+ __func__, idx, cindex, c->lk->con_id, r);
+ if (!r) {
+ pr_err("%s: found it!\n", __func__);
+ return c->lk->clk;
+ }
+ cindex++;
+ }
+#endif
+
+ pr_err("%s: ran out of options\n", __func__);
+ return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+ pr_err("%s: START\n", __func__);
+ of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+ pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk)
+{
+ struct ti_clk *c;
+ static bool of_added;
+
+ c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+ if (!c) {
+ pr_err("%s: No memory!! cannot add clk node!\n", __func__);
+ return;
+ }
+ clkdev_add(lk);
+ c->lk = lk;
+ list_add_tail(&c->node, &ti_clk_list);
+ pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+ if (!of_added) {
+ of_clk_init(NULL);
+ of_added = true;
+ }
+};
+
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 0000000..eb502a8
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk)
+{
+ clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-09 20:49 ` Nishanth Menon
(?)
@ 2013-04-09 21:54 ` Nishanth Menon
-1 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-09 21:54 UTC (permalink / raw)
To: Tony Lindgren
Cc: grygorii.strashko, linux, devicetree-discuss, linux-usb,
linux-kernel, balbi, linux-omap, linux-arm-kernel, Roger Quadros
On 15:49-20130409, Nishanth Menon wrote:
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
Approach #2:
Here is yet another revision -> here I am trying to avoid the risk of
folks messing up indexing. for example: using an older DTB with newer
kernel, clocks being inserted into existing list etc. to prevent these,
we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
the clock node. We try to minimize(not avoidable with integer indexing)
mistakes during development/productization.
>From 2b576affdc6f6bf0b51ebf9b85ef4319357a7994 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [RFC PATCH V2] OMAP: add devicetree support for clock nodes.(rev 2)
Dummy patch based on Roger's original idea
this time have lesser possibiltiy of screwing up indices. instead
use a specific integer ID to uniquely (TI SoC wide) identify an clock.
on the flip side, we do not all make clock nodes to be accesible from DT
clock indexing.
Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/ti,clock.txt | 48 +++++++++++
arch/arm/boot/dts/omap3.dtsi | 5 ++
arch/arm/boot/dts/omap34xx.dtsi | 2 +
arch/arm/boot/dts/omap4.dtsi | 5 ++
arch/arm/boot/dts/omap443x.dtsi | 2 +
arch/arm/mach-omap2/cclock3xxx_data.c | 5 +-
arch/arm/mach-omap2/cclock44xx_data.c | 5 +-
arch/arm/mach-omap2/clock.h | 12 +++
arch/arm/mach-omap2/pm.c | 11 ++-
drivers/clk/Kconfig | 6 ++
drivers/clk/Makefile | 2 +
drivers/clk/ti.c | 85 ++++++++++++++++++++
include/linux/clk/ti.h | 30 +++++++
13 files changed, 211 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/clock/ti,clock.txt
create mode 100644 drivers/clk/ti.c
create mode 100644 include/linux/clk/ti.h
diff --git a/Documentation/devicetree/bindings/clock/ti,clock.txt b/Documentation/devicetree/bindings/clock/ti,clock.txt
new file mode 100644
index 0000000..53c947c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti,clock.txt
@@ -0,0 +1,48 @@
+* Clock bindings for Texas Instruments clocks
+
+Required properties:
+- compatible: Should be "ti,clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell. The following is a list of ID reservations
+across TI SoCs
+
+ Clock ID
+ ------------------
+ cpu clock 1
+
+The definition is used by SoC clock data using CLKDT() macro
+(example of OMAP2+).
+
+Example Steps:
+/* step 1: definiting an SoC nodes compatible with ti clocks -skip if already done */
+clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+};
+
+/* step 2: Modify the bindings documentation to reserve an ID */
+ auxclk0_ck 2
+ auxclk1_ck 3
+ auxclk2_ck 4
+ auxclk3_ck 5
+ auxclk4_ck 6
+ auxclk5_ck 7
+etc. use an unique number not conflicting with previous reservations.
+WARNING: DONOT insert values - this breaks backward compatibility.
+/* Step 3: replace in clock data file */
+ CLK(NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+with
+ CLKDT(2, NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+
+/* step 4: in device tree entry, now we can use index 2 to uniquely identify auxclk0 clock */
+
+hsusb1_phy: hsusb1_phy {
+ compatible = "usb-nop-xceiv";
+ reset-supply = <&hsusb1_reset>;
+ clocks = <&aux_clks 2>;
+ clock-names = "main_clk";
+ clock-frequency = <19200000>;
+};
+
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3344f05..a08990d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -73,6 +73,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
intc: interrupt-controller@48200000 {
compatible = "ti,omap2-intc";
interrupt-controller;
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 75ed4ae..de59fb8 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -23,6 +23,8 @@
600000 1350000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 3329140..ad18d6a 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -106,6 +106,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
omap4_pmx_core: pinmux@4a100040 {
compatible = "ti,omap4-padconf", "pinctrl-single";
reg = <0x4a100040 0x0196>;
diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi
index cccf39a..5bfc02b 100644
--- a/arch/arm/boot/dts/omap443x.dtsi
+++ b/arch/arm/boot/dts/omap443x.dtsi
@@ -22,6 +22,8 @@
1008000 1375000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
index 4579c3c..2f2932b 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -22,6 +22,7 @@
#include <linux/clk-private.h>
#include <linux/list.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -3501,7 +3502,7 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL, "uart4_ick", &uart4_ick_am35xx, CK_AM35XX),
CLK(NULL, "timer_32k_ck", &omap_32k_fck, CK_3XXX),
CLK(NULL, "timer_sys_ck", &sys_ck, CK_3XXX),
- CLK(NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
};
static const char *enable_init_clks[] = {
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
c++)
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
index 0c6834a..74d4e8c 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
#include <linux/clk-private.h>
#include <linux/clkdev.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -1672,7 +1673,7 @@ static struct omap_clk omap44xx_clks[] = {
CLK("4013a000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013c000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013e000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
- CLK(NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
};
int __init omap4xxx_clk_init(void)
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
c++) {
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 60ddd86..9a7c95b 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -23,10 +23,22 @@
#include <linux/clk-provider.h>
struct omap_clk {
+ u16 dt_clkid;
u16 cpu;
struct clk_lookup lk;
};
+#define CLKDT(id, dev, con, ck, cp) \
+ { \
+ .dt_clkid = id, \
+ .cpu = cp, \
+ .lk = { \
+ .dev_id = dev, \
+ .con_id = con, \
+ .clk = ck, \
+ }, \
+ }
+
#define CLK(dev, con, ck, cp) \
{ \
.cpu = cp, \
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a47e6ee..03c6e48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
---help---
This driver supports Maxim 77686 crystal oscillator clock.
+config COMMON_CLK_TI
+ tristate "Clock driver for TI SoCs"
+ depends on ARCH_OMAP && OF
+ ---help---
+ Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
config CLK_TWL6040
tristate "External McPDM functional clock from twl6040"
depends on TWL6040_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..9621815 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_X86) += x86/
+obj-$(CONFIG_COMMON_CLK_TI) += ti.o
+
# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
new file mode 100644
index 0000000..56b8754
--- /dev/null
+++ b/drivers/clk/ti.c
@@ -0,0 +1,85 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+ struct clk_lookup *lk;
+ u16 id;
+ struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+ void *data)
+{
+ struct ti_clk *c;
+ int idx = clkspec->args[0];
+
+ list_for_each_entry(c, &ti_clk_list, node) {
+ if (idx == c->id)
+ return c->lk->clk;
+ }
+
+ pr_err("%s: Clock ID %d not found in list\n", __func__, idx);
+ return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+ pr_err("%s: START\n", __func__);
+ of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+ pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ struct ti_clk *c;
+ static bool of_added;
+
+ if (lk->dev_id || !id)
+ goto out;
+
+ /* No lists if we did not boot supported by DT entries */
+ if (!of_have_populated_dt())
+ goto out;
+
+ c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+ if (!c) {
+ pr_err("%s: No memory!! cannot add clk node for DT!\n",
+ __func__);
+ /* lets try atleast an regular clock node */
+ goto out;
+ }
+ c->lk = lk;
+ c->id = id;
+ list_add_tail(&c->node, &ti_clk_list);
+ pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+ if (!of_added) {
+ of_clk_init(NULL);
+ of_added = true;
+ }
+out:
+ clkdev_add(lk);
+};
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 0000000..ebed98a
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk, u16 id);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8d15f9a..6cf95160 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
static inline void omap_init_cpufreq(void)
{
- struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+ struct platform_device_info devinfo = { };
+
+ if (!of_have_populated_dt())
+ devinfo.name = "omap-cpufreq";
+ else
+ devinfo.name = "cpufreq-cpu0";
platform_device_register_full(&devinfo);
}
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */
omap_devinit_smartreflex();
- /* cpufreq dummy device instantiation */
- omap_init_cpufreq();
}
+ /* cpufreq dummy device instantiation */
+ omap_init_cpufreq();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-09 21:54 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-09 21:54 UTC (permalink / raw)
To: Tony Lindgren
Cc: grygorii.strashko, linux, devicetree-discuss, linux-usb,
linux-kernel, balbi, linux-omap, linux-arm-kernel, Roger Quadros
On 15:49-20130409, Nishanth Menon wrote:
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
Approach #2:
Here is yet another revision -> here I am trying to avoid the risk of
folks messing up indexing. for example: using an older DTB with newer
kernel, clocks being inserted into existing list etc. to prevent these,
we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
the clock node. We try to minimize(not avoidable with integer indexing)
mistakes during development/productization.
>From 2b576affdc6f6bf0b51ebf9b85ef4319357a7994 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [RFC PATCH V2] OMAP: add devicetree support for clock nodes.(rev 2)
Dummy patch based on Roger's original idea
this time have lesser possibiltiy of screwing up indices. instead
use a specific integer ID to uniquely (TI SoC wide) identify an clock.
on the flip side, we do not all make clock nodes to be accesible from DT
clock indexing.
Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/ti,clock.txt | 48 +++++++++++
arch/arm/boot/dts/omap3.dtsi | 5 ++
arch/arm/boot/dts/omap34xx.dtsi | 2 +
arch/arm/boot/dts/omap4.dtsi | 5 ++
arch/arm/boot/dts/omap443x.dtsi | 2 +
arch/arm/mach-omap2/cclock3xxx_data.c | 5 +-
arch/arm/mach-omap2/cclock44xx_data.c | 5 +-
arch/arm/mach-omap2/clock.h | 12 +++
arch/arm/mach-omap2/pm.c | 11 ++-
drivers/clk/Kconfig | 6 ++
drivers/clk/Makefile | 2 +
drivers/clk/ti.c | 85 ++++++++++++++++++++
include/linux/clk/ti.h | 30 +++++++
13 files changed, 211 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/clock/ti,clock.txt
create mode 100644 drivers/clk/ti.c
create mode 100644 include/linux/clk/ti.h
diff --git a/Documentation/devicetree/bindings/clock/ti,clock.txt b/Documentation/devicetree/bindings/clock/ti,clock.txt
new file mode 100644
index 0000000..53c947c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti,clock.txt
@@ -0,0 +1,48 @@
+* Clock bindings for Texas Instruments clocks
+
+Required properties:
+- compatible: Should be "ti,clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell. The following is a list of ID reservations
+across TI SoCs
+
+ Clock ID
+ ------------------
+ cpu clock 1
+
+The definition is used by SoC clock data using CLKDT() macro
+(example of OMAP2+).
+
+Example Steps:
+/* step 1: definiting an SoC nodes compatible with ti clocks -skip if already done */
+clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+};
+
+/* step 2: Modify the bindings documentation to reserve an ID */
+ auxclk0_ck 2
+ auxclk1_ck 3
+ auxclk2_ck 4
+ auxclk3_ck 5
+ auxclk4_ck 6
+ auxclk5_ck 7
+etc. use an unique number not conflicting with previous reservations.
+WARNING: DONOT insert values - this breaks backward compatibility.
+/* Step 3: replace in clock data file */
+ CLK(NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+with
+ CLKDT(2, NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+
+/* step 4: in device tree entry, now we can use index 2 to uniquely identify auxclk0 clock */
+
+hsusb1_phy: hsusb1_phy {
+ compatible = "usb-nop-xceiv";
+ reset-supply = <&hsusb1_reset>;
+ clocks = <&aux_clks 2>;
+ clock-names = "main_clk";
+ clock-frequency = <19200000>;
+};
+
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3344f05..a08990d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -73,6 +73,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
intc: interrupt-controller@48200000 {
compatible = "ti,omap2-intc";
interrupt-controller;
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 75ed4ae..de59fb8 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -23,6 +23,8 @@
600000 1350000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 3329140..ad18d6a 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -106,6 +106,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
omap4_pmx_core: pinmux@4a100040 {
compatible = "ti,omap4-padconf", "pinctrl-single";
reg = <0x4a100040 0x0196>;
diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi
index cccf39a..5bfc02b 100644
--- a/arch/arm/boot/dts/omap443x.dtsi
+++ b/arch/arm/boot/dts/omap443x.dtsi
@@ -22,6 +22,8 @@
1008000 1375000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
index 4579c3c..2f2932b 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -22,6 +22,7 @@
#include <linux/clk-private.h>
#include <linux/list.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -3501,7 +3502,7 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL, "uart4_ick", &uart4_ick_am35xx, CK_AM35XX),
CLK(NULL, "timer_32k_ck", &omap_32k_fck, CK_3XXX),
CLK(NULL, "timer_sys_ck", &sys_ck, CK_3XXX),
- CLK(NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
};
static const char *enable_init_clks[] = {
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
c++)
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
index 0c6834a..74d4e8c 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
#include <linux/clk-private.h>
#include <linux/clkdev.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -1672,7 +1673,7 @@ static struct omap_clk omap44xx_clks[] = {
CLK("4013a000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013c000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013e000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
- CLK(NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
};
int __init omap4xxx_clk_init(void)
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
c++) {
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 60ddd86..9a7c95b 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -23,10 +23,22 @@
#include <linux/clk-provider.h>
struct omap_clk {
+ u16 dt_clkid;
u16 cpu;
struct clk_lookup lk;
};
+#define CLKDT(id, dev, con, ck, cp) \
+ { \
+ .dt_clkid = id, \
+ .cpu = cp, \
+ .lk = { \
+ .dev_id = dev, \
+ .con_id = con, \
+ .clk = ck, \
+ }, \
+ }
+
#define CLK(dev, con, ck, cp) \
{ \
.cpu = cp, \
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a47e6ee..03c6e48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
---help---
This driver supports Maxim 77686 crystal oscillator clock.
+config COMMON_CLK_TI
+ tristate "Clock driver for TI SoCs"
+ depends on ARCH_OMAP && OF
+ ---help---
+ Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
config CLK_TWL6040
tristate "External McPDM functional clock from twl6040"
depends on TWL6040_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..9621815 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_X86) += x86/
+obj-$(CONFIG_COMMON_CLK_TI) += ti.o
+
# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
new file mode 100644
index 0000000..56b8754
--- /dev/null
+++ b/drivers/clk/ti.c
@@ -0,0 +1,85 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+ struct clk_lookup *lk;
+ u16 id;
+ struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+ void *data)
+{
+ struct ti_clk *c;
+ int idx = clkspec->args[0];
+
+ list_for_each_entry(c, &ti_clk_list, node) {
+ if (idx == c->id)
+ return c->lk->clk;
+ }
+
+ pr_err("%s: Clock ID %d not found in list\n", __func__, idx);
+ return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+ pr_err("%s: START\n", __func__);
+ of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+ pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ struct ti_clk *c;
+ static bool of_added;
+
+ if (lk->dev_id || !id)
+ goto out;
+
+ /* No lists if we did not boot supported by DT entries */
+ if (!of_have_populated_dt())
+ goto out;
+
+ c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+ if (!c) {
+ pr_err("%s: No memory!! cannot add clk node for DT!\n",
+ __func__);
+ /* lets try atleast an regular clock node */
+ goto out;
+ }
+ c->lk = lk;
+ c->id = id;
+ list_add_tail(&c->node, &ti_clk_list);
+ pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+ if (!of_added) {
+ of_clk_init(NULL);
+ of_added = true;
+ }
+out:
+ clkdev_add(lk);
+};
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 0000000..ebed98a
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk, u16 id);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8d15f9a..6cf95160 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
static inline void omap_init_cpufreq(void)
{
- struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+ struct platform_device_info devinfo = { };
+
+ if (!of_have_populated_dt())
+ devinfo.name = "omap-cpufreq";
+ else
+ devinfo.name = "cpufreq-cpu0";
platform_device_register_full(&devinfo);
}
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */
omap_devinit_smartreflex();
- /* cpufreq dummy device instantiation */
- omap_init_cpufreq();
}
+ /* cpufreq dummy device instantiation */
+ omap_init_cpufreq();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-09 21:54 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-09 21:54 UTC (permalink / raw)
To: linux-arm-kernel
On 15:49-20130409, Nishanth Menon wrote:
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
Approach #2:
Here is yet another revision -> here I am trying to avoid the risk of
folks messing up indexing. for example: using an older DTB with newer
kernel, clocks being inserted into existing list etc. to prevent these,
we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
the clock node. We try to minimize(not avoidable with integer indexing)
mistakes during development/productization.
>From 2b576affdc6f6bf0b51ebf9b85ef4319357a7994 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 26 Mar 2013 10:23:27 +0000
Subject: [RFC PATCH V2] OMAP: add devicetree support for clock nodes.(rev 2)
Dummy patch based on Roger's original idea
this time have lesser possibiltiy of screwing up indices. instead
use a specific integer ID to uniquely (TI SoC wide) identify an clock.
on the flip side, we do not all make clock nodes to be accesible from DT
clock indexing.
Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/ti,clock.txt | 48 +++++++++++
arch/arm/boot/dts/omap3.dtsi | 5 ++
arch/arm/boot/dts/omap34xx.dtsi | 2 +
arch/arm/boot/dts/omap4.dtsi | 5 ++
arch/arm/boot/dts/omap443x.dtsi | 2 +
arch/arm/mach-omap2/cclock3xxx_data.c | 5 +-
arch/arm/mach-omap2/cclock44xx_data.c | 5 +-
arch/arm/mach-omap2/clock.h | 12 +++
arch/arm/mach-omap2/pm.c | 11 ++-
drivers/clk/Kconfig | 6 ++
drivers/clk/Makefile | 2 +
drivers/clk/ti.c | 85 ++++++++++++++++++++
include/linux/clk/ti.h | 30 +++++++
13 files changed, 211 insertions(+), 7 deletions(-)
create mode 100644 Documentation/devicetree/bindings/clock/ti,clock.txt
create mode 100644 drivers/clk/ti.c
create mode 100644 include/linux/clk/ti.h
diff --git a/Documentation/devicetree/bindings/clock/ti,clock.txt b/Documentation/devicetree/bindings/clock/ti,clock.txt
new file mode 100644
index 0000000..53c947c
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/ti,clock.txt
@@ -0,0 +1,48 @@
+* Clock bindings for Texas Instruments clocks
+
+Required properties:
+- compatible: Should be "ti,clock"
+- #clock-cells: Should be <1>
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell. The following is a list of ID reservations
+across TI SoCs
+
+ Clock ID
+ ------------------
+ cpu clock 1
+
+The definition is used by SoC clock data using CLKDT() macro
+(example of OMAP2+).
+
+Example Steps:
+/* step 1: definiting an SoC nodes compatible with ti clocks -skip if already done */
+clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+};
+
+/* step 2: Modify the bindings documentation to reserve an ID */
+ auxclk0_ck 2
+ auxclk1_ck 3
+ auxclk2_ck 4
+ auxclk3_ck 5
+ auxclk4_ck 6
+ auxclk5_ck 7
+etc. use an unique number not conflicting with previous reservations.
+WARNING: DONOT insert values - this breaks backward compatibility.
+/* Step 3: replace in clock data file */
+ CLK(NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+with
+ CLKDT(2, NULL, "auxclk0_ck", &auxclk0_ck, CK_443X),
+
+/* step 4: in device tree entry, now we can use index 2 to uniquely identify auxclk0 clock */
+
+hsusb1_phy: hsusb1_phy {
+ compatible = "usb-nop-xceiv";
+ reset-supply = <&hsusb1_reset>;
+ clocks = <&aux_clks 2>;
+ clock-names = "main_clk";
+ clock-frequency = <19200000>;
+};
+
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 3344f05..a08990d 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -73,6 +73,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
intc: interrupt-controller at 48200000 {
compatible = "ti,omap2-intc";
interrupt-controller;
diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
index 75ed4ae..de59fb8 100644
--- a/arch/arm/boot/dts/omap34xx.dtsi
+++ b/arch/arm/boot/dts/omap34xx.dtsi
@@ -23,6 +23,8 @@
600000 1350000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 3329140..ad18d6a 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -106,6 +106,11 @@
ti,hwmods = "counter_32k";
};
+ clks: clocks {
+ compatible = "ti,clock";
+ #clock-cells = <1>;
+ };
+
omap4_pmx_core: pinmux at 4a100040 {
compatible = "ti,omap4-padconf", "pinctrl-single";
reg = <0x4a100040 0x0196>;
diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi
index cccf39a..5bfc02b 100644
--- a/arch/arm/boot/dts/omap443x.dtsi
+++ b/arch/arm/boot/dts/omap443x.dtsi
@@ -22,6 +22,8 @@
1008000 1375000
>;
clock-latency = <300000>; /* From legacy driver */
+ clocks = <&clks 1>;
+ clock-names = "cpu";
};
};
};
diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
index 4579c3c..2f2932b 100644
--- a/arch/arm/mach-omap2/cclock3xxx_data.c
+++ b/arch/arm/mach-omap2/cclock3xxx_data.c
@@ -22,6 +22,7 @@
#include <linux/clk-private.h>
#include <linux/list.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -3501,7 +3502,7 @@ static struct omap_clk omap3xxx_clks[] = {
CLK(NULL, "uart4_ick", &uart4_ick_am35xx, CK_AM35XX),
CLK(NULL, "timer_32k_ck", &omap_32k_fck, CK_3XXX),
CLK(NULL, "timer_sys_ck", &sys_ck, CK_3XXX),
- CLK(NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll1_ck, CK_3XXX),
};
static const char *enable_init_clks[] = {
@@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
c++)
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
index 0c6834a..74d4e8c 100644
--- a/arch/arm/mach-omap2/cclock44xx_data.c
+++ b/arch/arm/mach-omap2/cclock44xx_data.c
@@ -27,6 +27,7 @@
#include <linux/clk-private.h>
#include <linux/clkdev.h>
#include <linux/io.h>
+#include <linux/clk/ti.h>
#include "soc.h"
#include "iomap.h"
@@ -1672,7 +1673,7 @@ static struct omap_clk omap44xx_clks[] = {
CLK("4013a000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013c000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
CLK("4013e000.timer", "timer_sys_ck", &syc_clk_div_ck, CK_443X),
- CLK(NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
+ CLKDT(1, NULL, "cpufreq_ck", &dpll_mpu_ck, CK_443X),
};
int __init omap4xxx_clk_init(void)
@@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
c++) {
if (c->cpu & cpu_clkflg) {
- clkdev_add(&c->lk);
+ ti_clk_node_add(&c->lk, c->dt_clkid);
if (!__clk_init(NULL, c->lk.clk))
omap2_init_clk_hw_omap_clocks(c->lk.clk);
}
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 60ddd86..9a7c95b 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -23,10 +23,22 @@
#include <linux/clk-provider.h>
struct omap_clk {
+ u16 dt_clkid;
u16 cpu;
struct clk_lookup lk;
};
+#define CLKDT(id, dev, con, ck, cp) \
+ { \
+ .dt_clkid = id, \
+ .cpu = cp, \
+ .lk = { \
+ .dev_id = dev, \
+ .con_id = con, \
+ .clk = ck, \
+ }, \
+ }
+
#define CLK(dev, con, ck, cp) \
{ \
.cpu = cp, \
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index a47e6ee..03c6e48 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
---help---
This driver supports Maxim 77686 crystal oscillator clock.
+config COMMON_CLK_TI
+ tristate "Clock driver for TI SoCs"
+ depends on ARCH_OMAP && OF
+ ---help---
+ Fill me up.. some generic statement ofcourse (lets start with OMAP)
+
config CLK_TWL6040
tristate "External McPDM functional clock from twl6040"
depends on TWL6040_CORE
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..9621815 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_X86) += x86/
+obj-$(CONFIG_COMMON_CLK_TI) += ti.o
+
# Chip specific
obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
new file mode 100644
index 0000000..56b8754
--- /dev/null
+++ b/drivers/clk/ti.c
@@ -0,0 +1,85 @@
+/*
+ * TI Clock node provider
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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/kernel.h>
+#include <linux/list.h>
+#include <linux/clk-private.h>
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/of.h>
+#include <linux/clk/ti.h>
+
+struct ti_clk {
+ struct clk_lookup *lk;
+ u16 id;
+ struct list_head node;
+};
+
+static LIST_HEAD(ti_clk_list);
+
+static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
+ void *data)
+{
+ struct ti_clk *c;
+ int idx = clkspec->args[0];
+
+ list_for_each_entry(c, &ti_clk_list, node) {
+ if (idx == c->id)
+ return c->lk->clk;
+ }
+
+ pr_err("%s: Clock ID %d not found in list\n", __func__, idx);
+ return ERR_PTR(-ENODEV);
+}
+
+static void __init ti_clock_init(struct device_node *node)
+{
+
+ pr_err("%s: START\n", __func__);
+ of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
+ pr_err("%s: END\n", __func__);
+}
+CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
+
+void __init ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ struct ti_clk *c;
+ static bool of_added;
+
+ if (lk->dev_id || !id)
+ goto out;
+
+ /* No lists if we did not boot supported by DT entries */
+ if (!of_have_populated_dt())
+ goto out;
+
+ c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
+ if (!c) {
+ pr_err("%s: No memory!! cannot add clk node for DT!\n",
+ __func__);
+ /* lets try atleast an regular clock node */
+ goto out;
+ }
+ c->lk = lk;
+ c->id = id;
+ list_add_tail(&c->node, &ti_clk_list);
+ pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
+ if (!of_added) {
+ of_clk_init(NULL);
+ of_added = true;
+ }
+out:
+ clkdev_add(lk);
+};
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 0000000..ebed98a
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,30 @@
+/*
+ * TI Clock node provider header
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ *
+ * 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.
+ */
+#ifndef __TI_CLK_H
+#define __TI_CLK_H
+
+#include <linux/clkdev.h>
+
+#ifdef CONFIG_OF
+extern void ti_clk_node_add(struct clk_lookup *lk, u16 id);
+#else
+static inline void ti_clk_node_add(struct clk_lookup *lk, u16 id)
+{
+ clkdev_add(lk);
+}
+#endif /* CONFIG_OF */
+
+#endif /* __TI_CLK_H */
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index 8d15f9a..6cf95160 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
static inline void omap_init_cpufreq(void)
{
- struct platform_device_info devinfo = { .name = "omap-cpufreq", };
+ struct platform_device_info devinfo = { };
+
+ if (!of_have_populated_dt())
+ devinfo.name = "omap-cpufreq";
+ else
+ devinfo.name = "cpufreq-cpu0";
platform_device_register_full(&devinfo);
}
@@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
/* Smartreflex device init */
omap_devinit_smartreflex();
- /* cpufreq dummy device instantiation */
- omap_init_cpufreq();
}
+ /* cpufreq dummy device instantiation */
+ omap_init_cpufreq();
#ifdef CONFIG_SUSPEND
suspend_set_ops(&omap_pm_ops);
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-09 21:54 ` Nishanth Menon
(?)
@ 2013-04-10 11:04 ` Roger Quadros
-1 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 11:04 UTC (permalink / raw)
To: Nishanth Menon
Cc: Tony Lindgren, grygorii.strashko, linux, devicetree-discuss,
linux-usb, linux-kernel, balbi, linux-omap, linux-arm-kernel
On 04/10/2013 12:54 AM, Nishanth Menon wrote:
> On 15:49-20130409, Nishanth Menon wrote:
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
> Approach #2:
> Here is yet another revision -> here I am trying to avoid the risk of
> folks messing up indexing. for example: using an older DTB with newer
> kernel, clocks being inserted into existing list etc. to prevent these,
Why do you need to worry about users using old DTB with new kernel.
That is entirely the user's fault no?
> we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
> the clock node. We try to minimize(not avoidable with integer indexing)
> mistakes during development/productization.
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 11:04 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 11:04 UTC (permalink / raw)
To: Nishanth Menon
Cc: Tony Lindgren, grygorii.strashko, linux, devicetree-discuss,
linux-usb, linux-kernel, balbi, linux-omap, linux-arm-kernel
On 04/10/2013 12:54 AM, Nishanth Menon wrote:
> On 15:49-20130409, Nishanth Menon wrote:
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
> Approach #2:
> Here is yet another revision -> here I am trying to avoid the risk of
> folks messing up indexing. for example: using an older DTB with newer
> kernel, clocks being inserted into existing list etc. to prevent these,
Why do you need to worry about users using old DTB with new kernel.
That is entirely the user's fault no?
> we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
> the clock node. We try to minimize(not avoidable with integer indexing)
> mistakes during development/productization.
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread
* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 11:04 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 11:04 UTC (permalink / raw)
To: linux-arm-kernel
On 04/10/2013 12:54 AM, Nishanth Menon wrote:
> On 15:49-20130409, Nishanth Menon wrote:
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
> Approach #2:
> Here is yet another revision -> here I am trying to avoid the risk of
> folks messing up indexing. for example: using an older DTB with newer
> kernel, clocks being inserted into existing list etc. to prevent these,
Why do you need to worry about users using old DTB with new kernel.
That is entirely the user's fault no?
> we add an "DT_ID" for omap clock nodes, and use it to uniquely identify
> the clock node. We try to minimize(not avoidable with integer indexing)
> mistakes during development/productization.
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-09 20:49 ` Nishanth Menon
@ 2013-04-09 22:22 ` Tony Lindgren
-1 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-09 22:22 UTC (permalink / raw)
To: Nishanth Menon
Cc: Roger Quadros, linux-usb, linux, devicetree-discuss, linux-kernel,
balbi, grygorii.strashko, linux-omap, linux-arm-kernel
* Nishanth Menon <nm@ti.com> [130409 13:53]:
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
It seems that you should have a separate clock defines for each
clock instead. That way we can later on populate that with
the clock specific data.
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
Well I would make it even simpler initially. Just a standard .dts
clock defined that gets parsed by drivers/clock/ driver that just
calls clk_add_alias(). Then the consumer driver can just do clk_get()
and and the right clock is found, see below.
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -73,6 +73,11 @@
> ti,hwmods = "counter_32k";
> };
>
> + clks: clocks {
> + compatible = "ti,clock";
> + #clock-cells = <1>;
> + };
> +
> intc: interrupt-controller@48200000 {
> compatible = "ti,omap2-intc";
> interrupt-controller;
There should be a separate entry for each clock defined,
like auxclk1 in the USB case assuming the clock being used
is aux clock #1. I doubt that we want to map all the auxclks
as a single clock as they are separate clocks AFAIK.
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -23,6 +23,8 @@
> 600000 1350000
> >;
> clock-latency = <300000>; /* From legacy driver */
> + clocks = <&clks 249>; /* index to cpufreq_ck */
> + clock-names = "cpu";
> };
> };
> };
Then in the consumer driver you would just have:
clocks = <&auxclk1 0>;
for the USB case, then something else for the cpufreq driver.
> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> @@ -22,6 +22,7 @@
> #include <linux/clk-private.h>
> #include <linux/list.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
> c++)
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
AFAIK no need to tinkering with the clockxxxx_data.c files.
> --- /dev/null
> +++ b/drivers/clk/ti.c
> @@ -0,0 +1,100 @@
> +/*
> + * TI Clock node provider
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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/kernel.h>
> +#include <linux/list.h>
> +#include <linux/clk-private.h>
> +#include <linux/clkdev.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/clk/ti.h>
Then this can be just a minimal DT device driver that initially just
calls clk_add_alias() so the right clock is found when the driver
does clk_get(). Probably should be drivers/clock/omap/clk.c.
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-09 22:22 ` Tony Lindgren
0 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-09 22:22 UTC (permalink / raw)
To: linux-arm-kernel
* Nishanth Menon <nm@ti.com> [130409 13:53]:
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
It seems that you should have a separate clock defines for each
clock instead. That way we can later on populate that with
the clock specific data.
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
Well I would make it even simpler initially. Just a standard .dts
clock defined that gets parsed by drivers/clock/ driver that just
calls clk_add_alias(). Then the consumer driver can just do clk_get()
and and the right clock is found, see below.
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -73,6 +73,11 @@
> ti,hwmods = "counter_32k";
> };
>
> + clks: clocks {
> + compatible = "ti,clock";
> + #clock-cells = <1>;
> + };
> +
> intc: interrupt-controller at 48200000 {
> compatible = "ti,omap2-intc";
> interrupt-controller;
There should be a separate entry for each clock defined,
like auxclk1 in the USB case assuming the clock being used
is aux clock #1. I doubt that we want to map all the auxclks
as a single clock as they are separate clocks AFAIK.
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -23,6 +23,8 @@
> 600000 1350000
> >;
> clock-latency = <300000>; /* From legacy driver */
> + clocks = <&clks 249>; /* index to cpufreq_ck */
> + clock-names = "cpu";
> };
> };
> };
Then in the consumer driver you would just have:
clocks = <&auxclk1 0>;
for the USB case, then something else for the cpufreq driver.
> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> @@ -22,6 +22,7 @@
> #include <linux/clk-private.h>
> #include <linux/list.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
> c++)
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
AFAIK no need to tinkering with the clockxxxx_data.c files.
> --- /dev/null
> +++ b/drivers/clk/ti.c
> @@ -0,0 +1,100 @@
> +/*
> + * TI Clock node provider
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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/kernel.h>
> +#include <linux/list.h>
> +#include <linux/clk-private.h>
> +#include <linux/clkdev.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/clk/ti.h>
Then this can be just a minimal DT device driver that initially just
calls clk_add_alias() so the right clock is found when the driver
does clk_get(). Probably should be drivers/clock/omap/clk.c.
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-09 20:49 ` Nishanth Menon
(?)
@ 2013-04-10 8:06 ` Mike Turquette
-1 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-10 8:06 UTC (permalink / raw)
To: Nishanth Menon, Tony Lindgren
Cc: grygorii.strashko, linux, devicetree-discuss, linux-usb,
linux-kernel, balbi, linux-omap, linux-arm-kernel, Roger Quadros
Quoting Nishanth Menon (2013-04-09 13:49:00)
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
Regards,
Mike
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 26 Mar 2013 10:23:27 +0000
> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>
> Dummy patch based on Roger's original idea
>
> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> arch/arm/boot/dts/omap3.dtsi | 5 ++
> arch/arm/boot/dts/omap34xx.dtsi | 2 +
> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
> arch/arm/mach-omap2/pm.c | 11 +++-
> drivers/clk/Kconfig | 6 ++
> drivers/clk/Makefile | 2 +
> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
> include/linux/clk/ti.h | 30 ++++++++++
> 9 files changed, 157 insertions(+), 5 deletions(-)
> create mode 100644 drivers/clk/ti.c
> create mode 100644 include/linux/clk/ti.h
>
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 3344f05..a08990d 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -73,6 +73,11 @@
> ti,hwmods = "counter_32k";
> };
>
> + clks: clocks {
> + compatible = "ti,clock";
> + #clock-cells = <1>;
> + };
> +
> intc: interrupt-controller@48200000 {
> compatible = "ti,omap2-intc";
> interrupt-controller;
> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
> index 75ed4ae..93c2621 100644
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -23,6 +23,8 @@
> 600000 1350000
> >;
> clock-latency = <300000>; /* From legacy driver */
> + clocks = <&clks 249>; /* index to cpufreq_ck */
> + clock-names = "cpu";
> };
> };
> };
> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
> index 4579c3c..d5d5ef5 100644
> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> @@ -22,6 +22,7 @@
> #include <linux/clk-private.h>
> #include <linux/list.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
> c++)
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
> index 0c6834a..338ef64 100644
> --- a/arch/arm/mach-omap2/cclock44xx_data.c
> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
> @@ -27,6 +27,7 @@
> #include <linux/clk-private.h>
> #include <linux/clkdev.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
> c++) {
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 8d15f9a..6cf95160 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>
> static inline void omap_init_cpufreq(void)
> {
> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
> + struct platform_device_info devinfo = { };
> +
> + if (!of_have_populated_dt())
> + devinfo.name = "omap-cpufreq";
> + else
> + devinfo.name = "cpufreq-cpu0";
> platform_device_register_full(&devinfo);
> }
>
> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
> /* Smartreflex device init */
> omap_devinit_smartreflex();
>
> - /* cpufreq dummy device instantiation */
> - omap_init_cpufreq();
> }
> + /* cpufreq dummy device instantiation */
> + omap_init_cpufreq();
>
> #ifdef CONFIG_SUSPEND
> suspend_set_ops(&omap_pm_ops);
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index a47e6ee..03c6e48 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
> ---help---
> This driver supports Maxim 77686 crystal oscillator clock.
>
> +config COMMON_CLK_TI
> + tristate "Clock driver for TI SoCs"
> + depends on ARCH_OMAP && OF
> + ---help---
> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
> +
> config CLK_TWL6040
> tristate "External McPDM functional clock from twl6040"
> depends on TWL6040_CORE
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..9621815 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>
> obj-$(CONFIG_X86) += x86/
>
> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
> +
> # Chip specific
> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
> new file mode 100644
> index 0000000..c747381
> --- /dev/null
> +++ b/drivers/clk/ti.c
> @@ -0,0 +1,100 @@
> +/*
> + * TI Clock node provider
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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/kernel.h>
> +#include <linux/list.h>
> +#include <linux/clk-private.h>
> +#include <linux/clkdev.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/clk/ti.h>
> +
> +struct ti_clk {
> + struct clk_lookup *lk;
> + struct list_head node;
> +};
> +
> +static LIST_HEAD(ti_clk_list);
> +
> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
> + void *data)
> +{
> + struct ti_clk *c;
> +#if 0
> + /* Eww.. IF ONLY phandle arguments could be string */
> + char clk_name[32]; /* 32 is max size of property name */
> +
> + char *name = clkspec->args[0];
> +
> + snprintf(clk_name, 32, "%s_ck", name);
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = strncmp(c->lk->conn_id, clk_name, 32);
> + pr_err("%s: searching %s in %s - %d\n",
> + __func__, clk_name, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk.clk;
> + }
> + }
> +#else
> + /* Use integer indexing into clkdev list! Sigh.. */
> + int idx = clkspec->args[0];
> + int cindex = 1;
> +
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = (idx == cindex) ? 0 : 1;
> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
> + __func__, idx, cindex, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk->clk;
> + }
> + cindex++;
> + }
> +#endif
> +
> + pr_err("%s: ran out of options\n", __func__);
> + return ERR_PTR(-ENODEV);
> +}
> +
> +static void __init ti_clock_init(struct device_node *node)
> +{
> +
> + pr_err("%s: START\n", __func__);
> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
> + pr_err("%s: END\n", __func__);
> +}
> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
> +
> +void __init ti_clk_node_add(struct clk_lookup *lk)
> +{
> + struct ti_clk *c;
> + static bool of_added;
> +
> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
> + if (!c) {
> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
> + return;
> + }
> + clkdev_add(lk);
> + c->lk = lk;
> + list_add_tail(&c->node, &ti_clk_list);
> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
> + if (!of_added) {
> + of_clk_init(NULL);
> + of_added = true;
> + }
> +};
> +
> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
> new file mode 100644
> index 0000000..eb502a8
> --- /dev/null
> +++ b/include/linux/clk/ti.h
> @@ -0,0 +1,30 @@
> +/*
> + * TI Clock node provider header
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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.
> + */
> +#ifndef __TI_CLK_H
> +#define __TI_CLK_H
> +
> +#include <linux/clkdev.h>
> +
> +#ifdef CONFIG_OF
> +extern void ti_clk_node_add(struct clk_lookup *lk);
> +#else
> +static inline void ti_clk_node_add(struct clk_lookup *lk)
> +{
> + clkdev_add(lk);
> +}
> +#endif /* CONFIG_OF */
> +
> +#endif /* __TI_CLK_H */
> --
> 1.7.9.5
>
>
> --
> Regards,
> Nishanth Menon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 8:06 ` Mike Turquette
0 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-10 8:06 UTC (permalink / raw)
To: Nishanth Menon, Tony Lindgren
Cc: Roger Quadros, linux-usb, linux, devicetree-discuss, linux-kernel,
balbi, grygorii.strashko, linux-omap, linux-arm-kernel
Quoting Nishanth Menon (2013-04-09 13:49:00)
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
Regards,
Mike
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 26 Mar 2013 10:23:27 +0000
> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>
> Dummy patch based on Roger's original idea
>
> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> arch/arm/boot/dts/omap3.dtsi | 5 ++
> arch/arm/boot/dts/omap34xx.dtsi | 2 +
> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
> arch/arm/mach-omap2/pm.c | 11 +++-
> drivers/clk/Kconfig | 6 ++
> drivers/clk/Makefile | 2 +
> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
> include/linux/clk/ti.h | 30 ++++++++++
> 9 files changed, 157 insertions(+), 5 deletions(-)
> create mode 100644 drivers/clk/ti.c
> create mode 100644 include/linux/clk/ti.h
>
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 3344f05..a08990d 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -73,6 +73,11 @@
> ti,hwmods = "counter_32k";
> };
>
> + clks: clocks {
> + compatible = "ti,clock";
> + #clock-cells = <1>;
> + };
> +
> intc: interrupt-controller@48200000 {
> compatible = "ti,omap2-intc";
> interrupt-controller;
> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
> index 75ed4ae..93c2621 100644
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -23,6 +23,8 @@
> 600000 1350000
> >;
> clock-latency = <300000>; /* From legacy driver */
> + clocks = <&clks 249>; /* index to cpufreq_ck */
> + clock-names = "cpu";
> };
> };
> };
> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
> index 4579c3c..d5d5ef5 100644
> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> @@ -22,6 +22,7 @@
> #include <linux/clk-private.h>
> #include <linux/list.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
> c++)
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
> index 0c6834a..338ef64 100644
> --- a/arch/arm/mach-omap2/cclock44xx_data.c
> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
> @@ -27,6 +27,7 @@
> #include <linux/clk-private.h>
> #include <linux/clkdev.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
> c++) {
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 8d15f9a..6cf95160 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>
> static inline void omap_init_cpufreq(void)
> {
> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
> + struct platform_device_info devinfo = { };
> +
> + if (!of_have_populated_dt())
> + devinfo.name = "omap-cpufreq";
> + else
> + devinfo.name = "cpufreq-cpu0";
> platform_device_register_full(&devinfo);
> }
>
> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
> /* Smartreflex device init */
> omap_devinit_smartreflex();
>
> - /* cpufreq dummy device instantiation */
> - omap_init_cpufreq();
> }
> + /* cpufreq dummy device instantiation */
> + omap_init_cpufreq();
>
> #ifdef CONFIG_SUSPEND
> suspend_set_ops(&omap_pm_ops);
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index a47e6ee..03c6e48 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
> ---help---
> This driver supports Maxim 77686 crystal oscillator clock.
>
> +config COMMON_CLK_TI
> + tristate "Clock driver for TI SoCs"
> + depends on ARCH_OMAP && OF
> + ---help---
> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
> +
> config CLK_TWL6040
> tristate "External McPDM functional clock from twl6040"
> depends on TWL6040_CORE
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..9621815 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>
> obj-$(CONFIG_X86) += x86/
>
> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
> +
> # Chip specific
> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
> new file mode 100644
> index 0000000..c747381
> --- /dev/null
> +++ b/drivers/clk/ti.c
> @@ -0,0 +1,100 @@
> +/*
> + * TI Clock node provider
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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/kernel.h>
> +#include <linux/list.h>
> +#include <linux/clk-private.h>
> +#include <linux/clkdev.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/clk/ti.h>
> +
> +struct ti_clk {
> + struct clk_lookup *lk;
> + struct list_head node;
> +};
> +
> +static LIST_HEAD(ti_clk_list);
> +
> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
> + void *data)
> +{
> + struct ti_clk *c;
> +#if 0
> + /* Eww.. IF ONLY phandle arguments could be string */
> + char clk_name[32]; /* 32 is max size of property name */
> +
> + char *name = clkspec->args[0];
> +
> + snprintf(clk_name, 32, "%s_ck", name);
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = strncmp(c->lk->conn_id, clk_name, 32);
> + pr_err("%s: searching %s in %s - %d\n",
> + __func__, clk_name, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk.clk;
> + }
> + }
> +#else
> + /* Use integer indexing into clkdev list! Sigh.. */
> + int idx = clkspec->args[0];
> + int cindex = 1;
> +
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = (idx == cindex) ? 0 : 1;
> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
> + __func__, idx, cindex, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk->clk;
> + }
> + cindex++;
> + }
> +#endif
> +
> + pr_err("%s: ran out of options\n", __func__);
> + return ERR_PTR(-ENODEV);
> +}
> +
> +static void __init ti_clock_init(struct device_node *node)
> +{
> +
> + pr_err("%s: START\n", __func__);
> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
> + pr_err("%s: END\n", __func__);
> +}
> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
> +
> +void __init ti_clk_node_add(struct clk_lookup *lk)
> +{
> + struct ti_clk *c;
> + static bool of_added;
> +
> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
> + if (!c) {
> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
> + return;
> + }
> + clkdev_add(lk);
> + c->lk = lk;
> + list_add_tail(&c->node, &ti_clk_list);
> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
> + if (!of_added) {
> + of_clk_init(NULL);
> + of_added = true;
> + }
> +};
> +
> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
> new file mode 100644
> index 0000000..eb502a8
> --- /dev/null
> +++ b/include/linux/clk/ti.h
> @@ -0,0 +1,30 @@
> +/*
> + * TI Clock node provider header
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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.
> + */
> +#ifndef __TI_CLK_H
> +#define __TI_CLK_H
> +
> +#include <linux/clkdev.h>
> +
> +#ifdef CONFIG_OF
> +extern void ti_clk_node_add(struct clk_lookup *lk);
> +#else
> +static inline void ti_clk_node_add(struct clk_lookup *lk)
> +{
> + clkdev_add(lk);
> +}
> +#endif /* CONFIG_OF */
> +
> +#endif /* __TI_CLK_H */
> --
> 1.7.9.5
>
>
> --
> Regards,
> Nishanth Menon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 8:06 ` Mike Turquette
0 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-10 8:06 UTC (permalink / raw)
To: linux-arm-kernel
Quoting Nishanth Menon (2013-04-09 13:49:00)
> On 10:43-20130409, Tony Lindgren wrote:
> > * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> > > * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> > > > On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> > > > >
> > > > > Can't you just use the clock name there to get it?
> > > >
> > > > In device tree we don't pass around clock names. You can either get
> > > > a phandle or an index to the clock.
> > > >
> > > > e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> > >
> > > Yes I understand that. But the driver/clock/omap driver can just
> > > remap the DT device initially so the board specific clock is
> > > found from the clock alias table. Basically initially a passthrough
> > > driver that can be enhanced to parse DT clock bindings and load
> > > data from /lib/firmware.
> >
> > Actually probably the driver/clock/omap can even do even less
> > initially. There probably even no need to remap clocks there.
> >
> > As long as the DT clock driver understands that a board specific
> > auxclk is specified in the DT it can just call clk_add_alias() so
> > the driver will get the right auxclk from cclock44xx_data.c.
> >
> > Then other features can be added later on like to allocate a
> > clock entirely based on the binding etc.
> I did try to have an implementation for cpufreq using clock nodes.
> unfortunately, device tree wont let me have arguments of strings :(
> So, I am unable to do clock = <&clk mpu_dpll>;
> instead, I am forced to do clock = <&clk 249>;
>
See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
Regards,
Mike
> Here is an attempt on beagleXM - adds every clock node to the list.
> Tons of un-necessary prints added to give an idea - see log:
> http://pastebin.com/F9A2zSTr
>
> Would an cleaned up version be good enough as a step #1 of transition?
>
> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 26 Mar 2013 10:23:27 +0000
> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>
> Dummy patch based on Roger's original idea
>
> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> arch/arm/boot/dts/omap3.dtsi | 5 ++
> arch/arm/boot/dts/omap34xx.dtsi | 2 +
> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
> arch/arm/mach-omap2/pm.c | 11 +++-
> drivers/clk/Kconfig | 6 ++
> drivers/clk/Makefile | 2 +
> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
> include/linux/clk/ti.h | 30 ++++++++++
> 9 files changed, 157 insertions(+), 5 deletions(-)
> create mode 100644 drivers/clk/ti.c
> create mode 100644 include/linux/clk/ti.h
>
> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
> index 3344f05..a08990d 100644
> --- a/arch/arm/boot/dts/omap3.dtsi
> +++ b/arch/arm/boot/dts/omap3.dtsi
> @@ -73,6 +73,11 @@
> ti,hwmods = "counter_32k";
> };
>
> + clks: clocks {
> + compatible = "ti,clock";
> + #clock-cells = <1>;
> + };
> +
> intc: interrupt-controller at 48200000 {
> compatible = "ti,omap2-intc";
> interrupt-controller;
> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
> index 75ed4ae..93c2621 100644
> --- a/arch/arm/boot/dts/omap34xx.dtsi
> +++ b/arch/arm/boot/dts/omap34xx.dtsi
> @@ -23,6 +23,8 @@
> 600000 1350000
> >;
> clock-latency = <300000>; /* From legacy driver */
> + clocks = <&clks 249>; /* index to cpufreq_ck */
> + clock-names = "cpu";
> };
> };
> };
> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
> index 4579c3c..d5d5ef5 100644
> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
> @@ -22,6 +22,7 @@
> #include <linux/clk-private.h>
> #include <linux/list.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
> c++)
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
> index 0c6834a..338ef64 100644
> --- a/arch/arm/mach-omap2/cclock44xx_data.c
> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
> @@ -27,6 +27,7 @@
> #include <linux/clk-private.h>
> #include <linux/clkdev.h>
> #include <linux/io.h>
> +#include <linux/clk/ti.h>
>
> #include "soc.h"
> #include "iomap.h"
> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
> c++) {
> if (c->cpu & cpu_clkflg) {
> - clkdev_add(&c->lk);
> + ti_clk_node_add(&c->lk);
> if (!__clk_init(NULL, c->lk.clk))
> omap2_init_clk_hw_omap_clocks(c->lk.clk);
> }
> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
> index 8d15f9a..6cf95160 100644
> --- a/arch/arm/mach-omap2/pm.c
> +++ b/arch/arm/mach-omap2/pm.c
> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>
> static inline void omap_init_cpufreq(void)
> {
> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
> + struct platform_device_info devinfo = { };
> +
> + if (!of_have_populated_dt())
> + devinfo.name = "omap-cpufreq";
> + else
> + devinfo.name = "cpufreq-cpu0";
> platform_device_register_full(&devinfo);
> }
>
> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
> /* Smartreflex device init */
> omap_devinit_smartreflex();
>
> - /* cpufreq dummy device instantiation */
> - omap_init_cpufreq();
> }
> + /* cpufreq dummy device instantiation */
> + omap_init_cpufreq();
>
> #ifdef CONFIG_SUSPEND
> suspend_set_ops(&omap_pm_ops);
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index a47e6ee..03c6e48 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
> ---help---
> This driver supports Maxim 77686 crystal oscillator clock.
>
> +config COMMON_CLK_TI
> + tristate "Clock driver for TI SoCs"
> + depends on ARCH_OMAP && OF
> + ---help---
> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
> +
> config CLK_TWL6040
> tristate "External McPDM functional clock from twl6040"
> depends on TWL6040_CORE
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..9621815 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>
> obj-$(CONFIG_X86) += x86/
>
> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
> +
> # Chip specific
> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
> new file mode 100644
> index 0000000..c747381
> --- /dev/null
> +++ b/drivers/clk/ti.c
> @@ -0,0 +1,100 @@
> +/*
> + * TI Clock node provider
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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/kernel.h>
> +#include <linux/list.h>
> +#include <linux/clk-private.h>
> +#include <linux/clkdev.h>
> +#include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/clk/ti.h>
> +
> +struct ti_clk {
> + struct clk_lookup *lk;
> + struct list_head node;
> +};
> +
> +static LIST_HEAD(ti_clk_list);
> +
> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
> + void *data)
> +{
> + struct ti_clk *c;
> +#if 0
> + /* Eww.. IF ONLY phandle arguments could be string */
> + char clk_name[32]; /* 32 is max size of property name */
> +
> + char *name = clkspec->args[0];
> +
> + snprintf(clk_name, 32, "%s_ck", name);
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = strncmp(c->lk->conn_id, clk_name, 32);
> + pr_err("%s: searching %s in %s - %d\n",
> + __func__, clk_name, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk.clk;
> + }
> + }
> +#else
> + /* Use integer indexing into clkdev list! Sigh.. */
> + int idx = clkspec->args[0];
> + int cindex = 1;
> +
> + list_for_each_entry(c, &ti_clk_list, node) {
> + int r = (idx == cindex) ? 0 : 1;
> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
> + __func__, idx, cindex, c->lk->con_id, r);
> + if (!r) {
> + pr_err("%s: found it!\n", __func__);
> + return c->lk->clk;
> + }
> + cindex++;
> + }
> +#endif
> +
> + pr_err("%s: ran out of options\n", __func__);
> + return ERR_PTR(-ENODEV);
> +}
> +
> +static void __init ti_clock_init(struct device_node *node)
> +{
> +
> + pr_err("%s: START\n", __func__);
> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
> + pr_err("%s: END\n", __func__);
> +}
> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
> +
> +void __init ti_clk_node_add(struct clk_lookup *lk)
> +{
> + struct ti_clk *c;
> + static bool of_added;
> +
> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
> + if (!c) {
> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
> + return;
> + }
> + clkdev_add(lk);
> + c->lk = lk;
> + list_add_tail(&c->node, &ti_clk_list);
> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
> + if (!of_added) {
> + of_clk_init(NULL);
> + of_added = true;
> + }
> +};
> +
> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
> new file mode 100644
> index 0000000..eb502a8
> --- /dev/null
> +++ b/include/linux/clk/ti.h
> @@ -0,0 +1,30 @@
> +/*
> + * TI Clock node provider header
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + *
> + * 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.
> + */
> +#ifndef __TI_CLK_H
> +#define __TI_CLK_H
> +
> +#include <linux/clkdev.h>
> +
> +#ifdef CONFIG_OF
> +extern void ti_clk_node_add(struct clk_lookup *lk);
> +#else
> +static inline void ti_clk_node_add(struct clk_lookup *lk)
> +{
> + clkdev_add(lk);
> +}
> +#endif /* CONFIG_OF */
> +
> +#endif /* __TI_CLK_H */
> --
> 1.7.9.5
>
>
> --
> Regards,
> Nishanth Menon
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 8:06 ` Mike Turquette
(?)
@ 2013-04-10 10:55 ` Roger Quadros
-1 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 10:55 UTC (permalink / raw)
To: Mike Turquette
Cc: Nishanth Menon, grygorii.strashko, linux, Tony Lindgren,
devicetree-discuss, linux-usb, linux-kernel, balbi, linux-omap,
linux-arm-kernel
On 04/10/2013 11:06 AM, Mike Turquette wrote:
> Quoting Nishanth Menon (2013-04-09 13:49:00)
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>
> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>
Awesome. Thanks for pointing this out Mike.
Now all we need to do is create a named define for each clock index in the
header file.
cheers,
-roger
>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
>> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 26 Mar 2013 10:23:27 +0000
>> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>>
>> Dummy patch based on Roger's original idea
>>
>> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> arch/arm/boot/dts/omap3.dtsi | 5 ++
>> arch/arm/boot/dts/omap34xx.dtsi | 2 +
>> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
>> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
>> arch/arm/mach-omap2/pm.c | 11 +++-
>> drivers/clk/Kconfig | 6 ++
>> drivers/clk/Makefile | 2 +
>> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
>> include/linux/clk/ti.h | 30 ++++++++++
>> 9 files changed, 157 insertions(+), 5 deletions(-)
>> create mode 100644 drivers/clk/ti.c
>> create mode 100644 include/linux/clk/ti.h
>>
>> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
>> index 3344f05..a08990d 100644
>> --- a/arch/arm/boot/dts/omap3.dtsi
>> +++ b/arch/arm/boot/dts/omap3.dtsi
>> @@ -73,6 +73,11 @@
>> ti,hwmods = "counter_32k";
>> };
>>
>> + clks: clocks {
>> + compatible = "ti,clock";
>> + #clock-cells = <1>;
>> + };
>> +
>> intc: interrupt-controller@48200000 {
>> compatible = "ti,omap2-intc";
>> interrupt-controller;
>> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
>> index 75ed4ae..93c2621 100644
>> --- a/arch/arm/boot/dts/omap34xx.dtsi
>> +++ b/arch/arm/boot/dts/omap34xx.dtsi
>> @@ -23,6 +23,8 @@
>> 600000 1350000
>> >;
>> clock-latency = <300000>; /* From legacy driver */
>> + clocks = <&clks 249>; /* index to cpufreq_ck */
>> + clock-names = "cpu";
>> };
>> };
>> };
>> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
>> index 4579c3c..d5d5ef5 100644
>> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
>> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
>> @@ -22,6 +22,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/list.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
>> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
>> c++)
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
>> index 0c6834a..338ef64 100644
>> --- a/arch/arm/mach-omap2/cclock44xx_data.c
>> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
>> @@ -27,6 +27,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/clkdev.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
>> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
>> c++) {
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
>> index 8d15f9a..6cf95160 100644
>> --- a/arch/arm/mach-omap2/pm.c
>> +++ b/arch/arm/mach-omap2/pm.c
>> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>>
>> static inline void omap_init_cpufreq(void)
>> {
>> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
>> + struct platform_device_info devinfo = { };
>> +
>> + if (!of_have_populated_dt())
>> + devinfo.name = "omap-cpufreq";
>> + else
>> + devinfo.name = "cpufreq-cpu0";
>> platform_device_register_full(&devinfo);
>> }
>>
>> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
>> /* Smartreflex device init */
>> omap_devinit_smartreflex();
>>
>> - /* cpufreq dummy device instantiation */
>> - omap_init_cpufreq();
>> }
>> + /* cpufreq dummy device instantiation */
>> + omap_init_cpufreq();
>>
>> #ifdef CONFIG_SUSPEND
>> suspend_set_ops(&omap_pm_ops);
>> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
>> index a47e6ee..03c6e48 100644
>> --- a/drivers/clk/Kconfig
>> +++ b/drivers/clk/Kconfig
>> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
>> ---help---
>> This driver supports Maxim 77686 crystal oscillator clock.
>>
>> +config COMMON_CLK_TI
>> + tristate "Clock driver for TI SoCs"
>> + depends on ARCH_OMAP && OF
>> + ---help---
>> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
>> +
>> config CLK_TWL6040
>> tristate "External McPDM functional clock from twl6040"
>> depends on TWL6040_CORE
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..9621815 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
>> +
>> # Chip specific
>> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
>> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
>> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
>> new file mode 100644
>> index 0000000..c747381
>> --- /dev/null
>> +++ b/drivers/clk/ti.c
>> @@ -0,0 +1,100 @@
>> +/*
>> + * TI Clock node provider
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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/kernel.h>
>> +#include <linux/list.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/io.h>
>> +#include <linux/of.h>
>> +#include <linux/clk/ti.h>
>> +
>> +struct ti_clk {
>> + struct clk_lookup *lk;
>> + struct list_head node;
>> +};
>> +
>> +static LIST_HEAD(ti_clk_list);
>> +
>> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
>> + void *data)
>> +{
>> + struct ti_clk *c;
>> +#if 0
>> + /* Eww.. IF ONLY phandle arguments could be string */
>> + char clk_name[32]; /* 32 is max size of property name */
>> +
>> + char *name = clkspec->args[0];
>> +
>> + snprintf(clk_name, 32, "%s_ck", name);
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = strncmp(c->lk->conn_id, clk_name, 32);
>> + pr_err("%s: searching %s in %s - %d\n",
>> + __func__, clk_name, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk.clk;
>> + }
>> + }
>> +#else
>> + /* Use integer indexing into clkdev list! Sigh.. */
>> + int idx = clkspec->args[0];
>> + int cindex = 1;
>> +
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = (idx == cindex) ? 0 : 1;
>> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
>> + __func__, idx, cindex, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk->clk;
>> + }
>> + cindex++;
>> + }
>> +#endif
>> +
>> + pr_err("%s: ran out of options\n", __func__);
>> + return ERR_PTR(-ENODEV);
>> +}
>> +
>> +static void __init ti_clock_init(struct device_node *node)
>> +{
>> +
>> + pr_err("%s: START\n", __func__);
>> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
>> + pr_err("%s: END\n", __func__);
>> +}
>> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
>> +
>> +void __init ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + struct ti_clk *c;
>> + static bool of_added;
>> +
>> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
>> + if (!c) {
>> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
>> + return;
>> + }
>> + clkdev_add(lk);
>> + c->lk = lk;
>> + list_add_tail(&c->node, &ti_clk_list);
>> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
>> + if (!of_added) {
>> + of_clk_init(NULL);
>> + of_added = true;
>> + }
>> +};
>> +
>> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
>> new file mode 100644
>> index 0000000..eb502a8
>> --- /dev/null
>> +++ b/include/linux/clk/ti.h
>> @@ -0,0 +1,30 @@
>> +/*
>> + * TI Clock node provider header
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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.
>> + */
>> +#ifndef __TI_CLK_H
>> +#define __TI_CLK_H
>> +
>> +#include <linux/clkdev.h>
>> +
>> +#ifdef CONFIG_OF
>> +extern void ti_clk_node_add(struct clk_lookup *lk);
>> +#else
>> +static inline void ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + clkdev_add(lk);
>> +}
>> +#endif /* CONFIG_OF */
>> +
>> +#endif /* __TI_CLK_H */
>> --
>> 1.7.9.5
>>
>>
>> --
>> Regards,
>> Nishanth Menon
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 10:55 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 10:55 UTC (permalink / raw)
To: Mike Turquette
Cc: Nishanth Menon, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, grygorii.strashko,
linux-omap, linux-arm-kernel
On 04/10/2013 11:06 AM, Mike Turquette wrote:
> Quoting Nishanth Menon (2013-04-09 13:49:00)
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>
> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>
Awesome. Thanks for pointing this out Mike.
Now all we need to do is create a named define for each clock index in the
header file.
cheers,
-roger
>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
>> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 26 Mar 2013 10:23:27 +0000
>> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>>
>> Dummy patch based on Roger's original idea
>>
>> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> arch/arm/boot/dts/omap3.dtsi | 5 ++
>> arch/arm/boot/dts/omap34xx.dtsi | 2 +
>> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
>> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
>> arch/arm/mach-omap2/pm.c | 11 +++-
>> drivers/clk/Kconfig | 6 ++
>> drivers/clk/Makefile | 2 +
>> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
>> include/linux/clk/ti.h | 30 ++++++++++
>> 9 files changed, 157 insertions(+), 5 deletions(-)
>> create mode 100644 drivers/clk/ti.c
>> create mode 100644 include/linux/clk/ti.h
>>
>> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
>> index 3344f05..a08990d 100644
>> --- a/arch/arm/boot/dts/omap3.dtsi
>> +++ b/arch/arm/boot/dts/omap3.dtsi
>> @@ -73,6 +73,11 @@
>> ti,hwmods = "counter_32k";
>> };
>>
>> + clks: clocks {
>> + compatible = "ti,clock";
>> + #clock-cells = <1>;
>> + };
>> +
>> intc: interrupt-controller@48200000 {
>> compatible = "ti,omap2-intc";
>> interrupt-controller;
>> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
>> index 75ed4ae..93c2621 100644
>> --- a/arch/arm/boot/dts/omap34xx.dtsi
>> +++ b/arch/arm/boot/dts/omap34xx.dtsi
>> @@ -23,6 +23,8 @@
>> 600000 1350000
>> >;
>> clock-latency = <300000>; /* From legacy driver */
>> + clocks = <&clks 249>; /* index to cpufreq_ck */
>> + clock-names = "cpu";
>> };
>> };
>> };
>> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
>> index 4579c3c..d5d5ef5 100644
>> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
>> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
>> @@ -22,6 +22,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/list.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
>> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
>> c++)
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
>> index 0c6834a..338ef64 100644
>> --- a/arch/arm/mach-omap2/cclock44xx_data.c
>> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
>> @@ -27,6 +27,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/clkdev.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
>> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
>> c++) {
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
>> index 8d15f9a..6cf95160 100644
>> --- a/arch/arm/mach-omap2/pm.c
>> +++ b/arch/arm/mach-omap2/pm.c
>> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>>
>> static inline void omap_init_cpufreq(void)
>> {
>> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
>> + struct platform_device_info devinfo = { };
>> +
>> + if (!of_have_populated_dt())
>> + devinfo.name = "omap-cpufreq";
>> + else
>> + devinfo.name = "cpufreq-cpu0";
>> platform_device_register_full(&devinfo);
>> }
>>
>> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
>> /* Smartreflex device init */
>> omap_devinit_smartreflex();
>>
>> - /* cpufreq dummy device instantiation */
>> - omap_init_cpufreq();
>> }
>> + /* cpufreq dummy device instantiation */
>> + omap_init_cpufreq();
>>
>> #ifdef CONFIG_SUSPEND
>> suspend_set_ops(&omap_pm_ops);
>> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
>> index a47e6ee..03c6e48 100644
>> --- a/drivers/clk/Kconfig
>> +++ b/drivers/clk/Kconfig
>> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
>> ---help---
>> This driver supports Maxim 77686 crystal oscillator clock.
>>
>> +config COMMON_CLK_TI
>> + tristate "Clock driver for TI SoCs"
>> + depends on ARCH_OMAP && OF
>> + ---help---
>> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
>> +
>> config CLK_TWL6040
>> tristate "External McPDM functional clock from twl6040"
>> depends on TWL6040_CORE
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..9621815 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
>> +
>> # Chip specific
>> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
>> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
>> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
>> new file mode 100644
>> index 0000000..c747381
>> --- /dev/null
>> +++ b/drivers/clk/ti.c
>> @@ -0,0 +1,100 @@
>> +/*
>> + * TI Clock node provider
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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/kernel.h>
>> +#include <linux/list.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/io.h>
>> +#include <linux/of.h>
>> +#include <linux/clk/ti.h>
>> +
>> +struct ti_clk {
>> + struct clk_lookup *lk;
>> + struct list_head node;
>> +};
>> +
>> +static LIST_HEAD(ti_clk_list);
>> +
>> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
>> + void *data)
>> +{
>> + struct ti_clk *c;
>> +#if 0
>> + /* Eww.. IF ONLY phandle arguments could be string */
>> + char clk_name[32]; /* 32 is max size of property name */
>> +
>> + char *name = clkspec->args[0];
>> +
>> + snprintf(clk_name, 32, "%s_ck", name);
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = strncmp(c->lk->conn_id, clk_name, 32);
>> + pr_err("%s: searching %s in %s - %d\n",
>> + __func__, clk_name, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk.clk;
>> + }
>> + }
>> +#else
>> + /* Use integer indexing into clkdev list! Sigh.. */
>> + int idx = clkspec->args[0];
>> + int cindex = 1;
>> +
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = (idx == cindex) ? 0 : 1;
>> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
>> + __func__, idx, cindex, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk->clk;
>> + }
>> + cindex++;
>> + }
>> +#endif
>> +
>> + pr_err("%s: ran out of options\n", __func__);
>> + return ERR_PTR(-ENODEV);
>> +}
>> +
>> +static void __init ti_clock_init(struct device_node *node)
>> +{
>> +
>> + pr_err("%s: START\n", __func__);
>> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
>> + pr_err("%s: END\n", __func__);
>> +}
>> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
>> +
>> +void __init ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + struct ti_clk *c;
>> + static bool of_added;
>> +
>> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
>> + if (!c) {
>> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
>> + return;
>> + }
>> + clkdev_add(lk);
>> + c->lk = lk;
>> + list_add_tail(&c->node, &ti_clk_list);
>> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
>> + if (!of_added) {
>> + of_clk_init(NULL);
>> + of_added = true;
>> + }
>> +};
>> +
>> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
>> new file mode 100644
>> index 0000000..eb502a8
>> --- /dev/null
>> +++ b/include/linux/clk/ti.h
>> @@ -0,0 +1,30 @@
>> +/*
>> + * TI Clock node provider header
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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.
>> + */
>> +#ifndef __TI_CLK_H
>> +#define __TI_CLK_H
>> +
>> +#include <linux/clkdev.h>
>> +
>> +#ifdef CONFIG_OF
>> +extern void ti_clk_node_add(struct clk_lookup *lk);
>> +#else
>> +static inline void ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + clkdev_add(lk);
>> +}
>> +#endif /* CONFIG_OF */
>> +
>> +#endif /* __TI_CLK_H */
>> --
>> 1.7.9.5
>>
>>
>> --
>> Regards,
>> Nishanth Menon
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 10:55 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-10 10:55 UTC (permalink / raw)
To: linux-arm-kernel
On 04/10/2013 11:06 AM, Mike Turquette wrote:
> Quoting Nishanth Menon (2013-04-09 13:49:00)
>> On 10:43-20130409, Tony Lindgren wrote:
>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>
>>>>>> Can't you just use the clock name there to get it?
>>>>>
>>>>> In device tree we don't pass around clock names. You can either get
>>>>> a phandle or an index to the clock.
>>>>>
>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>
>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>> remap the DT device initially so the board specific clock is
>>>> found from the clock alias table. Basically initially a passthrough
>>>> driver that can be enhanced to parse DT clock bindings and load
>>>> data from /lib/firmware.
>>>
>>> Actually probably the driver/clock/omap can even do even less
>>> initially. There probably even no need to remap clocks there.
>>>
>>> As long as the DT clock driver understands that a board specific
>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>
>>> Then other features can be added later on like to allocate a
>>> clock entirely based on the binding etc.
>> I did try to have an implementation for cpufreq using clock nodes.
>> unfortunately, device tree wont let me have arguments of strings :(
>> So, I am unable to do clock = <&clk mpu_dpll>;
>> instead, I am forced to do clock = <&clk 249>;
>>
>
> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>
Awesome. Thanks for pointing this out Mike.
Now all we need to do is create a named define for each clock index in the
header file.
cheers,
-roger
>
>> Here is an attempt on beagleXM - adds every clock node to the list.
>> Tons of un-necessary prints added to give an idea - see log:
>> http://pastebin.com/F9A2zSTr
>>
>> Would an cleaned up version be good enough as a step #1 of transition?
>>
>> From 7d373bdb9e9549c1b6ba1775a8dfd96ebe78abfb Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 26 Mar 2013 10:23:27 +0000
>> Subject: [PATCH] OMAP: add devicetree support for clock nodes.
>>
>> Dummy patch based on Roger's original idea
>>
>> Nyet-Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> arch/arm/boot/dts/omap3.dtsi | 5 ++
>> arch/arm/boot/dts/omap34xx.dtsi | 2 +
>> arch/arm/mach-omap2/cclock3xxx_data.c | 3 +-
>> arch/arm/mach-omap2/cclock44xx_data.c | 3 +-
>> arch/arm/mach-omap2/pm.c | 11 +++-
>> drivers/clk/Kconfig | 6 ++
>> drivers/clk/Makefile | 2 +
>> drivers/clk/ti.c | 100 +++++++++++++++++++++++++++++++++
>> include/linux/clk/ti.h | 30 ++++++++++
>> 9 files changed, 157 insertions(+), 5 deletions(-)
>> create mode 100644 drivers/clk/ti.c
>> create mode 100644 include/linux/clk/ti.h
>>
>> diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
>> index 3344f05..a08990d 100644
>> --- a/arch/arm/boot/dts/omap3.dtsi
>> +++ b/arch/arm/boot/dts/omap3.dtsi
>> @@ -73,6 +73,11 @@
>> ti,hwmods = "counter_32k";
>> };
>>
>> + clks: clocks {
>> + compatible = "ti,clock";
>> + #clock-cells = <1>;
>> + };
>> +
>> intc: interrupt-controller at 48200000 {
>> compatible = "ti,omap2-intc";
>> interrupt-controller;
>> diff --git a/arch/arm/boot/dts/omap34xx.dtsi b/arch/arm/boot/dts/omap34xx.dtsi
>> index 75ed4ae..93c2621 100644
>> --- a/arch/arm/boot/dts/omap34xx.dtsi
>> +++ b/arch/arm/boot/dts/omap34xx.dtsi
>> @@ -23,6 +23,8 @@
>> 600000 1350000
>> >;
>> clock-latency = <300000>; /* From legacy driver */
>> + clocks = <&clks 249>; /* index to cpufreq_ck */
>> + clock-names = "cpu";
>> };
>> };
>> };
>> diff --git a/arch/arm/mach-omap2/cclock3xxx_data.c b/arch/arm/mach-omap2/cclock3xxx_data.c
>> index 4579c3c..d5d5ef5 100644
>> --- a/arch/arm/mach-omap2/cclock3xxx_data.c
>> +++ b/arch/arm/mach-omap2/cclock3xxx_data.c
>> @@ -22,6 +22,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/list.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -3574,7 +3575,7 @@ int __init omap3xxx_clk_init(void)
>> for (c = omap3xxx_clks; c < omap3xxx_clks + ARRAY_SIZE(omap3xxx_clks);
>> c++)
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/cclock44xx_data.c b/arch/arm/mach-omap2/cclock44xx_data.c
>> index 0c6834a..338ef64 100644
>> --- a/arch/arm/mach-omap2/cclock44xx_data.c
>> +++ b/arch/arm/mach-omap2/cclock44xx_data.c
>> @@ -27,6 +27,7 @@
>> #include <linux/clk-private.h>
>> #include <linux/clkdev.h>
>> #include <linux/io.h>
>> +#include <linux/clk/ti.h>
>>
>> #include "soc.h"
>> #include "iomap.h"
>> @@ -1697,7 +1698,7 @@ int __init omap4xxx_clk_init(void)
>> for (c = omap44xx_clks; c < omap44xx_clks + ARRAY_SIZE(omap44xx_clks);
>> c++) {
>> if (c->cpu & cpu_clkflg) {
>> - clkdev_add(&c->lk);
>> + ti_clk_node_add(&c->lk);
>> if (!__clk_init(NULL, c->lk.clk))
>> omap2_init_clk_hw_omap_clocks(c->lk.clk);
>> }
>> diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
>> index 8d15f9a..6cf95160 100644
>> --- a/arch/arm/mach-omap2/pm.c
>> +++ b/arch/arm/mach-omap2/pm.c
>> @@ -267,7 +267,12 @@ static void __init omap4_init_voltages(void)
>>
>> static inline void omap_init_cpufreq(void)
>> {
>> - struct platform_device_info devinfo = { .name = "omap-cpufreq", };
>> + struct platform_device_info devinfo = { };
>> +
>> + if (!of_have_populated_dt())
>> + devinfo.name = "omap-cpufreq";
>> + else
>> + devinfo.name = "cpufreq-cpu0";
>> platform_device_register_full(&devinfo);
>> }
>>
>> @@ -301,9 +306,9 @@ int __init omap2_common_pm_late_init(void)
>> /* Smartreflex device init */
>> omap_devinit_smartreflex();
>>
>> - /* cpufreq dummy device instantiation */
>> - omap_init_cpufreq();
>> }
>> + /* cpufreq dummy device instantiation */
>> + omap_init_cpufreq();
>>
>> #ifdef CONFIG_SUSPEND
>> suspend_set_ops(&omap_pm_ops);
>> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
>> index a47e6ee..03c6e48 100644
>> --- a/drivers/clk/Kconfig
>> +++ b/drivers/clk/Kconfig
>> @@ -55,6 +55,12 @@ config COMMON_CLK_MAX77686
>> ---help---
>> This driver supports Maxim 77686 crystal oscillator clock.
>>
>> +config COMMON_CLK_TI
>> + tristate "Clock driver for TI SoCs"
>> + depends on ARCH_OMAP && OF
>> + ---help---
>> + Fill me up.. some generic statement ofcourse (lets start with OMAP)
>> +
>> config CLK_TWL6040
>> tristate "External McPDM functional clock from twl6040"
>> depends on TWL6040_CORE
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..9621815 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -30,6 +30,8 @@ obj-$(CONFIG_ARCH_TEGRA) += tegra/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> +obj-$(CONFIG_COMMON_CLK_TI) += ti.o
>> +
>> # Chip specific
>> obj-$(CONFIG_COMMON_CLK_WM831X) += clk-wm831x.o
>> obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o
>> diff --git a/drivers/clk/ti.c b/drivers/clk/ti.c
>> new file mode 100644
>> index 0000000..c747381
>> --- /dev/null
>> +++ b/drivers/clk/ti.c
>> @@ -0,0 +1,100 @@
>> +/*
>> + * TI Clock node provider
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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/kernel.h>
>> +#include <linux/list.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/io.h>
>> +#include <linux/of.h>
>> +#include <linux/clk/ti.h>
>> +
>> +struct ti_clk {
>> + struct clk_lookup *lk;
>> + struct list_head node;
>> +};
>> +
>> +static LIST_HEAD(ti_clk_list);
>> +
>> +static struct clk *ti_bypass_clk_get_by_name(struct of_phandle_args *clkspec,
>> + void *data)
>> +{
>> + struct ti_clk *c;
>> +#if 0
>> + /* Eww.. IF ONLY phandle arguments could be string */
>> + char clk_name[32]; /* 32 is max size of property name */
>> +
>> + char *name = clkspec->args[0];
>> +
>> + snprintf(clk_name, 32, "%s_ck", name);
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = strncmp(c->lk->conn_id, clk_name, 32);
>> + pr_err("%s: searching %s in %s - %d\n",
>> + __func__, clk_name, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk.clk;
>> + }
>> + }
>> +#else
>> + /* Use integer indexing into clkdev list! Sigh.. */
>> + int idx = clkspec->args[0];
>> + int cindex = 1;
>> +
>> + list_for_each_entry(c, &ti_clk_list, node) {
>> + int r = (idx == cindex) ? 0 : 1;
>> + pr_err("%s: searching index search = %d in %d in %s - %d\n",
>> + __func__, idx, cindex, c->lk->con_id, r);
>> + if (!r) {
>> + pr_err("%s: found it!\n", __func__);
>> + return c->lk->clk;
>> + }
>> + cindex++;
>> + }
>> +#endif
>> +
>> + pr_err("%s: ran out of options\n", __func__);
>> + return ERR_PTR(-ENODEV);
>> +}
>> +
>> +static void __init ti_clock_init(struct device_node *node)
>> +{
>> +
>> + pr_err("%s: START\n", __func__);
>> + of_clk_add_provider(node, ti_bypass_clk_get_by_name, NULL);
>> + pr_err("%s: END\n", __func__);
>> +}
>> +CLK_OF_DECLARE(ti_clk, "ti,clock", ti_clock_init);
>> +
>> +void __init ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + struct ti_clk *c;
>> + static bool of_added;
>> +
>> + c = kzalloc(sizeof(struct ti_clk), GFP_KERNEL);
>> + if (!c) {
>> + pr_err("%s: No memory!! cannot add clk node!\n", __func__);
>> + return;
>> + }
>> + clkdev_add(lk);
>> + c->lk = lk;
>> + list_add_tail(&c->node, &ti_clk_list);
>> + pr_err("%s: Added clock node %s\n", __func__, lk->con_id);
>> + if (!of_added) {
>> + of_clk_init(NULL);
>> + of_added = true;
>> + }
>> +};
>> +
>> diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
>> new file mode 100644
>> index 0000000..eb502a8
>> --- /dev/null
>> +++ b/include/linux/clk/ti.h
>> @@ -0,0 +1,30 @@
>> +/*
>> + * TI Clock node provider header
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + *
>> + * 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.
>> + */
>> +#ifndef __TI_CLK_H
>> +#define __TI_CLK_H
>> +
>> +#include <linux/clkdev.h>
>> +
>> +#ifdef CONFIG_OF
>> +extern void ti_clk_node_add(struct clk_lookup *lk);
>> +#else
>> +static inline void ti_clk_node_add(struct clk_lookup *lk)
>> +{
>> + clkdev_add(lk);
>> +}
>> +#endif /* CONFIG_OF */
>> +
>> +#endif /* __TI_CLK_H */
>> --
>> 1.7.9.5
>>
>>
>> --
>> Regards,
>> Nishanth Menon
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
>> the body of a message to majordomo at vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 10:55 ` Roger Quadros
(?)
@ 2013-04-10 17:39 ` Nishanth Menon
-1 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 17:39 UTC (permalink / raw)
To: Roger Quadros
Cc: Mike Turquette, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, grygorii.strashko,
linux-omap, linux-arm-kernel
On 13:55-20130410, Roger Quadros wrote:
> On 04/10/2013 11:06 AM, Mike Turquette wrote:
> > Quoting Nishanth Menon (2013-04-09 13:49:00)
> >> On 10:43-20130409, Tony Lindgren wrote:
> >>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> >>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> >>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> >>>>>>
> >>>>>> Can't you just use the clock name there to get it?
> >>>>>
> >>>>> In device tree we don't pass around clock names. You can either get
> >>>>> a phandle or an index to the clock.
> >>>>>
> >>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> >>>>
> >>>> Yes I understand that. But the driver/clock/omap driver can just
> >>>> remap the DT device initially so the board specific clock is
> >>>> found from the clock alias table. Basically initially a passthrough
> >>>> driver that can be enhanced to parse DT clock bindings and load
> >>>> data from /lib/firmware.
> >>>
> >>> Actually probably the driver/clock/omap can even do even less
> >>> initially. There probably even no need to remap clocks there.
> >>>
> >>> As long as the DT clock driver understands that a board specific
> >>> auxclk is specified in the DT it can just call clk_add_alias() so
> >>> the driver will get the right auxclk from cclock44xx_data.c.
> >>>
> >>> Then other features can be added later on like to allocate a
> >>> clock entirely based on the binding etc.
> >> I did try to have an implementation for cpufreq using clock nodes.
> >> unfortunately, device tree wont let me have arguments of strings :(
> >> So, I am unable to do clock = <&clk mpu_dpll>;
> >> instead, I am forced to do clock = <&clk 249>;
> >>
> >
> > See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
> >
>
> Awesome. Thanks for pointing this out Mike.
>
> Now all we need to do is create a named define for each clock index in the
> header file.
Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
this.
Details in the patch below (Tony, I have added you as collaborator for
helping in getting this working-clk_add_alias was'nt needed in the
internal patch discussion we had - I have taken a bit of freedom in
adding your contributions to the patch below)
Folks, this does seem to be the best compromise we can achieve at this
point in time. feedback on this approach is much appreciated - if folks
are ok, I can post this as an formal patch series.
>From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data
OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
However, this presents an obstacle for using these clock nodes in
Device Tree definitions. There are many possible approaches to this
problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.
Even though we can claim this is user error, such errors are hard to
track down and fix.
An alternate approach introduced here is to introduce device tree bindings
corresponding to the clock nodes required in DT definition for SoC which
automatically maps back to the definitions in cclockXYZ_data.c.
The driver introduced here to do this mapping will eventually be the
place where the clock handling will migrate to. We need to consider this
angle as well so that the solution will be an valid transition point for
moving the clock data out of kernel image (into device tree or firmware load
etc..).
Overall strategy introduced here is simple: an clock node described in
device tree blob is used to identify the exact clock provided in the SoC
specific data. This is then linked back using of_clk_add_provider to the
device node to be accessible by of_clk_get.
Based on discussion contributions from Roger Quadros, Grygorii Strashko
and others.
[tony@atomide.com: co-developed]
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
drivers/clk/Makefile | 1 +
drivers/clk/omap/Makefile | 1 +
drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
4 files changed, 136 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
create mode 100644 drivers/clk/omap/Makefile
create mode 100644 drivers/clk/omap/clk.c
diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
new file mode 100644
index 0000000..07e3ff8
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+ CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
+Corresponding binding will be:
+ dpll1: dpll1 {
+ #clock-cells = <0>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+ CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
+Corresponding binding will be:
+ auxclk3: auxclk3 {
+ #clock-cells = <1>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&auxclk3>;
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..a0209d7 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
obj-$(CONFIG_ARCH_TEGRA) += tegra/
+obj-$(CONFIG_ARCH_OMAP) += omap/
obj-$(CONFIG_X86) += x86/
diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
new file mode 100644
index 0000000..8195931
--- /dev/null
+++ b/drivers/clk/omap/Makefile
@@ -0,0 +1 @@
+obj-y += clk.o
diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
new file mode 100644
index 0000000..63a4cce
--- /dev/null
+++ b/drivers/clk/omap/clk.c
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ * Tony Lindgren <tony@atomide.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/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+ {.compatible = "ti,omap-clock",},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev: device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+ struct clk *clk;
+ int res;
+
+ const struct of_device_id *match;
+ struct device_node *np = pdev->dev.of_node;
+ char clk_name[32];
+
+ match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+ /* Set up things so consumer can call clk_get() with name */
+ snprintf(clk_name, 32, "%s_ck", np->name);
+ clk = clk_get(NULL, clk_name);
+ if (IS_ERR(clk)) {
+ res = PTR_ERR(clk);
+ dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+ clk_name, res);
+ goto out;
+ }
+
+ /* This allows the driver to of_clk_get() */
+ res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+ if (res)
+ dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+ clk_name, res);
+
+ clk_put(clk);
+out:
+ return res;
+}
+
+MODULE_ALIAS("platform:omap_clk");
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+ .probe = omap_clk_probe,
+ .driver = {
+ .name = "omap_clk",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(omap_clk_of_match),
+ },
+};
+
+static int __init omap_clk_init(void)
+{
+ return platform_driver_register(&omap_clk_driver);
+}
+
+arch_initcall(omap_clk_init);
+
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 17:39 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 17:39 UTC (permalink / raw)
To: Roger Quadros
Cc: Mike Turquette, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, grygorii.strashko,
linux-omap, linux-arm-kernel
On 13:55-20130410, Roger Quadros wrote:
> On 04/10/2013 11:06 AM, Mike Turquette wrote:
> > Quoting Nishanth Menon (2013-04-09 13:49:00)
> >> On 10:43-20130409, Tony Lindgren wrote:
> >>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> >>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> >>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> >>>>>>
> >>>>>> Can't you just use the clock name there to get it?
> >>>>>
> >>>>> In device tree we don't pass around clock names. You can either get
> >>>>> a phandle or an index to the clock.
> >>>>>
> >>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> >>>>
> >>>> Yes I understand that. But the driver/clock/omap driver can just
> >>>> remap the DT device initially so the board specific clock is
> >>>> found from the clock alias table. Basically initially a passthrough
> >>>> driver that can be enhanced to parse DT clock bindings and load
> >>>> data from /lib/firmware.
> >>>
> >>> Actually probably the driver/clock/omap can even do even less
> >>> initially. There probably even no need to remap clocks there.
> >>>
> >>> As long as the DT clock driver understands that a board specific
> >>> auxclk is specified in the DT it can just call clk_add_alias() so
> >>> the driver will get the right auxclk from cclock44xx_data.c.
> >>>
> >>> Then other features can be added later on like to allocate a
> >>> clock entirely based on the binding etc.
> >> I did try to have an implementation for cpufreq using clock nodes.
> >> unfortunately, device tree wont let me have arguments of strings :(
> >> So, I am unable to do clock = <&clk mpu_dpll>;
> >> instead, I am forced to do clock = <&clk 249>;
> >>
> >
> > See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
> >
>
> Awesome. Thanks for pointing this out Mike.
>
> Now all we need to do is create a named define for each clock index in the
> header file.
Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
this.
Details in the patch below (Tony, I have added you as collaborator for
helping in getting this working-clk_add_alias was'nt needed in the
internal patch discussion we had - I have taken a bit of freedom in
adding your contributions to the patch below)
Folks, this does seem to be the best compromise we can achieve at this
point in time. feedback on this approach is much appreciated - if folks
are ok, I can post this as an formal patch series.
>From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data
OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
However, this presents an obstacle for using these clock nodes in
Device Tree definitions. There are many possible approaches to this
problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.
Even though we can claim this is user error, such errors are hard to
track down and fix.
An alternate approach introduced here is to introduce device tree bindings
corresponding to the clock nodes required in DT definition for SoC which
automatically maps back to the definitions in cclockXYZ_data.c.
The driver introduced here to do this mapping will eventually be the
place where the clock handling will migrate to. We need to consider this
angle as well so that the solution will be an valid transition point for
moving the clock data out of kernel image (into device tree or firmware load
etc..).
Overall strategy introduced here is simple: an clock node described in
device tree blob is used to identify the exact clock provided in the SoC
specific data. This is then linked back using of_clk_add_provider to the
device node to be accessible by of_clk_get.
Based on discussion contributions from Roger Quadros, Grygorii Strashko
and others.
[tony@atomide.com: co-developed]
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
drivers/clk/Makefile | 1 +
drivers/clk/omap/Makefile | 1 +
drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
4 files changed, 136 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
create mode 100644 drivers/clk/omap/Makefile
create mode 100644 drivers/clk/omap/clk.c
diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
new file mode 100644
index 0000000..07e3ff8
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+ CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
+Corresponding binding will be:
+ dpll1: dpll1 {
+ #clock-cells = <0>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+ CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
+Corresponding binding will be:
+ auxclk3: auxclk3 {
+ #clock-cells = <1>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&auxclk3>;
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..a0209d7 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
obj-$(CONFIG_ARCH_TEGRA) += tegra/
+obj-$(CONFIG_ARCH_OMAP) += omap/
obj-$(CONFIG_X86) += x86/
diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
new file mode 100644
index 0000000..8195931
--- /dev/null
+++ b/drivers/clk/omap/Makefile
@@ -0,0 +1 @@
+obj-y += clk.o
diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
new file mode 100644
index 0000000..63a4cce
--- /dev/null
+++ b/drivers/clk/omap/clk.c
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ * Tony Lindgren <tony@atomide.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/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+ {.compatible = "ti,omap-clock",},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev: device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+ struct clk *clk;
+ int res;
+
+ const struct of_device_id *match;
+ struct device_node *np = pdev->dev.of_node;
+ char clk_name[32];
+
+ match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+ /* Set up things so consumer can call clk_get() with name */
+ snprintf(clk_name, 32, "%s_ck", np->name);
+ clk = clk_get(NULL, clk_name);
+ if (IS_ERR(clk)) {
+ res = PTR_ERR(clk);
+ dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+ clk_name, res);
+ goto out;
+ }
+
+ /* This allows the driver to of_clk_get() */
+ res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+ if (res)
+ dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+ clk_name, res);
+
+ clk_put(clk);
+out:
+ return res;
+}
+
+MODULE_ALIAS("platform:omap_clk");
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+ .probe = omap_clk_probe,
+ .driver = {
+ .name = "omap_clk",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(omap_clk_of_match),
+ },
+};
+
+static int __init omap_clk_init(void)
+{
+ return platform_driver_register(&omap_clk_driver);
+}
+
+arch_initcall(omap_clk_init);
+
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 17:39 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 17:39 UTC (permalink / raw)
To: linux-arm-kernel
On 13:55-20130410, Roger Quadros wrote:
> On 04/10/2013 11:06 AM, Mike Turquette wrote:
> > Quoting Nishanth Menon (2013-04-09 13:49:00)
> >> On 10:43-20130409, Tony Lindgren wrote:
> >>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
> >>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
> >>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
> >>>>>>
> >>>>>> Can't you just use the clock name there to get it?
> >>>>>
> >>>>> In device tree we don't pass around clock names. You can either get
> >>>>> a phandle or an index to the clock.
> >>>>>
> >>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
> >>>>
> >>>> Yes I understand that. But the driver/clock/omap driver can just
> >>>> remap the DT device initially so the board specific clock is
> >>>> found from the clock alias table. Basically initially a passthrough
> >>>> driver that can be enhanced to parse DT clock bindings and load
> >>>> data from /lib/firmware.
> >>>
> >>> Actually probably the driver/clock/omap can even do even less
> >>> initially. There probably even no need to remap clocks there.
> >>>
> >>> As long as the DT clock driver understands that a board specific
> >>> auxclk is specified in the DT it can just call clk_add_alias() so
> >>> the driver will get the right auxclk from cclock44xx_data.c.
> >>>
> >>> Then other features can be added later on like to allocate a
> >>> clock entirely based on the binding etc.
> >> I did try to have an implementation for cpufreq using clock nodes.
> >> unfortunately, device tree wont let me have arguments of strings :(
> >> So, I am unable to do clock = <&clk mpu_dpll>;
> >> instead, I am forced to do clock = <&clk 249>;
> >>
> >
> > See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
> >
>
> Awesome. Thanks for pointing this out Mike.
>
> Now all we need to do is create a named define for each clock index in the
> header file.
Approach #3: Thanks to Tony for collaborating on this:
Works for cpufreq-cpu0 - additional patches:
http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
beagleXM)
Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
this.
Details in the patch below (Tony, I have added you as collaborator for
helping in getting this working-clk_add_alias was'nt needed in the
internal patch discussion we had - I have taken a bit of freedom in
adding your contributions to the patch below)
Folks, this does seem to be the best compromise we can achieve at this
point in time. feedback on this approach is much appreciated - if folks
are ok, I can post this as an formal patch series.
>From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
From: Nishanth Menon <nm@ti.com>
Date: Tue, 9 Apr 2013 19:26:40 -0500
Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
data
OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
However, this presents an obstacle for using these clock nodes in
Device Tree definitions. There are many possible approaches to this
problem as discussed in the following thread:
http://marc.info/?t=136370325600009&r=1&w=2
Highlights of the options:
a) device specific clk_add_alias:
cons: driver handling required
b) using an generic clk node and indexing to reach the clock required.
This is similar in approach taken by tegra and few other platforms.
example clock = <&clk 5>;
cons: potential to have mismatches in indexed table and associated
dtb data. In addition, managing continued documentation in bindings
as clock indexing increases. Even though readability angle could be
improved by using preprocessing of DT using macros, indexed approach
is inherently risky from cases like the following:
clk indexes in kernel:
1 - mpu_dpll
2 - aux_clk1
3 - core_clk
DT entry for peripheral x uses <&clk 2>, kernel updates to:
1 - mpu_dpll
2 - per_dpll
3 - aux_clk1
4 - core_clk
using the old dtb(or dts missing an update), on new kernel which has
updated indices will result in per_dpll now controlled for peripheral
X without warning or any potential error detection and warning.
Even though we can claim this is user error, such errors are hard to
track down and fix.
An alternate approach introduced here is to introduce device tree bindings
corresponding to the clock nodes required in DT definition for SoC which
automatically maps back to the definitions in cclockXYZ_data.c.
The driver introduced here to do this mapping will eventually be the
place where the clock handling will migrate to. We need to consider this
angle as well so that the solution will be an valid transition point for
moving the clock data out of kernel image (into device tree or firmware load
etc..).
Overall strategy introduced here is simple: an clock node described in
device tree blob is used to identify the exact clock provided in the SoC
specific data. This is then linked back using of_clk_add_provider to the
device node to be accessible by of_clk_get.
Based on discussion contributions from Roger Quadros, Grygorii Strashko
and others.
[tony at atomide.com: co-developed]
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
.../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
drivers/clk/Makefile | 1 +
drivers/clk/omap/Makefile | 1 +
drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
4 files changed, 136 insertions(+)
create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
create mode 100644 drivers/clk/omap/Makefile
create mode 100644 drivers/clk/omap/clk.c
diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
new file mode 100644
index 0000000..07e3ff8
--- /dev/null
+++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
@@ -0,0 +1,40 @@
+Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
+
+This binding is a work-in-progress, and meant to be stage #1 of transitioning
+OMAP clock data out of kernel image.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : shall be "ti,omap-clock"
+- #clock-cells : from common clock binding; shall be set to 0.
+NOTE:
+node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
+Since all clocks are described with _ck, the node name is optimized to drop the
+usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
+
+Example #1: describing clock node for CPU on OMAP34xx platform:
+Ref: arch/arm/mach-omap2/cclock3xxx_data.c
+describes the CPU clock to be as follows
+ CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
+Corresponding binding will be:
+ dpll1: dpll1 {
+ #clock-cells = <0>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&dpll1>;
+
+Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
+Ref: arch/arm/mach-omap2/cclock44xx_data.c
+describes the auxclk3 clock to be as follows:
+ CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
+Corresponding binding will be:
+ auxclk3: auxclk3 {
+ #clock-cells = <1>;
+ compatible = "ti,omap-clock";
+ };
+And it's usage will be:
+ clocks = <&auxclk3>;
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 300d477..a0209d7 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
obj-$(CONFIG_ARCH_TEGRA) += tegra/
+obj-$(CONFIG_ARCH_OMAP) += omap/
obj-$(CONFIG_X86) += x86/
diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
new file mode 100644
index 0000000..8195931
--- /dev/null
+++ b/drivers/clk/omap/Makefile
@@ -0,0 +1 @@
+obj-y += clk.o
diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
new file mode 100644
index 0000000..63a4cce
--- /dev/null
+++ b/drivers/clk/omap/clk.c
@@ -0,0 +1,94 @@
+/*
+ * Texas Instruments OMAP Clock driver
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Nishanth Menon
+ * Tony Lindgren <tony@atomide.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/clkdev.h>
+#include <linux/clk-private.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/string.h>
+
+static const struct of_device_id omap_clk_of_match[] = {
+ {.compatible = "ti,omap-clock",},
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, omap_clk_of_match);
+
+/**
+ * omap_clk_probe() - create link from DT definition to clock data
+ * @pdev: device node
+ *
+ * REVISIT: We are now assuming the following:
+ * 1. omap clock names end with _ck
+ * 2. omap clocks don't get removed
+ */
+static int omap_clk_probe(struct platform_device *pdev)
+{
+ struct clk *clk;
+ int res;
+
+ const struct of_device_id *match;
+ struct device_node *np = pdev->dev.of_node;
+ char clk_name[32];
+
+ match = of_match_device(omap_clk_of_match, &pdev->dev);
+
+ /* Set up things so consumer can call clk_get() with name */
+ snprintf(clk_name, 32, "%s_ck", np->name);
+ clk = clk_get(NULL, clk_name);
+ if (IS_ERR(clk)) {
+ res = PTR_ERR(clk);
+ dev_err(&pdev->dev, "could not get clock %s (%d)\n",
+ clk_name, res);
+ goto out;
+ }
+
+ /* This allows the driver to of_clk_get() */
+ res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
+ if (res)
+ dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
+ clk_name, res);
+
+ clk_put(clk);
+out:
+ return res;
+}
+
+MODULE_ALIAS("platform:omap_clk");
+
+/* We assume here that OMAP clocks will not be removed */
+static struct platform_driver omap_clk_driver = {
+ .probe = omap_clk_probe,
+ .driver = {
+ .name = "omap_clk",
+ .owner = THIS_MODULE,
+ .of_match_table = of_match_ptr(omap_clk_of_match),
+ },
+};
+
+static int __init omap_clk_init(void)
+{
+ return platform_driver_register(&omap_clk_driver);
+}
+
+arch_initcall(omap_clk_init);
+
+MODULE_DESCRIPTION("OMAP Clock driver");
+MODULE_AUTHOR("Texas Instruments Inc.");
+MODULE_LICENSE("GPL v2");
--
1.7.9.5
--
Regards,
Nishanth Menon
^ permalink raw reply related [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 17:39 ` Nishanth Menon
@ 2013-04-10 18:49 ` Tony Lindgren
-1 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-10 18:49 UTC (permalink / raw)
To: Nishanth Menon
Cc: Roger Quadros, Mike Turquette, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, grygorii.strashko,
linux-omap, linux-arm-kernel
* Nishanth Menon <nm@ti.com> [130410 10:44]:
> Details in the patch below (Tony, I have added you as collaborator for
> helping in getting this working-clk_add_alias was'nt needed in the
> internal patch discussion we had - I have taken a bit of freedom in
> adding your contributions to the patch below)
OK thanks. Noticed few minor things, see below.
> Folks, this does seem to be the best compromise we can achieve at this
> point in time. feedback on this approach is much appreciated - if folks
> are ok, I can post this as an formal patch series.
>
> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 9 Apr 2013 19:26:40 -0500
> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
> data
>
> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
> However, this presents an obstacle for using these clock nodes in
> Device Tree definitions. There are many possible approaches to this
> problem as discussed in the following thread:
> http://marc.info/?t=136370325600009&r=1&w=2
It might be worth clarifying that this is especially for the board
specific clocks initially. The fixed clocks are currently found via
the clock aliases table.
> Highlights of the options:
> a) device specific clk_add_alias:
> cons: driver handling required
> b) using an generic clk node and indexing to reach the clock required.
> This is similar in approach taken by tegra and few other platforms.
> example clock = <&clk 5>;
> cons: potential to have mismatches in indexed table and associated
> dtb data. In addition, managing continued documentation in bindings
> as clock indexing increases. Even though readability angle could be
> improved by using preprocessing of DT using macros, indexed approach
> is inherently risky from cases like the following:
> clk indexes in kernel:
> 1 - mpu_dpll
> 2 - aux_clk1
> 3 - core_clk
> DT entry for peripheral x uses <&clk 2>, kernel updates to:
> 1 - mpu_dpll
> 2 - per_dpll
> 3 - aux_clk1
> 4 - core_clk
> using the old dtb(or dts missing an update), on new kernel which has
> updated indices will result in per_dpll now controlled for peripheral
> X without warning or any potential error detection and warning.
>
> Even though we can claim this is user error, such errors are hard to
> track down and fix.
>
> An alternate approach introduced here is to introduce device tree bindings
> corresponding to the clock nodes required in DT definition for SoC which
> automatically maps back to the definitions in cclockXYZ_data.c.
>
> The driver introduced here to do this mapping will eventually be the
> place where the clock handling will migrate to. We need to consider this
> angle as well so that the solution will be an valid transition point for
> moving the clock data out of kernel image (into device tree or firmware load
> etc..).
>
> Overall strategy introduced here is simple: an clock node described in
> device tree blob is used to identify the exact clock provided in the SoC
> specific data. This is then linked back using of_clk_add_provider to the
> device node to be accessible by of_clk_get.
>
> Based on discussion contributions from Roger Quadros, Grygorii Strashko
> and others.
>
> [tony@atomide.com: co-developed]
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
> drivers/clk/Makefile | 1 +
> drivers/clk/omap/Makefile | 1 +
> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
> 4 files changed, 136 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
> create mode 100644 drivers/clk/omap/Makefile
> create mode 100644 drivers/clk/omap/clk.c
>
> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
> new file mode 100644
> index 0000000..07e3ff8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
> @@ -0,0 +1,40 @@
> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
> +
> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
> +OMAP clock data out of kernel image.
As it's using the common clock binding, this will be supported in the
long run too. So maybe replace work-in-progress with initial minimal
binding that can be enhanced later on.
> +This binding uses the common clock binding[1].
> +
> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> +
> +Required properties:
> +- compatible : shall be "ti,omap-clock"
> +- #clock-cells : from common clock binding; shall be set to 0.
> +NOTE:
> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
> +Since all clocks are described with _ck, the node name is optimized to drop the
> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
> +
> +Example #1: describing clock node for CPU on OMAP34xx platform:
> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
> +describes the CPU clock to be as follows
> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
> +Corresponding binding will be:
> + dpll1: dpll1 {
> + #clock-cells = <0>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&dpll1>;
> +
> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
> +describes the auxclk3 clock to be as follows:
> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
> +Corresponding binding will be:
> + auxclk3: auxclk3 {
> + #clock-cells = <1>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&auxclk3>;
The #clock-cells in the auxclk3 example should also be 0 instead of 1
AFAIK. We should only use #clock-cells = <1> when the same physical
clock provides multiple outputs. I believe the auxclocks are all separate,
but that needs to be verified.
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..a0209d7 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
> obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_ARCH_OMAP) += omap/
>
> obj-$(CONFIG_X86) += x86/
>
> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
> new file mode 100644
> index 0000000..8195931
> --- /dev/null
> +++ b/drivers/clk/omap/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/string.h>
> +
> +static const struct of_device_id omap_clk_of_match[] = {
> + {.compatible = "ti,omap-clock",},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
> +
> +/**
> + * omap_clk_probe() - create link from DT definition to clock data
> + * @pdev: device node
> + *
> + * REVISIT: We are now assuming the following:
> + * 1. omap clock names end with _ck
> + * 2. omap clocks don't get removed
> + */
> +static int omap_clk_probe(struct platform_device *pdev)
> +{
> + struct clk *clk;
> + int res;
> +
> + const struct of_device_id *match;
> + struct device_node *np = pdev->dev.of_node;
> + char clk_name[32];
> +
> + match = of_match_device(omap_clk_of_match, &pdev->dev);
> +
> + /* Set up things so consumer can call clk_get() with name */
> + snprintf(clk_name, 32, "%s_ck", np->name);
> + clk = clk_get(NULL, clk_name);
> + if (IS_ERR(clk)) {
> + res = PTR_ERR(clk);
> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
> + clk_name, res);
> + goto out;
> + }
It seems that at least for now we can assume the naming will stay
that way, then if we need other rules for finding clocks, we can
add omap_match_clock() function or something.
> + /* This allows the driver to of_clk_get() */
> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
> + if (res)
> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
> + clk_name, res);
> +
> + clk_put(clk);
> +out:
> + return res;
> +}
We can avoid the concern of storing the struct clk * and do the
look up lazily on consumer driver probe by setting a dummy struct
clk * here. Then replace of_clk_src_simple_get() with a custom
omap_clk_src_get() that does the lookup and replaces the struct
clk * with the real one.
> +MODULE_ALIAS("platform:omap_clk");
> +
> +/* We assume here that OMAP clocks will not be removed */
> +static struct platform_driver omap_clk_driver = {
> + .probe = omap_clk_probe,
> + .driver = {
> + .name = "omap_clk",
> + .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(omap_clk_of_match),
> + },
> +};
> +
> +static int __init omap_clk_init(void)
> +{
> + return platform_driver_register(&omap_clk_driver);
> +}
> +
> +arch_initcall(omap_clk_init);
>
> +MODULE_DESCRIPTION("OMAP Clock driver");
> +MODULE_AUTHOR("Texas Instruments Inc.");
> +MODULE_LICENSE("GPL v2");
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 18:49 ` Tony Lindgren
0 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-10 18:49 UTC (permalink / raw)
To: linux-arm-kernel
* Nishanth Menon <nm@ti.com> [130410 10:44]:
> Details in the patch below (Tony, I have added you as collaborator for
> helping in getting this working-clk_add_alias was'nt needed in the
> internal patch discussion we had - I have taken a bit of freedom in
> adding your contributions to the patch below)
OK thanks. Noticed few minor things, see below.
> Folks, this does seem to be the best compromise we can achieve at this
> point in time. feedback on this approach is much appreciated - if folks
> are ok, I can post this as an formal patch series.
>
> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 9 Apr 2013 19:26:40 -0500
> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
> data
>
> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
> However, this presents an obstacle for using these clock nodes in
> Device Tree definitions. There are many possible approaches to this
> problem as discussed in the following thread:
> http://marc.info/?t=136370325600009&r=1&w=2
It might be worth clarifying that this is especially for the board
specific clocks initially. The fixed clocks are currently found via
the clock aliases table.
> Highlights of the options:
> a) device specific clk_add_alias:
> cons: driver handling required
> b) using an generic clk node and indexing to reach the clock required.
> This is similar in approach taken by tegra and few other platforms.
> example clock = <&clk 5>;
> cons: potential to have mismatches in indexed table and associated
> dtb data. In addition, managing continued documentation in bindings
> as clock indexing increases. Even though readability angle could be
> improved by using preprocessing of DT using macros, indexed approach
> is inherently risky from cases like the following:
> clk indexes in kernel:
> 1 - mpu_dpll
> 2 - aux_clk1
> 3 - core_clk
> DT entry for peripheral x uses <&clk 2>, kernel updates to:
> 1 - mpu_dpll
> 2 - per_dpll
> 3 - aux_clk1
> 4 - core_clk
> using the old dtb(or dts missing an update), on new kernel which has
> updated indices will result in per_dpll now controlled for peripheral
> X without warning or any potential error detection and warning.
>
> Even though we can claim this is user error, such errors are hard to
> track down and fix.
>
> An alternate approach introduced here is to introduce device tree bindings
> corresponding to the clock nodes required in DT definition for SoC which
> automatically maps back to the definitions in cclockXYZ_data.c.
>
> The driver introduced here to do this mapping will eventually be the
> place where the clock handling will migrate to. We need to consider this
> angle as well so that the solution will be an valid transition point for
> moving the clock data out of kernel image (into device tree or firmware load
> etc..).
>
> Overall strategy introduced here is simple: an clock node described in
> device tree blob is used to identify the exact clock provided in the SoC
> specific data. This is then linked back using of_clk_add_provider to the
> device node to be accessible by of_clk_get.
>
> Based on discussion contributions from Roger Quadros, Grygorii Strashko
> and others.
>
> [tony at atomide.com: co-developed]
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
> drivers/clk/Makefile | 1 +
> drivers/clk/omap/Makefile | 1 +
> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
> 4 files changed, 136 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
> create mode 100644 drivers/clk/omap/Makefile
> create mode 100644 drivers/clk/omap/clk.c
>
> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
> new file mode 100644
> index 0000000..07e3ff8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
> @@ -0,0 +1,40 @@
> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
> +
> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
> +OMAP clock data out of kernel image.
As it's using the common clock binding, this will be supported in the
long run too. So maybe replace work-in-progress with initial minimal
binding that can be enhanced later on.
> +This binding uses the common clock binding[1].
> +
> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> +
> +Required properties:
> +- compatible : shall be "ti,omap-clock"
> +- #clock-cells : from common clock binding; shall be set to 0.
> +NOTE:
> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
> +Since all clocks are described with _ck, the node name is optimized to drop the
> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
> +
> +Example #1: describing clock node for CPU on OMAP34xx platform:
> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
> +describes the CPU clock to be as follows
> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
> +Corresponding binding will be:
> + dpll1: dpll1 {
> + #clock-cells = <0>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&dpll1>;
> +
> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
> +describes the auxclk3 clock to be as follows:
> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
> +Corresponding binding will be:
> + auxclk3: auxclk3 {
> + #clock-cells = <1>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&auxclk3>;
The #clock-cells in the auxclk3 example should also be 0 instead of 1
AFAIK. We should only use #clock-cells = <1> when the same physical
clock provides multiple outputs. I believe the auxclocks are all separate,
but that needs to be verified.
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..a0209d7 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
> obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_ARCH_OMAP) += omap/
>
> obj-$(CONFIG_X86) += x86/
>
> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
> new file mode 100644
> index 0000000..8195931
> --- /dev/null
> +++ b/drivers/clk/omap/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/string.h>
> +
> +static const struct of_device_id omap_clk_of_match[] = {
> + {.compatible = "ti,omap-clock",},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
> +
> +/**
> + * omap_clk_probe() - create link from DT definition to clock data
> + * @pdev: device node
> + *
> + * REVISIT: We are now assuming the following:
> + * 1. omap clock names end with _ck
> + * 2. omap clocks don't get removed
> + */
> +static int omap_clk_probe(struct platform_device *pdev)
> +{
> + struct clk *clk;
> + int res;
> +
> + const struct of_device_id *match;
> + struct device_node *np = pdev->dev.of_node;
> + char clk_name[32];
> +
> + match = of_match_device(omap_clk_of_match, &pdev->dev);
> +
> + /* Set up things so consumer can call clk_get() with name */
> + snprintf(clk_name, 32, "%s_ck", np->name);
> + clk = clk_get(NULL, clk_name);
> + if (IS_ERR(clk)) {
> + res = PTR_ERR(clk);
> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
> + clk_name, res);
> + goto out;
> + }
It seems that at least for now we can assume the naming will stay
that way, then if we need other rules for finding clocks, we can
add omap_match_clock() function or something.
> + /* This allows the driver to of_clk_get() */
> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
> + if (res)
> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
> + clk_name, res);
> +
> + clk_put(clk);
> +out:
> + return res;
> +}
We can avoid the concern of storing the struct clk * and do the
look up lazily on consumer driver probe by setting a dummy struct
clk * here. Then replace of_clk_src_simple_get() with a custom
omap_clk_src_get() that does the lookup and replaces the struct
clk * with the real one.
> +MODULE_ALIAS("platform:omap_clk");
> +
> +/* We assume here that OMAP clocks will not be removed */
> +static struct platform_driver omap_clk_driver = {
> + .probe = omap_clk_probe,
> + .driver = {
> + .name = "omap_clk",
> + .owner = THIS_MODULE,
> + .of_match_table = of_match_ptr(omap_clk_of_match),
> + },
> +};
> +
> +static int __init omap_clk_init(void)
> +{
> + return platform_driver_register(&omap_clk_driver);
> +}
> +
> +arch_initcall(omap_clk_init);
>
> +MODULE_DESCRIPTION("OMAP Clock driver");
> +MODULE_AUTHOR("Texas Instruments Inc.");
> +MODULE_LICENSE("GPL v2");
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread[parent not found: <20130410184919.GJ10155-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>]
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 18:49 ` Tony Lindgren
(?)
@ 2013-04-10 19:19 ` Nishanth Menon
-1 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 19:19 UTC (permalink / raw)
To: Tony Lindgren
Cc: Roger Quadros, Mike Turquette, linux-usb-u79uwXL29TY76Z2rM5mHXA,
Russell King - ARM Linux,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, lkml,
balbi-l0cyMroinI0, grygorii.strashko-l0cyMroinI0, linux-omap,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Hi Tony,
On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> wrote:
> * Nishanth Menon <nm-l0cyMroinI0@public.gmane.org> [130410 10:44]:
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>
> OK thanks. Noticed few minor things, see below.
Thanks on the checkup
>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
>>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>
> It might be worth clarifying that this is especially for the board
> specific clocks initially. The fixed clocks are currently found via
> the clock aliases table.
Ack.
[...]
>
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>
> The #clock-cells in the auxclk3 example should also be 0 instead of 1
> AFAIK. We should only use #clock-cells = <1> when the same physical
> clock provides multiple outputs. I believe the auxclocks are all separate,
> but that needs to be verified.
Oops.. my bad. you are correct here - auxclk is single output. all of them.
will fix.
[...]
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>
> It seems that at least for now we can assume the naming will stay
> that way, then if we need other rules for finding clocks, we can
> add omap_match_clock() function or something.
ack.
>
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>
> We can avoid the concern of storing the struct clk * and do the
> look up lazily on consumer driver probe by setting a dummy struct
> clk * here. Then replace of_clk_src_simple_get() with a custom
> omap_clk_src_get() that does the lookup and replaces the struct
> clk * with the real one.
Hmm.. this is interesting. will give it a try. Thanks on the suggestion.
Regards,
Nishanth Menon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 19:19 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 19:19 UTC (permalink / raw)
To: Tony Lindgren
Cc: Roger Quadros, Mike Turquette, linux-usb,
Russell King - ARM Linux, devicetree-discuss, lkml, balbi,
grygorii.strashko, linux-omap,
linux-arm-kernel@lists.infradead.org
Hi Tony,
On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Nishanth Menon <nm@ti.com> [130410 10:44]:
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>
> OK thanks. Noticed few minor things, see below.
Thanks on the checkup
>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
>>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>
> It might be worth clarifying that this is especially for the board
> specific clocks initially. The fixed clocks are currently found via
> the clock aliases table.
Ack.
[...]
>
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>
> The #clock-cells in the auxclk3 example should also be 0 instead of 1
> AFAIK. We should only use #clock-cells = <1> when the same physical
> clock provides multiple outputs. I believe the auxclocks are all separate,
> but that needs to be verified.
Oops.. my bad. you are correct here - auxclk is single output. all of them.
will fix.
[...]
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>
> It seems that at least for now we can assume the naming will stay
> that way, then if we need other rules for finding clocks, we can
> add omap_match_clock() function or something.
ack.
>
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>
> We can avoid the concern of storing the struct clk * and do the
> look up lazily on consumer driver probe by setting a dummy struct
> clk * here. Then replace of_clk_src_simple_get() with a custom
> omap_clk_src_get() that does the lookup and replaces the struct
> clk * with the real one.
Hmm.. this is interesting. will give it a try. Thanks on the suggestion.
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 19:19 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-10 19:19 UTC (permalink / raw)
To: linux-arm-kernel
Hi Tony,
On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren <tony@atomide.com> wrote:
> * Nishanth Menon <nm@ti.com> [130410 10:44]:
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>
> OK thanks. Noticed few minor things, see below.
Thanks on the checkup
>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
>>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>
> It might be worth clarifying that this is especially for the board
> specific clocks initially. The fixed clocks are currently found via
> the clock aliases table.
Ack.
[...]
>
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>
> The #clock-cells in the auxclk3 example should also be 0 instead of 1
> AFAIK. We should only use #clock-cells = <1> when the same physical
> clock provides multiple outputs. I believe the auxclocks are all separate,
> but that needs to be verified.
Oops.. my bad. you are correct here - auxclk is single output. all of them.
will fix.
[...]
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>
> It seems that at least for now we can assume the naming will stay
> that way, then if we need other rules for finding clocks, we can
> add omap_match_clock() function or something.
ack.
>
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>
> We can avoid the concern of storing the struct clk * and do the
> look up lazily on consumer driver probe by setting a dummy struct
> clk * here. Then replace of_clk_src_simple_get() with a custom
> omap_clk_src_get() that does the lookup and replaces the struct
> clk * with the real one.
Hmm.. this is interesting. will give it a try. Thanks on the suggestion.
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 19:19 ` Nishanth Menon
@ 2013-04-10 20:21 ` Tony Lindgren
-1 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-10 20:21 UTC (permalink / raw)
To: Nishanth Menon
Cc: Roger Quadros, Mike Turquette, linux-usb,
Russell King - ARM Linux, devicetree-discuss, lkml, balbi,
grygorii.strashko, linux-omap,
linux-arm-kernel@lists.infradead.org
* Nishanth Menon <nm@ti.com> [130410 12:23]:
> On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren <tony@atomide.com> wrote:
> >
> > We can avoid the concern of storing the struct clk * and do the
> > look up lazily on consumer driver probe by setting a dummy struct
> > clk * here. Then replace of_clk_src_simple_get() with a custom
> > omap_clk_src_get() that does the lookup and replaces the struct
> > clk * with the real one.
> Hmm.. this is interesting. will give it a try. Thanks on the suggestion.
Setting the struct clk * to NULL initially might work too, but that
needs to be checked.
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread
* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-10 20:21 ` Tony Lindgren
0 siblings, 0 replies; 117+ messages in thread
From: Tony Lindgren @ 2013-04-10 20:21 UTC (permalink / raw)
To: linux-arm-kernel
* Nishanth Menon <nm@ti.com> [130410 12:23]:
> On Wed, Apr 10, 2013 at 1:49 PM, Tony Lindgren <tony@atomide.com> wrote:
> >
> > We can avoid the concern of storing the struct clk * and do the
> > look up lazily on consumer driver probe by setting a dummy struct
> > clk * here. Then replace of_clk_src_simple_get() with a custom
> > omap_clk_src_get() that does the lookup and replaces the struct
> > clk * with the real one.
> Hmm.. this is interesting. will give it a try. Thanks on the suggestion.
Setting the struct clk * to NULL initially might work too, but that
needs to be checked.
Regards,
Tony
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 17:39 ` Nishanth Menon
(?)
@ 2013-04-11 7:48 ` Roger Quadros
-1 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-11 7:48 UTC (permalink / raw)
To: Nishanth Menon
Cc: grygorii.strashko-l0cyMroinI0, linux-lFZ/pmaqli7XmaaqVzeoHQ,
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, balbi-l0cyMroinI0,
Mike Turquette, linux-omap-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r
On 04/10/2013 08:39 PM, Nishanth Menon wrote:
> On 13:55-20130410, Roger Quadros wrote:
>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>> * Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> [130409 09:54]:
>>>>>> * Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org> [130409 03:00]:
>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>
>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>
>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>> a phandle or an index to the clock.
>>>>>>>
>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>
>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>> remap the DT device initially so the board specific clock is
>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>> data from /lib/firmware.
>>>>>
>>>>> Actually probably the driver/clock/omap can even do even less
>>>>> initially. There probably even no need to remap clocks there.
>>>>>
>>>>> As long as the DT clock driver understands that a board specific
>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>
>>>>> Then other features can be added later on like to allocate a
>>>>> clock entirely based on the binding etc.
>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>> instead, I am forced to do clock = <&clk 249>;
>>>>
>>>
>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>
>>
>> Awesome. Thanks for pointing this out Mike.
>>
>> Now all we need to do is create a named define for each clock index in the
>> header file.
> Approach #3: Thanks to Tony for collaborating on this:
> Works for cpufreq-cpu0 - additional patches:
> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
> beagleXM)
> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
> this.
> Details in the patch below (Tony, I have added you as collaborator for
> helping in getting this working-clk_add_alias was'nt needed in the
> internal patch discussion we had - I have taken a bit of freedom in
> adding your contributions to the patch below)
>
> Folks, this does seem to be the best compromise we can achieve at this
> point in time. feedback on this approach is much appreciated - if folks
> are ok, I can post this as an formal patch series.
This looks fine to me. Minor comments below.
>
> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>
> Date: Tue, 9 Apr 2013 19:26:40 -0500
> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
> data
>
> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
> However, this presents an obstacle for using these clock nodes in
> Device Tree definitions. There are many possible approaches to this
> problem as discussed in the following thread:
> http://marc.info/?t=136370325600009&r=1&w=2
> Highlights of the options:
> a) device specific clk_add_alias:
> cons: driver handling required
> b) using an generic clk node and indexing to reach the clock required.
> This is similar in approach taken by tegra and few other platforms.
> example clock = <&clk 5>;
> cons: potential to have mismatches in indexed table and associated
> dtb data. In addition, managing continued documentation in bindings
> as clock indexing increases. Even though readability angle could be
> improved by using preprocessing of DT using macros, indexed approach
> is inherently risky from cases like the following:
> clk indexes in kernel:
> 1 - mpu_dpll
> 2 - aux_clk1
> 3 - core_clk
> DT entry for peripheral x uses <&clk 2>, kernel updates to:
> 1 - mpu_dpll
> 2 - per_dpll
> 3 - aux_clk1
> 4 - core_clk
> using the old dtb(or dts missing an update), on new kernel which has
> updated indices will result in per_dpll now controlled for peripheral
> X without warning or any potential error detection and warning.
>
> Even though we can claim this is user error, such errors are hard to
> track down and fix.
>
> An alternate approach introduced here is to introduce device tree bindings
> corresponding to the clock nodes required in DT definition for SoC which
> automatically maps back to the definitions in cclockXYZ_data.c.
>
> The driver introduced here to do this mapping will eventually be the
> place where the clock handling will migrate to. We need to consider this
> angle as well so that the solution will be an valid transition point for
> moving the clock data out of kernel image (into device tree or firmware load
> etc..).
>
> Overall strategy introduced here is simple: an clock node described in
typo: "an"->"a"
> device tree blob is used to identify the exact clock provided in the SoC
> specific data. This is then linked back using of_clk_add_provider to the
> device node to be accessible by of_clk_get.
>
> Based on discussion contributions from Roger Quadros, Grygorii Strashko
> and others.
>
> [tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org: co-developed]
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> Signed-off-by: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>
> ---
> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
> drivers/clk/Makefile | 1 +
> drivers/clk/omap/Makefile | 1 +
> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
> 4 files changed, 136 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
> create mode 100644 drivers/clk/omap/Makefile
> create mode 100644 drivers/clk/omap/clk.c
>
> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
> new file mode 100644
> index 0000000..07e3ff8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
> @@ -0,0 +1,40 @@
> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
> +
> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
> +OMAP clock data out of kernel image.
> +
> +This binding uses the common clock binding[1].
> +
> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> +
> +Required properties:
> +- compatible : shall be "ti,omap-clock"
> +- #clock-cells : from common clock binding; shall be set to 0.
> +NOTE:
> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
> +Since all clocks are described with _ck, the node name is optimized to drop the
> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
> +
> +Example #1: describing clock node for CPU on OMAP34xx platform:
> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
> +describes the CPU clock to be as follows
> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
> +Corresponding binding will be:
> + dpll1: dpll1 {
> + #clock-cells = <0>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&dpll1>;
> +
> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
> +describes the auxclk3 clock to be as follows:
> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
> +Corresponding binding will be:
> + auxclk3: auxclk3 {
> + #clock-cells = <1>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&auxclk3>;
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..a0209d7 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
> obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_ARCH_OMAP) += omap/
>
> obj-$(CONFIG_X86) += x86/
>
> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
> new file mode 100644
> index 0000000..8195931
> --- /dev/null
> +++ b/drivers/clk/omap/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
missing e-mail id.
> + * Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> + *
> + * 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/clkdev.h>
> +#include <linux/clk-private.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/string.h>
> +
> +static const struct of_device_id omap_clk_of_match[] = {
> + {.compatible = "ti,omap-clock",},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
> +
Is this driver ever going to be a loadable module? If not then you don't need this.
> +/**
> + * omap_clk_probe() - create link from DT definition to clock data
> + * @pdev: device node
> + *
> + * REVISIT: We are now assuming the following:
> + * 1. omap clock names end with _ck
> + * 2. omap clocks don't get removed
> + */
> +static int omap_clk_probe(struct platform_device *pdev)
> +{
> + struct clk *clk;
> + int res;
> +
> + const struct of_device_id *match;
> + struct device_node *np = pdev->dev.of_node;
> + char clk_name[32];
> +
> + match = of_match_device(omap_clk_of_match, &pdev->dev);
> +
> + /* Set up things so consumer can call clk_get() with name */
> + snprintf(clk_name, 32, "%s_ck", np->name);
> + clk = clk_get(NULL, clk_name);
> + if (IS_ERR(clk)) {
> + res = PTR_ERR(clk);
> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
> + clk_name, res);
> + goto out;
> + }
> +
> + /* This allows the driver to of_clk_get() */
> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
> + if (res)
> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
> + clk_name, res);
> +
> + clk_put(clk);
> +out:
> + return res;
> +}
> +
> +MODULE_ALIAS("platform:omap_clk");
ditto.
> +
> +/* We assume here that OMAP clocks will not be removed */
> +static struct platform_driver omap_clk_driver = {
> + .probe = omap_clk_probe,
> + .driver = {
> + .name = "omap_clk",
> + .owner = THIS_MODULE,
same here.
> + .of_match_table = of_match_ptr(omap_clk_of_match),
> + },
> +};
> +
> +static int __init omap_clk_init(void)
> +{
> + return platform_driver_register(&omap_clk_driver);
> +}
> +
> +arch_initcall(omap_clk_init);
> +
> +MODULE_DESCRIPTION("OMAP Clock driver");
> +MODULE_AUTHOR("Texas Instruments Inc.");
> +MODULE_LICENSE("GPL v2");
>
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 7:48 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-11 7:48 UTC (permalink / raw)
To: Nishanth Menon
Cc: Mike Turquette, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, grygorii.strashko,
linux-omap, linux-arm-kernel
On 04/10/2013 08:39 PM, Nishanth Menon wrote:
> On 13:55-20130410, Roger Quadros wrote:
>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>
>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>
>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>> a phandle or an index to the clock.
>>>>>>>
>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>
>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>> remap the DT device initially so the board specific clock is
>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>> data from /lib/firmware.
>>>>>
>>>>> Actually probably the driver/clock/omap can even do even less
>>>>> initially. There probably even no need to remap clocks there.
>>>>>
>>>>> As long as the DT clock driver understands that a board specific
>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>
>>>>> Then other features can be added later on like to allocate a
>>>>> clock entirely based on the binding etc.
>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>> instead, I am forced to do clock = <&clk 249>;
>>>>
>>>
>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>
>>
>> Awesome. Thanks for pointing this out Mike.
>>
>> Now all we need to do is create a named define for each clock index in the
>> header file.
> Approach #3: Thanks to Tony for collaborating on this:
> Works for cpufreq-cpu0 - additional patches:
> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
> beagleXM)
> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
> this.
> Details in the patch below (Tony, I have added you as collaborator for
> helping in getting this working-clk_add_alias was'nt needed in the
> internal patch discussion we had - I have taken a bit of freedom in
> adding your contributions to the patch below)
>
> Folks, this does seem to be the best compromise we can achieve at this
> point in time. feedback on this approach is much appreciated - if folks
> are ok, I can post this as an formal patch series.
This looks fine to me. Minor comments below.
>
> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 9 Apr 2013 19:26:40 -0500
> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
> data
>
> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
> However, this presents an obstacle for using these clock nodes in
> Device Tree definitions. There are many possible approaches to this
> problem as discussed in the following thread:
> http://marc.info/?t=136370325600009&r=1&w=2
> Highlights of the options:
> a) device specific clk_add_alias:
> cons: driver handling required
> b) using an generic clk node and indexing to reach the clock required.
> This is similar in approach taken by tegra and few other platforms.
> example clock = <&clk 5>;
> cons: potential to have mismatches in indexed table and associated
> dtb data. In addition, managing continued documentation in bindings
> as clock indexing increases. Even though readability angle could be
> improved by using preprocessing of DT using macros, indexed approach
> is inherently risky from cases like the following:
> clk indexes in kernel:
> 1 - mpu_dpll
> 2 - aux_clk1
> 3 - core_clk
> DT entry for peripheral x uses <&clk 2>, kernel updates to:
> 1 - mpu_dpll
> 2 - per_dpll
> 3 - aux_clk1
> 4 - core_clk
> using the old dtb(or dts missing an update), on new kernel which has
> updated indices will result in per_dpll now controlled for peripheral
> X without warning or any potential error detection and warning.
>
> Even though we can claim this is user error, such errors are hard to
> track down and fix.
>
> An alternate approach introduced here is to introduce device tree bindings
> corresponding to the clock nodes required in DT definition for SoC which
> automatically maps back to the definitions in cclockXYZ_data.c.
>
> The driver introduced here to do this mapping will eventually be the
> place where the clock handling will migrate to. We need to consider this
> angle as well so that the solution will be an valid transition point for
> moving the clock data out of kernel image (into device tree or firmware load
> etc..).
>
> Overall strategy introduced here is simple: an clock node described in
typo: "an"->"a"
> device tree blob is used to identify the exact clock provided in the SoC
> specific data. This is then linked back using of_clk_add_provider to the
> device node to be accessible by of_clk_get.
>
> Based on discussion contributions from Roger Quadros, Grygorii Strashko
> and others.
>
> [tony@atomide.com: co-developed]
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
> drivers/clk/Makefile | 1 +
> drivers/clk/omap/Makefile | 1 +
> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
> 4 files changed, 136 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
> create mode 100644 drivers/clk/omap/Makefile
> create mode 100644 drivers/clk/omap/clk.c
>
> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
> new file mode 100644
> index 0000000..07e3ff8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
> @@ -0,0 +1,40 @@
> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
> +
> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
> +OMAP clock data out of kernel image.
> +
> +This binding uses the common clock binding[1].
> +
> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> +
> +Required properties:
> +- compatible : shall be "ti,omap-clock"
> +- #clock-cells : from common clock binding; shall be set to 0.
> +NOTE:
> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
> +Since all clocks are described with _ck, the node name is optimized to drop the
> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
> +
> +Example #1: describing clock node for CPU on OMAP34xx platform:
> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
> +describes the CPU clock to be as follows
> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
> +Corresponding binding will be:
> + dpll1: dpll1 {
> + #clock-cells = <0>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&dpll1>;
> +
> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
> +describes the auxclk3 clock to be as follows:
> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
> +Corresponding binding will be:
> + auxclk3: auxclk3 {
> + #clock-cells = <1>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&auxclk3>;
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..a0209d7 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
> obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_ARCH_OMAP) += omap/
>
> obj-$(CONFIG_X86) += x86/
>
> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
> new file mode 100644
> index 0000000..8195931
> --- /dev/null
> +++ b/drivers/clk/omap/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
missing e-mail id.
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/string.h>
> +
> +static const struct of_device_id omap_clk_of_match[] = {
> + {.compatible = "ti,omap-clock",},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
> +
Is this driver ever going to be a loadable module? If not then you don't need this.
> +/**
> + * omap_clk_probe() - create link from DT definition to clock data
> + * @pdev: device node
> + *
> + * REVISIT: We are now assuming the following:
> + * 1. omap clock names end with _ck
> + * 2. omap clocks don't get removed
> + */
> +static int omap_clk_probe(struct platform_device *pdev)
> +{
> + struct clk *clk;
> + int res;
> +
> + const struct of_device_id *match;
> + struct device_node *np = pdev->dev.of_node;
> + char clk_name[32];
> +
> + match = of_match_device(omap_clk_of_match, &pdev->dev);
> +
> + /* Set up things so consumer can call clk_get() with name */
> + snprintf(clk_name, 32, "%s_ck", np->name);
> + clk = clk_get(NULL, clk_name);
> + if (IS_ERR(clk)) {
> + res = PTR_ERR(clk);
> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
> + clk_name, res);
> + goto out;
> + }
> +
> + /* This allows the driver to of_clk_get() */
> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
> + if (res)
> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
> + clk_name, res);
> +
> + clk_put(clk);
> +out:
> + return res;
> +}
> +
> +MODULE_ALIAS("platform:omap_clk");
ditto.
> +
> +/* We assume here that OMAP clocks will not be removed */
> +static struct platform_driver omap_clk_driver = {
> + .probe = omap_clk_probe,
> + .driver = {
> + .name = "omap_clk",
> + .owner = THIS_MODULE,
same here.
> + .of_match_table = of_match_ptr(omap_clk_of_match),
> + },
> +};
> +
> +static int __init omap_clk_init(void)
> +{
> + return platform_driver_register(&omap_clk_driver);
> +}
> +
> +arch_initcall(omap_clk_init);
> +
> +MODULE_DESCRIPTION("OMAP Clock driver");
> +MODULE_AUTHOR("Texas Instruments Inc.");
> +MODULE_LICENSE("GPL v2");
>
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 7:48 ` Roger Quadros
0 siblings, 0 replies; 117+ messages in thread
From: Roger Quadros @ 2013-04-11 7:48 UTC (permalink / raw)
To: linux-arm-kernel
On 04/10/2013 08:39 PM, Nishanth Menon wrote:
> On 13:55-20130410, Roger Quadros wrote:
>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>
>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>
>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>> a phandle or an index to the clock.
>>>>>>>
>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>
>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>> remap the DT device initially so the board specific clock is
>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>> data from /lib/firmware.
>>>>>
>>>>> Actually probably the driver/clock/omap can even do even less
>>>>> initially. There probably even no need to remap clocks there.
>>>>>
>>>>> As long as the DT clock driver understands that a board specific
>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>
>>>>> Then other features can be added later on like to allocate a
>>>>> clock entirely based on the binding etc.
>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>> instead, I am forced to do clock = <&clk 249>;
>>>>
>>>
>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>
>>
>> Awesome. Thanks for pointing this out Mike.
>>
>> Now all we need to do is create a named define for each clock index in the
>> header file.
> Approach #3: Thanks to Tony for collaborating on this:
> Works for cpufreq-cpu0 - additional patches:
> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
> beagleXM)
> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
> this.
> Details in the patch below (Tony, I have added you as collaborator for
> helping in getting this working-clk_add_alias was'nt needed in the
> internal patch discussion we had - I have taken a bit of freedom in
> adding your contributions to the patch below)
>
> Folks, this does seem to be the best compromise we can achieve at this
> point in time. feedback on this approach is much appreciated - if folks
> are ok, I can post this as an formal patch series.
This looks fine to me. Minor comments below.
>
> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
> From: Nishanth Menon <nm@ti.com>
> Date: Tue, 9 Apr 2013 19:26:40 -0500
> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
> data
>
> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
> However, this presents an obstacle for using these clock nodes in
> Device Tree definitions. There are many possible approaches to this
> problem as discussed in the following thread:
> http://marc.info/?t=136370325600009&r=1&w=2
> Highlights of the options:
> a) device specific clk_add_alias:
> cons: driver handling required
> b) using an generic clk node and indexing to reach the clock required.
> This is similar in approach taken by tegra and few other platforms.
> example clock = <&clk 5>;
> cons: potential to have mismatches in indexed table and associated
> dtb data. In addition, managing continued documentation in bindings
> as clock indexing increases. Even though readability angle could be
> improved by using preprocessing of DT using macros, indexed approach
> is inherently risky from cases like the following:
> clk indexes in kernel:
> 1 - mpu_dpll
> 2 - aux_clk1
> 3 - core_clk
> DT entry for peripheral x uses <&clk 2>, kernel updates to:
> 1 - mpu_dpll
> 2 - per_dpll
> 3 - aux_clk1
> 4 - core_clk
> using the old dtb(or dts missing an update), on new kernel which has
> updated indices will result in per_dpll now controlled for peripheral
> X without warning or any potential error detection and warning.
>
> Even though we can claim this is user error, such errors are hard to
> track down and fix.
>
> An alternate approach introduced here is to introduce device tree bindings
> corresponding to the clock nodes required in DT definition for SoC which
> automatically maps back to the definitions in cclockXYZ_data.c.
>
> The driver introduced here to do this mapping will eventually be the
> place where the clock handling will migrate to. We need to consider this
> angle as well so that the solution will be an valid transition point for
> moving the clock data out of kernel image (into device tree or firmware load
> etc..).
>
> Overall strategy introduced here is simple: an clock node described in
typo: "an"->"a"
> device tree blob is used to identify the exact clock provided in the SoC
> specific data. This is then linked back using of_clk_add_provider to the
> device node to be accessible by of_clk_get.
>
> Based on discussion contributions from Roger Quadros, Grygorii Strashko
> and others.
>
> [tony at atomide.com: co-developed]
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
> drivers/clk/Makefile | 1 +
> drivers/clk/omap/Makefile | 1 +
> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
> 4 files changed, 136 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
> create mode 100644 drivers/clk/omap/Makefile
> create mode 100644 drivers/clk/omap/clk.c
>
> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
> new file mode 100644
> index 0000000..07e3ff8
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
> @@ -0,0 +1,40 @@
> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
> +
> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
> +OMAP clock data out of kernel image.
> +
> +This binding uses the common clock binding[1].
> +
> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
> +
> +Required properties:
> +- compatible : shall be "ti,omap-clock"
> +- #clock-cells : from common clock binding; shall be set to 0.
> +NOTE:
> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
> +Since all clocks are described with _ck, the node name is optimized to drop the
> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
> +
> +Example #1: describing clock node for CPU on OMAP34xx platform:
> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
> +describes the CPU clock to be as follows
> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
> +Corresponding binding will be:
> + dpll1: dpll1 {
> + #clock-cells = <0>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&dpll1>;
> +
> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
> +describes the auxclk3 clock to be as follows:
> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
> +Corresponding binding will be:
> + auxclk3: auxclk3 {
> + #clock-cells = <1>;
> + compatible = "ti,omap-clock";
> + };
> +And it's usage will be:
> + clocks = <&auxclk3>;
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 300d477..a0209d7 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
> obj-$(CONFIG_ARCH_TEGRA) += tegra/
> +obj-$(CONFIG_ARCH_OMAP) += omap/
>
> obj-$(CONFIG_X86) += x86/
>
> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
> new file mode 100644
> index 0000000..8195931
> --- /dev/null
> +++ b/drivers/clk/omap/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
missing e-mail id.
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/string.h>
> +
> +static const struct of_device_id omap_clk_of_match[] = {
> + {.compatible = "ti,omap-clock",},
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
> +
Is this driver ever going to be a loadable module? If not then you don't need this.
> +/**
> + * omap_clk_probe() - create link from DT definition to clock data
> + * @pdev: device node
> + *
> + * REVISIT: We are now assuming the following:
> + * 1. omap clock names end with _ck
> + * 2. omap clocks don't get removed
> + */
> +static int omap_clk_probe(struct platform_device *pdev)
> +{
> + struct clk *clk;
> + int res;
> +
> + const struct of_device_id *match;
> + struct device_node *np = pdev->dev.of_node;
> + char clk_name[32];
> +
> + match = of_match_device(omap_clk_of_match, &pdev->dev);
> +
> + /* Set up things so consumer can call clk_get() with name */
> + snprintf(clk_name, 32, "%s_ck", np->name);
> + clk = clk_get(NULL, clk_name);
> + if (IS_ERR(clk)) {
> + res = PTR_ERR(clk);
> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
> + clk_name, res);
> + goto out;
> + }
> +
> + /* This allows the driver to of_clk_get() */
> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
> + if (res)
> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
> + clk_name, res);
> +
> + clk_put(clk);
> +out:
> + return res;
> +}
> +
> +MODULE_ALIAS("platform:omap_clk");
ditto.
> +
> +/* We assume here that OMAP clocks will not be removed */
> +static struct platform_driver omap_clk_driver = {
> + .probe = omap_clk_probe,
> + .driver = {
> + .name = "omap_clk",
> + .owner = THIS_MODULE,
same here.
> + .of_match_table = of_match_ptr(omap_clk_of_match),
> + },
> +};
> +
> +static int __init omap_clk_init(void)
> +{
> + return platform_driver_register(&omap_clk_driver);
> +}
> +
> +arch_initcall(omap_clk_init);
> +
> +MODULE_DESCRIPTION("OMAP Clock driver");
> +MODULE_AUTHOR("Texas Instruments Inc.");
> +MODULE_LICENSE("GPL v2");
>
cheers,
-roger
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-11 7:48 ` Roger Quadros
(?)
@ 2013-04-11 9:04 ` Grygorii Strashko
-1 siblings, 0 replies; 117+ messages in thread
From: Grygorii Strashko @ 2013-04-11 9:04 UTC (permalink / raw)
To: Roger Quadros
Cc: Nishanth Menon, Mike Turquette, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, linux-omap,
linux-arm-kernel
On 04/11/2013 10:48 AM, Roger Quadros wrote:
> On 04/10/2013 08:39 PM, Nishanth Menon wrote:
>> On 13:55-20130410, Roger Quadros wrote:
>>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>>> a phandle or an index to the clock.
>>>>>>>>
>>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>>> remap the DT device initially so the board specific clock is
>>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>>> data from /lib/firmware.
>>>>>> Actually probably the driver/clock/omap can even do even less
>>>>>> initially. There probably even no need to remap clocks there.
>>>>>>
>>>>>> As long as the DT clock driver understands that a board specific
>>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>>
>>>>>> Then other features can be added later on like to allocate a
>>>>>> clock entirely based on the binding etc.
>>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>>> instead, I am forced to do clock = <&clk 249>;
>>>>>
>>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>>
>>> Awesome. Thanks for pointing this out Mike.
>>>
>>> Now all we need to do is create a named define for each clock index in the
>>> header file.
>> Approach #3: Thanks to Tony for collaborating on this:
>> Works for cpufreq-cpu0 - additional patches:
>> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
>> beagleXM)
>> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
>> this.
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
> This looks fine to me. Minor comments below.
I like it. No IDs and can add clocks support in DT as needed.
>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>> Highlights of the options:
>> a) device specific clk_add_alias:
>> cons: driver handling required
>> b) using an generic clk node and indexing to reach the clock required.
>> This is similar in approach taken by tegra and few other platforms.
>> example clock = <&clk 5>;
>> cons: potential to have mismatches in indexed table and associated
>> dtb data. In addition, managing continued documentation in bindings
>> as clock indexing increases. Even though readability angle could be
>> improved by using preprocessing of DT using macros, indexed approach
>> is inherently risky from cases like the following:
>> clk indexes in kernel:
>> 1 - mpu_dpll
>> 2 - aux_clk1
>> 3 - core_clk
>> DT entry for peripheral x uses <&clk 2>, kernel updates to:
>> 1 - mpu_dpll
>> 2 - per_dpll
>> 3 - aux_clk1
>> 4 - core_clk
>> using the old dtb(or dts missing an update), on new kernel which has
>> updated indices will result in per_dpll now controlled for peripheral
>> X without warning or any potential error detection and warning.
>>
>> Even though we can claim this is user error, such errors are hard to
>> track down and fix.
>>
>> An alternate approach introduced here is to introduce device tree bindings
>> corresponding to the clock nodes required in DT definition for SoC which
>> automatically maps back to the definitions in cclockXYZ_data.c.
>>
>> The driver introduced here to do this mapping will eventually be the
>> place where the clock handling will migrate to. We need to consider this
>> angle as well so that the solution will be an valid transition point for
>> moving the clock data out of kernel image (into device tree or firmware load
>> etc..).
>>
>> Overall strategy introduced here is simple: an clock node described in
> typo: "an"->"a"
>
>> device tree blob is used to identify the exact clock provided in the SoC
>> specific data. This is then linked back using of_clk_add_provider to the
>> device node to be accessible by of_clk_get.
>>
>> Based on discussion contributions from Roger Quadros, Grygorii Strashko
>> and others.
>>
>> [tony@atomide.com: co-developed]
>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
>> drivers/clk/Makefile | 1 +
>> drivers/clk/omap/Makefile | 1 +
>> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
>> 4 files changed, 136 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
>> create mode 100644 drivers/clk/omap/Makefile
>> create mode 100644 drivers/clk/omap/clk.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> new file mode 100644
>> index 0000000..07e3ff8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> @@ -0,0 +1,40 @@
>> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
>> +
>> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
>> +OMAP clock data out of kernel image.
>> +
>> +This binding uses the common clock binding[1].
>> +
>> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +
>> +Required properties:
>> +- compatible : shall be "ti,omap-clock"
>> +- #clock-cells : from common clock binding; shall be set to 0.
>> +NOTE:
>> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
>> +Since all clocks are described with _ck, the node name is optimized to drop the
>> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
>> +
>> +Example #1: describing clock node for CPU on OMAP34xx platform:
>> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
>> +describes the CPU clock to be as follows
>> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
>> +Corresponding binding will be:
>> + dpll1: dpll1 {
>> + #clock-cells = <0>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&dpll1>;
>> +
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..a0209d7 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
>> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
>> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
>> obj-$(CONFIG_ARCH_TEGRA) += tegra/
>> +obj-$(CONFIG_ARCH_OMAP) += omap/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
>> new file mode 100644
>> index 0000000..8195931
>> --- /dev/null
>> +++ b/drivers/clk/omap/Makefile
>> @@ -0,0 +1 @@
>> +obj-y += clk.o
>> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
>> new file mode 100644
>> index 0000000..63a4cce
>> --- /dev/null
>> +++ b/drivers/clk/omap/clk.c
>> @@ -0,0 +1,94 @@
>> +/*
>> + * Texas Instruments OMAP Clock driver
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
> missing e-mail id.
>
>> + * Tony Lindgren <tony@atomide.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/clkdev.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/string.h>
>> +
>> +static const struct of_device_id omap_clk_of_match[] = {
>> + {.compatible = "ti,omap-clock",},
>> + {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
>> +
> Is this driver ever going to be a loadable module? If not then you don't need this.
>
>> +/**
>> + * omap_clk_probe() - create link from DT definition to clock data
>> + * @pdev: device node
>> + *
>> + * REVISIT: We are now assuming the following:
>> + * 1. omap clock names end with _ck
>> + * 2. omap clocks don't get removed
>> + */
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>> +
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>> +
>> +MODULE_ALIAS("platform:omap_clk");
> ditto.
>
>> +
>> +/* We assume here that OMAP clocks will not be removed */
>> +static struct platform_driver omap_clk_driver = {
>> + .probe = omap_clk_probe,
>> + .driver = {
>> + .name = "omap_clk",
>> + .owner = THIS_MODULE,
> same here.
>
>> + .of_match_table = of_match_ptr(omap_clk_of_match),
>> + },
>> +};
>> +
>> +static int __init omap_clk_init(void)
>> +{
>> + return platform_driver_register(&omap_clk_driver);
>> +}
>> +
>> +arch_initcall(omap_clk_init);
>> +
>> +MODULE_DESCRIPTION("OMAP Clock driver");
>> +MODULE_AUTHOR("Texas Instruments Inc.");
>> +MODULE_LICENSE("GPL v2");
>>
> cheers,
> -roger
-grygorii
^ permalink raw reply [flat|nested] 117+ messages in thread* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 9:04 ` Grygorii Strashko
0 siblings, 0 replies; 117+ messages in thread
From: Grygorii Strashko @ 2013-04-11 9:04 UTC (permalink / raw)
To: Roger Quadros
Cc: Nishanth Menon, Mike Turquette, Tony Lindgren, linux-usb, linux,
devicetree-discuss, linux-kernel, balbi, linux-omap,
linux-arm-kernel
On 04/11/2013 10:48 AM, Roger Quadros wrote:
> On 04/10/2013 08:39 PM, Nishanth Menon wrote:
>> On 13:55-20130410, Roger Quadros wrote:
>>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>>> a phandle or an index to the clock.
>>>>>>>>
>>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>>> remap the DT device initially so the board specific clock is
>>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>>> data from /lib/firmware.
>>>>>> Actually probably the driver/clock/omap can even do even less
>>>>>> initially. There probably even no need to remap clocks there.
>>>>>>
>>>>>> As long as the DT clock driver understands that a board specific
>>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>>
>>>>>> Then other features can be added later on like to allocate a
>>>>>> clock entirely based on the binding etc.
>>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>>> instead, I am forced to do clock = <&clk 249>;
>>>>>
>>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>>
>>> Awesome. Thanks for pointing this out Mike.
>>>
>>> Now all we need to do is create a named define for each clock index in the
>>> header file.
>> Approach #3: Thanks to Tony for collaborating on this:
>> Works for cpufreq-cpu0 - additional patches:
>> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
>> beagleXM)
>> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
>> this.
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
> This looks fine to me. Minor comments below.
I like it. No IDs and can add clocks support in DT as needed.
>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>> Highlights of the options:
>> a) device specific clk_add_alias:
>> cons: driver handling required
>> b) using an generic clk node and indexing to reach the clock required.
>> This is similar in approach taken by tegra and few other platforms.
>> example clock = <&clk 5>;
>> cons: potential to have mismatches in indexed table and associated
>> dtb data. In addition, managing continued documentation in bindings
>> as clock indexing increases. Even though readability angle could be
>> improved by using preprocessing of DT using macros, indexed approach
>> is inherently risky from cases like the following:
>> clk indexes in kernel:
>> 1 - mpu_dpll
>> 2 - aux_clk1
>> 3 - core_clk
>> DT entry for peripheral x uses <&clk 2>, kernel updates to:
>> 1 - mpu_dpll
>> 2 - per_dpll
>> 3 - aux_clk1
>> 4 - core_clk
>> using the old dtb(or dts missing an update), on new kernel which has
>> updated indices will result in per_dpll now controlled for peripheral
>> X without warning or any potential error detection and warning.
>>
>> Even though we can claim this is user error, such errors are hard to
>> track down and fix.
>>
>> An alternate approach introduced here is to introduce device tree bindings
>> corresponding to the clock nodes required in DT definition for SoC which
>> automatically maps back to the definitions in cclockXYZ_data.c.
>>
>> The driver introduced here to do this mapping will eventually be the
>> place where the clock handling will migrate to. We need to consider this
>> angle as well so that the solution will be an valid transition point for
>> moving the clock data out of kernel image (into device tree or firmware load
>> etc..).
>>
>> Overall strategy introduced here is simple: an clock node described in
> typo: "an"->"a"
>
>> device tree blob is used to identify the exact clock provided in the SoC
>> specific data. This is then linked back using of_clk_add_provider to the
>> device node to be accessible by of_clk_get.
>>
>> Based on discussion contributions from Roger Quadros, Grygorii Strashko
>> and others.
>>
>> [tony@atomide.com: co-developed]
>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
>> drivers/clk/Makefile | 1 +
>> drivers/clk/omap/Makefile | 1 +
>> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
>> 4 files changed, 136 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
>> create mode 100644 drivers/clk/omap/Makefile
>> create mode 100644 drivers/clk/omap/clk.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> new file mode 100644
>> index 0000000..07e3ff8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> @@ -0,0 +1,40 @@
>> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
>> +
>> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
>> +OMAP clock data out of kernel image.
>> +
>> +This binding uses the common clock binding[1].
>> +
>> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +
>> +Required properties:
>> +- compatible : shall be "ti,omap-clock"
>> +- #clock-cells : from common clock binding; shall be set to 0.
>> +NOTE:
>> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
>> +Since all clocks are described with _ck, the node name is optimized to drop the
>> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
>> +
>> +Example #1: describing clock node for CPU on OMAP34xx platform:
>> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
>> +describes the CPU clock to be as follows
>> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
>> +Corresponding binding will be:
>> + dpll1: dpll1 {
>> + #clock-cells = <0>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&dpll1>;
>> +
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..a0209d7 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
>> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
>> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
>> obj-$(CONFIG_ARCH_TEGRA) += tegra/
>> +obj-$(CONFIG_ARCH_OMAP) += omap/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
>> new file mode 100644
>> index 0000000..8195931
>> --- /dev/null
>> +++ b/drivers/clk/omap/Makefile
>> @@ -0,0 +1 @@
>> +obj-y += clk.o
>> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
>> new file mode 100644
>> index 0000000..63a4cce
>> --- /dev/null
>> +++ b/drivers/clk/omap/clk.c
>> @@ -0,0 +1,94 @@
>> +/*
>> + * Texas Instruments OMAP Clock driver
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
> missing e-mail id.
>
>> + * Tony Lindgren <tony@atomide.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/clkdev.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/string.h>
>> +
>> +static const struct of_device_id omap_clk_of_match[] = {
>> + {.compatible = "ti,omap-clock",},
>> + {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
>> +
> Is this driver ever going to be a loadable module? If not then you don't need this.
>
>> +/**
>> + * omap_clk_probe() - create link from DT definition to clock data
>> + * @pdev: device node
>> + *
>> + * REVISIT: We are now assuming the following:
>> + * 1. omap clock names end with _ck
>> + * 2. omap clocks don't get removed
>> + */
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>> +
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>> +
>> +MODULE_ALIAS("platform:omap_clk");
> ditto.
>
>> +
>> +/* We assume here that OMAP clocks will not be removed */
>> +static struct platform_driver omap_clk_driver = {
>> + .probe = omap_clk_probe,
>> + .driver = {
>> + .name = "omap_clk",
>> + .owner = THIS_MODULE,
> same here.
>
>> + .of_match_table = of_match_ptr(omap_clk_of_match),
>> + },
>> +};
>> +
>> +static int __init omap_clk_init(void)
>> +{
>> + return platform_driver_register(&omap_clk_driver);
>> +}
>> +
>> +arch_initcall(omap_clk_init);
>> +
>> +MODULE_DESCRIPTION("OMAP Clock driver");
>> +MODULE_AUTHOR("Texas Instruments Inc.");
>> +MODULE_LICENSE("GPL v2");
>>
> cheers,
> -roger
-grygorii
^ permalink raw reply [flat|nested] 117+ messages in thread* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 9:04 ` Grygorii Strashko
0 siblings, 0 replies; 117+ messages in thread
From: Grygorii Strashko @ 2013-04-11 9:04 UTC (permalink / raw)
To: linux-arm-kernel
On 04/11/2013 10:48 AM, Roger Quadros wrote:
> On 04/10/2013 08:39 PM, Nishanth Menon wrote:
>> On 13:55-20130410, Roger Quadros wrote:
>>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>>>>> On 10:43-20130409, Tony Lindgren wrote:
>>>>>> * Tony Lindgren <tony@atomide.com> [130409 09:54]:
>>>>>>> * Roger Quadros <rogerq@ti.com> [130409 03:00]:
>>>>>>>> On 04/05/2013 06:58 PM, Tony Lindgren wrote:
>>>>>>>>> Can't you just use the clock name there to get it?
>>>>>>>> In device tree we don't pass around clock names. You can either get
>>>>>>>> a phandle or an index to the clock.
>>>>>>>>
>>>>>>>> e.g. Documentation/devicetree/bindings/clock/imx31-clock.txt
>>>>>>> Yes I understand that. But the driver/clock/omap driver can just
>>>>>>> remap the DT device initially so the board specific clock is
>>>>>>> found from the clock alias table. Basically initially a passthrough
>>>>>>> driver that can be enhanced to parse DT clock bindings and load
>>>>>>> data from /lib/firmware.
>>>>>> Actually probably the driver/clock/omap can even do even less
>>>>>> initially. There probably even no need to remap clocks there.
>>>>>>
>>>>>> As long as the DT clock driver understands that a board specific
>>>>>> auxclk is specified in the DT it can just call clk_add_alias() so
>>>>>> the driver will get the right auxclk from cclock44xx_data.c.
>>>>>>
>>>>>> Then other features can be added later on like to allocate a
>>>>>> clock entirely based on the binding etc.
>>>>> I did try to have an implementation for cpufreq using clock nodes.
>>>>> unfortunately, device tree wont let me have arguments of strings :(
>>>>> So, I am unable to do clock = <&clk mpu_dpll>;
>>>>> instead, I am forced to do clock = <&clk 249>;
>>>>>
>>>> See http://article.gmane.org/gmane.linux.ports.arm.kernel/229034
>>>>
>>> Awesome. Thanks for pointing this out Mike.
>>>
>>> Now all we need to do is create a named define for each clock index in the
>>> header file.
>> Approach #3: Thanks to Tony for collaborating on this:
>> Works for cpufreq-cpu0 - additional patches:
>> http://pastebin.com/GHnTRVJf, http://pastebin.com/FZS89J6L (tested on
>> beagleXM)
>> Work for USB - http://pastebin.com/aJpDnXci - thanks Roger for testing
>> this.
>> Details in the patch below (Tony, I have added you as collaborator for
>> helping in getting this working-clk_add_alias was'nt needed in the
>> internal patch discussion we had - I have taken a bit of freedom in
>> adding your contributions to the patch below)
>>
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
> This looks fine to me. Minor comments below.
I like it. No IDs and can add clocks support in DT as needed.
>
>> From 130a41821bf57081ca45ef654029175d173135e6 Mon Sep 17 00:00:00 2001
>> From: Nishanth Menon <nm@ti.com>
>> Date: Tue, 9 Apr 2013 19:26:40 -0500
>> Subject: [RFC PATCH] clk: OMAP: introduce device tree binding to kernel clock
>> data
>>
>> OMAP clock data is located in arch/arm/mach-omap2/cclockXYZ_data.c.
>> However, this presents an obstacle for using these clock nodes in
>> Device Tree definitions. There are many possible approaches to this
>> problem as discussed in the following thread:
>> http://marc.info/?t=136370325600009&r=1&w=2
>> Highlights of the options:
>> a) device specific clk_add_alias:
>> cons: driver handling required
>> b) using an generic clk node and indexing to reach the clock required.
>> This is similar in approach taken by tegra and few other platforms.
>> example clock = <&clk 5>;
>> cons: potential to have mismatches in indexed table and associated
>> dtb data. In addition, managing continued documentation in bindings
>> as clock indexing increases. Even though readability angle could be
>> improved by using preprocessing of DT using macros, indexed approach
>> is inherently risky from cases like the following:
>> clk indexes in kernel:
>> 1 - mpu_dpll
>> 2 - aux_clk1
>> 3 - core_clk
>> DT entry for peripheral x uses <&clk 2>, kernel updates to:
>> 1 - mpu_dpll
>> 2 - per_dpll
>> 3 - aux_clk1
>> 4 - core_clk
>> using the old dtb(or dts missing an update), on new kernel which has
>> updated indices will result in per_dpll now controlled for peripheral
>> X without warning or any potential error detection and warning.
>>
>> Even though we can claim this is user error, such errors are hard to
>> track down and fix.
>>
>> An alternate approach introduced here is to introduce device tree bindings
>> corresponding to the clock nodes required in DT definition for SoC which
>> automatically maps back to the definitions in cclockXYZ_data.c.
>>
>> The driver introduced here to do this mapping will eventually be the
>> place where the clock handling will migrate to. We need to consider this
>> angle as well so that the solution will be an valid transition point for
>> moving the clock data out of kernel image (into device tree or firmware load
>> etc..).
>>
>> Overall strategy introduced here is simple: an clock node described in
> typo: "an"->"a"
>
>> device tree blob is used to identify the exact clock provided in the SoC
>> specific data. This is then linked back using of_clk_add_provider to the
>> device node to be accessible by of_clk_get.
>>
>> Based on discussion contributions from Roger Quadros, Grygorii Strashko
>> and others.
>>
>> [tony at atomide.com: co-developed]
>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>> Signed-off-by: Nishanth Menon <nm@ti.com>
>> ---
>> .../devicetree/bindings/clock/omap-clock.txt | 40 +++++++++
>> drivers/clk/Makefile | 1 +
>> drivers/clk/omap/Makefile | 1 +
>> drivers/clk/omap/clk.c | 94 ++++++++++++++++++++
>> 4 files changed, 136 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/clock/omap-clock.txt
>> create mode 100644 drivers/clk/omap/Makefile
>> create mode 100644 drivers/clk/omap/clk.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/omap-clock.txt b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> new file mode 100644
>> index 0000000..07e3ff8
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/clock/omap-clock.txt
>> @@ -0,0 +1,40 @@
>> +Device Tree Clock bindings for Texas Instrument's OMAP compatible platforms
>> +
>> +This binding is a work-in-progress, and meant to be stage #1 of transitioning
>> +OMAP clock data out of kernel image.
>> +
>> +This binding uses the common clock binding[1].
>> +
>> +[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
>> +
>> +Required properties:
>> +- compatible : shall be "ti,omap-clock"
>> +- #clock-cells : from common clock binding; shall be set to 0.
>> +NOTE:
>> +node name should map to clock database in arch/arm/mach-omap2/cclock<SoC>_data.c
>> +Since all clocks are described with _ck, the node name is optimized to drop the
>> +usage of _ck. For example, a clock called dpll1_ck will be defined as dpll1.
>> +
>> +Example #1: describing clock node for CPU on OMAP34xx platform:
>> +Ref: arch/arm/mach-omap2/cclock3xxx_data.c
>> +describes the CPU clock to be as follows
>> + CLK(NULL, "dpll1_ck", &dpll1_ck, CK_3XXX),
>> +Corresponding binding will be:
>> + dpll1: dpll1 {
>> + #clock-cells = <0>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&dpll1>;
>> +
>> +Example #2: describing clock node for auxilary clock #3 on OMAP443x platform:
>> +Ref: arch/arm/mach-omap2/cclock44xx_data.c
>> +describes the auxclk3 clock to be as follows:
>> + CLK(NULL, "auxclk3_ck", &auxclk3_ck, CK_443X),
>> +Corresponding binding will be:
>> + auxclk3: auxclk3 {
>> + #clock-cells = <1>;
>> + compatible = "ti,omap-clock";
>> + };
>> +And it's usage will be:
>> + clocks = <&auxclk3>;
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 300d477..a0209d7 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -27,6 +27,7 @@ obj-$(CONFIG_ARCH_U8500) += ux500/
>> obj-$(CONFIG_ARCH_VT8500) += clk-vt8500.o
>> obj-$(CONFIG_ARCH_ZYNQ) += clk-zynq.o
>> obj-$(CONFIG_ARCH_TEGRA) += tegra/
>> +obj-$(CONFIG_ARCH_OMAP) += omap/
>>
>> obj-$(CONFIG_X86) += x86/
>>
>> diff --git a/drivers/clk/omap/Makefile b/drivers/clk/omap/Makefile
>> new file mode 100644
>> index 0000000..8195931
>> --- /dev/null
>> +++ b/drivers/clk/omap/Makefile
>> @@ -0,0 +1 @@
>> +obj-y += clk.o
>> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
>> new file mode 100644
>> index 0000000..63a4cce
>> --- /dev/null
>> +++ b/drivers/clk/omap/clk.c
>> @@ -0,0 +1,94 @@
>> +/*
>> + * Texas Instruments OMAP Clock driver
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
> missing e-mail id.
>
>> + * Tony Lindgren <tony@atomide.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/clkdev.h>
>> +#include <linux/clk-private.h>
>> +#include <linux/kernel.h>
>> +#include <linux/module.h>
>> +#include <linux/of_device.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/string.h>
>> +
>> +static const struct of_device_id omap_clk_of_match[] = {
>> + {.compatible = "ti,omap-clock",},
>> + {},
>> +};
>> +
>> +MODULE_DEVICE_TABLE(of, omap_clk_of_match);
>> +
> Is this driver ever going to be a loadable module? If not then you don't need this.
>
>> +/**
>> + * omap_clk_probe() - create link from DT definition to clock data
>> + * @pdev: device node
>> + *
>> + * REVISIT: We are now assuming the following:
>> + * 1. omap clock names end with _ck
>> + * 2. omap clocks don't get removed
>> + */
>> +static int omap_clk_probe(struct platform_device *pdev)
>> +{
>> + struct clk *clk;
>> + int res;
>> +
>> + const struct of_device_id *match;
>> + struct device_node *np = pdev->dev.of_node;
>> + char clk_name[32];
>> +
>> + match = of_match_device(omap_clk_of_match, &pdev->dev);
>> +
>> + /* Set up things so consumer can call clk_get() with name */
>> + snprintf(clk_name, 32, "%s_ck", np->name);
>> + clk = clk_get(NULL, clk_name);
>> + if (IS_ERR(clk)) {
>> + res = PTR_ERR(clk);
>> + dev_err(&pdev->dev, "could not get clock %s (%d)\n",
>> + clk_name, res);
>> + goto out;
>> + }
>> +
>> + /* This allows the driver to of_clk_get() */
>> + res = of_clk_add_provider(np, of_clk_src_simple_get, clk);
>> + if (res)
>> + dev_err(&pdev->dev, "could not add provider for %s (%d)\n",
>> + clk_name, res);
>> +
>> + clk_put(clk);
>> +out:
>> + return res;
>> +}
>> +
>> +MODULE_ALIAS("platform:omap_clk");
> ditto.
>
>> +
>> +/* We assume here that OMAP clocks will not be removed */
>> +static struct platform_driver omap_clk_driver = {
>> + .probe = omap_clk_probe,
>> + .driver = {
>> + .name = "omap_clk",
>> + .owner = THIS_MODULE,
> same here.
>
>> + .of_match_table = of_match_ptr(omap_clk_of_match),
>> + },
>> +};
>> +
>> +static int __init omap_clk_init(void)
>> +{
>> + return platform_driver_register(&omap_clk_driver);
>> +}
>> +
>> +arch_initcall(omap_clk_init);
>> +
>> +MODULE_DESCRIPTION("OMAP Clock driver");
>> +MODULE_AUTHOR("Texas Instruments Inc.");
>> +MODULE_LICENSE("GPL v2");
>>
> cheers,
> -roger
-grygorii
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-11 7:48 ` Roger Quadros
@ 2013-04-11 22:45 ` Nishanth Menon
-1 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-11 22:45 UTC (permalink / raw)
To: Roger Quadros
Cc: Mike Turquette, Tony Lindgren, linux-usb,
Russell King - ARM Linux, devicetree-discuss, lkml, balbi,
grygorii.strashko, linux-omap,
linux-arm-kernel@lists.infradead.org
On Thu, Apr 11, 2013 at 2:48 AM, Roger Quadros <rogerq@ti.com> wrote:
> On 04/10/2013 08:39 PM, Nishanth Menon wrote:
>> On 13:55-20130410, Roger Quadros wrote:
>>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
>
> This looks fine to me. Minor comments below.
Thanks on the review. will fix in my next post
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread
* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 22:45 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-11 22:45 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Apr 11, 2013 at 2:48 AM, Roger Quadros <rogerq@ti.com> wrote:
> On 04/10/2013 08:39 PM, Nishanth Menon wrote:
>> On 13:55-20130410, Roger Quadros wrote:
>>> On 04/10/2013 11:06 AM, Mike Turquette wrote:
>>>> Quoting Nishanth Menon (2013-04-09 13:49:00)
>> Folks, this does seem to be the best compromise we can achieve at this
>> point in time. feedback on this approach is much appreciated - if folks
>> are ok, I can post this as an formal patch series.
>
> This looks fine to me. Minor comments below.
Thanks on the review. will fix in my next post
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-10 17:39 ` Nishanth Menon
(?)
@ 2013-04-11 18:46 ` Mike Turquette
-1 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-11 18:46 UTC (permalink / raw)
To: Nishanth Menon, Roger Quadros
Cc: grygorii.strashko, linux, Tony Lindgren, devicetree-discuss,
linux-usb, linux-kernel, balbi, linux-omap, linux-arm-kernel
Quoting Nishanth Menon (2013-04-10 10:39:21)
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
Please use clk-provider.h. Otherwise this looks like an OK transitional
solution. Hopefully this will be replaced with a more legitimate clock
driver for 3.11.
Regards,
Mike
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 18:46 ` Mike Turquette
0 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-11 18:46 UTC (permalink / raw)
To: Nishanth Menon, Roger Quadros
Cc: Tony Lindgren, linux-usb, linux, devicetree-discuss, linux-kernel,
balbi, grygorii.strashko, linux-omap, linux-arm-kernel
Quoting Nishanth Menon (2013-04-10 10:39:21)
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
Please use clk-provider.h. Otherwise this looks like an OK transitional
solution. Hopefully this will be replaced with a more legitimate clock
driver for 3.11.
Regards,
Mike
^ permalink raw reply [flat|nested] 117+ messages in thread
* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 18:46 ` Mike Turquette
0 siblings, 0 replies; 117+ messages in thread
From: Mike Turquette @ 2013-04-11 18:46 UTC (permalink / raw)
To: linux-arm-kernel
Quoting Nishanth Menon (2013-04-10 10:39:21)
> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
> new file mode 100644
> index 0000000..63a4cce
> --- /dev/null
> +++ b/drivers/clk/omap/clk.c
> @@ -0,0 +1,94 @@
> +/*
> + * Texas Instruments OMAP Clock driver
> + *
> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
> + * Nishanth Menon
> + * Tony Lindgren <tony@atomide.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/clkdev.h>
> +#include <linux/clk-private.h>
Please use clk-provider.h. Otherwise this looks like an OK transitional
solution. Hopefully this will be replaced with a more legitimate clock
driver for 3.11.
Regards,
Mike
^ permalink raw reply [flat|nested] 117+ messages in thread
* Re: [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
2013-04-11 18:46 ` Mike Turquette
@ 2013-04-11 22:40 ` Nishanth Menon
-1 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-11 22:40 UTC (permalink / raw)
To: Mike Turquette
Cc: Roger Quadros, grygorii.strashko, Russell King - ARM Linux,
Tony Lindgren, devicetree-discuss, linux-usb, lkml, balbi,
linux-omap, linux-arm-kernel@lists.infradead.org
On Thu, Apr 11, 2013 at 1:46 PM, Mike Turquette <mturquette@linaro.org> wrote:
> Quoting Nishanth Menon (2013-04-10 10:39:21)
>> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
>> new file mode 100644
>> index 0000000..63a4cce
>> --- /dev/null
>> +++ b/drivers/clk/omap/clk.c
>> @@ -0,0 +1,94 @@
>> +/*
>> + * Texas Instruments OMAP Clock driver
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + * Tony Lindgren <tony@atomide.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/clkdev.h>
>> +#include <linux/clk-private.h>
>
> Please use clk-provider.h. Otherwise this looks like an OK transitional
k. thanks for checking up on this. will update.
> solution. Hopefully this will be replaced with a more legitimate clock
> driver for 3.11.
I hope so too. At least we should start debate with the direction we'd
like to take and start migrating towards that purpose.
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread
* [RFC][PATCH 1/2] ARM: OMAP4: clock: Add device tree support for AUXCLKs
@ 2013-04-11 22:40 ` Nishanth Menon
0 siblings, 0 replies; 117+ messages in thread
From: Nishanth Menon @ 2013-04-11 22:40 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Apr 11, 2013 at 1:46 PM, Mike Turquette <mturquette@linaro.org> wrote:
> Quoting Nishanth Menon (2013-04-10 10:39:21)
>> diff --git a/drivers/clk/omap/clk.c b/drivers/clk/omap/clk.c
>> new file mode 100644
>> index 0000000..63a4cce
>> --- /dev/null
>> +++ b/drivers/clk/omap/clk.c
>> @@ -0,0 +1,94 @@
>> +/*
>> + * Texas Instruments OMAP Clock driver
>> + *
>> + * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
>> + * Nishanth Menon
>> + * Tony Lindgren <tony@atomide.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/clkdev.h>
>> +#include <linux/clk-private.h>
>
> Please use clk-provider.h. Otherwise this looks like an OK transitional
k. thanks for checking up on this. will update.
> solution. Hopefully this will be replaced with a more legitimate clock
> driver for 3.11.
I hope so too. At least we should start debate with the direction we'd
like to take and start migrating towards that purpose.
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 117+ messages in thread