aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTero Kristo <t-kristo@ti.com>2015-04-27 15:23:06 -0400
committerTero Kristo <t-kristo@ti.com>2015-06-02 05:31:46 -0400
commit989feafb84118a840ff21250a1e5f516f43e3dbb (patch)
tree8bbd67f41a35f671419c649beb5d6f04d32eb66c
parente3aedf0234e7f12554c591bc37236f3469fed8fa (diff)
clk: ti: move low-level access and init code under clock driver
With most of the clock code under clock driver already, the low-level register access code, and the init code for the same, is no longer needed outside the clock driver. Thus, these can be moved under clock driver also. Signed-off-by: Tero Kristo <t-kristo@ti.com>
-rw-r--r--arch/arm/mach-omap2/clock.c84
-rw-r--r--arch/arm/mach-omap2/clock.h5
-rw-r--r--drivers/clk/ti/clk.c75
-rw-r--r--include/linux/clk/ti.h7
4 files changed, 78 insertions, 93 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index 79cec5fbbe74..4340ba6524d1 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -23,9 +23,7 @@
23#include <linux/clk-provider.h> 23#include <linux/clk-provider.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/bitops.h> 25#include <linux/bitops.h>
26#include <linux/regmap.h>
27#include <linux/of_address.h> 26#include <linux/of_address.h>
28#include <linux/bootmem.h>
29#include <asm/cpu.h> 27#include <asm/cpu.h>
30 28
31#include <trace/events/power.h> 29#include <trace/events/power.h>
@@ -55,41 +53,7 @@ u16 cpu_mask;
55#define OMAP3PLUS_DPLL_FINT_MIN 32000 53#define OMAP3PLUS_DPLL_FINT_MIN 32000
56#define OMAP3PLUS_DPLL_FINT_MAX 52000000 54#define OMAP3PLUS_DPLL_FINT_MAX 52000000
57 55
58struct clk_iomap {
59 struct regmap *regmap;
60 void __iomem *mem;
61};
62
63static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
64
65static void clk_memmap_writel(u32 val, void __iomem *reg)
66{
67 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
68 struct clk_iomap *io = clk_memmaps[r->index];
69
70 if (io->regmap)
71 regmap_write(io->regmap, r->offset, val);
72 else
73 writel_relaxed(val, io->mem + r->offset);
74}
75
76static u32 clk_memmap_readl(void __iomem *reg)
77{
78 u32 val;
79 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
80 struct clk_iomap *io = clk_memmaps[r->index];
81
82 if (io->regmap)
83 regmap_read(io->regmap, r->offset, &val);
84 else
85 val = readl_relaxed(io->mem + r->offset);
86
87 return val;
88}
89
90static struct ti_clk_ll_ops omap_clk_ll_ops = { 56static struct ti_clk_ll_ops omap_clk_ll_ops = {
91 .clk_readl = clk_memmap_readl,
92 .clk_writel = clk_memmap_writel,
93 .clkdm_clk_enable = clkdm_clk_enable, 57 .clkdm_clk_enable = clkdm_clk_enable,
94 .clkdm_clk_disable = clkdm_clk_disable, 58 .clkdm_clk_disable = clkdm_clk_disable,
95 .cm_wait_module_ready = omap_cm_wait_module_ready, 59 .cm_wait_module_ready = omap_cm_wait_module_ready,
@@ -109,54 +73,6 @@ int __init omap2_clk_setup_ll_ops(void)
109 return ti_clk_setup_ll_ops(&omap_clk_ll_ops); 73 return ti_clk_setup_ll_ops(&omap_clk_ll_ops);
110} 74}
111 75
112/**
113 * omap2_clk_provider_init - initialize a clock provider
114 * @match_table: DT device table to match for devices to init
115 * @np: device node pointer for the this clock provider
116 * @index: index for the clock provider
117 + @syscon: syscon regmap pointer
118 * @mem: iomem pointer for the clock provider memory area, only used if
119 * syscon is not provided
120 *
121 * Initializes a clock provider module (CM/PRM etc.), registering
122 * the memory mapping at specified index and initializing the
123 * low level driver infrastructure. Returns 0 in success.
124 */
125int __init omap2_clk_provider_init(struct device_node *np, int index,
126 struct regmap *syscon, void __iomem *mem)
127{
128 struct clk_iomap *io;
129
130 io = kzalloc(sizeof(*io), GFP_KERNEL);
131
132 io->regmap = syscon;
133 io->mem = mem;
134
135 clk_memmaps[index] = io;
136
137 ti_dt_clk_init_provider(np, index);
138
139 return 0;
140}
141
142/**
143 * omap2_clk_legacy_provider_init - initialize a legacy clock provider
144 * @index: index for the clock provider
145 * @mem: iomem pointer for the clock provider memory area
146 *
147 * Initializes a legacy clock provider memory mapping.
148 */
149void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)
150{
151 struct clk_iomap *io;
152
153 io = memblock_virt_alloc(sizeof(*io), 0);
154
155 io->mem = mem;
156
157 clk_memmaps[index] = io;
158}
159
160/* 76/*
161 * OMAP2+ specific clock functions 77 * OMAP2+ specific clock functions
162 */ 78 */
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index f3dc04cd5538..67da640ba1c7 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -75,11 +75,6 @@ extern const struct clkops clkops_omap2_dflt;
75 75
76extern struct clk_functions omap2_clk_functions; 76extern struct clk_functions omap2_clk_functions;
77 77
78struct regmap;
79
80int __init omap2_clk_provider_init(struct device_node *np, int index,
81 struct regmap *syscon, void __iomem *mem);
82void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem);
83int __init omap2_clk_setup_ll_ops(void); 78int __init omap2_clk_setup_ll_ops(void);
84 79
85void __init ti_clk_init_features(void); 80void __init ti_clk_init_features(void);
diff --git a/drivers/clk/ti/clk.c b/drivers/clk/ti/clk.c
index 58b83e0af90f..07584e00677e 100644
--- a/drivers/clk/ti/clk.c
+++ b/drivers/clk/ti/clk.c
@@ -21,6 +21,8 @@
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/of_address.h> 22#include <linux/of_address.h>
23#include <linux/list.h> 23#include <linux/list.h>
24#include <linux/regmap.h>
25#include <linux/bootmem.h>
24 26
25#include "clock.h" 27#include "clock.h"
26 28
@@ -32,6 +34,38 @@ static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS];
32 34
33struct ti_clk_features ti_clk_features; 35struct ti_clk_features ti_clk_features;
34 36
37struct clk_iomap {
38 struct regmap *regmap;
39 void __iomem *mem;
40};
41
42static struct clk_iomap *clk_memmaps[CLK_MAX_MEMMAPS];
43
44static void clk_memmap_writel(u32 val, void __iomem *reg)
45{
46 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
47 struct clk_iomap *io = clk_memmaps[r->index];
48
49 if (io->regmap)
50 regmap_write(io->regmap, r->offset, val);
51 else
52 writel_relaxed(val, io->mem + r->offset);
53}
54
55static u32 clk_memmap_readl(void __iomem *reg)
56{
57 u32 val;
58 struct clk_omap_reg *r = (struct clk_omap_reg *)&reg;
59 struct clk_iomap *io = clk_memmaps[r->index];
60
61 if (io->regmap)
62 regmap_read(io->regmap, r->offset, &val);
63 else
64 val = readl_relaxed(io->mem + r->offset);
65
66 return val;
67}
68
35/** 69/**
36 * ti_clk_setup_ll_ops - setup low level clock operations 70 * ti_clk_setup_ll_ops - setup low level clock operations
37 * @ops: low level clock ops descriptor 71 * @ops: low level clock ops descriptor
@@ -49,6 +83,8 @@ int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops)
49 } 83 }
50 84
51 ti_clk_ll_ops = ops; 85 ti_clk_ll_ops = ops;
86 ops->clk_readl = clk_memmap_readl;
87 ops->clk_writel = clk_memmap_writel;
52 88
53 return 0; 89 return 0;
54} 90}
@@ -161,28 +197,61 @@ void __iomem *ti_clk_get_reg_addr(struct device_node *node, int index)
161} 197}
162 198
163/** 199/**
164 * ti_dt_clk_init_provider - init master clock provider 200 * omap2_clk_provider_init - init master clock provider
165 * @parent: master node 201 * @parent: master node
166 * @index: internal index for clk_reg_ops 202 * @index: internal index for clk_reg_ops
203 * @syscon: syscon regmap pointer for accessing clock registers
204 * @mem: iomem pointer for the clock provider memory area, only used if
205 * syscon is not provided
167 * 206 *
168 * Initializes a master clock IP block. This basically sets up the 207 * Initializes a master clock IP block. This basically sets up the
169 * mapping from clocks node to the memory map index. All the clocks 208 * mapping from clocks node to the memory map index. All the clocks
170 * are then initialized through the common of_clk_init call, and the 209 * are then initialized through the common of_clk_init call, and the
171 * clocks will access their memory maps based on the node layout. 210 * clocks will access their memory maps based on the node layout.
211 * Returns 0 in success.
172 */ 212 */
173void ti_dt_clk_init_provider(struct device_node *parent, int index) 213int __init omap2_clk_provider_init(struct device_node *parent, int index,
214 struct regmap *syscon, void __iomem *mem)
174{ 215{
175 struct device_node *clocks; 216 struct device_node *clocks;
217 struct clk_iomap *io;
176 218
177 /* get clocks for this parent */ 219 /* get clocks for this parent */
178 clocks = of_get_child_by_name(parent, "clocks"); 220 clocks = of_get_child_by_name(parent, "clocks");
179 if (!clocks) { 221 if (!clocks) {
180 pr_err("%s missing 'clocks' child node.\n", parent->name); 222 pr_err("%s missing 'clocks' child node.\n", parent->name);
181 return; 223 return -EINVAL;
182 } 224 }
183 225
184 /* add clocks node info */ 226 /* add clocks node info */
185 clocks_node_ptr[index] = clocks; 227 clocks_node_ptr[index] = clocks;
228
229 io = kzalloc(sizeof(*io), GFP_KERNEL);
230
231 io->regmap = syscon;
232 io->mem = mem;
233
234 clk_memmaps[index] = io;
235
236 return 0;
237}
238
239/**
240 * omap2_clk_legacy_provider_init - initialize a legacy clock provider
241 * @index: index for the clock provider
242 * @mem: iomem pointer for the clock provider memory area
243 *
244 * Initializes a legacy clock provider memory mapping.
245 */
246void __init omap2_clk_legacy_provider_init(int index, void __iomem *mem)
247{
248 struct clk_iomap *io;
249
250 io = memblock_virt_alloc(sizeof(*io), 0);
251
252 io->mem = mem;
253
254 clk_memmaps[index] = io;
186} 255}
187 256
188/** 257/**
diff --git a/include/linux/clk/ti.h b/include/linux/clk/ti.h
index 5b644313e38a..9299222d680d 100644
--- a/include/linux/clk/ti.h
+++ b/include/linux/clk/ti.h
@@ -250,11 +250,16 @@ void omap2xxx_clkt_dpllcore_init(struct clk_hw *hw);
250void omap2xxx_clkt_vps_init(void); 250void omap2xxx_clkt_vps_init(void);
251unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk); 251unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk);
252 252
253void ti_dt_clk_init_provider(struct device_node *np, int index);
254void ti_dt_clk_init_retry_clks(void); 253void ti_dt_clk_init_retry_clks(void);
255void ti_dt_clockdomains_setup(void); 254void ti_dt_clockdomains_setup(void);
256int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops); 255int ti_clk_setup_ll_ops(struct ti_clk_ll_ops *ops);
257 256
257struct regmap;
258
259int omap2_clk_provider_init(struct device_node *parent, int index,
260 struct regmap *syscon, void __iomem *mem);
261void omap2_clk_legacy_provider_init(int index, void __iomem *mem);
262
258int omap3430_dt_clk_init(void); 263int omap3430_dt_clk_init(void);
259int omap3630_dt_clk_init(void); 264int omap3630_dt_clk_init(void);
260int am35xx_dt_clk_init(void); 265int am35xx_dt_clk_init(void);