aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2013-07-18 04:52:33 -0400
committerMike Turquette <mturquette@linaro.org>2014-01-17 15:32:38 -0500
commita8aceccb4d5db0acb476b74051525fb26f57f8ae (patch)
tree1ea3c1b912f065fab116417d750d208de1973454
parent68b9f608679424ea08e6fbead5dc82599bfe667f (diff)
CLK: TI: add DT alias clock registration mechanism
Some devices require their clocks to be available with a specific dev-id con-id mapping. With DT, the clocks can be found by default only with their name, or alternatively through the device node of the consumer. With drivers, that don't support DT fully yet, add mechanism to register specific clock names. Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Mike Turquette <mturquette@linaro.org>
-rw-r--r--drivers/clk/Makefile1
-rw-r--r--drivers/clk/ti/Makefile3
-rw-r--r--drivers/clk/ti/clk.c55
-rw-r--r--include/linux/clk/ti.h42
4 files changed, 101 insertions, 0 deletions
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 972da894baa1..13c1e91a86bc 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_PLAT_SAMSUNG) += samsung/
38obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o 38obj-$(CONFIG_COMMON_CLK_XGENE) += clk-xgene.o
39obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/ 39obj-$(CONFIG_COMMON_CLK_KEYSTONE) += keystone/
40obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += shmobile/ 40obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += shmobile/
41obj-$(CONFIG_ARCH_OMAP2PLUS) += ti/
41 42
42obj-$(CONFIG_X86) += x86/ 43obj-$(CONFIG_X86) += x86/
43 44
diff --git a/drivers/clk/ti/Makefile b/drivers/clk/ti/Makefile
new file mode 100644
index 000000000000..1825f7f4bdc0
--- /dev/null
+++ b/drivers/clk/ti/Makefile
@@ -0,0 +1,3 @@
1ifneq ($(CONFIG_OF),)
2obj-y += clk.o
3endif
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
new file mode 100644
index 000000000000..ef1a7cdecfd9
--- /dev/null
+++ b/drivers/clk/ti/clk.c
@@ -0,0 +1,55 @@
1/*
2 * TI clock support
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 *
6 * Tero Kristo <t-kristo@ti.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#include <linux/clk-provider.h>
19#include <linux/clkdev.h>
20#include <linux/clk/ti.h>
21#include <linux/of.h>
22
23#undef pr_fmt
24#define pr_fmt(fmt) "%s: " fmt, __func__
25
26/**
27 * ti_dt_clocks_register - register DT alias clocks during boot
28 * @oclks: list of clocks to register
29 *
30 * Register alias or non-standard DT clock entries during boot. By
31 * default, DT clocks are found based on their node name. If any
32 * additional con-id / dev-id -> clock mapping is required, use this
33 * function to list these.
34 */
35void __init ti_dt_clocks_register(struct ti_dt_clk oclks[])
36{
37 struct ti_dt_clk *c;
38 struct device_node *node;
39 struct clk *clk;
40 struct of_phandle_args clkspec;
41
42 for (c = oclks; c->node_name != NULL; c++) {
43 node = of_find_node_by_name(NULL, c->node_name);
44 clkspec.np = node;
45 clk = of_clk_get_from_provider(&clkspec);
46
47 if (!IS_ERR(clk)) {
48 c->lk.clk = clk;
49 clkdev_add(&c->lk);
50 } else {
51 pr_warn("failed to lookup clock node %s\n",
52 c->node_name);
53 }
54 }
55}
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
new file mode 100644
index 000000000000..df94c243205e
--- /dev/null
+++ b/include/linux/clk/ti.h
@@ -0,0 +1,42 @@
1/*
2 * TI clock drivers support
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
11 * kind, whether express or implied; without even the implied warranty
12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15#ifndef __LINUX_CLK_TI_H__
16#define __LINUX_CLK_TI_H__
17
18#include <linux/clkdev.h>
19
20/**
21 * struct ti_dt_clk - OMAP DT clock alias declarations
22 * @lk: clock lookup definition
23 * @node_name: clock DT node to map to
24 */
25struct ti_dt_clk {
26 struct clk_lookup lk;
27 char *node_name;
28};
29
30#define DT_CLK(dev, con, name) \
31 { \
32 .lk = { \
33 .dev_id = dev, \
34 .con_id = con, \
35 }, \
36 .node_name = name, \
37 }
38
39
40void ti_dt_clocks_register(struct ti_dt_clk *oclks);
41
42#endif