]>
Commit | Line | Data |
---|---|---|
3cd4a596 TK |
1 | /* |
2 | * OMAP clockdomain 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/slab.h> | |
20 | #include <linux/of.h> | |
21 | #include <linux/of_address.h> | |
22 | #include <linux/clk/ti.h> | |
23 | ||
24 | #undef pr_fmt | |
25 | #define pr_fmt(fmt) "%s: " fmt, __func__ | |
26 | ||
27 | static void __init of_ti_clockdomain_setup(struct device_node *node) | |
28 | { | |
29 | struct clk *clk; | |
30 | struct clk_hw *clk_hw; | |
31 | const char *clkdm_name = node->name; | |
32 | int i; | |
33 | int num_clks; | |
34 | ||
35 | num_clks = of_count_phandle_with_args(node, "clocks", "#clock-cells"); | |
36 | ||
37 | for (i = 0; i < num_clks; i++) { | |
38 | clk = of_clk_get(node, i); | |
319f1276 SAS |
39 | if (IS_ERR(clk)) { |
40 | pr_err("%s: Failed get %s' clock nr %d (%ld)\n", | |
41 | __func__, node->full_name, i, PTR_ERR(clk)); | |
42 | continue; | |
43 | } | |
3cd4a596 TK |
44 | if (__clk_get_flags(clk) & CLK_IS_BASIC) { |
45 | pr_warn("can't setup clkdm for basic clk %s\n", | |
46 | __clk_get_name(clk)); | |
47 | continue; | |
48 | } | |
49 | clk_hw = __clk_get_hw(clk); | |
50 | to_clk_hw_omap(clk_hw)->clkdm_name = clkdm_name; | |
51 | omap2_init_clk_clkdm(clk_hw); | |
52 | } | |
53 | } | |
54 | ||
55 | static struct of_device_id ti_clkdm_match_table[] __initdata = { | |
56 | { .compatible = "ti,clockdomain" }, | |
57 | { } | |
58 | }; | |
59 | ||
60 | /** | |
61 | * ti_dt_clockdomains_setup - setup device tree clockdomains | |
62 | * | |
63 | * Initializes clockdomain nodes for a SoC. This parses through all the | |
64 | * nodes with compatible = "ti,clockdomain", and add the clockdomain | |
65 | * info for all the clocks listed under these. This function shall be | |
66 | * called after rest of the DT clock init has completed and all | |
67 | * clock nodes have been registered. | |
68 | */ | |
69 | void __init ti_dt_clockdomains_setup(void) | |
70 | { | |
71 | struct device_node *np; | |
72 | for_each_matching_node(np, ti_clkdm_match_table) { | |
73 | of_ti_clockdomain_setup(np); | |
74 | } | |
75 | } |