aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-02 19:15:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-02 19:15:12 -0400
commit825f4e0271b0de3f7f31d963dcdaa0056fe9b73a (patch)
treeaef1f198da011a96fefbe9851137ca17afd929a4 /drivers
parent0a58471541cc823ef8056d23945c39fec154481c (diff)
parentb5b9324a6296bd0176fe1f8e06a1220207bd1bd3 (diff)
Merge tag 'soc-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc into next
Pull part one of ARM SoC updates from Olof Johansson: "A quite large set of SoC updates this cycle. In no particular order: - Multi-cluster power management for Samsung Exynos, adding support for big.LITTLE CPU switching on EXYNOS5 - SMP support for Marvell Armada 375 and 38x - SMP rework on Allwinner A31 - Xilinx Zynq support for SOC_BUS, big endian - Marvell orion5x platform cleanup, modernizing the implementation and moving to DT. - _Finally_ moving Samsung Exynos over to support MULTIPLATFORM, so that their platform can be enabled in the same kernel binary as most of the other v7 platforms in the tree. \o/ The work isn't quite complete, there's some driver fixes still needed, but the basics now work. New SoC support added: - Freescale i.MX6SX - LSI Axxia AXM55xx SoCs - Samsung EXYNOS 3250, 5260, 5410, 5420 and 5800 - STi STIH407 plus a large set of various smaller updates for different platforms. I'm probably missing some important one here" * tag 'soc-for-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (281 commits) ARM: exynos: don't run exynos4 l2x0 setup on other platforms ARM: exynos: Fix "allmodconfig" build errors in mcpm and hotplug ARM: EXYNOS: mcpm rename the power_down_finish ARM: EXYNOS: Enable mcpm for dual-cluster exynos5800 SoC ARM: EXYNOS: Enable multi-platform build support ARM: EXYNOS: Consolidate Kconfig entries ARM: EXYNOS: Add support for EXYNOS5410 SoC ARM: EXYNOS: Support secondary CPU boot of Exynos3250 ARM: EXYNOS: Add Exynos3250 SoC ID ARM: EXYNOS: Add 5800 SoC support ARM: EXYNOS: initial board support for exynos5260 SoC clk: exynos5410: register clocks using common clock framework ARM: debug: qcom: add UART addresses to Kconfig help for APQ8084 ARM: sunxi: allow building without reset controller Documentation: devicetree: arm: sort enable-method entries ARM: rockchip: convert smp bringup to CPU_METHOD_OF_DECLARE clk: exynos5250: Add missing sysmmu clocks for DISP and ISP blocks ARM: dts: axxia: Add reset controller power: reset: Add Axxia system reset driver ARM: axxia: Adding defconfig for AXM55xx ...
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bus/mvebu-mbus.c11
-rw-r--r--drivers/clk/Kconfig2
-rw-r--r--drivers/clk/Makefile2
-rw-r--r--drivers/clk/at91/Makefile4
-rw-r--r--drivers/clk/at91/clk-main.c577
-rw-r--r--drivers/clk/at91/clk-slow.c467
-rw-r--r--drivers/clk/at91/pmc.c17
-rw-r--r--drivers/clk/at91/pmc.h9
-rw-r--r--drivers/clk/at91/sckc.c57
-rw-r--r--drivers/clk/at91/sckc.h22
-rw-r--r--drivers/clk/samsung/Kconfig26
-rw-r--r--drivers/clk/samsung/Makefile3
-rw-r--r--drivers/clk/samsung/clk-exynos3250.c780
-rw-r--r--drivers/clk/samsung/clk-exynos4.c51
-rw-r--r--drivers/clk/samsung/clk-exynos5250.c76
-rw-r--r--drivers/clk/samsung/clk-exynos5260.c1980
-rw-r--r--drivers/clk/samsung/clk-exynos5260.h459
-rw-r--r--drivers/clk/samsung/clk-exynos5410.c209
-rw-r--r--drivers/clk/samsung/clk-exynos5420.c1127
-rw-r--r--drivers/clk/samsung/clk-exynos5440.c18
-rw-r--r--drivers/clk/samsung/clk-pll.c223
-rw-r--r--drivers/clk/samsung/clk-pll.h2
-rw-r--r--drivers/clk/samsung/clk-s3c2410.c51
-rw-r--r--drivers/clk/samsung/clk-s3c2412.c29
-rw-r--r--drivers/clk/samsung/clk-s3c2443.c46
-rw-r--r--drivers/clk/samsung/clk-s3c64xx.c44
-rw-r--r--drivers/clk/samsung/clk.c123
-rw-r--r--drivers/clk/samsung/clk.h72
-rw-r--r--drivers/clocksource/cadence_ttc_timer.c54
-rw-r--r--drivers/cpuidle/Kconfig.arm5
-rw-r--r--drivers/cpuidle/Makefile1
-rw-r--r--drivers/cpuidle/cpuidle-armada-370-xp.c93
-rw-r--r--drivers/iio/adc/at91_adc.c340
-rw-r--r--drivers/input/touchscreen/Kconfig12
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/atmel_tsadcc.c358
-rw-r--r--drivers/irqchip/irq-armada-370-xp.c24
-rw-r--r--drivers/irqchip/irq-orion.c4
-rw-r--r--drivers/mfd/twl-core.c15
-rw-r--r--drivers/power/reset/Kconfig8
-rw-r--r--drivers/power/reset/Makefile1
-rw-r--r--drivers/power/reset/axxia-reset.c88
42 files changed, 6419 insertions, 1072 deletions
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index 00b73448b22e..26c3779d871d 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -704,7 +704,6 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,
704 phys_addr_t sdramwins_phys_base, 704 phys_addr_t sdramwins_phys_base,
705 size_t sdramwins_size) 705 size_t sdramwins_size)
706{ 706{
707 struct device_node *np;
708 int win; 707 int win;
709 708
710 mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size); 709 mbus->mbuswins_base = ioremap(mbuswins_phys_base, mbuswins_size);
@@ -717,12 +716,6 @@ static int __init mvebu_mbus_common_init(struct mvebu_mbus_state *mbus,
717 return -ENOMEM; 716 return -ENOMEM;
718 } 717 }
719 718
720 np = of_find_compatible_node(NULL, NULL, "marvell,coherency-fabric");
721 if (np) {
722 mbus->hw_io_coherency = 1;
723 of_node_put(np);
724 }
725
726 for (win = 0; win < mbus->soc->num_wins; win++) 719 for (win = 0; win < mbus->soc->num_wins; win++)
727 mvebu_mbus_disable_window(mbus, win); 720 mvebu_mbus_disable_window(mbus, win);
728 721
@@ -892,7 +885,7 @@ static void __init mvebu_mbus_get_pcie_resources(struct device_node *np,
892 } 885 }
893} 886}
894 887
895int __init mvebu_mbus_dt_init(void) 888int __init mvebu_mbus_dt_init(bool is_coherent)
896{ 889{
897 struct resource mbuswins_res, sdramwins_res; 890 struct resource mbuswins_res, sdramwins_res;
898 struct device_node *np, *controller; 891 struct device_node *np, *controller;
@@ -930,6 +923,8 @@ int __init mvebu_mbus_dt_init(void)
930 return -EINVAL; 923 return -EINVAL;
931 } 924 }
932 925
926 mbus_state.hw_io_coherency = is_coherent;
927
933 /* Get optional pcie-{mem,io}-aperture properties */ 928 /* Get optional pcie-{mem,io}-aperture properties */
934 mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture, 929 mvebu_mbus_get_pcie_resources(np, &mbus_state.pcie_mem_aperture,
935 &mbus_state.pcie_io_aperture); 930 &mbus_state.pcie_io_aperture);
diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index 4fdfd6c70bd3..3a2196481b11 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -108,3 +108,5 @@ endmenu
108 108
109source "drivers/clk/bcm/Kconfig" 109source "drivers/clk/bcm/Kconfig"
110source "drivers/clk/mvebu/Kconfig" 110source "drivers/clk/mvebu/Kconfig"
111
112source "drivers/clk/samsung/Kconfig"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 5f8a28735c96..17d7f13d19a5 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_PLAT_ORION) += mvebu/
41obj-$(CONFIG_ARCH_MXS) += mxs/ 41obj-$(CONFIG_ARCH_MXS) += mxs/
42obj-$(CONFIG_COMMON_CLK_QCOM) += qcom/ 42obj-$(CONFIG_COMMON_CLK_QCOM) += qcom/
43obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/ 43obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
44obj-$(CONFIG_PLAT_SAMSUNG) += samsung/ 44obj-$(CONFIG_COMMON_CLK_SAMSUNG) += samsung/
45obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += shmobile/ 45obj-$(CONFIG_ARCH_SHMOBILE_MULTI) += shmobile/
46obj-$(CONFIG_ARCH_SIRF) += sirf/ 46obj-$(CONFIG_ARCH_SIRF) += sirf/
47obj-$(CONFIG_ARCH_SOCFPGA) += socfpga/ 47obj-$(CONFIG_ARCH_SOCFPGA) += socfpga/
diff --git a/drivers/clk/at91/Makefile b/drivers/clk/at91/Makefile
index 46c1d3d0d66b..4998aee59267 100644
--- a/drivers/clk/at91/Makefile
+++ b/drivers/clk/at91/Makefile
@@ -2,8 +2,8 @@
2# Makefile for at91 specific clk 2# Makefile for at91 specific clk
3# 3#
4 4
5obj-y += pmc.o 5obj-y += pmc.o sckc.o
6obj-y += clk-main.o clk-pll.o clk-plldiv.o clk-master.o 6obj-y += clk-slow.o clk-main.o clk-pll.o clk-plldiv.o clk-master.o
7obj-y += clk-system.o clk-peripheral.o clk-programmable.o 7obj-y += clk-system.o clk-peripheral.o clk-programmable.o
8 8
9obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o 9obj-$(CONFIG_HAVE_AT91_UTMI) += clk-utmi.o
diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index 8e9e8cc0412d..733306131b99 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -30,99 +30,546 @@
30#define MAINF_LOOP_MIN_WAIT (USEC_PER_SEC / SLOW_CLOCK_FREQ) 30#define MAINF_LOOP_MIN_WAIT (USEC_PER_SEC / SLOW_CLOCK_FREQ)
31#define MAINF_LOOP_MAX_WAIT MAINFRDY_TIMEOUT 31#define MAINF_LOOP_MAX_WAIT MAINFRDY_TIMEOUT
32 32
33struct clk_main { 33#define MOR_KEY_MASK (0xff << 16)
34
35struct clk_main_osc {
34 struct clk_hw hw; 36 struct clk_hw hw;
35 struct at91_pmc *pmc; 37 struct at91_pmc *pmc;
36 unsigned long rate;
37 unsigned int irq; 38 unsigned int irq;
38 wait_queue_head_t wait; 39 wait_queue_head_t wait;
39}; 40};
40 41
41#define to_clk_main(hw) container_of(hw, struct clk_main, hw) 42#define to_clk_main_osc(hw) container_of(hw, struct clk_main_osc, hw)
43
44struct clk_main_rc_osc {
45 struct clk_hw hw;
46 struct at91_pmc *pmc;
47 unsigned int irq;
48 wait_queue_head_t wait;
49 unsigned long frequency;
50 unsigned long accuracy;
51};
52
53#define to_clk_main_rc_osc(hw) container_of(hw, struct clk_main_rc_osc, hw)
54
55struct clk_rm9200_main {
56 struct clk_hw hw;
57 struct at91_pmc *pmc;
58};
59
60#define to_clk_rm9200_main(hw) container_of(hw, struct clk_rm9200_main, hw)
42 61
43static irqreturn_t clk_main_irq_handler(int irq, void *dev_id) 62struct clk_sam9x5_main {
63 struct clk_hw hw;
64 struct at91_pmc *pmc;
65 unsigned int irq;
66 wait_queue_head_t wait;
67 u8 parent;
68};
69
70#define to_clk_sam9x5_main(hw) container_of(hw, struct clk_sam9x5_main, hw)
71
72static irqreturn_t clk_main_osc_irq_handler(int irq, void *dev_id)
44{ 73{
45 struct clk_main *clkmain = (struct clk_main *)dev_id; 74 struct clk_main_osc *osc = dev_id;
46 75
47 wake_up(&clkmain->wait); 76 wake_up(&osc->wait);
48 disable_irq_nosync(clkmain->irq); 77 disable_irq_nosync(osc->irq);
49 78
50 return IRQ_HANDLED; 79 return IRQ_HANDLED;
51} 80}
52 81
53static int clk_main_prepare(struct clk_hw *hw) 82static int clk_main_osc_prepare(struct clk_hw *hw)
54{ 83{
55 struct clk_main *clkmain = to_clk_main(hw); 84 struct clk_main_osc *osc = to_clk_main_osc(hw);
56 struct at91_pmc *pmc = clkmain->pmc; 85 struct at91_pmc *pmc = osc->pmc;
57 unsigned long halt_time, timeout;
58 u32 tmp; 86 u32 tmp;
59 87
88 tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK;
89 if (tmp & AT91_PMC_OSCBYPASS)
90 return 0;
91
92 if (!(tmp & AT91_PMC_MOSCEN)) {
93 tmp |= AT91_PMC_MOSCEN | AT91_PMC_KEY;
94 pmc_write(pmc, AT91_CKGR_MOR, tmp);
95 }
96
60 while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS)) { 97 while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS)) {
61 enable_irq(clkmain->irq); 98 enable_irq(osc->irq);
62 wait_event(clkmain->wait, 99 wait_event(osc->wait,
63 pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS); 100 pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS);
64 } 101 }
65 102
66 if (clkmain->rate) 103 return 0;
67 return 0; 104}
105
106static void clk_main_osc_unprepare(struct clk_hw *hw)
107{
108 struct clk_main_osc *osc = to_clk_main_osc(hw);
109 struct at91_pmc *pmc = osc->pmc;
110 u32 tmp = pmc_read(pmc, AT91_CKGR_MOR);
111
112 if (tmp & AT91_PMC_OSCBYPASS)
113 return;
114
115 if (!(tmp & AT91_PMC_MOSCEN))
116 return;
117
118 tmp &= ~(AT91_PMC_KEY | AT91_PMC_MOSCEN);
119 pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_KEY);
120}
121
122static int clk_main_osc_is_prepared(struct clk_hw *hw)
123{
124 struct clk_main_osc *osc = to_clk_main_osc(hw);
125 struct at91_pmc *pmc = osc->pmc;
126 u32 tmp = pmc_read(pmc, AT91_CKGR_MOR);
127
128 if (tmp & AT91_PMC_OSCBYPASS)
129 return 1;
130
131 return !!((pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCS) &&
132 (pmc_read(pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCEN));
133}
134
135static const struct clk_ops main_osc_ops = {
136 .prepare = clk_main_osc_prepare,
137 .unprepare = clk_main_osc_unprepare,
138 .is_prepared = clk_main_osc_is_prepared,
139};
140
141static struct clk * __init
142at91_clk_register_main_osc(struct at91_pmc *pmc,
143 unsigned int irq,
144 const char *name,
145 const char *parent_name,
146 bool bypass)
147{
148 int ret;
149 struct clk_main_osc *osc;
150 struct clk *clk = NULL;
151 struct clk_init_data init;
152
153 if (!pmc || !irq || !name || !parent_name)
154 return ERR_PTR(-EINVAL);
155
156 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
157 if (!osc)
158 return ERR_PTR(-ENOMEM);
159
160 init.name = name;
161 init.ops = &main_osc_ops;
162 init.parent_names = &parent_name;
163 init.num_parents = 1;
164 init.flags = CLK_IGNORE_UNUSED;
165
166 osc->hw.init = &init;
167 osc->pmc = pmc;
168 osc->irq = irq;
169
170 init_waitqueue_head(&osc->wait);
171 irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
172 ret = request_irq(osc->irq, clk_main_osc_irq_handler,
173 IRQF_TRIGGER_HIGH, name, osc);
174 if (ret)
175 return ERR_PTR(ret);
176
177 if (bypass)
178 pmc_write(pmc, AT91_CKGR_MOR,
179 (pmc_read(pmc, AT91_CKGR_MOR) &
180 ~(MOR_KEY_MASK | AT91_PMC_MOSCEN)) |
181 AT91_PMC_OSCBYPASS | AT91_PMC_KEY);
182
183 clk = clk_register(NULL, &osc->hw);
184 if (IS_ERR(clk)) {
185 free_irq(irq, osc);
186 kfree(osc);
187 }
188
189 return clk;
190}
191
192void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np,
193 struct at91_pmc *pmc)
194{
195 struct clk *clk;
196 unsigned int irq;
197 const char *name = np->name;
198 const char *parent_name;
199 bool bypass;
200
201 of_property_read_string(np, "clock-output-names", &name);
202 bypass = of_property_read_bool(np, "atmel,osc-bypass");
203 parent_name = of_clk_get_parent_name(np, 0);
204
205 irq = irq_of_parse_and_map(np, 0);
206 if (!irq)
207 return;
208
209 clk = at91_clk_register_main_osc(pmc, irq, name, parent_name, bypass);
210 if (IS_ERR(clk))
211 return;
212
213 of_clk_add_provider(np, of_clk_src_simple_get, clk);
214}
215
216static irqreturn_t clk_main_rc_osc_irq_handler(int irq, void *dev_id)
217{
218 struct clk_main_rc_osc *osc = dev_id;
219
220 wake_up(&osc->wait);
221 disable_irq_nosync(osc->irq);
222
223 return IRQ_HANDLED;
224}
225
226static int clk_main_rc_osc_prepare(struct clk_hw *hw)
227{
228 struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw);
229 struct at91_pmc *pmc = osc->pmc;
230 u32 tmp;
231
232 tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK;
233
234 if (!(tmp & AT91_PMC_MOSCRCEN)) {
235 tmp |= AT91_PMC_MOSCRCEN | AT91_PMC_KEY;
236 pmc_write(pmc, AT91_CKGR_MOR, tmp);
237 }
238
239 while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS)) {
240 enable_irq(osc->irq);
241 wait_event(osc->wait,
242 pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS);
243 }
244
245 return 0;
246}
247
248static void clk_main_rc_osc_unprepare(struct clk_hw *hw)
249{
250 struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw);
251 struct at91_pmc *pmc = osc->pmc;
252 u32 tmp = pmc_read(pmc, AT91_CKGR_MOR);
253
254 if (!(tmp & AT91_PMC_MOSCRCEN))
255 return;
256
257 tmp &= ~(MOR_KEY_MASK | AT91_PMC_MOSCRCEN);
258 pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_KEY);
259}
260
261static int clk_main_rc_osc_is_prepared(struct clk_hw *hw)
262{
263 struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw);
264 struct at91_pmc *pmc = osc->pmc;
265
266 return !!((pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCRCS) &&
267 (pmc_read(pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCRCEN));
268}
269
270static unsigned long clk_main_rc_osc_recalc_rate(struct clk_hw *hw,
271 unsigned long parent_rate)
272{
273 struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw);
274
275 return osc->frequency;
276}
277
278static unsigned long clk_main_rc_osc_recalc_accuracy(struct clk_hw *hw,
279 unsigned long parent_acc)
280{
281 struct clk_main_rc_osc *osc = to_clk_main_rc_osc(hw);
282
283 return osc->accuracy;
284}
285
286static const struct clk_ops main_rc_osc_ops = {
287 .prepare = clk_main_rc_osc_prepare,
288 .unprepare = clk_main_rc_osc_unprepare,
289 .is_prepared = clk_main_rc_osc_is_prepared,
290 .recalc_rate = clk_main_rc_osc_recalc_rate,
291 .recalc_accuracy = clk_main_rc_osc_recalc_accuracy,
292};
293
294static struct clk * __init
295at91_clk_register_main_rc_osc(struct at91_pmc *pmc,
296 unsigned int irq,
297 const char *name,
298 u32 frequency, u32 accuracy)
299{
300 int ret;
301 struct clk_main_rc_osc *osc;
302 struct clk *clk = NULL;
303 struct clk_init_data init;
304
305 if (!pmc || !irq || !name || !frequency)
306 return ERR_PTR(-EINVAL);
307
308 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
309 if (!osc)
310 return ERR_PTR(-ENOMEM);
311
312 init.name = name;
313 init.ops = &main_rc_osc_ops;
314 init.parent_names = NULL;
315 init.num_parents = 0;
316 init.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED;
317
318 osc->hw.init = &init;
319 osc->pmc = pmc;
320 osc->irq = irq;
321 osc->frequency = frequency;
322 osc->accuracy = accuracy;
323
324 init_waitqueue_head(&osc->wait);
325 irq_set_status_flags(osc->irq, IRQ_NOAUTOEN);
326 ret = request_irq(osc->irq, clk_main_rc_osc_irq_handler,
327 IRQF_TRIGGER_HIGH, name, osc);
328 if (ret)
329 return ERR_PTR(ret);
330
331 clk = clk_register(NULL, &osc->hw);
332 if (IS_ERR(clk)) {
333 free_irq(irq, osc);
334 kfree(osc);
335 }
336
337 return clk;
338}
339
340void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np,
341 struct at91_pmc *pmc)
342{
343 struct clk *clk;
344 unsigned int irq;
345 u32 frequency = 0;
346 u32 accuracy = 0;
347 const char *name = np->name;
348
349 of_property_read_string(np, "clock-output-names", &name);
350 of_property_read_u32(np, "clock-frequency", &frequency);
351 of_property_read_u32(np, "clock-accuracy", &accuracy);
352
353 irq = irq_of_parse_and_map(np, 0);
354 if (!irq)
355 return;
356
357 clk = at91_clk_register_main_rc_osc(pmc, irq, name, frequency,
358 accuracy);
359 if (IS_ERR(clk))
360 return;
361
362 of_clk_add_provider(np, of_clk_src_simple_get, clk);
363}
364
365
366static int clk_main_probe_frequency(struct at91_pmc *pmc)
367{
368 unsigned long prep_time, timeout;
369 u32 tmp;
68 370
69 timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT); 371 timeout = jiffies + usecs_to_jiffies(MAINFRDY_TIMEOUT);
70 do { 372 do {
71 halt_time = jiffies; 373 prep_time = jiffies;
72 tmp = pmc_read(pmc, AT91_CKGR_MCFR); 374 tmp = pmc_read(pmc, AT91_CKGR_MCFR);
73 if (tmp & AT91_PMC_MAINRDY) 375 if (tmp & AT91_PMC_MAINRDY)
74 return 0; 376 return 0;
75 usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT); 377 usleep_range(MAINF_LOOP_MIN_WAIT, MAINF_LOOP_MAX_WAIT);
76 } while (time_before(halt_time, timeout)); 378 } while (time_before(prep_time, timeout));
77 379
78 return 0; 380 return -ETIMEDOUT;
79} 381}
80 382
81static int clk_main_is_prepared(struct clk_hw *hw) 383static unsigned long clk_main_recalc_rate(struct at91_pmc *pmc,
384 unsigned long parent_rate)
82{ 385{
83 struct clk_main *clkmain = to_clk_main(hw); 386 u32 tmp;
387
388 if (parent_rate)
389 return parent_rate;
390
391 tmp = pmc_read(pmc, AT91_CKGR_MCFR);
392 if (!(tmp & AT91_PMC_MAINRDY))
393 return 0;
84 394
85 return !!(pmc_read(clkmain->pmc, AT91_PMC_SR) & AT91_PMC_MOSCS); 395 return ((tmp & AT91_PMC_MAINF) * SLOW_CLOCK_FREQ) / MAINF_DIV;
86} 396}
87 397
88static unsigned long clk_main_recalc_rate(struct clk_hw *hw, 398static int clk_rm9200_main_prepare(struct clk_hw *hw)
89 unsigned long parent_rate)
90{ 399{
91 u32 tmp; 400 struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw);
92 struct clk_main *clkmain = to_clk_main(hw); 401
402 return clk_main_probe_frequency(clkmain->pmc);
403}
404
405static int clk_rm9200_main_is_prepared(struct clk_hw *hw)
406{
407 struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw);
408
409 return !!(pmc_read(clkmain->pmc, AT91_CKGR_MCFR) & AT91_PMC_MAINRDY);
410}
411
412static unsigned long clk_rm9200_main_recalc_rate(struct clk_hw *hw,
413 unsigned long parent_rate)
414{
415 struct clk_rm9200_main *clkmain = to_clk_rm9200_main(hw);
416
417 return clk_main_recalc_rate(clkmain->pmc, parent_rate);
418}
419
420static const struct clk_ops rm9200_main_ops = {
421 .prepare = clk_rm9200_main_prepare,
422 .is_prepared = clk_rm9200_main_is_prepared,
423 .recalc_rate = clk_rm9200_main_recalc_rate,
424};
425
426static struct clk * __init
427at91_clk_register_rm9200_main(struct at91_pmc *pmc,
428 const char *name,
429 const char *parent_name)
430{
431 struct clk_rm9200_main *clkmain;
432 struct clk *clk = NULL;
433 struct clk_init_data init;
434
435 if (!pmc || !name)
436 return ERR_PTR(-EINVAL);
437
438 if (!parent_name)
439 return ERR_PTR(-EINVAL);
440
441 clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
442 if (!clkmain)
443 return ERR_PTR(-ENOMEM);
444
445 init.name = name;
446 init.ops = &rm9200_main_ops;
447 init.parent_names = &parent_name;
448 init.num_parents = 1;
449 init.flags = 0;
450
451 clkmain->hw.init = &init;
452 clkmain->pmc = pmc;
453
454 clk = clk_register(NULL, &clkmain->hw);
455 if (IS_ERR(clk))
456 kfree(clkmain);
457
458 return clk;
459}
460
461void __init of_at91rm9200_clk_main_setup(struct device_node *np,
462 struct at91_pmc *pmc)
463{
464 struct clk *clk;
465 const char *parent_name;
466 const char *name = np->name;
467
468 parent_name = of_clk_get_parent_name(np, 0);
469 of_property_read_string(np, "clock-output-names", &name);
470
471 clk = at91_clk_register_rm9200_main(pmc, name, parent_name);
472 if (IS_ERR(clk))
473 return;
474
475 of_clk_add_provider(np, of_clk_src_simple_get, clk);
476}
477
478static irqreturn_t clk_sam9x5_main_irq_handler(int irq, void *dev_id)
479{
480 struct clk_sam9x5_main *clkmain = dev_id;
481
482 wake_up(&clkmain->wait);
483 disable_irq_nosync(clkmain->irq);
484
485 return IRQ_HANDLED;
486}
487
488static int clk_sam9x5_main_prepare(struct clk_hw *hw)
489{
490 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
93 struct at91_pmc *pmc = clkmain->pmc; 491 struct at91_pmc *pmc = clkmain->pmc;
94 492
95 if (clkmain->rate) 493 while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS)) {
96 return clkmain->rate; 494 enable_irq(clkmain->irq);
495 wait_event(clkmain->wait,
496 pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS);
497 }
498
499 return clk_main_probe_frequency(pmc);
500}
97 501
98 tmp = pmc_read(pmc, AT91_CKGR_MCFR) & AT91_PMC_MAINF; 502static int clk_sam9x5_main_is_prepared(struct clk_hw *hw)
99 clkmain->rate = (tmp * parent_rate) / MAINF_DIV; 503{
504 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
100 505
101 return clkmain->rate; 506 return !!(pmc_read(clkmain->pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS);
102} 507}
103 508
104static const struct clk_ops main_ops = { 509static unsigned long clk_sam9x5_main_recalc_rate(struct clk_hw *hw,
105 .prepare = clk_main_prepare, 510 unsigned long parent_rate)
106 .is_prepared = clk_main_is_prepared, 511{
107 .recalc_rate = clk_main_recalc_rate, 512 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
513
514 return clk_main_recalc_rate(clkmain->pmc, parent_rate);
515}
516
517static int clk_sam9x5_main_set_parent(struct clk_hw *hw, u8 index)
518{
519 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
520 struct at91_pmc *pmc = clkmain->pmc;
521 u32 tmp;
522
523 if (index > 1)
524 return -EINVAL;
525
526 tmp = pmc_read(pmc, AT91_CKGR_MOR) & ~MOR_KEY_MASK;
527
528 if (index && !(tmp & AT91_PMC_MOSCSEL))
529 pmc_write(pmc, AT91_CKGR_MOR, tmp | AT91_PMC_MOSCSEL);
530 else if (!index && (tmp & AT91_PMC_MOSCSEL))
531 pmc_write(pmc, AT91_CKGR_MOR, tmp & ~AT91_PMC_MOSCSEL);
532
533 while (!(pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS)) {
534 enable_irq(clkmain->irq);
535 wait_event(clkmain->wait,
536 pmc_read(pmc, AT91_PMC_SR) & AT91_PMC_MOSCSELS);
537 }
538
539 return 0;
540}
541
542static u8 clk_sam9x5_main_get_parent(struct clk_hw *hw)
543{
544 struct clk_sam9x5_main *clkmain = to_clk_sam9x5_main(hw);
545
546 return !!(pmc_read(clkmain->pmc, AT91_CKGR_MOR) & AT91_PMC_MOSCEN);
547}
548
549static const struct clk_ops sam9x5_main_ops = {
550 .prepare = clk_sam9x5_main_prepare,
551 .is_prepared = clk_sam9x5_main_is_prepared,
552 .recalc_rate = clk_sam9x5_main_recalc_rate,
553 .set_parent = clk_sam9x5_main_set_parent,
554 .get_parent = clk_sam9x5_main_get_parent,
108}; 555};
109 556
110static struct clk * __init 557static struct clk * __init
111at91_clk_register_main(struct at91_pmc *pmc, 558at91_clk_register_sam9x5_main(struct at91_pmc *pmc,
112 unsigned int irq, 559 unsigned int irq,
113 const char *name, 560 const char *name,
114 const char *parent_name, 561 const char **parent_names,
115 unsigned long rate) 562 int num_parents)
116{ 563{
117 int ret; 564 int ret;
118 struct clk_main *clkmain; 565 struct clk_sam9x5_main *clkmain;
119 struct clk *clk = NULL; 566 struct clk *clk = NULL;
120 struct clk_init_data init; 567 struct clk_init_data init;
121 568
122 if (!pmc || !irq || !name) 569 if (!pmc || !irq || !name)
123 return ERR_PTR(-EINVAL); 570 return ERR_PTR(-EINVAL);
124 571
125 if (!rate && !parent_name) 572 if (!parent_names || !num_parents)
126 return ERR_PTR(-EINVAL); 573 return ERR_PTR(-EINVAL);
127 574
128 clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL); 575 clkmain = kzalloc(sizeof(*clkmain), GFP_KERNEL);
@@ -130,19 +577,20 @@ at91_clk_register_main(struct at91_pmc *pmc,
130 return ERR_PTR(-ENOMEM); 577 return ERR_PTR(-ENOMEM);
131 578
132 init.name = name; 579 init.name = name;
133 init.ops = &main_ops; 580 init.ops = &sam9x5_main_ops;
134 init.parent_names = parent_name ? &parent_name : NULL; 581 init.parent_names = parent_names;
135 init.num_parents = parent_name ? 1 : 0; 582 init.num_parents = num_parents;
136 init.flags = parent_name ? 0 : CLK_IS_ROOT; 583 init.flags = CLK_SET_PARENT_GATE;
137 584
138 clkmain->hw.init = &init; 585 clkmain->hw.init = &init;
139 clkmain->rate = rate;
140 clkmain->pmc = pmc; 586 clkmain->pmc = pmc;
141 clkmain->irq = irq; 587 clkmain->irq = irq;
588 clkmain->parent = !!(pmc_read(clkmain->pmc, AT91_CKGR_MOR) &
589 AT91_PMC_MOSCEN);
142 init_waitqueue_head(&clkmain->wait); 590 init_waitqueue_head(&clkmain->wait);
143 irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN); 591 irq_set_status_flags(clkmain->irq, IRQ_NOAUTOEN);
144 ret = request_irq(clkmain->irq, clk_main_irq_handler, 592 ret = request_irq(clkmain->irq, clk_sam9x5_main_irq_handler,
145 IRQF_TRIGGER_HIGH, "clk-main", clkmain); 593 IRQF_TRIGGER_HIGH, name, clkmain);
146 if (ret) 594 if (ret)
147 return ERR_PTR(ret); 595 return ERR_PTR(ret);
148 596
@@ -155,33 +603,36 @@ at91_clk_register_main(struct at91_pmc *pmc,
155 return clk; 603 return clk;
156} 604}
157 605
158 606void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
159 607 struct at91_pmc *pmc)
160static void __init
161of_at91_clk_main_setup(struct device_node *np, struct at91_pmc *pmc)
162{ 608{
163 struct clk *clk; 609 struct clk *clk;
610 const char *parent_names[2];
611 int num_parents;
164 unsigned int irq; 612 unsigned int irq;
165 const char *parent_name;
166 const char *name = np->name; 613 const char *name = np->name;
167 u32 rate = 0; 614 int i;
615
616 num_parents = of_count_phandle_with_args(np, "clocks", "#clock-cells");
617 if (num_parents <= 0 || num_parents > 2)
618 return;
619
620 for (i = 0; i < num_parents; ++i) {
621 parent_names[i] = of_clk_get_parent_name(np, i);
622 if (!parent_names[i])
623 return;
624 }
168 625
169 parent_name = of_clk_get_parent_name(np, 0);
170 of_property_read_string(np, "clock-output-names", &name); 626 of_property_read_string(np, "clock-output-names", &name);
171 of_property_read_u32(np, "clock-frequency", &rate); 627
172 irq = irq_of_parse_and_map(np, 0); 628 irq = irq_of_parse_and_map(np, 0);
173 if (!irq) 629 if (!irq)
174 return; 630 return;
175 631
176 clk = at91_clk_register_main(pmc, irq, name, parent_name, rate); 632 clk = at91_clk_register_sam9x5_main(pmc, irq, name, parent_names,
633 num_parents);
177 if (IS_ERR(clk)) 634 if (IS_ERR(clk))
178 return; 635 return;
179 636
180 of_clk_add_provider(np, of_clk_src_simple_get, clk); 637 of_clk_add_provider(np, of_clk_src_simple_get, clk);
181} 638}
182
183void __init of_at91rm9200_clk_main_setup(struct device_node *np,
184 struct at91_pmc *pmc)
185{
186 of_at91_clk_main_setup(np, pmc);
187}
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
new file mode 100644
index 000000000000..0300c46ee247
--- /dev/null
+++ b/drivers/clk/at91/clk-slow.c
@@ -0,0 +1,467 @@
1/*
2 * drivers/clk/at91/clk-slow.c
3 *
4 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */
12
13#include <linux/clk-provider.h>
14#include <linux/clkdev.h>
15#include <linux/clk/at91_pmc.h>
16#include <linux/delay.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19#include <linux/of_irq.h>
20#include <linux/io.h>
21#include <linux/interrupt.h>
22#include <linux/irq.h>
23#include <linux/sched.h>
24#include <linux/wait.h>
25
26#include "pmc.h"
27#include "sckc.h"
28
29#define SLOW_CLOCK_FREQ 32768
30#define SLOWCK_SW_CYCLES 5
31#define SLOWCK_SW_TIME_USEC ((SLOWCK_SW_CYCLES * USEC_PER_SEC) / \
32 SLOW_CLOCK_FREQ)
33
34#define AT91_SCKC_CR 0x00
35#define AT91_SCKC_RCEN (1 << 0)
36#define AT91_SCKC_OSC32EN (1 << 1)
37#define AT91_SCKC_OSC32BYP (1 << 2)
38#define AT91_SCKC_OSCSEL (1 << 3)
39
40struct clk_slow_osc {
41 struct clk_hw hw;
42 void __iomem *sckcr;
43 unsigned long startup_usec;
44};
45
46#define to_clk_slow_osc(hw) container_of(hw, struct clk_slow_osc, hw)
47
48struct clk_slow_rc_osc {
49 struct clk_hw hw;
50 void __iomem *sckcr;
51 unsigned long frequency;
52 unsigned long accuracy;
53 unsigned long startup_usec;
54};
55
56#define to_clk_slow_rc_osc(hw) container_of(hw, struct clk_slow_rc_osc, hw)
57
58struct clk_sam9260_slow {
59 struct clk_hw hw;
60 struct at91_pmc *pmc;
61};
62
63#define to_clk_sam9260_slow(hw) container_of(hw, struct clk_sam9260_slow, hw)
64
65struct clk_sam9x5_slow {
66 struct clk_hw hw;
67 void __iomem *sckcr;
68 u8 parent;
69};
70
71#define to_clk_sam9x5_slow(hw) container_of(hw, struct clk_sam9x5_slow, hw)
72
73
74static int clk_slow_osc_prepare(struct clk_hw *hw)
75{
76 struct clk_slow_osc *osc = to_clk_slow_osc(hw);
77 void __iomem *sckcr = osc->sckcr;
78 u32 tmp = readl(sckcr);
79
80 if (tmp & AT91_SCKC_OSC32BYP)
81 return 0;
82
83 writel(tmp | AT91_SCKC_OSC32EN, sckcr);
84
85 usleep_range(osc->startup_usec, osc->startup_usec + 1);
86
87 return 0;
88}
89
90static void clk_slow_osc_unprepare(struct clk_hw *hw)
91{
92 struct clk_slow_osc *osc = to_clk_slow_osc(hw);
93 void __iomem *sckcr = osc->sckcr;
94 u32 tmp = readl(sckcr);
95
96 if (tmp & AT91_SCKC_OSC32BYP)
97 return;
98
99 writel(tmp & ~AT91_SCKC_OSC32EN, sckcr);
100}
101
102static int clk_slow_osc_is_prepared(struct clk_hw *hw)
103{
104 struct clk_slow_osc *osc = to_clk_slow_osc(hw);
105 void __iomem *sckcr = osc->sckcr;
106 u32 tmp = readl(sckcr);
107
108 if (tmp & AT91_SCKC_OSC32BYP)
109 return 1;
110
111 return !!(tmp & AT91_SCKC_OSC32EN);
112}
113
114static const struct clk_ops slow_osc_ops = {
115 .prepare = clk_slow_osc_prepare,
116 .unprepare = clk_slow_osc_unprepare,
117 .is_prepared = clk_slow_osc_is_prepared,
118};
119
120static struct clk * __init
121at91_clk_register_slow_osc(void __iomem *sckcr,
122 const char *name,
123 const char *parent_name,
124 unsigned long startup,
125 bool bypass)
126{
127 struct clk_slow_osc *osc;
128 struct clk *clk = NULL;
129 struct clk_init_data init;
130
131 if (!sckcr || !name || !parent_name)
132 return ERR_PTR(-EINVAL);
133
134 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
135 if (!osc)
136 return ERR_PTR(-ENOMEM);
137
138 init.name = name;
139 init.ops = &slow_osc_ops;
140 init.parent_names = &parent_name;
141 init.num_parents = 1;
142 init.flags = CLK_IGNORE_UNUSED;
143
144 osc->hw.init = &init;
145 osc->sckcr = sckcr;
146 osc->startup_usec = startup;
147
148 if (bypass)
149 writel((readl(sckcr) & ~AT91_SCKC_OSC32EN) | AT91_SCKC_OSC32BYP,
150 sckcr);
151
152 clk = clk_register(NULL, &osc->hw);
153 if (IS_ERR(clk))
154 kfree(osc);
155
156 return clk;
157}
158
159void __init of_at91sam9x5_clk_slow_osc_setup(struct device_node *np,
160 void __iomem *sckcr)
161{
162 struct clk *clk;
163 const char *parent_name;
164 const char *name = np->name;
165 u32 startup;
166 bool bypass;
167
168 parent_name = of_clk_get_parent_name(np, 0);
169 of_property_read_string(np, "clock-output-names", &name);
170 of_property_read_u32(np, "atmel,startup-time-usec", &startup);
171 bypass = of_property_read_bool(np, "atmel,osc-bypass");
172
173 clk = at91_clk_register_slow_osc(sckcr, name, parent_name, startup,
174 bypass);
175 if (IS_ERR(clk))
176 return;
177
178 of_clk_add_provider(np, of_clk_src_simple_get, clk);
179}
180
181static unsigned long clk_slow_rc_osc_recalc_rate(struct clk_hw *hw,
182 unsigned long parent_rate)
183{
184 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
185
186 return osc->frequency;
187}
188
189static unsigned long clk_slow_rc_osc_recalc_accuracy(struct clk_hw *hw,
190 unsigned long parent_acc)
191{
192 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
193
194 return osc->accuracy;
195}
196
197static int clk_slow_rc_osc_prepare(struct clk_hw *hw)
198{
199 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
200 void __iomem *sckcr = osc->sckcr;
201
202 writel(readl(sckcr) | AT91_SCKC_RCEN, sckcr);
203
204 usleep_range(osc->startup_usec, osc->startup_usec + 1);
205
206 return 0;
207}
208
209static void clk_slow_rc_osc_unprepare(struct clk_hw *hw)
210{
211 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
212 void __iomem *sckcr = osc->sckcr;
213
214 writel(readl(sckcr) & ~AT91_SCKC_RCEN, sckcr);
215}
216
217static int clk_slow_rc_osc_is_prepared(struct clk_hw *hw)
218{
219 struct clk_slow_rc_osc *osc = to_clk_slow_rc_osc(hw);
220
221 return !!(readl(osc->sckcr) & AT91_SCKC_RCEN);
222}
223
224static const struct clk_ops slow_rc_osc_ops = {
225 .prepare = clk_slow_rc_osc_prepare,
226 .unprepare = clk_slow_rc_osc_unprepare,
227 .is_prepared = clk_slow_rc_osc_is_prepared,
228 .recalc_rate = clk_slow_rc_osc_recalc_rate,
229 .recalc_accuracy = clk_slow_rc_osc_recalc_accuracy,
230};
231
232static struct clk * __init
233at91_clk_register_slow_rc_osc(void __iomem *sckcr,
234 const char *name,
235 unsigned long frequency,
236 unsigned long accuracy,
237 unsigned long startup)
238{
239 struct clk_slow_rc_osc *osc;
240 struct clk *clk = NULL;
241 struct clk_init_data init;
242
243 if (!sckcr || !name)
244 return ERR_PTR(-EINVAL);
245
246 osc = kzalloc(sizeof(*osc), GFP_KERNEL);
247 if (!osc)
248 return ERR_PTR(-ENOMEM);
249
250 init.name = name;
251 init.ops = &slow_rc_osc_ops;
252 init.parent_names = NULL;
253 init.num_parents = 0;
254 init.flags = CLK_IS_ROOT | CLK_IGNORE_UNUSED;
255
256 osc->hw.init = &init;
257 osc->sckcr = sckcr;
258 osc->frequency = frequency;
259 osc->accuracy = accuracy;
260 osc->startup_usec = startup;
261
262 clk = clk_register(NULL, &osc->hw);
263 if (IS_ERR(clk))
264 kfree(osc);
265
266 return clk;
267}
268
269void __init of_at91sam9x5_clk_slow_rc_osc_setup(struct device_node *np,
270 void __iomem *sckcr)
271{
272 struct clk *clk;
273 u32 frequency = 0;
274 u32 accuracy = 0;
275 u32 startup = 0;
276 const char *name = np->name;
277
278 of_property_read_string(np, "clock-output-names", &name);
279 of_property_read_u32(np, "clock-frequency", &frequency);
280 of_property_read_u32(np, "clock-accuracy", &accuracy);
281 of_property_read_u32(np, "atmel,startup-time-usec", &startup);
282
283 clk = at91_clk_register_slow_rc_osc(sckcr, name, frequency, accuracy,
284 startup);
285 if (IS_ERR(clk))
286 return;
287
288 of_clk_add_provider(np, of_clk_src_simple_get, clk);
289}
290
291static int clk_sam9x5_slow_set_parent(struct clk_hw *hw, u8 index)
292{
293 struct clk_sam9x5_slow *slowck = to_clk_sam9x5_slow(hw);
294 void __iomem *sckcr = slowck->sckcr;
295 u32 tmp;
296
297 if (index > 1)
298 return -EINVAL;
299
300 tmp = readl(sckcr);
301
302 if ((!index && !(tmp & AT91_SCKC_OSCSEL)) ||
303 (index && (tmp & AT91_SCKC_OSCSEL)))
304 return 0;
305
306 if (index)
307 tmp |= AT91_SCKC_OSCSEL;
308 else
309 tmp &= ~AT91_SCKC_OSCSEL;
310
311 writel(tmp, sckcr);
312
313 usleep_range(SLOWCK_SW_TIME_USEC, SLOWCK_SW_TIME_USEC + 1);
314
315 return 0;
316}
317
318static u8 clk_sam9x5_slow_get_parent(struct clk_hw *hw)
319{
320 struct clk_sam9x5_slow *slowck = to_clk_sam9x5_slow(hw);
321
322 return !!(readl(slowck->sckcr) & AT91_SCKC_OSCSEL);
323}
324
325static const struct clk_ops sam9x5_slow_ops = {
326 .set_parent = clk_sam9x5_slow_set_parent,
327 .get_parent = clk_sam9x5_slow_get_parent,
328};
329
330static struct clk * __init
331at91_clk_register_sam9x5_slow(void __iomem *sckcr,
332 const char *name,
333 const char **parent_names,
334 int num_parents)
335{
336 struct clk_sam9x5_slow *slowck;
337 struct clk *clk = NULL;
338 struct clk_init_data init;
339
340 if (!sckcr || !name || !parent_names || !num_parents)
341 return ERR_PTR(-EINVAL);
342
343 slowck = kzalloc(sizeof(*slowck), GFP_KERNEL);
344 if (!slowck)
345 return ERR_PTR(-ENOMEM);
346
347 init.name = name;
348 init.ops = &sam9x5_slow_ops;
349 init.parent_names = parent_names;
350 init.num_parents = num_parents;
351 init.flags = 0;
352
353 slowck->hw.init = &init;
354 slowck->sckcr = sckcr;
355 slowck->parent = !!(readl(sckcr) & AT91_SCKC_OSCSEL);
356
357 clk = clk_register(NULL, &slowck->hw);
358 if (IS_ERR(clk))
359 kfree(slowck);
360
361 return clk;
362}
363
364void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
365 void __iomem *sckcr)
366{
367 struct clk *clk;
368 const char *parent_names[2];
369 int num_parents;
370 const char *name = np->name;
371 int i;
372
373 num_parents = of_count_phandle_with_args(np, "clocks", "#clock-cells");
374 if (num_parents <= 0 || num_parents > 2)
375 return;
376
377 for (i = 0; i < num_parents; ++i) {
378 parent_names[i] = of_clk_get_parent_name(np, i);
379 if (!parent_names[i])
380 return;
381 }
382
383 of_property_read_string(np, "clock-output-names", &name);
384
385 clk = at91_clk_register_sam9x5_slow(sckcr, name, parent_names,
386 num_parents);
387 if (IS_ERR(clk))
388 return;
389
390 of_clk_add_provider(np, of_clk_src_simple_get, clk);
391}
392
393static u8 clk_sam9260_slow_get_parent(struct clk_hw *hw)
394{
395 struct clk_sam9260_slow *slowck = to_clk_sam9260_slow(hw);
396
397 return !!(pmc_read(slowck->pmc, AT91_PMC_SR) & AT91_PMC_OSCSEL);
398}
399
400static const struct clk_ops sam9260_slow_ops = {
401 .get_parent = clk_sam9260_slow_get_parent,
402};
403
404static struct clk * __init
405at91_clk_register_sam9260_slow(struct at91_pmc *pmc,
406 const char *name,
407 const char **parent_names,
408 int num_parents)
409{
410 struct clk_sam9260_slow *slowck;
411 struct clk *clk = NULL;
412 struct clk_init_data init;
413
414 if (!pmc || !name)
415 return ERR_PTR(-EINVAL);
416
417 if (!parent_names || !num_parents)
418 return ERR_PTR(-EINVAL);
419
420 slowck = kzalloc(sizeof(*slowck), GFP_KERNEL);
421 if (!slowck)
422 return ERR_PTR(-ENOMEM);
423
424 init.name = name;
425 init.ops = &sam9260_slow_ops;
426 init.parent_names = parent_names;
427 init.num_parents = num_parents;
428 init.flags = 0;
429
430 slowck->hw.init = &init;
431 slowck->pmc = pmc;
432
433 clk = clk_register(NULL, &slowck->hw);
434 if (IS_ERR(clk))
435 kfree(slowck);
436
437 return clk;
438}
439
440void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
441 struct at91_pmc *pmc)
442{
443 struct clk *clk;
444 const char *parent_names[2];
445 int num_parents;
446 const char *name = np->name;
447 int i;
448
449 num_parents = of_count_phandle_with_args(np, "clocks", "#clock-cells");
450 if (num_parents <= 0 || num_parents > 1)
451 return;
452
453 for (i = 0; i < num_parents; ++i) {
454 parent_names[i] = of_clk_get_parent_name(np, i);
455 if (!parent_names[i])
456 return;
457 }
458
459 of_property_read_string(np, "clock-output-names", &name);
460
461 clk = at91_clk_register_sam9260_slow(pmc, name, parent_names,
462 num_parents);
463 if (IS_ERR(clk))
464 return;
465
466 of_clk_add_provider(np, of_clk_src_simple_get, clk);
467}
diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
index 6a61477a57e0..524196bb35a5 100644
--- a/drivers/clk/at91/pmc.c
+++ b/drivers/clk/at91/pmc.c
@@ -229,11 +229,28 @@ out_free_pmc:
229} 229}
230 230
231static const struct of_device_id pmc_clk_ids[] __initconst = { 231static const struct of_device_id pmc_clk_ids[] __initconst = {
232 /* Slow oscillator */
233 {
234 .compatible = "atmel,at91sam9260-clk-slow",
235 .data = of_at91sam9260_clk_slow_setup,
236 },
232 /* Main clock */ 237 /* Main clock */
233 { 238 {
239 .compatible = "atmel,at91rm9200-clk-main-osc",
240 .data = of_at91rm9200_clk_main_osc_setup,
241 },
242 {
243 .compatible = "atmel,at91sam9x5-clk-main-rc-osc",
244 .data = of_at91sam9x5_clk_main_rc_osc_setup,
245 },
246 {
234 .compatible = "atmel,at91rm9200-clk-main", 247 .compatible = "atmel,at91rm9200-clk-main",
235 .data = of_at91rm9200_clk_main_setup, 248 .data = of_at91rm9200_clk_main_setup,
236 }, 249 },
250 {
251 .compatible = "atmel,at91sam9x5-clk-main",
252 .data = of_at91sam9x5_clk_main_setup,
253 },
237 /* PLL clocks */ 254 /* PLL clocks */
238 { 255 {
239 .compatible = "atmel,at91rm9200-clk-pll", 256 .compatible = "atmel,at91rm9200-clk-pll",
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h
index 441350983ccb..6c7625976113 100644
--- a/drivers/clk/at91/pmc.h
+++ b/drivers/clk/at91/pmc.h
@@ -58,8 +58,17 @@ static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value)
58int of_at91_get_clk_range(struct device_node *np, const char *propname, 58int of_at91_get_clk_range(struct device_node *np, const char *propname,
59 struct clk_range *range); 59 struct clk_range *range);
60 60
61extern void __init of_at91sam9260_clk_slow_setup(struct device_node *np,
62 struct at91_pmc *pmc);
63
64extern void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np,
65 struct at91_pmc *pmc);
66extern void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np,
67 struct at91_pmc *pmc);
61extern void __init of_at91rm9200_clk_main_setup(struct device_node *np, 68extern void __init of_at91rm9200_clk_main_setup(struct device_node *np,
62 struct at91_pmc *pmc); 69 struct at91_pmc *pmc);
70extern void __init of_at91sam9x5_clk_main_setup(struct device_node *np,
71 struct at91_pmc *pmc);
63 72
64extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np, 73extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np,
65 struct at91_pmc *pmc); 74 struct at91_pmc *pmc);
diff --git a/drivers/clk/at91/sckc.c b/drivers/clk/at91/sckc.c
new file mode 100644
index 000000000000..1184d76a7ab7
--- /dev/null
+++ b/drivers/clk/at91/sckc.c
@@ -0,0 +1,57 @@
1/*
2 * drivers/clk/at91/sckc.c
3 *
4 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 */
12
13#include <linux/clk-provider.h>
14#include <linux/clkdev.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
17#include <linux/io.h>
18
19#include "sckc.h"
20
21static const struct of_device_id sckc_clk_ids[] __initconst = {
22 /* Slow clock */
23 {
24 .compatible = "atmel,at91sam9x5-clk-slow-osc",
25 .data = of_at91sam9x5_clk_slow_osc_setup,
26 },
27 {
28 .compatible = "atmel,at91sam9x5-clk-slow-rc-osc",
29 .data = of_at91sam9x5_clk_slow_rc_osc_setup,
30 },
31 {
32 .compatible = "atmel,at91sam9x5-clk-slow",
33 .data = of_at91sam9x5_clk_slow_setup,
34 },
35 { /*sentinel*/ }
36};
37
38static void __init of_at91sam9x5_sckc_setup(struct device_node *np)
39{
40 struct device_node *childnp;
41 void (*clk_setup)(struct device_node *, void __iomem *);
42 const struct of_device_id *clk_id;
43 void __iomem *regbase = of_iomap(np, 0);
44
45 if (!regbase)
46 return;
47
48 for_each_child_of_node(np, childnp) {
49 clk_id = of_match_node(sckc_clk_ids, childnp);
50 if (!clk_id)
51 continue;
52 clk_setup = clk_id->data;
53 clk_setup(childnp, regbase);
54 }
55}
56CLK_OF_DECLARE(at91sam9x5_clk_sckc, "atmel,at91sam9x5-sckc",
57 of_at91sam9x5_sckc_setup);
diff --git a/drivers/clk/at91/sckc.h b/drivers/clk/at91/sckc.h
new file mode 100644
index 000000000000..836fcf59820f
--- /dev/null
+++ b/drivers/clk/at91/sckc.h
@@ -0,0 +1,22 @@
1/*
2 * drivers/clk/at91/sckc.h
3 *
4 * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com>
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 as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 */
11
12#ifndef __AT91_SCKC_H_
13#define __AT91_SCKC_H_
14
15extern void __init of_at91sam9x5_clk_slow_osc_setup(struct device_node *np,
16 void __iomem *sckcr);
17extern void __init of_at91sam9x5_clk_slow_rc_osc_setup(struct device_node *np,
18 void __iomem *sckcr);
19extern void __init of_at91sam9x5_clk_slow_setup(struct device_node *np,
20 void __iomem *sckcr);
21
22#endif /* __AT91_SCKC_H_ */
diff --git a/drivers/clk/samsung/Kconfig b/drivers/clk/samsung/Kconfig
new file mode 100644
index 000000000000..84196ecdaa12
--- /dev/null
+++ b/drivers/clk/samsung/Kconfig
@@ -0,0 +1,26 @@
1config COMMON_CLK_SAMSUNG
2 bool
3 select COMMON_CLK
4
5config S3C2410_COMMON_CLK
6 bool
7 select COMMON_CLK_SAMSUNG
8 help
9 Build the s3c2410 clock driver based on the common clock framework.
10
11config S3C2410_COMMON_DCLK
12 bool
13 select COMMON_CLK_SAMSUNG
14 select REGMAP_MMIO
15 help
16 Temporary symbol to build the dclk driver based on the common clock
17 framework.
18
19config S3C2412_COMMON_CLK
20 bool
21 select COMMON_CLK_SAMSUNG
22
23config S3C2443_COMMON_CLK
24 bool
25 select COMMON_CLK_SAMSUNG
26
diff --git a/drivers/clk/samsung/Makefile b/drivers/clk/samsung/Makefile
index 2cb62f87e068..69e81773164e 100644
--- a/drivers/clk/samsung/Makefile
+++ b/drivers/clk/samsung/Makefile
@@ -3,8 +3,11 @@
3# 3#
4 4
5obj-$(CONFIG_COMMON_CLK) += clk.o clk-pll.o 5obj-$(CONFIG_COMMON_CLK) += clk.o clk-pll.o
6obj-$(CONFIG_SOC_EXYNOS3250) += clk-exynos3250.o
6obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o 7obj-$(CONFIG_ARCH_EXYNOS4) += clk-exynos4.o
7obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o 8obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o
9obj-$(CONFIG_SOC_EXYNOS5260) += clk-exynos5260.o
10obj-$(CONFIG_SOC_EXYNOS5410) += clk-exynos5410.o
8obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o 11obj-$(CONFIG_SOC_EXYNOS5420) += clk-exynos5420.o
9obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o 12obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o
10obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o 13obj-$(CONFIG_ARCH_EXYNOS) += clk-exynos-audss.o
diff --git a/drivers/clk/samsung/clk-exynos3250.c b/drivers/clk/samsung/clk-exynos3250.c
new file mode 100644
index 000000000000..7a17bd40d1dd
--- /dev/null
+++ b/drivers/clk/samsung/clk-exynos3250.c
@@ -0,0 +1,780 @@
1/*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * Common Clock Framework support for Exynos3250 SoC.
9 */
10
11#include <linux/clk.h>
12#include <linux/clkdev.h>
13#include <linux/clk-provider.h>
14#include <linux/of.h>
15#include <linux/of_address.h>
16#include <linux/platform_device.h>
17#include <linux/syscore_ops.h>
18
19#include <dt-bindings/clock/exynos3250.h>
20
21#include "clk.h"
22#include "clk-pll.h"
23
24#define SRC_LEFTBUS 0x4200
25#define DIV_LEFTBUS 0x4500
26#define GATE_IP_LEFTBUS 0x4800
27#define SRC_RIGHTBUS 0x8200
28#define DIV_RIGHTBUS 0x8500
29#define GATE_IP_RIGHTBUS 0x8800
30#define GATE_IP_PERIR 0x8960
31#define MPLL_LOCK 0xc010
32#define MPLL_CON0 0xc110
33#define VPLL_LOCK 0xc020
34#define VPLL_CON0 0xc120
35#define UPLL_LOCK 0xc030
36#define UPLL_CON0 0xc130
37#define SRC_TOP0 0xc210
38#define SRC_TOP1 0xc214
39#define SRC_CAM 0xc220
40#define SRC_MFC 0xc228
41#define SRC_G3D 0xc22c
42#define SRC_LCD 0xc234
43#define SRC_ISP 0xc238
44#define SRC_FSYS 0xc240
45#define SRC_PERIL0 0xc250
46#define SRC_PERIL1 0xc254
47#define SRC_MASK_TOP 0xc310
48#define SRC_MASK_CAM 0xc320
49#define SRC_MASK_LCD 0xc334
50#define SRC_MASK_ISP 0xc338
51#define SRC_MASK_FSYS 0xc340
52#define SRC_MASK_PERIL0 0xc350
53#define SRC_MASK_PERIL1 0xc354
54#define DIV_TOP 0xc510
55#define DIV_CAM 0xc520
56#define DIV_MFC 0xc528
57#define DIV_G3D 0xc52c
58#define DIV_LCD 0xc534
59#define DIV_ISP 0xc538
60#define DIV_FSYS0 0xc540
61#define DIV_FSYS1 0xc544
62#define DIV_FSYS2 0xc548
63#define DIV_PERIL0 0xc550
64#define DIV_PERIL1 0xc554
65#define DIV_PERIL3 0xc55c
66#define DIV_PERIL4 0xc560
67#define DIV_PERIL5 0xc564
68#define DIV_CAM1 0xc568
69#define CLKDIV2_RATIO 0xc580
70#define GATE_SCLK_CAM 0xc820
71#define GATE_SCLK_MFC 0xc828
72#define GATE_SCLK_G3D 0xc82c
73#define GATE_SCLK_LCD 0xc834
74#define GATE_SCLK_ISP_TOP 0xc838
75#define GATE_SCLK_FSYS 0xc840
76#define GATE_SCLK_PERIL 0xc850
77#define GATE_IP_CAM 0xc920
78#define GATE_IP_MFC 0xc928
79#define GATE_IP_G3D 0xc92c
80#define GATE_IP_LCD 0xc934
81#define GATE_IP_ISP 0xc938
82#define GATE_IP_FSYS 0xc940
83#define GATE_IP_PERIL 0xc950
84#define GATE_BLOCK 0xc970
85#define APLL_LOCK 0x14000
86#define APLL_CON0 0x14100
87#define SRC_CPU 0x14200
88#define DIV_CPU0 0x14500
89#define DIV_CPU1 0x14504
90
91/* list of PLLs to be registered */
92enum exynos3250_plls {
93 apll, mpll, vpll, upll,
94 nr_plls
95};
96
97static void __iomem *reg_base;
98
99/*
100 * Support for CMU save/restore across system suspends
101 */
102#ifdef CONFIG_PM_SLEEP
103static struct samsung_clk_reg_dump *exynos3250_clk_regs;
104
105static unsigned long exynos3250_cmu_clk_regs[] __initdata = {
106 SRC_LEFTBUS,
107 DIV_LEFTBUS,
108 GATE_IP_LEFTBUS,
109 SRC_RIGHTBUS,
110 DIV_RIGHTBUS,
111 GATE_IP_RIGHTBUS,
112 GATE_IP_PERIR,
113 MPLL_LOCK,
114 MPLL_CON0,
115 VPLL_LOCK,
116 VPLL_CON0,
117 UPLL_LOCK,
118 UPLL_CON0,
119 SRC_TOP0,
120 SRC_TOP1,
121 SRC_CAM,
122 SRC_MFC,
123 SRC_G3D,
124 SRC_LCD,
125 SRC_ISP,
126 SRC_FSYS,
127 SRC_PERIL0,
128 SRC_PERIL1,
129 SRC_MASK_TOP,
130 SRC_MASK_CAM,
131 SRC_MASK_LCD,
132 SRC_MASK_ISP,
133 SRC_MASK_FSYS,
134 SRC_MASK_PERIL0,
135 SRC_MASK_PERIL1,
136 DIV_TOP,
137 DIV_CAM,
138 DIV_MFC,
139 DIV_G3D,
140 DIV_LCD,
141 DIV_ISP,
142 DIV_FSYS0,
143 DIV_FSYS1,
144 DIV_FSYS2,
145 DIV_PERIL0,
146 DIV_PERIL1,
147 DIV_PERIL3,
148 DIV_PERIL4,
149 DIV_PERIL5,
150 DIV_CAM1,
151 CLKDIV2_RATIO,
152 GATE_SCLK_CAM,
153 GATE_SCLK_MFC,
154 GATE_SCLK_G3D,
155 GATE_SCLK_LCD,
156 GATE_SCLK_ISP_TOP,
157 GATE_SCLK_FSYS,
158 GATE_SCLK_PERIL,
159 GATE_IP_CAM,
160 GATE_IP_MFC,
161 GATE_IP_G3D,
162 GATE_IP_LCD,
163 GATE_IP_ISP,
164 GATE_IP_FSYS,
165 GATE_IP_PERIL,
166 GATE_BLOCK,
167 APLL_LOCK,
168 SRC_CPU,
169 DIV_CPU0,
170 DIV_CPU1,
171};
172
173static int exynos3250_clk_suspend(void)
174{
175 samsung_clk_save(reg_base, exynos3250_clk_regs,
176 ARRAY_SIZE(exynos3250_cmu_clk_regs));
177 return 0;
178}
179
180static void exynos3250_clk_resume(void)
181{
182 samsung_clk_restore(reg_base, exynos3250_clk_regs,
183 ARRAY_SIZE(exynos3250_cmu_clk_regs));
184}
185
186static struct syscore_ops exynos3250_clk_syscore_ops = {
187 .suspend = exynos3250_clk_suspend,
188 .resume = exynos3250_clk_resume,
189};
190
191static void exynos3250_clk_sleep_init(void)
192{
193 exynos3250_clk_regs =
194 samsung_clk_alloc_reg_dump(exynos3250_cmu_clk_regs,
195 ARRAY_SIZE(exynos3250_cmu_clk_regs));
196 if (!exynos3250_clk_regs) {
197 pr_warn("%s: Failed to allocate sleep save data\n", __func__);
198 goto err;
199 }
200
201 register_syscore_ops(&exynos3250_clk_syscore_ops);
202 return;
203err:
204 kfree(exynos3250_clk_regs);
205}
206#else
207static inline void exynos3250_clk_sleep_init(void) { }
208#endif
209
210/* list of all parent clock list */
211PNAME(mout_vpllsrc_p) = { "fin_pll", };
212
213PNAME(mout_apll_p) = { "fin_pll", "fout_apll", };
214PNAME(mout_mpll_p) = { "fin_pll", "fout_mpll", };
215PNAME(mout_vpll_p) = { "fin_pll", "fout_vpll", };
216PNAME(mout_upll_p) = { "fin_pll", "fout_upll", };
217
218PNAME(mout_mpll_user_p) = { "fin_pll", "div_mpll_pre", };
219PNAME(mout_epll_user_p) = { "fin_pll", "mout_epll", };
220PNAME(mout_core_p) = { "mout_apll", "mout_mpll_user_c", };
221PNAME(mout_hpm_p) = { "mout_apll", "mout_mpll_user_c", };
222
223PNAME(mout_ebi_p) = { "div_aclk_200", "div_aclk_160", };
224PNAME(mout_ebi_1_p) = { "mout_ebi", "mout_vpll", };
225
226PNAME(mout_gdl_p) = { "mout_mpll_user_l", };
227PNAME(mout_gdr_p) = { "mout_mpll_user_r", };
228
229PNAME(mout_aclk_400_mcuisp_sub_p)
230 = { "fin_pll", "div_aclk_400_mcuisp", };
231PNAME(mout_aclk_266_0_p) = { "div_mpll_pre", "mout_vpll", };
232PNAME(mout_aclk_266_1_p) = { "mout_epll_user", };
233PNAME(mout_aclk_266_p) = { "mout_aclk_266_0", "mout_aclk_266_1", };
234PNAME(mout_aclk_266_sub_p) = { "fin_pll", "div_aclk_266", };
235
236PNAME(group_div_mpll_pre_p) = { "div_mpll_pre", };
237PNAME(group_epll_vpll_p) = { "mout_epll_user", "mout_vpll" };
238PNAME(group_sclk_p) = { "xxti", "xusbxti",
239 "none", "none",
240 "none", "none", "div_mpll_pre",
241 "mout_epll_user", "mout_vpll", };
242PNAME(group_sclk_audio_p) = { "audiocdclk", "none",
243 "none", "none",
244 "xxti", "xusbxti",
245 "div_mpll_pre", "mout_epll_user",
246 "mout_vpll", };
247PNAME(group_sclk_cam_blk_p) = { "xxti", "xusbxti",
248 "none", "none", "none",
249 "none", "div_mpll_pre",
250 "mout_epll_user", "mout_vpll",
251 "div_cam_blk_320", };
252PNAME(group_sclk_fimd0_p) = { "xxti", "xusbxti",
253 "m_bitclkhsdiv4_2l", "none",
254 "none", "none", "div_mpll_pre",
255 "mout_epll_user", "mout_vpll",
256 "none", "none", "none",
257 "div_lcd_blk_145", };
258
259PNAME(mout_mfc_p) = { "mout_mfc_0", "mout_mfc_1" };
260PNAME(mout_g3d_p) = { "mout_g3d_0", "mout_g3d_1" };
261
262static struct samsung_fixed_factor_clock fixed_factor_clks[] __initdata = {
263 FFACTOR(0, "sclk_mpll_1600", "mout_mpll", 1, 1, 0),
264 FFACTOR(0, "sclk_mpll_mif", "mout_mpll", 1, 2, 0),
265 FFACTOR(0, "sclk_bpll", "fout_bpll", 1, 2, 0),
266 FFACTOR(0, "div_cam_blk_320", "sclk_mpll_1600", 1, 5, 0),
267 FFACTOR(0, "div_lcd_blk_145", "sclk_mpll_1600", 1, 11, 0),
268
269 /* HACK: fin_pll hardcoded to xusbxti until detection is implemented. */
270 FFACTOR(CLK_FIN_PLL, "fin_pll", "xusbxti", 1, 1, 0),
271};
272
273static struct samsung_mux_clock mux_clks[] __initdata = {
274 /*
275 * NOTE: Following table is sorted by register address in ascending
276 * order and then bitfield shift in descending order, as it is done
277 * in the User's Manual. When adding new entries, please make sure
278 * that the order is preserved, to avoid merge conflicts and make
279 * further work with defined data easier.
280 */
281
282 /* SRC_LEFTBUS */
283 MUX(CLK_MOUT_MPLL_USER_L, "mout_mpll_user_l", mout_mpll_user_p,
284 SRC_LEFTBUS, 4, 1),
285 MUX(CLK_MOUT_GDL, "mout_gdl", mout_gdl_p, SRC_LEFTBUS, 0, 1),
286
287 /* SRC_RIGHTBUS */
288 MUX(CLK_MOUT_MPLL_USER_R, "mout_mpll_user_r", mout_mpll_user_p,
289 SRC_RIGHTBUS, 4, 1),
290 MUX(CLK_MOUT_GDR, "mout_gdr", mout_gdr_p, SRC_RIGHTBUS, 0, 1),
291
292 /* SRC_TOP0 */
293 MUX(CLK_MOUT_EBI, "mout_ebi", mout_ebi_p, SRC_TOP0, 28, 1),
294 MUX(CLK_MOUT_ACLK_200, "mout_aclk_200", group_div_mpll_pre_p,SRC_TOP0, 24, 1),
295 MUX(CLK_MOUT_ACLK_160, "mout_aclk_160", group_div_mpll_pre_p, SRC_TOP0, 20, 1),
296 MUX(CLK_MOUT_ACLK_100, "mout_aclk_100", group_div_mpll_pre_p, SRC_TOP0, 16, 1),
297 MUX(CLK_MOUT_ACLK_266_1, "mout_aclk_266_1", mout_aclk_266_1_p, SRC_TOP0, 14, 1),
298 MUX(CLK_MOUT_ACLK_266_0, "mout_aclk_266_0", mout_aclk_266_0_p, SRC_TOP0, 13, 1),
299 MUX(CLK_MOUT_ACLK_266, "mout_aclk_266", mout_aclk_266_p, SRC_TOP0, 12, 1),
300 MUX(CLK_MOUT_VPLL, "mout_vpll", mout_vpll_p, SRC_TOP0, 8, 1),
301 MUX(CLK_MOUT_EPLL_USER, "mout_epll_user", mout_epll_user_p, SRC_TOP0, 4, 1),
302 MUX(CLK_MOUT_EBI_1, "mout_ebi_1", mout_ebi_1_p, SRC_TOP0, 0, 1),
303
304 /* SRC_TOP1 */
305 MUX(CLK_MOUT_UPLL, "mout_upll", mout_upll_p, SRC_TOP1, 28, 1),
306 MUX(CLK_MOUT_ACLK_400_MCUISP_SUB, "mout_aclk_400_mcuisp_sub", mout_aclk_400_mcuisp_sub_p,
307 SRC_TOP1, 24, 1),
308 MUX(CLK_MOUT_ACLK_266_SUB, "mout_aclk_266_sub", mout_aclk_266_sub_p, SRC_TOP1, 20, 1),
309 MUX(CLK_MOUT_MPLL, "mout_mpll", mout_mpll_p, SRC_TOP1, 12, 1),
310 MUX(CLK_MOUT_ACLK_400_MCUISP, "mout_aclk_400_mcuisp", group_div_mpll_pre_p, SRC_TOP1, 8, 1),
311 MUX(CLK_MOUT_VPLLSRC, "mout_vpllsrc", mout_vpllsrc_p, SRC_TOP1, 0, 1),
312
313 /* SRC_CAM */
314 MUX(CLK_MOUT_CAM1, "mout_cam1", group_sclk_p, SRC_CAM, 20, 4),
315 MUX(CLK_MOUT_CAM_BLK, "mout_cam_blk", group_sclk_cam_blk_p, SRC_CAM, 0, 4),
316
317 /* SRC_MFC */
318 MUX(CLK_MOUT_MFC, "mout_mfc", mout_mfc_p, SRC_MFC, 8, 1),
319 MUX(CLK_MOUT_MFC_1, "mout_mfc_1", group_epll_vpll_p, SRC_MFC, 4, 1),
320 MUX(CLK_MOUT_MFC_0, "mout_mfc_0", group_div_mpll_pre_p, SRC_MFC, 0, 1),
321
322 /* SRC_G3D */
323 MUX(CLK_MOUT_G3D, "mout_g3d", mout_g3d_p, SRC_G3D, 8, 1),
324 MUX(CLK_MOUT_G3D_1, "mout_g3d_1", group_epll_vpll_p, SRC_G3D, 4, 1),
325 MUX(CLK_MOUT_G3D_0, "mout_g3d_0", group_div_mpll_pre_p, SRC_G3D, 0, 1),
326
327 /* SRC_LCD */
328 MUX(CLK_MOUT_MIPI0, "mout_mipi0", group_sclk_p, SRC_LCD, 12, 4),
329 MUX(CLK_MOUT_FIMD0, "mout_fimd0", group_sclk_fimd0_p, SRC_LCD, 0, 4),
330
331 /* SRC_ISP */
332 MUX(CLK_MOUT_UART_ISP, "mout_uart_isp", group_sclk_p, SRC_ISP, 12, 4),
333 MUX(CLK_MOUT_SPI1_ISP, "mout_spi1_isp", group_sclk_p, SRC_ISP, 8, 4),
334 MUX(CLK_MOUT_SPI0_ISP, "mout_spi0_isp", group_sclk_p, SRC_ISP, 4, 4),
335
336 /* SRC_FSYS */
337 MUX(CLK_MOUT_TSADC, "mout_tsadc", group_sclk_p, SRC_FSYS, 28, 4),
338 MUX(CLK_MOUT_MMC1, "mout_mmc1", group_sclk_p, SRC_FSYS, 4, 3),
339 MUX(CLK_MOUT_MMC0, "mout_mmc0", group_sclk_p, SRC_FSYS, 0, 3),
340
341 /* SRC_PERIL0 */
342 MUX(CLK_MOUT_UART1, "mout_uart1", group_sclk_p, SRC_PERIL0, 4, 4),
343 MUX(CLK_MOUT_UART0, "mout_uart0", group_sclk_p, SRC_PERIL0, 0, 4),
344
345 /* SRC_PERIL1 */
346 MUX(CLK_MOUT_SPI1, "mout_spi1", group_sclk_p, SRC_PERIL1, 20, 4),
347 MUX(CLK_MOUT_SPI0, "mout_spi0", group_sclk_p, SRC_PERIL1, 16, 4),
348 MUX(CLK_MOUT_AUDIO, "mout_audio", group_sclk_audio_p, SRC_PERIL1, 4, 4),
349
350 /* SRC_CPU */
351 MUX(CLK_MOUT_MPLL_USER_C, "mout_mpll_user_c", mout_mpll_user_p,
352 SRC_CPU, 24, 1),
353 MUX(CLK_MOUT_HPM, "mout_hpm", mout_hpm_p, SRC_CPU, 20, 1),
354 MUX(CLK_MOUT_CORE, "mout_core", mout_core_p, SRC_CPU, 16, 1),
355 MUX(CLK_MOUT_APLL, "mout_apll", mout_apll_p, SRC_CPU, 0, 1),
356};
357
358static struct samsung_div_clock div_clks[] __initdata = {
359 /*
360 * NOTE: Following table is sorted by register address in ascending
361 * order and then bitfield shift in descending order, as it is done
362 * in the User's Manual. When adding new entries, please make sure
363 * that the order is preserved, to avoid merge conflicts and make
364 * further work with defined data easier.
365 */
366
367 /* DIV_LEFTBUS */
368 DIV(CLK_DIV_GPL, "div_gpl", "div_gdl", DIV_LEFTBUS, 4, 3),
369 DIV(CLK_DIV_GDL, "div_gdl", "mout_gdl", DIV_LEFTBUS, 0, 4),
370
371 /* DIV_RIGHTBUS */
372 DIV(CLK_DIV_GPR, "div_gpr", "div_gdr", DIV_RIGHTBUS, 4, 3),
373 DIV(CLK_DIV_GDR, "div_gdr", "mout_gdr", DIV_RIGHTBUS, 0, 4),
374
375 /* DIV_TOP */
376 DIV(CLK_DIV_MPLL_PRE, "div_mpll_pre", "sclk_mpll_mif", DIV_TOP, 28, 2),
377 DIV(CLK_DIV_ACLK_400_MCUISP, "div_aclk_400_mcuisp",
378 "mout_aclk_400_mcuisp", DIV_TOP, 24, 3),
379 DIV(CLK_DIV_EBI, "div_ebi", "mout_ebi_1", DIV_TOP, 16, 3),
380 DIV(CLK_DIV_ACLK_200, "div_aclk_200", "mout_aclk_200", DIV_TOP, 12, 3),
381 DIV(CLK_DIV_ACLK_160, "div_aclk_160", "mout_aclk_160", DIV_TOP, 8, 3),
382 DIV(CLK_DIV_ACLK_100, "div_aclk_100", "mout_aclk_100", DIV_TOP, 4, 4),
383 DIV(CLK_DIV_ACLK_266, "div_aclk_266", "mout_aclk_266", DIV_TOP, 0, 3),
384
385 /* DIV_CAM */
386 DIV(CLK_DIV_CAM1, "div_cam1", "mout_cam1", DIV_CAM, 20, 4),
387 DIV(CLK_DIV_CAM_BLK, "div_cam_blk", "mout_cam_blk", DIV_CAM, 0, 4),
388
389 /* DIV_MFC */
390 DIV(CLK_DIV_MFC, "div_mfc", "mout_mfc", DIV_MFC, 0, 4),
391
392 /* DIV_G3D */
393 DIV(CLK_DIV_G3D, "div_g3d", "mout_g3d", DIV_G3D, 0, 4),
394
395 /* DIV_LCD */
396 DIV_F(CLK_DIV_MIPI0_PRE, "div_mipi0_pre", "div_mipi0", DIV_LCD, 20, 4,
397 CLK_SET_RATE_PARENT, 0),
398 DIV(CLK_DIV_MIPI0, "div_mipi0", "mout_mipi0", DIV_LCD, 16, 4),
399 DIV(CLK_DIV_FIMD0, "div_fimd0", "mout_fimd0", DIV_LCD, 0, 4),
400
401 /* DIV_ISP */
402 DIV(CLK_DIV_UART_ISP, "div_uart_isp", "mout_uart_isp", DIV_ISP, 28, 4),
403 DIV_F(CLK_DIV_SPI1_ISP_PRE, "div_spi1_isp_pre", "div_spi1_isp",
404 DIV_ISP, 20, 8, CLK_SET_RATE_PARENT, 0),
405 DIV(CLK_DIV_SPI1_ISP, "div_spi1_isp", "mout_spi1_isp", DIV_ISP, 16, 4),
406 DIV_F(CLK_DIV_SPI0_ISP_PRE, "div_spi0_isp_pre", "div_spi0_isp",
407 DIV_ISP, 8, 8, CLK_SET_RATE_PARENT, 0),
408 DIV(CLK_DIV_SPI0_ISP, "div_spi0_isp", "mout_spi0_isp", DIV_ISP, 0, 4),
409
410 /* DIV_FSYS0 */
411 DIV_F(CLK_DIV_TSADC_PRE, "div_tsadc_pre", "div_tsadc", DIV_FSYS0, 8, 8,
412 CLK_SET_RATE_PARENT, 0),
413 DIV(CLK_DIV_TSADC, "div_tsadc", "mout_tsadc", DIV_FSYS0, 0, 4),
414
415 /* DIV_FSYS1 */
416 DIV_F(CLK_DIV_MMC1_PRE, "div_mmc1_pre", "div_mmc1", DIV_FSYS1, 24, 8,
417 CLK_SET_RATE_PARENT, 0),
418 DIV(CLK_DIV_MMC1, "div_mmc1", "mout_mmc1", DIV_FSYS1, 16, 4),
419 DIV_F(CLK_DIV_MMC0_PRE, "div_mmc0_pre", "div_mmc0", DIV_FSYS1, 8, 8,
420 CLK_SET_RATE_PARENT, 0),
421 DIV(CLK_DIV_MMC0, "div_mmc0", "mout_mmc0", DIV_FSYS1, 0, 4),
422
423 /* DIV_PERIL0 */
424 DIV(CLK_DIV_UART1, "div_uart1", "mout_uart1", DIV_PERIL0, 4, 4),
425 DIV(CLK_DIV_UART0, "div_uart0", "mout_uart0", DIV_PERIL0, 0, 4),
426
427 /* DIV_PERIL1 */
428 DIV_F(CLK_DIV_SPI1_PRE, "div_spi1_pre", "div_spi1", DIV_PERIL1, 24, 8,
429 CLK_SET_RATE_PARENT, 0),
430 DIV(CLK_DIV_SPI1, "div_spi1", "mout_spi1", DIV_PERIL1, 16, 4),
431 DIV_F(CLK_DIV_SPI0_PRE, "div_spi0_pre", "div_spi0", DIV_PERIL1, 8, 8,
432 CLK_SET_RATE_PARENT, 0),
433 DIV(CLK_DIV_SPI0, "div_spi0", "mout_spi0", DIV_PERIL1, 0, 4),
434
435 /* DIV_PERIL4 */
436 DIV(CLK_DIV_PCM, "div_pcm", "div_audio", DIV_PERIL4, 20, 8),
437 DIV(CLK_DIV_AUDIO, "div_audio", "mout_audio", DIV_PERIL4, 16, 4),
438
439 /* DIV_PERIL5 */
440 DIV(CLK_DIV_I2S, "div_i2s", "div_audio", DIV_PERIL5, 8, 6),
441
442 /* DIV_CPU0 */
443 DIV(CLK_DIV_CORE2, "div_core2", "div_core", DIV_CPU0, 28, 3),
444 DIV(CLK_DIV_APLL, "div_apll", "mout_apll", DIV_CPU0, 24, 3),
445 DIV(CLK_DIV_PCLK_DBG, "div_pclk_dbg", "div_core2", DIV_CPU0, 20, 3),
446 DIV(CLK_DIV_ATB, "div_atb", "div_core2", DIV_CPU0, 16, 3),
447 DIV(CLK_DIV_COREM, "div_corem", "div_core2", DIV_CPU0, 4, 3),
448 DIV(CLK_DIV_CORE, "div_core", "mout_core", DIV_CPU0, 0, 3),
449
450 /* DIV_CPU1 */
451 DIV(CLK_DIV_HPM, "div_hpm", "div_copy", DIV_CPU1, 4, 3),
452 DIV(CLK_DIV_COPY, "div_copy", "mout_hpm", DIV_CPU1, 0, 3),
453};
454
455static struct samsung_gate_clock gate_clks[] __initdata = {
456 /*
457 * NOTE: Following table is sorted by register address in ascending
458 * order and then bitfield shift in descending order, as it is done
459 * in the User's Manual. When adding new entries, please make sure
460 * that the order is preserved, to avoid merge conflicts and make
461 * further work with defined data easier.
462 */
463
464 /* GATE_IP_LEFTBUS */
465 GATE(CLK_ASYNC_G3D, "async_g3d", "div_aclk_100", GATE_IP_LEFTBUS, 6,
466 CLK_IGNORE_UNUSED, 0),
467 GATE(CLK_ASYNC_MFCL, "async_mfcl", "div_aclk_100", GATE_IP_LEFTBUS, 4,
468 CLK_IGNORE_UNUSED, 0),
469 GATE(CLK_PPMULEFT, "ppmuleft", "div_aclk_100", GATE_IP_LEFTBUS, 1,
470 CLK_IGNORE_UNUSED, 0),
471 GATE(CLK_GPIO_LEFT, "gpio_left", "div_aclk_100", GATE_IP_LEFTBUS, 0,
472 CLK_IGNORE_UNUSED, 0),
473
474 /* GATE_IP_RIGHTBUS */
475 GATE(CLK_ASYNC_ISPMX, "async_ispmx", "div_aclk_100",
476 GATE_IP_RIGHTBUS, 9, CLK_IGNORE_UNUSED, 0),
477 GATE(CLK_ASYNC_FSYSD, "async_fsysd", "div_aclk_100",
478 GATE_IP_RIGHTBUS, 5, CLK_IGNORE_UNUSED, 0),
479 GATE(CLK_ASYNC_LCD0X, "async_lcd0x", "div_aclk_100",
480 GATE_IP_RIGHTBUS, 3, CLK_IGNORE_UNUSED, 0),
481 GATE(CLK_ASYNC_CAMX, "async_camx", "div_aclk_100", GATE_IP_RIGHTBUS, 2,
482 CLK_IGNORE_UNUSED, 0),
483 GATE(CLK_PPMURIGHT, "ppmuright", "div_aclk_100", GATE_IP_RIGHTBUS, 1,
484 CLK_IGNORE_UNUSED, 0),
485 GATE(CLK_GPIO_RIGHT, "gpio_right", "div_aclk_100", GATE_IP_RIGHTBUS, 0,
486 CLK_IGNORE_UNUSED, 0),
487
488 /* GATE_IP_PERIR */
489 GATE(CLK_MONOCNT, "monocnt", "div_aclk_100", GATE_IP_PERIR, 22,
490 CLK_IGNORE_UNUSED, 0),
491 GATE(CLK_TZPC6, "tzpc6", "div_aclk_100", GATE_IP_PERIR, 21,
492 CLK_IGNORE_UNUSED, 0),
493 GATE(CLK_PROVISIONKEY1, "provisionkey1", "div_aclk_100",
494 GATE_IP_PERIR, 20, CLK_IGNORE_UNUSED, 0),
495 GATE(CLK_PROVISIONKEY0, "provisionkey0", "div_aclk_100",
496 GATE_IP_PERIR, 19, CLK_IGNORE_UNUSED, 0),
497 GATE(CLK_CMU_ISPPART, "cmu_isppart", "div_aclk_100", GATE_IP_PERIR, 18,
498 CLK_IGNORE_UNUSED, 0),
499 GATE(CLK_TMU_APBIF, "tmu_apbif", "div_aclk_100",
500 GATE_IP_PERIR, 17, 0, 0),
501 GATE(CLK_KEYIF, "keyif", "div_aclk_100", GATE_IP_PERIR, 16, 0, 0),
502 GATE(CLK_RTC, "rtc", "div_aclk_100", GATE_IP_PERIR, 15, 0, 0),
503 GATE(CLK_WDT, "wdt", "div_aclk_100", GATE_IP_PERIR, 14, 0, 0),
504 GATE(CLK_MCT, "mct", "div_aclk_100", GATE_IP_PERIR, 13, 0, 0),
505 GATE(CLK_SECKEY, "seckey", "div_aclk_100", GATE_IP_PERIR, 12,
506 CLK_IGNORE_UNUSED, 0),
507 GATE(CLK_TZPC5, "tzpc5", "div_aclk_100", GATE_IP_PERIR, 10,
508 CLK_IGNORE_UNUSED, 0),
509 GATE(CLK_TZPC4, "tzpc4", "div_aclk_100", GATE_IP_PERIR, 9,
510 CLK_IGNORE_UNUSED, 0),
511 GATE(CLK_TZPC3, "tzpc3", "div_aclk_100", GATE_IP_PERIR, 8,
512 CLK_IGNORE_UNUSED, 0),
513 GATE(CLK_TZPC2, "tzpc2", "div_aclk_100", GATE_IP_PERIR, 7,
514 CLK_IGNORE_UNUSED, 0),
515 GATE(CLK_TZPC1, "tzpc1", "div_aclk_100", GATE_IP_PERIR, 6,
516 CLK_IGNORE_UNUSED, 0),
517 GATE(CLK_TZPC0, "tzpc0", "div_aclk_100", GATE_IP_PERIR, 5,
518 CLK_IGNORE_UNUSED, 0),
519 GATE(CLK_CMU_COREPART, "cmu_corepart", "div_aclk_100", GATE_IP_PERIR, 4,
520 CLK_IGNORE_UNUSED, 0),
521 GATE(CLK_CMU_TOPPART, "cmu_toppart", "div_aclk_100", GATE_IP_PERIR, 3,
522 CLK_IGNORE_UNUSED, 0),
523 GATE(CLK_PMU_APBIF, "pmu_apbif", "div_aclk_100", GATE_IP_PERIR, 2,
524 CLK_IGNORE_UNUSED, 0),
525 GATE(CLK_SYSREG, "sysreg", "div_aclk_100", GATE_IP_PERIR, 1,
526 CLK_IGNORE_UNUSED, 0),
527 GATE(CLK_CHIP_ID, "chip_id", "div_aclk_100", GATE_IP_PERIR, 0,
528 CLK_IGNORE_UNUSED, 0),
529
530 /* GATE_SCLK_CAM */
531 GATE(CLK_SCLK_JPEG, "sclk_jpeg", "div_cam_blk",
532 GATE_SCLK_CAM, 8, CLK_SET_RATE_PARENT, 0),
533 GATE(CLK_SCLK_M2MSCALER, "sclk_m2mscaler", "div_cam_blk",
534 GATE_SCLK_CAM, 2, CLK_SET_RATE_PARENT, 0),
535 GATE(CLK_SCLK_GSCALER1, "sclk_gscaler1", "div_cam_blk",
536 GATE_SCLK_CAM, 1, CLK_SET_RATE_PARENT, 0),
537 GATE(CLK_SCLK_GSCALER0, "sclk_gscaler0", "div_cam_blk",
538 GATE_SCLK_CAM, 0, CLK_SET_RATE_PARENT, 0),
539
540 /* GATE_SCLK_MFC */
541 GATE(CLK_SCLK_MFC, "sclk_mfc", "div_mfc",
542 GATE_SCLK_MFC, 0, CLK_SET_RATE_PARENT, 0),
543
544 /* GATE_SCLK_G3D */
545 GATE(CLK_SCLK_G3D, "sclk_g3d", "div_g3d",
546 GATE_SCLK_G3D, 0, CLK_SET_RATE_PARENT, 0),
547
548 /* GATE_SCLK_LCD */
549 GATE(CLK_SCLK_MIPIDPHY2L, "sclk_mipidphy2l", "div_mipi0",
550 GATE_SCLK_LCD, 4, CLK_SET_RATE_PARENT, 0),
551 GATE(CLK_SCLK_MIPI0, "sclk_mipi0", "div_mipi0_pre",
552 GATE_SCLK_LCD, 3, CLK_SET_RATE_PARENT, 0),
553 GATE(CLK_SCLK_FIMD0, "sclk_fimd0", "div_fimd0",
554 GATE_SCLK_LCD, 0, CLK_SET_RATE_PARENT, 0),
555
556 /* GATE_SCLK_ISP_TOP */
557 GATE(CLK_SCLK_CAM1, "sclk_cam1", "div_cam1",
558 GATE_SCLK_ISP_TOP, 4, CLK_SET_RATE_PARENT, 0),
559 GATE(CLK_SCLK_UART_ISP, "sclk_uart_isp", "div_uart_isp",
560 GATE_SCLK_ISP_TOP, 3, CLK_SET_RATE_PARENT, 0),
561 GATE(CLK_SCLK_SPI1_ISP, "sclk_spi1_isp", "div_spi1_isp",
562 GATE_SCLK_ISP_TOP, 2, CLK_SET_RATE_PARENT, 0),
563 GATE(CLK_SCLK_SPI0_ISP, "sclk_spi0_isp", "div_spi0_isp",
564 GATE_SCLK_ISP_TOP, 1, CLK_SET_RATE_PARENT, 0),
565
566 /* GATE_SCLK_FSYS */
567 GATE(CLK_SCLK_UPLL, "sclk_upll", "mout_upll", GATE_SCLK_FSYS, 10, 0, 0),
568 GATE(CLK_SCLK_TSADC, "sclk_tsadc", "div_tsadc_pre",
569 GATE_SCLK_FSYS, 9, CLK_SET_RATE_PARENT, 0),
570 GATE(CLK_SCLK_EBI, "sclk_ebi", "div_ebi",
571 GATE_SCLK_FSYS, 6, CLK_SET_RATE_PARENT, 0),
572 GATE(CLK_SCLK_MMC1, "sclk_mmc1", "div_mmc1_pre",
573 GATE_SCLK_FSYS, 1, CLK_SET_RATE_PARENT, 0),
574 GATE(CLK_SCLK_MMC0, "sclk_mmc0", "div_mmc0_pre",
575 GATE_SCLK_FSYS, 0, CLK_SET_RATE_PARENT, 0),
576
577 /* GATE_SCLK_PERIL */
578 GATE(CLK_SCLK_I2S, "sclk_i2s", "div_i2s",
579 GATE_SCLK_PERIL, 18, CLK_SET_RATE_PARENT, 0),
580 GATE(CLK_SCLK_PCM, "sclk_pcm", "div_pcm",
581 GATE_SCLK_PERIL, 16, CLK_SET_RATE_PARENT, 0),
582 GATE(CLK_SCLK_SPI1, "sclk_spi1", "div_spi1_pre",
583 GATE_SCLK_PERIL, 7, CLK_SET_RATE_PARENT, 0),
584 GATE(CLK_SCLK_SPI0, "sclk_spi0", "div_spi0_pre",
585 GATE_SCLK_PERIL, 6, CLK_SET_RATE_PARENT, 0),
586 GATE(CLK_SCLK_UART1, "sclk_uart1", "div_uart1",
587 GATE_SCLK_PERIL, 1, CLK_SET_RATE_PARENT, 0),
588 GATE(CLK_SCLK_UART0, "sclk_uart0", "div_uart0",
589 GATE_SCLK_PERIL, 0, CLK_SET_RATE_PARENT, 0),
590
591 /* GATE_IP_CAM */
592 GATE(CLK_QEJPEG, "qejpeg", "div_cam_blk_320", GATE_IP_CAM, 19,
593 CLK_IGNORE_UNUSED, 0),
594 GATE(CLK_PIXELASYNCM1, "pixelasyncm1", "div_cam_blk_320",
595 GATE_IP_CAM, 18, CLK_IGNORE_UNUSED, 0),
596 GATE(CLK_PIXELASYNCM0, "pixelasyncm0", "div_cam_blk_320",
597 GATE_IP_CAM, 17, CLK_IGNORE_UNUSED, 0),
598 GATE(CLK_PPMUCAMIF, "ppmucamif", "div_cam_blk_320",
599 GATE_IP_CAM, 16, CLK_IGNORE_UNUSED, 0),
600 GATE(CLK_QEM2MSCALER, "qem2mscaler", "div_cam_blk_320",
601 GATE_IP_CAM, 14, CLK_IGNORE_UNUSED, 0),
602 GATE(CLK_QEGSCALER1, "qegscaler1", "div_cam_blk_320",
603 GATE_IP_CAM, 13, CLK_IGNORE_UNUSED, 0),
604 GATE(CLK_QEGSCALER0, "qegscaler0", "div_cam_blk_320",
605 GATE_IP_CAM, 12, CLK_IGNORE_UNUSED, 0),
606 GATE(CLK_SMMUJPEG, "smmujpeg", "div_cam_blk_320",
607 GATE_IP_CAM, 11, 0, 0),
608 GATE(CLK_SMMUM2M2SCALER, "smmum2m2scaler", "div_cam_blk_320",
609 GATE_IP_CAM, 9, 0, 0),
610 GATE(CLK_SMMUGSCALER1, "smmugscaler1", "div_cam_blk_320",
611 GATE_IP_CAM, 8, 0, 0),
612 GATE(CLK_SMMUGSCALER0, "smmugscaler0", "div_cam_blk_320",
613 GATE_IP_CAM, 7, 0, 0),
614 GATE(CLK_JPEG, "jpeg", "div_cam_blk_320", GATE_IP_CAM, 6, 0, 0),
615 GATE(CLK_M2MSCALER, "m2mscaler", "div_cam_blk_320",
616 GATE_IP_CAM, 2, 0, 0),
617 GATE(CLK_GSCALER1, "gscaler1", "div_cam_blk_320", GATE_IP_CAM, 1, 0, 0),
618 GATE(CLK_GSCALER0, "gscaler0", "div_cam_blk_320", GATE_IP_CAM, 0, 0, 0),
619
620 /* GATE_IP_MFC */
621 GATE(CLK_QEMFC, "qemfc", "div_aclk_200", GATE_IP_MFC, 5,
622 CLK_IGNORE_UNUSED, 0),
623 GATE(CLK_PPMUMFC_L, "ppmumfc_l", "div_aclk_200", GATE_IP_MFC, 3,
624 CLK_IGNORE_UNUSED, 0),
625 GATE(CLK_SMMUMFC_L, "smmumfc_l", "div_aclk_200", GATE_IP_MFC, 1, 0, 0),
626 GATE(CLK_MFC, "mfc", "div_aclk_200", GATE_IP_MFC, 0, 0, 0),
627
628 /* GATE_IP_G3D */
629 GATE(CLK_SMMUG3D, "smmug3d", "div_aclk_200", GATE_IP_G3D, 3, 0, 0),
630 GATE(CLK_QEG3D, "qeg3d", "div_aclk_200", GATE_IP_G3D, 2,
631 CLK_IGNORE_UNUSED, 0),
632 GATE(CLK_PPMUG3D, "ppmug3d", "div_aclk_200", GATE_IP_G3D, 1,
633 CLK_IGNORE_UNUSED, 0),
634 GATE(CLK_G3D, "g3d", "div_aclk_200", GATE_IP_G3D, 0, 0, 0),
635
636 /* GATE_IP_LCD */
637 GATE(CLK_QE_CH1_LCD, "qe_ch1_lcd", "div_aclk_160", GATE_IP_LCD, 7,
638 CLK_IGNORE_UNUSED, 0),
639 GATE(CLK_QE_CH0_LCD, "qe_ch0_lcd", "div_aclk_160", GATE_IP_LCD, 6,
640 CLK_IGNORE_UNUSED, 0),
641 GATE(CLK_PPMULCD0, "ppmulcd0", "div_aclk_160", GATE_IP_LCD, 5,
642 CLK_IGNORE_UNUSED, 0),
643 GATE(CLK_SMMUFIMD0, "smmufimd0", "div_aclk_160", GATE_IP_LCD, 4, 0, 0),
644 GATE(CLK_DSIM0, "dsim0", "div_aclk_160", GATE_IP_LCD, 3, 0, 0),
645 GATE(CLK_SMIES, "smies", "div_aclk_160", GATE_IP_LCD, 2, 0, 0),
646 GATE(CLK_FIMD0, "fimd0", "div_aclk_160", GATE_IP_LCD, 0, 0, 0),
647
648 /* GATE_IP_ISP */
649 GATE(CLK_CAM1, "cam1", "mout_aclk_266_sub", GATE_IP_ISP, 5, 0, 0),
650 GATE(CLK_UART_ISP_TOP, "uart_isp_top", "mout_aclk_266_sub",
651 GATE_IP_ISP, 3, 0, 0),
652 GATE(CLK_SPI1_ISP_TOP, "spi1_isp_top", "mout_aclk_266_sub",
653 GATE_IP_ISP, 2, 0, 0),
654 GATE(CLK_SPI0_ISP_TOP, "spi0_isp_top", "mout_aclk_266_sub",
655 GATE_IP_ISP, 1, 0, 0),
656
657 /* GATE_IP_FSYS */
658 GATE(CLK_TSADC, "tsadc", "div_aclk_200", GATE_IP_FSYS, 20, 0, 0),
659 GATE(CLK_PPMUFILE, "ppmufile", "div_aclk_200", GATE_IP_FSYS, 17,
660 CLK_IGNORE_UNUSED, 0),
661 GATE(CLK_USBOTG, "usbotg", "div_aclk_200", GATE_IP_FSYS, 13, 0, 0),
662 GATE(CLK_USBHOST, "usbhost", "div_aclk_200", GATE_IP_FSYS, 12, 0, 0),
663 GATE(CLK_SROMC, "sromc", "div_aclk_200", GATE_IP_FSYS, 11, 0, 0),
664 GATE(CLK_SDMMC1, "sdmmc1", "div_aclk_200", GATE_IP_FSYS, 6, 0, 0),
665 GATE(CLK_SDMMC0, "sdmmc0", "div_aclk_200", GATE_IP_FSYS, 5, 0, 0),
666 GATE(CLK_PDMA1, "pdma1", "div_aclk_200", GATE_IP_FSYS, 1, 0, 0),
667 GATE(CLK_PDMA0, "pdma0", "div_aclk_200", GATE_IP_FSYS, 0, 0, 0),
668
669 /* GATE_IP_PERIL */
670 GATE(CLK_PWM, "pwm", "div_aclk_100", GATE_IP_PERIL, 24, 0, 0),
671 GATE(CLK_PCM, "pcm", "div_aclk_100", GATE_IP_PERIL, 23, 0, 0),
672 GATE(CLK_I2S, "i2s", "div_aclk_100", GATE_IP_PERIL, 21, 0, 0),
673 GATE(CLK_SPI1, "spi1", "div_aclk_100", GATE_IP_PERIL, 17, 0, 0),
674 GATE(CLK_SPI0, "spi0", "div_aclk_100", GATE_IP_PERIL, 16, 0, 0),
675 GATE(CLK_I2C7, "i2c7", "div_aclk_100", GATE_IP_PERIL, 13, 0, 0),
676 GATE(CLK_I2C6, "i2c6", "div_aclk_100", GATE_IP_PERIL, 12, 0, 0),
677 GATE(CLK_I2C5, "i2c5", "div_aclk_100", GATE_IP_PERIL, 11, 0, 0),
678 GATE(CLK_I2C4, "i2c4", "div_aclk_100", GATE_IP_PERIL, 10, 0, 0),
679 GATE(CLK_I2C3, "i2c3", "div_aclk_100", GATE_IP_PERIL, 9, 0, 0),
680 GATE(CLK_I2C2, "i2c2", "div_aclk_100", GATE_IP_PERIL, 8, 0, 0),
681 GATE(CLK_I2C1, "i2c1", "div_aclk_100", GATE_IP_PERIL, 7, 0, 0),
682 GATE(CLK_I2C0, "i2c0", "div_aclk_100", GATE_IP_PERIL, 6, 0, 0),
683 GATE(CLK_UART1, "uart1", "div_aclk_100", GATE_IP_PERIL, 1, 0, 0),
684 GATE(CLK_UART0, "uart0", "div_aclk_100", GATE_IP_PERIL, 0, 0, 0),
685};
686
687/* APLL & MPLL & BPLL & UPLL */
688static struct samsung_pll_rate_table exynos3250_pll_rates[] = {
689 PLL_35XX_RATE(1200000000, 400, 4, 1),
690 PLL_35XX_RATE(1100000000, 275, 3, 1),
691 PLL_35XX_RATE(1066000000, 533, 6, 1),
692 PLL_35XX_RATE(1000000000, 250, 3, 1),
693 PLL_35XX_RATE( 960000000, 320, 4, 1),
694 PLL_35XX_RATE( 900000000, 300, 4, 1),
695 PLL_35XX_RATE( 850000000, 425, 6, 1),
696 PLL_35XX_RATE( 800000000, 200, 3, 1),
697 PLL_35XX_RATE( 700000000, 175, 3, 1),
698 PLL_35XX_RATE( 667000000, 667, 12, 1),
699 PLL_35XX_RATE( 600000000, 400, 4, 2),
700 PLL_35XX_RATE( 533000000, 533, 6, 2),
701 PLL_35XX_RATE( 520000000, 260, 3, 2),
702 PLL_35XX_RATE( 500000000, 250, 3, 2),
703 PLL_35XX_RATE( 400000000, 200, 3, 2),
704 PLL_35XX_RATE( 200000000, 200, 3, 3),
705 PLL_35XX_RATE( 100000000, 200, 3, 4),
706 { /* sentinel */ }
707};
708
709/* VPLL */
710static struct samsung_pll_rate_table exynos3250_vpll_rates[] = {
711 PLL_36XX_RATE(600000000, 100, 2, 1, 0),
712 PLL_36XX_RATE(533000000, 266, 3, 2, 32768),
713 PLL_36XX_RATE(519230987, 173, 2, 2, 5046),
714 PLL_36XX_RATE(500000000, 250, 3, 2, 0),
715 PLL_36XX_RATE(445500000, 148, 2, 2, 32768),
716 PLL_36XX_RATE(445055007, 148, 2, 2, 23047),
717 PLL_36XX_RATE(400000000, 200, 3, 2, 0),
718 PLL_36XX_RATE(371250000, 123, 2, 2, 49152),
719 PLL_36XX_RATE(370878997, 185, 3, 2, 28803),
720 PLL_36XX_RATE(340000000, 170, 3, 2, 0),
721 PLL_36XX_RATE(335000015, 111, 2, 2, 43691),
722 PLL_36XX_RATE(333000000, 111, 2, 2, 0),
723 PLL_36XX_RATE(330000000, 110, 2, 2, 0),
724 PLL_36XX_RATE(320000015, 106, 2, 2, 43691),
725 PLL_36XX_RATE(300000000, 100, 2, 2, 0),
726 PLL_36XX_RATE(275000000, 275, 3, 3, 0),
727 PLL_36XX_RATE(222750000, 148, 2, 3, 32768),
728 PLL_36XX_RATE(222528007, 148, 2, 3, 23069),
729 PLL_36XX_RATE(160000000, 160, 3, 3, 0),
730 PLL_36XX_RATE(148500000, 99, 2, 3, 0),
731 PLL_36XX_RATE(148352005, 98, 2, 3, 59070),
732 PLL_36XX_RATE(108000000, 144, 2, 4, 0),
733 PLL_36XX_RATE( 74250000, 99, 2, 4, 0),
734 PLL_36XX_RATE( 74176002, 98, 3, 4, 59070),
735 PLL_36XX_RATE( 54054000, 216, 3, 5, 14156),
736 PLL_36XX_RATE( 54000000, 144, 2, 5, 0),
737 { /* sentinel */ }
738};
739
740static struct samsung_pll_clock exynos3250_plls[nr_plls] __initdata = {
741 [apll] = PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll",
742 APLL_LOCK, APLL_CON0, NULL),
743 [mpll] = PLL(pll_35xx, CLK_FOUT_MPLL, "fout_mpll", "fin_pll",
744 MPLL_LOCK, MPLL_CON0, NULL),
745 [vpll] = PLL(pll_36xx, CLK_FOUT_VPLL, "fout_vpll", "fin_pll",
746 VPLL_LOCK, VPLL_CON0, NULL),
747 [upll] = PLL(pll_35xx, CLK_FOUT_UPLL, "fout_upll", "fin_pll",
748 UPLL_LOCK, UPLL_CON0, NULL),
749};
750
751static void __init exynos3250_cmu_init(struct device_node *np)
752{
753 struct samsung_clk_provider *ctx;
754
755 reg_base = of_iomap(np, 0);
756 if (!reg_base)
757 panic("%s: failed to map registers\n", __func__);
758
759 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
760 if (!ctx)
761 panic("%s: unable to allocate context.\n", __func__);
762
763 samsung_clk_register_fixed_factor(ctx, fixed_factor_clks,
764 ARRAY_SIZE(fixed_factor_clks));
765
766 exynos3250_plls[apll].rate_table = exynos3250_pll_rates;
767 exynos3250_plls[mpll].rate_table = exynos3250_pll_rates;
768 exynos3250_plls[vpll].rate_table = exynos3250_vpll_rates;
769 exynos3250_plls[upll].rate_table = exynos3250_pll_rates;
770
771 samsung_clk_register_pll(ctx, exynos3250_plls,
772 ARRAY_SIZE(exynos3250_plls), reg_base);
773
774 samsung_clk_register_mux(ctx, mux_clks, ARRAY_SIZE(mux_clks));
775 samsung_clk_register_div(ctx, div_clks, ARRAY_SIZE(div_clks));
776 samsung_clk_register_gate(ctx, gate_clks, ARRAY_SIZE(gate_clks));
777
778 exynos3250_clk_sleep_init();
779}
780CLK_OF_DECLARE(exynos3250_cmu, "samsung,exynos3250-cmu", exynos3250_cmu_init);
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c
index b4f967210175..c4df294bb7fb 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -428,7 +428,7 @@ static struct samsung_fixed_rate_clock exynos4_fixed_rate_ext_clks[] __initdata
428/* fixed rate clocks generated inside the soc */ 428/* fixed rate clocks generated inside the soc */
429static struct samsung_fixed_rate_clock exynos4_fixed_rate_clks[] __initdata = { 429static struct samsung_fixed_rate_clock exynos4_fixed_rate_clks[] __initdata = {
430 FRATE(0, "sclk_hdmi24m", NULL, CLK_IS_ROOT, 24000000), 430 FRATE(0, "sclk_hdmi24m", NULL, CLK_IS_ROOT, 24000000),
431 FRATE(0, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 27000000), 431 FRATE(CLK_SCLK_HDMIPHY, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 27000000),
432 FRATE(0, "sclk_usbphy0", NULL, CLK_IS_ROOT, 48000000), 432 FRATE(0, "sclk_usbphy0", NULL, CLK_IS_ROOT, 48000000),
433}; 433};
434 434
@@ -903,7 +903,7 @@ static struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = {
903 GATE(CLK_AUDSS, "audss", "sclk_epll", E4X12_GATE_IP_MAUDIO, 0, 0, 0), 903 GATE(CLK_AUDSS, "audss", "sclk_epll", E4X12_GATE_IP_MAUDIO, 0, 0, 0),
904 GATE(CLK_MDNIE0, "mdnie0", "aclk160", GATE_IP_LCD0, 2, 0, 0), 904 GATE(CLK_MDNIE0, "mdnie0", "aclk160", GATE_IP_LCD0, 2, 0, 0),
905 GATE(CLK_ROTATOR, "rotator", "aclk200", E4X12_GATE_IP_IMAGE, 1, 0, 0), 905 GATE(CLK_ROTATOR, "rotator", "aclk200", E4X12_GATE_IP_IMAGE, 1, 0, 0),
906 GATE(CLK_MDMA2, "mdma2", "aclk200", E4X12_GATE_IP_IMAGE, 2, 0, 0), 906 GATE(CLK_MDMA, "mdma", "aclk200", E4X12_GATE_IP_IMAGE, 2, 0, 0),
907 GATE(CLK_SMMU_MDMA, "smmu_mdma", "aclk200", E4X12_GATE_IP_IMAGE, 5, 0, 907 GATE(CLK_SMMU_MDMA, "smmu_mdma", "aclk200", E4X12_GATE_IP_IMAGE, 5, 0,
908 0), 908 0),
909 GATE(CLK_MIPI_HSI, "mipi_hsi", "aclk133", GATE_IP_FSYS, 10, 0, 0), 909 GATE(CLK_MIPI_HSI, "mipi_hsi", "aclk133", GATE_IP_FSYS, 10, 0, 0),
@@ -1043,7 +1043,7 @@ static unsigned long exynos4_get_xom(void)
1043 return xom; 1043 return xom;
1044} 1044}
1045 1045
1046static void __init exynos4_clk_register_finpll(void) 1046static void __init exynos4_clk_register_finpll(struct samsung_clk_provider *ctx)
1047{ 1047{
1048 struct samsung_fixed_rate_clock fclk; 1048 struct samsung_fixed_rate_clock fclk;
1049 struct clk *clk; 1049 struct clk *clk;
@@ -1066,7 +1066,7 @@ static void __init exynos4_clk_register_finpll(void)
1066 fclk.parent_name = NULL; 1066 fclk.parent_name = NULL;
1067 fclk.flags = CLK_IS_ROOT; 1067 fclk.flags = CLK_IS_ROOT;
1068 fclk.fixed_rate = finpll_f; 1068 fclk.fixed_rate = finpll_f;
1069 samsung_clk_register_fixed_rate(&fclk, 1); 1069 samsung_clk_register_fixed_rate(ctx, &fclk, 1);
1070 1070
1071} 1071}
1072 1072
@@ -1176,22 +1176,25 @@ static struct samsung_pll_clock exynos4x12_plls[nr_plls] __initdata = {
1176static void __init exynos4_clk_init(struct device_node *np, 1176static void __init exynos4_clk_init(struct device_node *np,
1177 enum exynos4_soc soc) 1177 enum exynos4_soc soc)
1178{ 1178{
1179 struct samsung_clk_provider *ctx;
1179 exynos4_soc = soc; 1180 exynos4_soc = soc;
1180 1181
1181 reg_base = of_iomap(np, 0); 1182 reg_base = of_iomap(np, 0);
1182 if (!reg_base) 1183 if (!reg_base)
1183 panic("%s: failed to map registers\n", __func__); 1184 panic("%s: failed to map registers\n", __func__);
1184 1185
1185 samsung_clk_init(np, reg_base, CLK_NR_CLKS); 1186 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
1187 if (!ctx)
1188 panic("%s: unable to allocate context.\n", __func__);
1186 1189
1187 samsung_clk_of_register_fixed_ext(exynos4_fixed_rate_ext_clks, 1190 samsung_clk_of_register_fixed_ext(ctx, exynos4_fixed_rate_ext_clks,
1188 ARRAY_SIZE(exynos4_fixed_rate_ext_clks), 1191 ARRAY_SIZE(exynos4_fixed_rate_ext_clks),
1189 ext_clk_match); 1192 ext_clk_match);
1190 1193
1191 exynos4_clk_register_finpll(); 1194 exynos4_clk_register_finpll(ctx);
1192 1195
1193 if (exynos4_soc == EXYNOS4210) { 1196 if (exynos4_soc == EXYNOS4210) {
1194 samsung_clk_register_mux(exynos4210_mux_early, 1197 samsung_clk_register_mux(ctx, exynos4210_mux_early,
1195 ARRAY_SIZE(exynos4210_mux_early)); 1198 ARRAY_SIZE(exynos4210_mux_early));
1196 1199
1197 if (_get_rate("fin_pll") == 24000000) { 1200 if (_get_rate("fin_pll") == 24000000) {
@@ -1205,7 +1208,7 @@ static void __init exynos4_clk_init(struct device_node *np,
1205 exynos4210_plls[vpll].rate_table = 1208 exynos4210_plls[vpll].rate_table =
1206 exynos4210_vpll_rates; 1209 exynos4210_vpll_rates;
1207 1210
1208 samsung_clk_register_pll(exynos4210_plls, 1211 samsung_clk_register_pll(ctx, exynos4210_plls,
1209 ARRAY_SIZE(exynos4210_plls), reg_base); 1212 ARRAY_SIZE(exynos4210_plls), reg_base);
1210 } else { 1213 } else {
1211 if (_get_rate("fin_pll") == 24000000) { 1214 if (_get_rate("fin_pll") == 24000000) {
@@ -1217,42 +1220,42 @@ static void __init exynos4_clk_init(struct device_node *np,
1217 exynos4x12_vpll_rates; 1220 exynos4x12_vpll_rates;
1218 } 1221 }
1219 1222
1220 samsung_clk_register_pll(exynos4x12_plls, 1223 samsung_clk_register_pll(ctx, exynos4x12_plls,
1221 ARRAY_SIZE(exynos4x12_plls), reg_base); 1224 ARRAY_SIZE(exynos4x12_plls), reg_base);
1222 } 1225 }
1223 1226
1224 samsung_clk_register_fixed_rate(exynos4_fixed_rate_clks, 1227 samsung_clk_register_fixed_rate(ctx, exynos4_fixed_rate_clks,
1225 ARRAY_SIZE(exynos4_fixed_rate_clks)); 1228 ARRAY_SIZE(exynos4_fixed_rate_clks));
1226 samsung_clk_register_mux(exynos4_mux_clks, 1229 samsung_clk_register_mux(ctx, exynos4_mux_clks,
1227 ARRAY_SIZE(exynos4_mux_clks)); 1230 ARRAY_SIZE(exynos4_mux_clks));
1228 samsung_clk_register_div(exynos4_div_clks, 1231 samsung_clk_register_div(ctx, exynos4_div_clks,
1229 ARRAY_SIZE(exynos4_div_clks)); 1232 ARRAY_SIZE(exynos4_div_clks));
1230 samsung_clk_register_gate(exynos4_gate_clks, 1233 samsung_clk_register_gate(ctx, exynos4_gate_clks,
1231 ARRAY_SIZE(exynos4_gate_clks)); 1234 ARRAY_SIZE(exynos4_gate_clks));
1232 1235
1233 if (exynos4_soc == EXYNOS4210) { 1236 if (exynos4_soc == EXYNOS4210) {
1234 samsung_clk_register_fixed_rate(exynos4210_fixed_rate_clks, 1237 samsung_clk_register_fixed_rate(ctx, exynos4210_fixed_rate_clks,
1235 ARRAY_SIZE(exynos4210_fixed_rate_clks)); 1238 ARRAY_SIZE(exynos4210_fixed_rate_clks));
1236 samsung_clk_register_mux(exynos4210_mux_clks, 1239 samsung_clk_register_mux(ctx, exynos4210_mux_clks,
1237 ARRAY_SIZE(exynos4210_mux_clks)); 1240 ARRAY_SIZE(exynos4210_mux_clks));
1238 samsung_clk_register_div(exynos4210_div_clks, 1241 samsung_clk_register_div(ctx, exynos4210_div_clks,
1239 ARRAY_SIZE(exynos4210_div_clks)); 1242 ARRAY_SIZE(exynos4210_div_clks));
1240 samsung_clk_register_gate(exynos4210_gate_clks, 1243 samsung_clk_register_gate(ctx, exynos4210_gate_clks,
1241 ARRAY_SIZE(exynos4210_gate_clks)); 1244 ARRAY_SIZE(exynos4210_gate_clks));
1242 samsung_clk_register_alias(exynos4210_aliases, 1245 samsung_clk_register_alias(ctx, exynos4210_aliases,
1243 ARRAY_SIZE(exynos4210_aliases)); 1246 ARRAY_SIZE(exynos4210_aliases));
1244 } else { 1247 } else {
1245 samsung_clk_register_mux(exynos4x12_mux_clks, 1248 samsung_clk_register_mux(ctx, exynos4x12_mux_clks,
1246 ARRAY_SIZE(exynos4x12_mux_clks)); 1249 ARRAY_SIZE(exynos4x12_mux_clks));
1247 samsung_clk_register_div(exynos4x12_div_clks, 1250 samsung_clk_register_div(ctx, exynos4x12_div_clks,
1248 ARRAY_SIZE(exynos4x12_div_clks)); 1251 ARRAY_SIZE(exynos4x12_div_clks));
1249 samsung_clk_register_gate(exynos4x12_gate_clks, 1252 samsung_clk_register_gate(ctx, exynos4x12_gate_clks,
1250 ARRAY_SIZE(exynos4x12_gate_clks)); 1253 ARRAY_SIZE(exynos4x12_gate_clks));
1251 samsung_clk_register_alias(exynos4x12_aliases, 1254 samsung_clk_register_alias(ctx, exynos4x12_aliases,
1252 ARRAY_SIZE(exynos4x12_aliases)); 1255 ARRAY_SIZE(exynos4x12_aliases));
1253 } 1256 }
1254 1257
1255 samsung_clk_register_alias(exynos4_aliases, 1258 samsung_clk_register_alias(ctx, exynos4_aliases,
1256 ARRAY_SIZE(exynos4_aliases)); 1259 ARRAY_SIZE(exynos4_aliases));
1257 1260
1258 exynos4_clk_sleep_init(); 1261 exynos4_clk_sleep_init();
diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c
index e7ee4420da81..870e18b9a687 100644
--- a/drivers/clk/samsung/clk-exynos5250.c
+++ b/drivers/clk/samsung/clk-exynos5250.c
@@ -28,6 +28,8 @@
28#define MPLL_CON0 0x4100 28#define MPLL_CON0 0x4100
29#define SRC_CORE1 0x4204 29#define SRC_CORE1 0x4204
30#define GATE_IP_ACP 0x8800 30#define GATE_IP_ACP 0x8800
31#define GATE_IP_ISP0 0xc800
32#define GATE_IP_ISP1 0xc804
31#define CPLL_LOCK 0x10020 33#define CPLL_LOCK 0x10020
32#define EPLL_LOCK 0x10030 34#define EPLL_LOCK 0x10030
33#define VPLL_LOCK 0x10040 35#define VPLL_LOCK 0x10040
@@ -37,6 +39,7 @@
37#define VPLL_CON0 0x10140 39#define VPLL_CON0 0x10140
38#define GPLL_CON0 0x10150 40#define GPLL_CON0 0x10150
39#define SRC_TOP0 0x10210 41#define SRC_TOP0 0x10210
42#define SRC_TOP1 0x10214
40#define SRC_TOP2 0x10218 43#define SRC_TOP2 0x10218
41#define SRC_TOP3 0x1021c 44#define SRC_TOP3 0x1021c
42#define SRC_GSCL 0x10220 45#define SRC_GSCL 0x10220
@@ -71,6 +74,7 @@
71#define GATE_IP_GSCL 0x10920 74#define GATE_IP_GSCL 0x10920
72#define GATE_IP_DISP1 0x10928 75#define GATE_IP_DISP1 0x10928
73#define GATE_IP_MFC 0x1092c 76#define GATE_IP_MFC 0x1092c
77#define GATE_IP_G3D 0x10930
74#define GATE_IP_GEN 0x10934 78#define GATE_IP_GEN 0x10934
75#define GATE_IP_FSYS 0x10944 79#define GATE_IP_FSYS 0x10944
76#define GATE_IP_PERIC 0x10950 80#define GATE_IP_PERIC 0x10950
@@ -100,6 +104,7 @@ static unsigned long exynos5250_clk_regs[] __initdata = {
100 DIV_CPU0, 104 DIV_CPU0,
101 SRC_CORE1, 105 SRC_CORE1,
102 SRC_TOP0, 106 SRC_TOP0,
107 SRC_TOP1,
103 SRC_TOP2, 108 SRC_TOP2,
104 SRC_TOP3, 109 SRC_TOP3,
105 SRC_GSCL, 110 SRC_GSCL,
@@ -133,6 +138,7 @@ static unsigned long exynos5250_clk_regs[] __initdata = {
133 DIV_PERIC5, 138 DIV_PERIC5,
134 GATE_IP_GSCL, 139 GATE_IP_GSCL,
135 GATE_IP_MFC, 140 GATE_IP_MFC,
141 GATE_IP_G3D,
136 GATE_IP_GEN, 142 GATE_IP_GEN,
137 GATE_IP_FSYS, 143 GATE_IP_FSYS,
138 GATE_IP_PERIC, 144 GATE_IP_PERIC,
@@ -141,6 +147,8 @@ static unsigned long exynos5250_clk_regs[] __initdata = {
141 PLL_DIV2_SEL, 147 PLL_DIV2_SEL,
142 GATE_IP_DISP1, 148 GATE_IP_DISP1,
143 GATE_IP_ACP, 149 GATE_IP_ACP,
150 GATE_IP_ISP0,
151 GATE_IP_ISP1,
144}; 152};
145 153
146static int exynos5250_clk_suspend(void) 154static int exynos5250_clk_suspend(void)
@@ -189,13 +197,16 @@ PNAME(mout_vpllsrc_p) = { "fin_pll", "sclk_hdmi27m" };
189PNAME(mout_vpll_p) = { "mout_vpllsrc", "fout_vpll" }; 197PNAME(mout_vpll_p) = { "mout_vpllsrc", "fout_vpll" };
190PNAME(mout_cpll_p) = { "fin_pll", "fout_cpll" }; 198PNAME(mout_cpll_p) = { "fin_pll", "fout_cpll" };
191PNAME(mout_epll_p) = { "fin_pll", "fout_epll" }; 199PNAME(mout_epll_p) = { "fin_pll", "fout_epll" };
200PNAME(mout_gpll_p) = { "fin_pll", "fout_gpll" };
192PNAME(mout_mpll_user_p) = { "fin_pll", "mout_mpll" }; 201PNAME(mout_mpll_user_p) = { "fin_pll", "mout_mpll" };
193PNAME(mout_bpll_user_p) = { "fin_pll", "mout_bpll" }; 202PNAME(mout_bpll_user_p) = { "fin_pll", "mout_bpll" };
194PNAME(mout_aclk166_p) = { "mout_cpll", "mout_mpll_user" }; 203PNAME(mout_aclk166_p) = { "mout_cpll", "mout_mpll_user" };
195PNAME(mout_aclk200_p) = { "mout_mpll_user", "mout_bpll_user" }; 204PNAME(mout_aclk200_p) = { "mout_mpll_user", "mout_bpll_user" };
205PNAME(mout_aclk400_p) = { "mout_aclk400_g3d_mid", "mout_gpll" };
196PNAME(mout_aclk200_sub_p) = { "fin_pll", "div_aclk200" }; 206PNAME(mout_aclk200_sub_p) = { "fin_pll", "div_aclk200" };
197PNAME(mout_aclk266_sub_p) = { "fin_pll", "div_aclk266" }; 207PNAME(mout_aclk266_sub_p) = { "fin_pll", "div_aclk266" };
198PNAME(mout_aclk333_sub_p) = { "fin_pll", "div_aclk333" }; 208PNAME(mout_aclk333_sub_p) = { "fin_pll", "div_aclk333" };
209PNAME(mout_aclk400_isp_sub_p) = { "fin_pll", "div_aclk400_isp" };
199PNAME(mout_hdmi_p) = { "div_hdmi_pixel", "sclk_hdmiphy" }; 210PNAME(mout_hdmi_p) = { "div_hdmi_pixel", "sclk_hdmiphy" };
200PNAME(mout_usb3_p) = { "mout_mpll_user", "mout_cpll" }; 211PNAME(mout_usb3_p) = { "mout_mpll_user", "mout_cpll" };
201PNAME(mout_group1_p) = { "fin_pll", "fin_pll", "sclk_hdmi27m", 212PNAME(mout_group1_p) = { "fin_pll", "fin_pll", "sclk_hdmi27m",
@@ -273,15 +284,23 @@ static struct samsung_mux_clock exynos5250_mux_clks[] __initdata = {
273 MUX(0, "mout_aclk166", mout_aclk166_p, SRC_TOP0, 8, 1), 284 MUX(0, "mout_aclk166", mout_aclk166_p, SRC_TOP0, 8, 1),
274 MUX(0, "mout_aclk200", mout_aclk200_p, SRC_TOP0, 12, 1), 285 MUX(0, "mout_aclk200", mout_aclk200_p, SRC_TOP0, 12, 1),
275 MUX(0, "mout_aclk333", mout_aclk166_p, SRC_TOP0, 16, 1), 286 MUX(0, "mout_aclk333", mout_aclk166_p, SRC_TOP0, 16, 1),
287 MUX(0, "mout_aclk400_g3d_mid", mout_aclk200_p, SRC_TOP0, 20, 1),
288
289 MUX(0, "mout_aclk400_isp", mout_aclk200_p, SRC_TOP1, 24, 1),
290 MUX(0, "mout_aclk400_g3d", mout_aclk400_p, SRC_TOP1, 28, 1),
276 291
277 MUX(0, "mout_cpll", mout_cpll_p, SRC_TOP2, 8, 1), 292 MUX(0, "mout_cpll", mout_cpll_p, SRC_TOP2, 8, 1),
278 MUX(0, "mout_epll", mout_epll_p, SRC_TOP2, 12, 1), 293 MUX(0, "mout_epll", mout_epll_p, SRC_TOP2, 12, 1),
279 MUX(0, "mout_vpll", mout_vpll_p, SRC_TOP2, 16, 1), 294 MUX(0, "mout_vpll", mout_vpll_p, SRC_TOP2, 16, 1),
280 MUX(0, "mout_mpll_user", mout_mpll_user_p, SRC_TOP2, 20, 1), 295 MUX(0, "mout_mpll_user", mout_mpll_user_p, SRC_TOP2, 20, 1),
281 MUX(0, "mout_bpll_user", mout_bpll_user_p, SRC_TOP2, 24, 1), 296 MUX(0, "mout_bpll_user", mout_bpll_user_p, SRC_TOP2, 24, 1),
297 MUX(CLK_MOUT_GPLL, "mout_gpll", mout_gpll_p, SRC_TOP2, 28, 1),
282 298
283 MUX(0, "mout_aclk200_disp1_sub", mout_aclk200_sub_p, SRC_TOP3, 4, 1), 299 MUX(0, "mout_aclk200_disp1_sub", mout_aclk200_sub_p, SRC_TOP3, 4, 1),
284 MUX(0, "mout_aclk266_gscl_sub", mout_aclk266_sub_p, SRC_TOP3, 8, 1), 300 MUX(0, "mout_aclk266_gscl_sub", mout_aclk266_sub_p, SRC_TOP3, 8, 1),
301 MUX(0, "mout_aclk_266_isp_sub", mout_aclk266_sub_p, SRC_TOP3, 16, 1),
302 MUX(0, "mout_aclk_400_isp_sub", mout_aclk400_isp_sub_p,
303 SRC_TOP3, 20, 1),
285 MUX(0, "mout_aclk333_sub", mout_aclk333_sub_p, SRC_TOP3, 24, 1), 304 MUX(0, "mout_aclk333_sub", mout_aclk333_sub_p, SRC_TOP3, 24, 1),
286 305
287 MUX(0, "mout_cam_bayer", mout_group1_p, SRC_GSCL, 12, 4), 306 MUX(0, "mout_cam_bayer", mout_group1_p, SRC_GSCL, 12, 4),
@@ -351,7 +370,10 @@ static struct samsung_div_clock exynos5250_div_clks[] __initdata = {
351 DIV(0, "div_aclk200", "mout_aclk200", DIV_TOP0, 12, 3), 370 DIV(0, "div_aclk200", "mout_aclk200", DIV_TOP0, 12, 3),
352 DIV(0, "div_aclk266", "mout_mpll_user", DIV_TOP0, 16, 3), 371 DIV(0, "div_aclk266", "mout_mpll_user", DIV_TOP0, 16, 3),
353 DIV(0, "div_aclk333", "mout_aclk333", DIV_TOP0, 20, 3), 372 DIV(0, "div_aclk333", "mout_aclk333", DIV_TOP0, 20, 3),
373 DIV(0, "div_aclk400_g3d", "mout_aclk400_g3d", DIV_TOP0,
374 24, 3),
354 375
376 DIV(0, "div_aclk400_isp", "mout_aclk400_isp", DIV_TOP1, 20, 3),
355 DIV(0, "div_aclk66_pre", "mout_mpll_user", DIV_TOP1, 24, 3), 377 DIV(0, "div_aclk66_pre", "mout_mpll_user", DIV_TOP1, 24, 3),
356 378
357 DIV(0, "div_cam_bayer", "mout_cam_bayer", DIV_GSCL, 12, 4), 379 DIV(0, "div_cam_bayer", "mout_cam_bayer", DIV_GSCL, 12, 4),
@@ -428,6 +450,7 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
428 * CMU_ACP 450 * CMU_ACP
429 */ 451 */
430 GATE(CLK_MDMA0, "mdma0", "div_aclk266", GATE_IP_ACP, 1, 0, 0), 452 GATE(CLK_MDMA0, "mdma0", "div_aclk266", GATE_IP_ACP, 1, 0, 0),
453 GATE(CLK_SSS, "sss", "div_aclk266", GATE_IP_ACP, 2, 0, 0),
431 GATE(CLK_G2D, "g2d", "div_aclk200", GATE_IP_ACP, 3, 0, 0), 454 GATE(CLK_G2D, "g2d", "div_aclk200", GATE_IP_ACP, 3, 0, 0),
432 GATE(CLK_SMMU_MDMA0, "smmu_mdma0", "div_aclk266", GATE_IP_ACP, 5, 0, 0), 455 GATE(CLK_SMMU_MDMA0, "smmu_mdma0", "div_aclk266", GATE_IP_ACP, 5, 0, 0),
433 456
@@ -533,7 +556,8 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
533 0), 556 0),
534 GATE(CLK_SMMU_MFCL, "smmu_mfcl", "mout_aclk333_sub", GATE_IP_MFC, 2, 0, 557 GATE(CLK_SMMU_MFCL, "smmu_mfcl", "mout_aclk333_sub", GATE_IP_MFC, 2, 0,
535 0), 558 0),
536 559 GATE(CLK_G3D, "g3d", "div_aclk400_g3d", GATE_IP_G3D, 0,
560 CLK_SET_RATE_PARENT, 0),
537 GATE(CLK_ROTATOR, "rotator", "div_aclk266", GATE_IP_GEN, 1, 0, 0), 561 GATE(CLK_ROTATOR, "rotator", "div_aclk266", GATE_IP_GEN, 1, 0, 0),
538 GATE(CLK_JPEG, "jpeg", "div_aclk166", GATE_IP_GEN, 2, 0, 0), 562 GATE(CLK_JPEG, "jpeg", "div_aclk166", GATE_IP_GEN, 2, 0, 0),
539 GATE(CLK_MDMA1, "mdma1", "div_aclk266", GATE_IP_GEN, 4, 0, 0), 563 GATE(CLK_MDMA1, "mdma1", "div_aclk266", GATE_IP_GEN, 4, 0, 0),
@@ -615,6 +639,31 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = {
615 GATE(CLK_WDT, "wdt", "div_aclk66", GATE_IP_PERIS, 19, 0, 0), 639 GATE(CLK_WDT, "wdt", "div_aclk66", GATE_IP_PERIS, 19, 0, 0),
616 GATE(CLK_RTC, "rtc", "div_aclk66", GATE_IP_PERIS, 20, 0, 0), 640 GATE(CLK_RTC, "rtc", "div_aclk66", GATE_IP_PERIS, 20, 0, 0),
617 GATE(CLK_TMU, "tmu", "div_aclk66", GATE_IP_PERIS, 21, 0, 0), 641 GATE(CLK_TMU, "tmu", "div_aclk66", GATE_IP_PERIS, 21, 0, 0),
642 GATE(CLK_SMMU_TV, "smmu_tv", "mout_aclk200_disp1_sub",
643 GATE_IP_DISP1, 2, 0, 0),
644 GATE(CLK_SMMU_FIMD1, "smmu_fimd1", "mout_aclk200_disp1_sub",
645 GATE_IP_DISP1, 8, 0, 0),
646 GATE(CLK_SMMU_2D, "smmu_2d", "div_aclk200", GATE_IP_ACP, 7, 0, 0),
647 GATE(CLK_SMMU_FIMC_ISP, "smmu_fimc_isp", "mout_aclk_266_isp_sub",
648 GATE_IP_ISP0, 8, 0, 0),
649 GATE(CLK_SMMU_FIMC_DRC, "smmu_fimc_drc", "mout_aclk_266_isp_sub",
650 GATE_IP_ISP0, 9, 0, 0),
651 GATE(CLK_SMMU_FIMC_FD, "smmu_fimc_fd", "mout_aclk_266_isp_sub",
652 GATE_IP_ISP0, 10, 0, 0),
653 GATE(CLK_SMMU_FIMC_SCC, "smmu_fimc_scc", "mout_aclk_266_isp_sub",
654 GATE_IP_ISP0, 11, 0, 0),
655 GATE(CLK_SMMU_FIMC_SCP, "smmu_fimc_scp", "mout_aclk_266_isp_sub",
656 GATE_IP_ISP0, 12, 0, 0),
657 GATE(CLK_SMMU_FIMC_MCU, "smmu_fimc_mcu", "mout_aclk_400_isp_sub",
658 GATE_IP_ISP0, 13, 0, 0),
659 GATE(CLK_SMMU_FIMC_ODC, "smmu_fimc_odc", "mout_aclk_266_isp_sub",
660 GATE_IP_ISP1, 4, 0, 0),
661 GATE(CLK_SMMU_FIMC_DIS0, "smmu_fimc_dis0", "mout_aclk_266_isp_sub",
662 GATE_IP_ISP1, 5, 0, 0),
663 GATE(CLK_SMMU_FIMC_DIS1, "smmu_fimc_dis1", "mout_aclk_266_isp_sub",
664 GATE_IP_ISP1, 6, 0, 0),
665 GATE(CLK_SMMU_FIMC_3DNR, "smmu_fimc_3dnr", "mout_aclk_266_isp_sub",
666 GATE_IP_ISP1, 7, 0, 0),
618}; 667};
619 668
620static struct samsung_pll_rate_table vpll_24mhz_tbl[] __initdata = { 669static struct samsung_pll_rate_table vpll_24mhz_tbl[] __initdata = {
@@ -686,6 +735,8 @@ static struct of_device_id ext_clk_match[] __initdata = {
686/* register exynox5250 clocks */ 735/* register exynox5250 clocks */
687static void __init exynos5250_clk_init(struct device_node *np) 736static void __init exynos5250_clk_init(struct device_node *np)
688{ 737{
738 struct samsung_clk_provider *ctx;
739
689 if (np) { 740 if (np) {
690 reg_base = of_iomap(np, 0); 741 reg_base = of_iomap(np, 0);
691 if (!reg_base) 742 if (!reg_base)
@@ -694,11 +745,13 @@ static void __init exynos5250_clk_init(struct device_node *np)
694 panic("%s: unable to determine soc\n", __func__); 745 panic("%s: unable to determine soc\n", __func__);
695 } 746 }
696 747
697 samsung_clk_init(np, reg_base, CLK_NR_CLKS); 748 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
698 samsung_clk_of_register_fixed_ext(exynos5250_fixed_rate_ext_clks, 749 if (!ctx)
750 panic("%s: unable to allocate context.\n", __func__);
751 samsung_clk_of_register_fixed_ext(ctx, exynos5250_fixed_rate_ext_clks,
699 ARRAY_SIZE(exynos5250_fixed_rate_ext_clks), 752 ARRAY_SIZE(exynos5250_fixed_rate_ext_clks),
700 ext_clk_match); 753 ext_clk_match);
701 samsung_clk_register_mux(exynos5250_pll_pmux_clks, 754 samsung_clk_register_mux(ctx, exynos5250_pll_pmux_clks,
702 ARRAY_SIZE(exynos5250_pll_pmux_clks)); 755 ARRAY_SIZE(exynos5250_pll_pmux_clks));
703 756
704 if (_get_rate("fin_pll") == 24 * MHZ) { 757 if (_get_rate("fin_pll") == 24 * MHZ) {
@@ -709,17 +762,18 @@ static void __init exynos5250_clk_init(struct device_node *np)
709 if (_get_rate("mout_vpllsrc") == 24 * MHZ) 762 if (_get_rate("mout_vpllsrc") == 24 * MHZ)
710 exynos5250_plls[vpll].rate_table = vpll_24mhz_tbl; 763 exynos5250_plls[vpll].rate_table = vpll_24mhz_tbl;
711 764
712 samsung_clk_register_pll(exynos5250_plls, ARRAY_SIZE(exynos5250_plls), 765 samsung_clk_register_pll(ctx, exynos5250_plls,
713 reg_base); 766 ARRAY_SIZE(exynos5250_plls),
714 samsung_clk_register_fixed_rate(exynos5250_fixed_rate_clks, 767 reg_base);
768 samsung_clk_register_fixed_rate(ctx, exynos5250_fixed_rate_clks,
715 ARRAY_SIZE(exynos5250_fixed_rate_clks)); 769 ARRAY_SIZE(exynos5250_fixed_rate_clks));
716 samsung_clk_register_fixed_factor(exynos5250_fixed_factor_clks, 770 samsung_clk_register_fixed_factor(ctx, exynos5250_fixed_factor_clks,
717 ARRAY_SIZE(exynos5250_fixed_factor_clks)); 771 ARRAY_SIZE(exynos5250_fixed_factor_clks));
718 samsung_clk_register_mux(exynos5250_mux_clks, 772 samsung_clk_register_mux(ctx, exynos5250_mux_clks,
719 ARRAY_SIZE(exynos5250_mux_clks)); 773 ARRAY_SIZE(exynos5250_mux_clks));
720 samsung_clk_register_div(exynos5250_div_clks, 774 samsung_clk_register_div(ctx, exynos5250_div_clks,
721 ARRAY_SIZE(exynos5250_div_clks)); 775 ARRAY_SIZE(exynos5250_div_clks));
722 samsung_clk_register_gate(exynos5250_gate_clks, 776 samsung_clk_register_gate(ctx, exynos5250_gate_clks,
723 ARRAY_SIZE(exynos5250_gate_clks)); 777 ARRAY_SIZE(exynos5250_gate_clks));
724 778
725 exynos5250_clk_sleep_init(); 779 exynos5250_clk_sleep_init();
diff --git a/drivers/clk/samsung/clk-exynos5260.c b/drivers/clk/samsung/clk-exynos5260.c
new file mode 100644
index 000000000000..64596ba58df1
--- /dev/null
+++ b/drivers/clk/samsung/clk-exynos5260.c
@@ -0,0 +1,1980 @@
1/*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 * Author: Rahul Sharma <rahul.sharma@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Common Clock Framework support for Exynos5260 SoC.
10 */
11
12#include <linux/clk.h>
13#include <linux/clkdev.h>
14#include <linux/clk-provider.h>
15#include <linux/of.h>
16#include <linux/of_address.h>
17#include <linux/syscore_ops.h>
18
19#include "clk-exynos5260.h"
20#include "clk.h"
21#include "clk-pll.h"
22
23#include <dt-bindings/clock/exynos5260-clk.h>
24
25static LIST_HEAD(clock_reg_cache_list);
26
27struct exynos5260_clock_reg_cache {
28 struct list_head node;
29 void __iomem *reg_base;
30 struct samsung_clk_reg_dump *rdump;
31 unsigned int rd_num;
32};
33
34struct exynos5260_cmu_info {
35 /* list of pll clocks and respective count */
36 struct samsung_pll_clock *pll_clks;
37 unsigned int nr_pll_clks;
38 /* list of mux clocks and respective count */
39 struct samsung_mux_clock *mux_clks;
40 unsigned int nr_mux_clks;
41 /* list of div clocks and respective count */
42 struct samsung_div_clock *div_clks;
43 unsigned int nr_div_clks;
44 /* list of gate clocks and respective count */
45 struct samsung_gate_clock *gate_clks;
46 unsigned int nr_gate_clks;
47 /* list of fixed clocks and respective count */
48 struct samsung_fixed_rate_clock *fixed_clks;
49 unsigned int nr_fixed_clks;
50 /* total number of clocks with IDs assigned*/
51 unsigned int nr_clk_ids;
52
53 /* list and number of clocks registers */
54 unsigned long *clk_regs;
55 unsigned int nr_clk_regs;
56};
57
58/*
59 * Applicable for all 2550 Type PLLS for Exynos5260, listed below
60 * DISP_PLL, EGL_PLL, KFC_PLL, MEM_PLL, BUS_PLL, MEDIA_PLL, G3D_PLL.
61 */
62static struct samsung_pll_rate_table pll2550_24mhz_tbl[] __initdata = {
63 PLL_35XX_RATE(1700000000, 425, 6, 0),
64 PLL_35XX_RATE(1600000000, 200, 3, 0),
65 PLL_35XX_RATE(1500000000, 250, 4, 0),
66 PLL_35XX_RATE(1400000000, 175, 3, 0),
67 PLL_35XX_RATE(1300000000, 325, 6, 0),
68 PLL_35XX_RATE(1200000000, 400, 4, 1),
69 PLL_35XX_RATE(1100000000, 275, 3, 1),
70 PLL_35XX_RATE(1000000000, 250, 3, 1),
71 PLL_35XX_RATE(933000000, 311, 4, 1),
72 PLL_35XX_RATE(900000000, 300, 4, 1),
73 PLL_35XX_RATE(800000000, 200, 3, 1),
74 PLL_35XX_RATE(733000000, 733, 12, 1),
75 PLL_35XX_RATE(700000000, 175, 3, 1),
76 PLL_35XX_RATE(667000000, 667, 12, 1),
77 PLL_35XX_RATE(633000000, 211, 4, 1),
78 PLL_35XX_RATE(620000000, 310, 3, 2),
79 PLL_35XX_RATE(600000000, 400, 4, 2),
80 PLL_35XX_RATE(543000000, 362, 4, 2),
81 PLL_35XX_RATE(533000000, 533, 6, 2),
82 PLL_35XX_RATE(500000000, 250, 3, 2),
83 PLL_35XX_RATE(450000000, 300, 4, 2),
84 PLL_35XX_RATE(400000000, 200, 3, 2),
85 PLL_35XX_RATE(350000000, 175, 3, 2),
86 PLL_35XX_RATE(300000000, 400, 4, 3),
87 PLL_35XX_RATE(266000000, 266, 3, 3),
88 PLL_35XX_RATE(200000000, 200, 3, 3),
89 PLL_35XX_RATE(160000000, 160, 3, 3),
90};
91
92/*
93 * Applicable for 2650 Type PLL for AUD_PLL.
94 */
95static struct samsung_pll_rate_table pll2650_24mhz_tbl[] __initdata = {
96 PLL_36XX_RATE(1600000000, 200, 3, 0, 0),
97 PLL_36XX_RATE(1200000000, 100, 2, 0, 0),
98 PLL_36XX_RATE(1000000000, 250, 3, 1, 0),
99 PLL_36XX_RATE(800000000, 200, 3, 1, 0),
100 PLL_36XX_RATE(600000000, 100, 2, 1, 0),
101 PLL_36XX_RATE(532000000, 266, 3, 2, 0),
102 PLL_36XX_RATE(480000000, 160, 2, 2, 0),
103 PLL_36XX_RATE(432000000, 144, 2, 2, 0),
104 PLL_36XX_RATE(400000000, 200, 3, 2, 0),
105 PLL_36XX_RATE(394073130, 459, 7, 2, 49282),
106 PLL_36XX_RATE(333000000, 111, 2, 2, 0),
107 PLL_36XX_RATE(300000000, 100, 2, 2, 0),
108 PLL_36XX_RATE(266000000, 266, 3, 3, 0),
109 PLL_36XX_RATE(200000000, 200, 3, 3, 0),
110 PLL_36XX_RATE(166000000, 166, 3, 3, 0),
111 PLL_36XX_RATE(133000000, 266, 3, 4, 0),
112 PLL_36XX_RATE(100000000, 200, 3, 4, 0),
113 PLL_36XX_RATE(66000000, 176, 2, 5, 0),
114};
115
116#ifdef CONFIG_PM_SLEEP
117
118static int exynos5260_clk_suspend(void)
119{
120 struct exynos5260_clock_reg_cache *cache;
121
122 list_for_each_entry(cache, &clock_reg_cache_list, node)
123 samsung_clk_save(cache->reg_base, cache->rdump,
124 cache->rd_num);
125
126 return 0;
127}
128
129static void exynos5260_clk_resume(void)
130{
131 struct exynos5260_clock_reg_cache *cache;
132
133 list_for_each_entry(cache, &clock_reg_cache_list, node)
134 samsung_clk_restore(cache->reg_base, cache->rdump,
135 cache->rd_num);
136}
137
138static struct syscore_ops exynos5260_clk_syscore_ops = {
139 .suspend = exynos5260_clk_suspend,
140 .resume = exynos5260_clk_resume,
141};
142
143static void exynos5260_clk_sleep_init(void __iomem *reg_base,
144 unsigned long *rdump,
145 unsigned long nr_rdump)
146{
147 struct exynos5260_clock_reg_cache *reg_cache;
148
149 reg_cache = kzalloc(sizeof(struct exynos5260_clock_reg_cache),
150 GFP_KERNEL);
151 if (!reg_cache)
152 panic("could not allocate register cache.\n");
153
154 reg_cache->rdump = samsung_clk_alloc_reg_dump(rdump, nr_rdump);
155
156 if (!reg_cache->rdump)
157 panic("could not allocate register dump storage.\n");
158
159 if (list_empty(&clock_reg_cache_list))
160 register_syscore_ops(&exynos5260_clk_syscore_ops);
161
162 reg_cache->rd_num = nr_rdump;
163 reg_cache->reg_base = reg_base;
164 list_add_tail(&reg_cache->node, &clock_reg_cache_list);
165}
166
167#else
168static void exynos5260_clk_sleep_init(void __iomem *reg_base,
169 unsigned long *rdump,
170 unsigned long nr_rdump){}
171#endif
172
173/*
174 * Common function which registers plls, muxes, dividers and gates
175 * for each CMU. It also add CMU register list to register cache.
176 */
177
178void __init exynos5260_cmu_register_one(struct device_node *np,
179 struct exynos5260_cmu_info *cmu)
180{
181 void __iomem *reg_base;
182 struct samsung_clk_provider *ctx;
183
184 reg_base = of_iomap(np, 0);
185 if (!reg_base)
186 panic("%s: failed to map registers\n", __func__);
187
188 ctx = samsung_clk_init(np, reg_base, cmu->nr_clk_ids);
189 if (!ctx)
190 panic("%s: unable to alllocate ctx\n", __func__);
191
192 if (cmu->pll_clks)
193 samsung_clk_register_pll(ctx, cmu->pll_clks, cmu->nr_pll_clks,
194 reg_base);
195 if (cmu->mux_clks)
196 samsung_clk_register_mux(ctx, cmu->mux_clks,
197 cmu->nr_mux_clks);
198 if (cmu->div_clks)
199 samsung_clk_register_div(ctx, cmu->div_clks, cmu->nr_div_clks);
200 if (cmu->gate_clks)
201 samsung_clk_register_gate(ctx, cmu->gate_clks,
202 cmu->nr_gate_clks);
203 if (cmu->fixed_clks)
204 samsung_clk_register_fixed_rate(ctx, cmu->fixed_clks,
205 cmu->nr_fixed_clks);
206 if (cmu->clk_regs)
207 exynos5260_clk_sleep_init(reg_base, cmu->clk_regs,
208 cmu->nr_clk_regs);
209}
210
211
212/* CMU_AUD */
213
214static unsigned long aud_clk_regs[] __initdata = {
215 MUX_SEL_AUD,
216 DIV_AUD0,
217 DIV_AUD1,
218 EN_ACLK_AUD,
219 EN_PCLK_AUD,
220 EN_SCLK_AUD,
221 EN_IP_AUD,
222};
223
224PNAME(mout_aud_pll_user_p) = {"fin_pll", "fout_aud_pll"};
225PNAME(mout_sclk_aud_i2s_p) = {"mout_aud_pll_user", "ioclk_i2s_cdclk"};
226PNAME(mout_sclk_aud_pcm_p) = {"mout_aud_pll_user", "ioclk_pcm_extclk"};
227
228struct samsung_mux_clock aud_mux_clks[] __initdata = {
229 MUX(AUD_MOUT_AUD_PLL_USER, "mout_aud_pll_user", mout_aud_pll_user_p,
230 MUX_SEL_AUD, 0, 1),
231 MUX(AUD_MOUT_SCLK_AUD_I2S, "mout_sclk_aud_i2s", mout_sclk_aud_i2s_p,
232 MUX_SEL_AUD, 4, 1),
233 MUX(AUD_MOUT_SCLK_AUD_PCM, "mout_sclk_aud_pcm", mout_sclk_aud_pcm_p,
234 MUX_SEL_AUD, 8, 1),
235};
236
237struct samsung_div_clock aud_div_clks[] __initdata = {
238 DIV(AUD_DOUT_ACLK_AUD_131, "dout_aclk_aud_131", "mout_aud_pll_user",
239 DIV_AUD0, 0, 4),
240
241 DIV(AUD_DOUT_SCLK_AUD_I2S, "dout_sclk_aud_i2s", "mout_sclk_aud_i2s",
242 DIV_AUD1, 0, 4),
243 DIV(AUD_DOUT_SCLK_AUD_PCM, "dout_sclk_aud_pcm", "mout_sclk_aud_pcm",
244 DIV_AUD1, 4, 8),
245 DIV(AUD_DOUT_SCLK_AUD_UART, "dout_sclk_aud_uart", "mout_aud_pll_user",
246 DIV_AUD1, 12, 4),
247};
248
249struct samsung_gate_clock aud_gate_clks[] __initdata = {
250 GATE(AUD_SCLK_I2S, "sclk_aud_i2s", "dout_sclk_aud_i2s",
251 EN_SCLK_AUD, 0, CLK_SET_RATE_PARENT, 0),
252 GATE(AUD_SCLK_PCM, "sclk_aud_pcm", "dout_sclk_aud_pcm",
253 EN_SCLK_AUD, 1, CLK_SET_RATE_PARENT, 0),
254 GATE(AUD_SCLK_AUD_UART, "sclk_aud_uart", "dout_sclk_aud_uart",
255 EN_SCLK_AUD, 2, CLK_SET_RATE_PARENT, 0),
256
257 GATE(AUD_CLK_SRAMC, "clk_sramc", "dout_aclk_aud_131", EN_IP_AUD,
258 0, 0, 0),
259 GATE(AUD_CLK_DMAC, "clk_dmac", "dout_aclk_aud_131",
260 EN_IP_AUD, 1, 0, 0),
261 GATE(AUD_CLK_I2S, "clk_i2s", "dout_aclk_aud_131", EN_IP_AUD, 2, 0, 0),
262 GATE(AUD_CLK_PCM, "clk_pcm", "dout_aclk_aud_131", EN_IP_AUD, 3, 0, 0),
263 GATE(AUD_CLK_AUD_UART, "clk_aud_uart", "dout_aclk_aud_131",
264 EN_IP_AUD, 4, 0, 0),
265};
266
267static void __init exynos5260_clk_aud_init(struct device_node *np)
268{
269 struct exynos5260_cmu_info cmu = {0};
270
271 cmu.mux_clks = aud_mux_clks;
272 cmu.nr_mux_clks = ARRAY_SIZE(aud_mux_clks);
273 cmu.div_clks = aud_div_clks;
274 cmu.nr_div_clks = ARRAY_SIZE(aud_div_clks);
275 cmu.gate_clks = aud_gate_clks;
276 cmu.nr_gate_clks = ARRAY_SIZE(aud_gate_clks);
277 cmu.nr_clk_ids = AUD_NR_CLK;
278 cmu.clk_regs = aud_clk_regs;
279 cmu.nr_clk_regs = ARRAY_SIZE(aud_clk_regs);
280
281 exynos5260_cmu_register_one(np, &cmu);
282}
283
284CLK_OF_DECLARE(exynos5260_clk_aud, "samsung,exynos5260-clock-aud",
285 exynos5260_clk_aud_init);
286
287
288/* CMU_DISP */
289
290static unsigned long disp_clk_regs[] __initdata = {
291 MUX_SEL_DISP0,
292 MUX_SEL_DISP1,
293 MUX_SEL_DISP2,
294 MUX_SEL_DISP3,
295 MUX_SEL_DISP4,
296 DIV_DISP,
297 EN_ACLK_DISP,
298 EN_PCLK_DISP,
299 EN_SCLK_DISP0,
300 EN_SCLK_DISP1,
301 EN_IP_DISP,
302 EN_IP_DISP_BUS,
303};
304
305PNAME(mout_phyclk_dptx_phy_ch3_txd_clk_user_p) = {"fin_pll",
306 "phyclk_dptx_phy_ch3_txd_clk"};
307PNAME(mout_phyclk_dptx_phy_ch2_txd_clk_user_p) = {"fin_pll",
308 "phyclk_dptx_phy_ch2_txd_clk"};
309PNAME(mout_phyclk_dptx_phy_ch1_txd_clk_user_p) = {"fin_pll",
310 "phyclk_dptx_phy_ch1_txd_clk"};
311PNAME(mout_phyclk_dptx_phy_ch0_txd_clk_user_p) = {"fin_pll",
312 "phyclk_dptx_phy_ch0_txd_clk"};
313PNAME(mout_aclk_disp_222_user_p) = {"fin_pll", "dout_aclk_disp_222"};
314PNAME(mout_sclk_disp_pixel_user_p) = {"fin_pll", "dout_sclk_disp_pixel"};
315PNAME(mout_aclk_disp_333_user_p) = {"fin_pll", "dout_aclk_disp_333"};
316PNAME(mout_phyclk_hdmi_phy_tmds_clko_user_p) = {"fin_pll",
317 "phyclk_hdmi_phy_tmds_clko"};
318PNAME(mout_phyclk_hdmi_phy_ref_clko_user_p) = {"fin_pll",
319 "phyclk_hdmi_phy_ref_clko"};
320PNAME(mout_phyclk_hdmi_phy_pixel_clko_user_p) = {"fin_pll",
321 "phyclk_hdmi_phy_pixel_clko"};
322PNAME(mout_phyclk_hdmi_link_o_tmds_clkhi_user_p) = {"fin_pll",
323 "phyclk_hdmi_link_o_tmds_clkhi"};
324PNAME(mout_phyclk_mipi_dphy_4l_m_txbyte_clkhs_p) = {"fin_pll",
325 "phyclk_mipi_dphy_4l_m_txbyte_clkhs"};
326PNAME(mout_phyclk_dptx_phy_o_ref_clk_24m_user_p) = {"fin_pll",
327 "phyclk_dptx_phy_o_ref_clk_24m"};
328PNAME(mout_phyclk_dptx_phy_clk_div2_user_p) = {"fin_pll",
329 "phyclk_dptx_phy_clk_div2"};
330PNAME(mout_sclk_hdmi_pixel_p) = {"mout_sclk_disp_pixel_user",
331 "mout_aclk_disp_222_user"};
332PNAME(mout_phyclk_mipi_dphy_4lmrxclk_esc0_user_p) = {"fin_pll",
333 "phyclk_mipi_dphy_4l_m_rxclkesc0"};
334PNAME(mout_sclk_hdmi_spdif_p) = {"fin_pll", "ioclk_spdif_extclk",
335 "dout_aclk_peri_aud", "phyclk_hdmi_phy_ref_cko"};
336
337struct samsung_mux_clock disp_mux_clks[] __initdata = {
338 MUX(DISP_MOUT_ACLK_DISP_333_USER, "mout_aclk_disp_333_user",
339 mout_aclk_disp_333_user_p,
340 MUX_SEL_DISP0, 0, 1),
341 MUX(DISP_MOUT_SCLK_DISP_PIXEL_USER, "mout_sclk_disp_pixel_user",
342 mout_sclk_disp_pixel_user_p,
343 MUX_SEL_DISP0, 4, 1),
344 MUX(DISP_MOUT_ACLK_DISP_222_USER, "mout_aclk_disp_222_user",
345 mout_aclk_disp_222_user_p,
346 MUX_SEL_DISP0, 8, 1),
347 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_CH0_TXD_CLK_USER,
348 "mout_phyclk_dptx_phy_ch0_txd_clk_user",
349 mout_phyclk_dptx_phy_ch0_txd_clk_user_p,
350 MUX_SEL_DISP0, 16, 1),
351 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_CH1_TXD_CLK_USER,
352 "mout_phyclk_dptx_phy_ch1_txd_clk_user",
353 mout_phyclk_dptx_phy_ch1_txd_clk_user_p,
354 MUX_SEL_DISP0, 20, 1),
355 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_CH2_TXD_CLK_USER,
356 "mout_phyclk_dptx_phy_ch2_txd_clk_user",
357 mout_phyclk_dptx_phy_ch2_txd_clk_user_p,
358 MUX_SEL_DISP0, 24, 1),
359 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_CH3_TXD_CLK_USER,
360 "mout_phyclk_dptx_phy_ch3_txd_clk_user",
361 mout_phyclk_dptx_phy_ch3_txd_clk_user_p,
362 MUX_SEL_DISP0, 28, 1),
363
364 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_CLK_DIV2_USER,
365 "mout_phyclk_dptx_phy_clk_div2_user",
366 mout_phyclk_dptx_phy_clk_div2_user_p,
367 MUX_SEL_DISP1, 0, 1),
368 MUX(DISP_MOUT_PHYCLK_DPTX_PHY_O_REF_CLK_24M_USER,
369 "mout_phyclk_dptx_phy_o_ref_clk_24m_user",
370 mout_phyclk_dptx_phy_o_ref_clk_24m_user_p,
371 MUX_SEL_DISP1, 4, 1),
372 MUX(DISP_MOUT_PHYCLK_MIPI_DPHY_4L_M_TXBYTE_CLKHS,
373 "mout_phyclk_mipi_dphy_4l_m_txbyte_clkhs",
374 mout_phyclk_mipi_dphy_4l_m_txbyte_clkhs_p,
375 MUX_SEL_DISP1, 8, 1),
376 MUX(DISP_MOUT_PHYCLK_HDMI_LINK_O_TMDS_CLKHI_USER,
377 "mout_phyclk_hdmi_link_o_tmds_clkhi_user",
378 mout_phyclk_hdmi_link_o_tmds_clkhi_user_p,
379 MUX_SEL_DISP1, 16, 1),
380 MUX(DISP_MOUT_HDMI_PHY_PIXEL,
381 "mout_phyclk_hdmi_phy_pixel_clko_user",
382 mout_phyclk_hdmi_phy_pixel_clko_user_p,
383 MUX_SEL_DISP1, 20, 1),
384 MUX(DISP_MOUT_PHYCLK_HDMI_PHY_REF_CLKO_USER,
385 "mout_phyclk_hdmi_phy_ref_clko_user",
386 mout_phyclk_hdmi_phy_ref_clko_user_p,
387 MUX_SEL_DISP1, 24, 1),
388 MUX(DISP_MOUT_PHYCLK_HDMI_PHY_TMDS_CLKO_USER,
389 "mout_phyclk_hdmi_phy_tmds_clko_user",
390 mout_phyclk_hdmi_phy_tmds_clko_user_p,
391 MUX_SEL_DISP1, 28, 1),
392
393 MUX(DISP_MOUT_PHYCLK_MIPI_DPHY_4LMRXCLK_ESC0_USER,
394 "mout_phyclk_mipi_dphy_4lmrxclk_esc0_user",
395 mout_phyclk_mipi_dphy_4lmrxclk_esc0_user_p,
396 MUX_SEL_DISP2, 0, 1),
397 MUX(DISP_MOUT_SCLK_HDMI_PIXEL, "mout_sclk_hdmi_pixel",
398 mout_sclk_hdmi_pixel_p,
399 MUX_SEL_DISP2, 4, 1),
400
401 MUX(DISP_MOUT_SCLK_HDMI_SPDIF, "mout_sclk_hdmi_spdif",
402 mout_sclk_hdmi_spdif_p,
403 MUX_SEL_DISP4, 4, 2),
404};
405
406struct samsung_div_clock disp_div_clks[] __initdata = {
407 DIV(DISP_DOUT_PCLK_DISP_111, "dout_pclk_disp_111",
408 "mout_aclk_disp_222_user",
409 DIV_DISP, 8, 4),
410 DIV(DISP_DOUT_SCLK_FIMD1_EXTCLKPLL, "dout_sclk_fimd1_extclkpll",
411 "mout_sclk_disp_pixel_user",
412 DIV_DISP, 12, 4),
413 DIV(DISP_DOUT_SCLK_HDMI_PHY_PIXEL_CLKI,
414 "dout_sclk_hdmi_phy_pixel_clki",
415 "mout_sclk_hdmi_pixel",
416 DIV_DISP, 16, 4),
417};
418
419struct samsung_gate_clock disp_gate_clks[] __initdata = {
420 GATE(DISP_MOUT_HDMI_PHY_PIXEL_USER, "sclk_hdmi_link_i_pixel",
421 "mout_phyclk_hdmi_phy_pixel_clko_user",
422 EN_SCLK_DISP0, 26, CLK_SET_RATE_PARENT, 0),
423 GATE(DISP_SCLK_PIXEL, "sclk_hdmi_phy_pixel_clki",
424 "dout_sclk_hdmi_phy_pixel_clki",
425 EN_SCLK_DISP0, 29, CLK_SET_RATE_PARENT, 0),
426
427 GATE(DISP_CLK_DP, "clk_dptx_link", "mout_aclk_disp_222_user",
428 EN_IP_DISP, 4, 0, 0),
429 GATE(DISP_CLK_DPPHY, "clk_dptx_phy", "mout_aclk_disp_222_user",
430 EN_IP_DISP, 5, 0, 0),
431 GATE(DISP_CLK_DSIM1, "clk_dsim1", "mout_aclk_disp_222_user",
432 EN_IP_DISP, 6, 0, 0),
433 GATE(DISP_CLK_FIMD1, "clk_fimd1", "mout_aclk_disp_222_user",
434 EN_IP_DISP, 7, 0, 0),
435 GATE(DISP_CLK_HDMI, "clk_hdmi", "mout_aclk_disp_222_user",
436 EN_IP_DISP, 8, 0, 0),
437 GATE(DISP_CLK_HDMIPHY, "clk_hdmiphy", "mout_aclk_disp_222_user",
438 EN_IP_DISP, 9, 0, 0),
439 GATE(DISP_CLK_MIPIPHY, "clk_mipi_dphy", "mout_aclk_disp_222_user",
440 EN_IP_DISP, 10, 0, 0),
441 GATE(DISP_CLK_MIXER, "clk_mixer", "mout_aclk_disp_222_user",
442 EN_IP_DISP, 11, 0, 0),
443 GATE(DISP_CLK_PIXEL_DISP, "clk_pixel_disp", "mout_aclk_disp_222_user",
444 EN_IP_DISP, 12, CLK_IGNORE_UNUSED, 0),
445 GATE(DISP_CLK_PIXEL_MIXER, "clk_pixel_mixer", "mout_aclk_disp_222_user",
446 EN_IP_DISP, 13, CLK_IGNORE_UNUSED, 0),
447 GATE(DISP_CLK_SMMU_FIMD1M0, "clk_smmu3_fimd1m0",
448 "mout_aclk_disp_222_user",
449 EN_IP_DISP, 22, 0, 0),
450 GATE(DISP_CLK_SMMU_FIMD1M1, "clk_smmu3_fimd1m1",
451 "mout_aclk_disp_222_user",
452 EN_IP_DISP, 23, 0, 0),
453 GATE(DISP_CLK_SMMU_TV, "clk_smmu3_tv", "mout_aclk_disp_222_user",
454 EN_IP_DISP, 25, 0, 0),
455};
456
457static void __init exynos5260_clk_disp_init(struct device_node *np)
458{
459 struct exynos5260_cmu_info cmu = {0};
460
461 cmu.mux_clks = disp_mux_clks;
462 cmu.nr_mux_clks = ARRAY_SIZE(disp_mux_clks);
463 cmu.div_clks = disp_div_clks;
464 cmu.nr_div_clks = ARRAY_SIZE(disp_div_clks);
465 cmu.gate_clks = disp_gate_clks;
466 cmu.nr_gate_clks = ARRAY_SIZE(disp_gate_clks);
467 cmu.nr_clk_ids = DISP_NR_CLK;
468 cmu.clk_regs = disp_clk_regs;
469 cmu.nr_clk_regs = ARRAY_SIZE(disp_clk_regs);
470
471 exynos5260_cmu_register_one(np, &cmu);
472}
473
474CLK_OF_DECLARE(exynos5260_clk_disp, "samsung,exynos5260-clock-disp",
475 exynos5260_clk_disp_init);
476
477
478/* CMU_EGL */
479
480static unsigned long egl_clk_regs[] __initdata = {
481 EGL_PLL_LOCK,
482 EGL_PLL_CON0,
483 EGL_PLL_CON1,
484 EGL_PLL_FREQ_DET,
485 MUX_SEL_EGL,
486 MUX_ENABLE_EGL,
487 DIV_EGL,
488 DIV_EGL_PLL_FDET,
489 EN_ACLK_EGL,
490 EN_PCLK_EGL,
491 EN_SCLK_EGL,
492};
493
494PNAME(mout_egl_b_p) = {"mout_egl_pll", "dout_bus_pll"};
495PNAME(mout_egl_pll_p) = {"fin_pll", "fout_egl_pll"};
496
497struct samsung_mux_clock egl_mux_clks[] __initdata = {
498 MUX(EGL_MOUT_EGL_PLL, "mout_egl_pll", mout_egl_pll_p,
499 MUX_SEL_EGL, 4, 1),
500 MUX(EGL_MOUT_EGL_B, "mout_egl_b", mout_egl_b_p, MUX_SEL_EGL, 16, 1),
501};
502
503struct samsung_div_clock egl_div_clks[] __initdata = {
504 DIV(EGL_DOUT_EGL1, "dout_egl1", "mout_egl_b", DIV_EGL, 0, 3),
505 DIV(EGL_DOUT_EGL2, "dout_egl2", "dout_egl1", DIV_EGL, 4, 3),
506 DIV(EGL_DOUT_ACLK_EGL, "dout_aclk_egl", "dout_egl2", DIV_EGL, 8, 3),
507 DIV(EGL_DOUT_PCLK_EGL, "dout_pclk_egl", "dout_egl_atclk",
508 DIV_EGL, 12, 3),
509 DIV(EGL_DOUT_EGL_ATCLK, "dout_egl_atclk", "dout_egl2", DIV_EGL, 16, 3),
510 DIV(EGL_DOUT_EGL_PCLK_DBG, "dout_egl_pclk_dbg", "dout_egl_atclk",
511 DIV_EGL, 20, 3),
512 DIV(EGL_DOUT_EGL_PLL, "dout_egl_pll", "mout_egl_b", DIV_EGL, 24, 3),
513};
514
515static struct samsung_pll_clock egl_pll_clks[] __initdata = {
516 PLL(pll_2550xx, EGL_FOUT_EGL_PLL, "fout_egl_pll", "fin_pll",
517 EGL_PLL_LOCK, EGL_PLL_CON0,
518 pll2550_24mhz_tbl),
519};
520
521static void __init exynos5260_clk_egl_init(struct device_node *np)
522{
523 struct exynos5260_cmu_info cmu = {0};
524
525 cmu.pll_clks = egl_pll_clks;
526 cmu.nr_pll_clks = ARRAY_SIZE(egl_pll_clks);
527 cmu.mux_clks = egl_mux_clks;
528 cmu.nr_mux_clks = ARRAY_SIZE(egl_mux_clks);
529 cmu.div_clks = egl_div_clks;
530 cmu.nr_div_clks = ARRAY_SIZE(egl_div_clks);
531 cmu.nr_clk_ids = EGL_NR_CLK;
532 cmu.clk_regs = egl_clk_regs;
533 cmu.nr_clk_regs = ARRAY_SIZE(egl_clk_regs);
534
535 exynos5260_cmu_register_one(np, &cmu);
536}
537
538CLK_OF_DECLARE(exynos5260_clk_egl, "samsung,exynos5260-clock-egl",
539 exynos5260_clk_egl_init);
540
541
542/* CMU_FSYS */
543
544static unsigned long fsys_clk_regs[] __initdata = {
545 MUX_SEL_FSYS0,
546 MUX_SEL_FSYS1,
547 EN_ACLK_FSYS,
548 EN_ACLK_FSYS_SECURE_RTIC,
549 EN_ACLK_FSYS_SECURE_SMMU_RTIC,
550 EN_SCLK_FSYS,
551 EN_IP_FSYS,
552 EN_IP_FSYS_SECURE_RTIC,
553 EN_IP_FSYS_SECURE_SMMU_RTIC,
554};
555
556PNAME(mout_phyclk_usbhost20_phyclk_user_p) = {"fin_pll",
557 "phyclk_usbhost20_phy_phyclock"};
558PNAME(mout_phyclk_usbhost20_freeclk_user_p) = {"fin_pll",
559 "phyclk_usbhost20_phy_freeclk"};
560PNAME(mout_phyclk_usbhost20_clk48mohci_user_p) = {"fin_pll",
561 "phyclk_usbhost20_phy_clk48mohci"};
562PNAME(mout_phyclk_usbdrd30_pipe_pclk_user_p) = {"fin_pll",
563 "phyclk_usbdrd30_udrd30_pipe_pclk"};
564PNAME(mout_phyclk_usbdrd30_phyclock_user_p) = {"fin_pll",
565 "phyclk_usbdrd30_udrd30_phyclock"};
566
567struct samsung_mux_clock fsys_mux_clks[] __initdata = {
568 MUX(FSYS_MOUT_PHYCLK_USBDRD30_PHYCLOCK_USER,
569 "mout_phyclk_usbdrd30_phyclock_user",
570 mout_phyclk_usbdrd30_phyclock_user_p,
571 MUX_SEL_FSYS1, 0, 1),
572 MUX(FSYS_MOUT_PHYCLK_USBDRD30_PIPE_PCLK_USER,
573 "mout_phyclk_usbdrd30_pipe_pclk_user",
574 mout_phyclk_usbdrd30_pipe_pclk_user_p,
575 MUX_SEL_FSYS1, 4, 1),
576 MUX(FSYS_MOUT_PHYCLK_USBHOST20_CLK48MOHCI_USER,
577 "mout_phyclk_usbhost20_clk48mohci_user",
578 mout_phyclk_usbhost20_clk48mohci_user_p,
579 MUX_SEL_FSYS1, 8, 1),
580 MUX(FSYS_MOUT_PHYCLK_USBHOST20_FREECLK_USER,
581 "mout_phyclk_usbhost20_freeclk_user",
582 mout_phyclk_usbhost20_freeclk_user_p,
583 MUX_SEL_FSYS1, 12, 1),
584 MUX(FSYS_MOUT_PHYCLK_USBHOST20_PHYCLK_USER,
585 "mout_phyclk_usbhost20_phyclk_user",
586 mout_phyclk_usbhost20_phyclk_user_p,
587 MUX_SEL_FSYS1, 16, 1),
588};
589
590struct samsung_gate_clock fsys_gate_clks[] __initdata = {
591 GATE(FSYS_PHYCLK_USBHOST20, "phyclk_usbhost20_phyclock",
592 "mout_phyclk_usbdrd30_phyclock_user",
593 EN_SCLK_FSYS, 1, 0, 0),
594 GATE(FSYS_PHYCLK_USBDRD30, "phyclk_usbdrd30_udrd30_phyclock_g",
595 "mout_phyclk_usbdrd30_phyclock_user",
596 EN_SCLK_FSYS, 7, 0, 0),
597
598 GATE(FSYS_CLK_MMC0, "clk_mmc0", "dout_aclk_fsys_200",
599 EN_IP_FSYS, 6, 0, 0),
600 GATE(FSYS_CLK_MMC1, "clk_mmc1", "dout_aclk_fsys_200",
601 EN_IP_FSYS, 7, 0, 0),
602 GATE(FSYS_CLK_MMC2, "clk_mmc2", "dout_aclk_fsys_200",
603 EN_IP_FSYS, 8, 0, 0),
604 GATE(FSYS_CLK_PDMA, "clk_pdma", "dout_aclk_fsys_200",
605 EN_IP_FSYS, 9, 0, 0),
606 GATE(FSYS_CLK_SROMC, "clk_sromc", "dout_aclk_fsys_200",
607 EN_IP_FSYS, 13, 0, 0),
608 GATE(FSYS_CLK_USBDRD30, "clk_usbdrd30", "dout_aclk_fsys_200",
609 EN_IP_FSYS, 14, 0, 0),
610 GATE(FSYS_CLK_USBHOST20, "clk_usbhost20", "dout_aclk_fsys_200",
611 EN_IP_FSYS, 15, 0, 0),
612 GATE(FSYS_CLK_USBLINK, "clk_usblink", "dout_aclk_fsys_200",
613 EN_IP_FSYS, 18, 0, 0),
614 GATE(FSYS_CLK_TSI, "clk_tsi", "dout_aclk_fsys_200",
615 EN_IP_FSYS, 20, 0, 0),
616
617 GATE(FSYS_CLK_RTIC, "clk_rtic", "dout_aclk_fsys_200",
618 EN_IP_FSYS_SECURE_RTIC, 11, 0, 0),
619 GATE(FSYS_CLK_SMMU_RTIC, "clk_smmu_rtic", "dout_aclk_fsys_200",
620 EN_IP_FSYS_SECURE_SMMU_RTIC, 12, 0, 0),
621};
622
623static void __init exynos5260_clk_fsys_init(struct device_node *np)
624{
625 struct exynos5260_cmu_info cmu = {0};
626
627 cmu.mux_clks = fsys_mux_clks;
628 cmu.nr_mux_clks = ARRAY_SIZE(fsys_mux_clks);
629 cmu.gate_clks = fsys_gate_clks;
630 cmu.nr_gate_clks = ARRAY_SIZE(fsys_gate_clks);
631 cmu.nr_clk_ids = FSYS_NR_CLK;
632 cmu.clk_regs = fsys_clk_regs;
633 cmu.nr_clk_regs = ARRAY_SIZE(fsys_clk_regs);
634
635 exynos5260_cmu_register_one(np, &cmu);
636}
637
638CLK_OF_DECLARE(exynos5260_clk_fsys, "samsung,exynos5260-clock-fsys",
639 exynos5260_clk_fsys_init);
640
641
642/* CMU_G2D */
643
644static unsigned long g2d_clk_regs[] __initdata = {
645 MUX_SEL_G2D,
646 MUX_STAT_G2D,
647 DIV_G2D,
648 EN_ACLK_G2D,
649 EN_ACLK_G2D_SECURE_SSS,
650 EN_ACLK_G2D_SECURE_SLIM_SSS,
651 EN_ACLK_G2D_SECURE_SMMU_SLIM_SSS,
652 EN_ACLK_G2D_SECURE_SMMU_SSS,
653 EN_ACLK_G2D_SECURE_SMMU_MDMA,
654 EN_ACLK_G2D_SECURE_SMMU_G2D,
655 EN_PCLK_G2D,
656 EN_PCLK_G2D_SECURE_SMMU_SLIM_SSS,
657 EN_PCLK_G2D_SECURE_SMMU_SSS,
658 EN_PCLK_G2D_SECURE_SMMU_MDMA,
659 EN_PCLK_G2D_SECURE_SMMU_G2D,
660 EN_IP_G2D,
661 EN_IP_G2D_SECURE_SSS,
662 EN_IP_G2D_SECURE_SLIM_SSS,
663 EN_IP_G2D_SECURE_SMMU_SLIM_SSS,
664 EN_IP_G2D_SECURE_SMMU_SSS,
665 EN_IP_G2D_SECURE_SMMU_MDMA,
666 EN_IP_G2D_SECURE_SMMU_G2D,
667};
668
669PNAME(mout_aclk_g2d_333_user_p) = {"fin_pll", "dout_aclk_g2d_333"};
670
671struct samsung_mux_clock g2d_mux_clks[] __initdata = {
672 MUX(G2D_MOUT_ACLK_G2D_333_USER, "mout_aclk_g2d_333_user",
673 mout_aclk_g2d_333_user_p,
674 MUX_SEL_G2D, 0, 1),
675};
676
677struct samsung_div_clock g2d_div_clks[] __initdata = {
678 DIV(G2D_DOUT_PCLK_G2D_83, "dout_pclk_g2d_83", "mout_aclk_g2d_333_user",
679 DIV_G2D, 0, 3),
680};
681
682struct samsung_gate_clock g2d_gate_clks[] __initdata = {
683 GATE(G2D_CLK_G2D, "clk_g2d", "mout_aclk_g2d_333_user",
684 EN_IP_G2D, 4, 0, 0),
685 GATE(G2D_CLK_JPEG, "clk_jpeg", "mout_aclk_g2d_333_user",
686 EN_IP_G2D, 5, 0, 0),
687 GATE(G2D_CLK_MDMA, "clk_mdma", "mout_aclk_g2d_333_user",
688 EN_IP_G2D, 6, 0, 0),
689 GATE(G2D_CLK_SMMU3_JPEG, "clk_smmu3_jpeg", "mout_aclk_g2d_333_user",
690 EN_IP_G2D, 16, 0, 0),
691
692 GATE(G2D_CLK_SSS, "clk_sss", "mout_aclk_g2d_333_user",
693 EN_IP_G2D_SECURE_SSS, 17, 0, 0),
694
695 GATE(G2D_CLK_SLIM_SSS, "clk_slim_sss", "mout_aclk_g2d_333_user",
696 EN_IP_G2D_SECURE_SLIM_SSS, 11, 0, 0),
697
698 GATE(G2D_CLK_SMMU_SLIM_SSS, "clk_smmu_slim_sss",
699 "mout_aclk_g2d_333_user",
700 EN_IP_G2D_SECURE_SMMU_SLIM_SSS, 13, 0, 0),
701
702 GATE(G2D_CLK_SMMU_SSS, "clk_smmu_sss", "mout_aclk_g2d_333_user",
703 EN_IP_G2D_SECURE_SMMU_SSS, 14, 0, 0),
704
705 GATE(G2D_CLK_SMMU_MDMA, "clk_smmu_mdma", "mout_aclk_g2d_333_user",
706 EN_IP_G2D_SECURE_SMMU_MDMA, 12, 0, 0),
707
708 GATE(G2D_CLK_SMMU3_G2D, "clk_smmu3_g2d", "mout_aclk_g2d_333_user",
709 EN_IP_G2D_SECURE_SMMU_G2D, 15, 0, 0),
710};
711
712static void __init exynos5260_clk_g2d_init(struct device_node *np)
713{
714 struct exynos5260_cmu_info cmu = {0};
715
716 cmu.mux_clks = g2d_mux_clks;
717 cmu.nr_mux_clks = ARRAY_SIZE(g2d_mux_clks);
718 cmu.div_clks = g2d_div_clks;
719 cmu.nr_div_clks = ARRAY_SIZE(g2d_div_clks);
720 cmu.gate_clks = g2d_gate_clks;
721 cmu.nr_gate_clks = ARRAY_SIZE(g2d_gate_clks);
722 cmu.nr_clk_ids = G2D_NR_CLK;
723 cmu.clk_regs = g2d_clk_regs;
724 cmu.nr_clk_regs = ARRAY_SIZE(g2d_clk_regs);
725
726 exynos5260_cmu_register_one(np, &cmu);
727}
728
729CLK_OF_DECLARE(exynos5260_clk_g2d, "samsung,exynos5260-clock-g2d",
730 exynos5260_clk_g2d_init);
731
732
733/* CMU_G3D */
734
735static unsigned long g3d_clk_regs[] __initdata = {
736 G3D_PLL_LOCK,
737 G3D_PLL_CON0,
738 G3D_PLL_CON1,
739 G3D_PLL_FDET,
740 MUX_SEL_G3D,
741 DIV_G3D,
742 DIV_G3D_PLL_FDET,
743 EN_ACLK_G3D,
744 EN_PCLK_G3D,
745 EN_SCLK_G3D,
746 EN_IP_G3D,
747};
748
749PNAME(mout_g3d_pll_p) = {"fin_pll", "fout_g3d_pll"};
750
751struct samsung_mux_clock g3d_mux_clks[] __initdata = {
752 MUX(G3D_MOUT_G3D_PLL, "mout_g3d_pll", mout_g3d_pll_p,
753 MUX_SEL_G3D, 0, 1),
754};
755
756struct samsung_div_clock g3d_div_clks[] __initdata = {
757 DIV(G3D_DOUT_PCLK_G3D, "dout_pclk_g3d", "dout_aclk_g3d", DIV_G3D, 0, 3),
758 DIV(G3D_DOUT_ACLK_G3D, "dout_aclk_g3d", "mout_g3d_pll", DIV_G3D, 4, 3),
759};
760
761struct samsung_gate_clock g3d_gate_clks[] __initdata = {
762 GATE(G3D_CLK_G3D, "clk_g3d", "dout_aclk_g3d", EN_IP_G3D, 2, 0, 0),
763 GATE(G3D_CLK_G3D_HPM, "clk_g3d_hpm", "dout_aclk_g3d",
764 EN_IP_G3D, 3, 0, 0),
765};
766
767static struct samsung_pll_clock g3d_pll_clks[] __initdata = {
768 PLL(pll_2550, G3D_FOUT_G3D_PLL, "fout_g3d_pll", "fin_pll",
769 G3D_PLL_LOCK, G3D_PLL_CON0,
770 pll2550_24mhz_tbl),
771};
772
773static void __init exynos5260_clk_g3d_init(struct device_node *np)
774{
775 struct exynos5260_cmu_info cmu = {0};
776
777 cmu.pll_clks = g3d_pll_clks;
778 cmu.nr_pll_clks = ARRAY_SIZE(g3d_pll_clks);
779 cmu.mux_clks = g3d_mux_clks;
780 cmu.nr_mux_clks = ARRAY_SIZE(g3d_mux_clks);
781 cmu.div_clks = g3d_div_clks;
782 cmu.nr_div_clks = ARRAY_SIZE(g3d_div_clks);
783 cmu.gate_clks = g3d_gate_clks;
784 cmu.nr_gate_clks = ARRAY_SIZE(g3d_gate_clks);
785 cmu.nr_clk_ids = G3D_NR_CLK;
786 cmu.clk_regs = g3d_clk_regs;
787 cmu.nr_clk_regs = ARRAY_SIZE(g3d_clk_regs);
788
789 exynos5260_cmu_register_one(np, &cmu);
790}
791
792CLK_OF_DECLARE(exynos5260_clk_g3d, "samsung,exynos5260-clock-g3d",
793 exynos5260_clk_g3d_init);
794
795
796/* CMU_GSCL */
797
798static unsigned long gscl_clk_regs[] __initdata = {
799 MUX_SEL_GSCL,
800 DIV_GSCL,
801 EN_ACLK_GSCL,
802 EN_ACLK_GSCL_FIMC,
803 EN_ACLK_GSCL_SECURE_SMMU_GSCL0,
804 EN_ACLK_GSCL_SECURE_SMMU_GSCL1,
805 EN_ACLK_GSCL_SECURE_SMMU_MSCL0,
806 EN_ACLK_GSCL_SECURE_SMMU_MSCL1,
807 EN_PCLK_GSCL,
808 EN_PCLK_GSCL_FIMC,
809 EN_PCLK_GSCL_SECURE_SMMU_GSCL0,
810 EN_PCLK_GSCL_SECURE_SMMU_GSCL1,
811 EN_PCLK_GSCL_SECURE_SMMU_MSCL0,
812 EN_PCLK_GSCL_SECURE_SMMU_MSCL1,
813 EN_SCLK_GSCL,
814 EN_SCLK_GSCL_FIMC,
815 EN_IP_GSCL,
816 EN_IP_GSCL_FIMC,
817 EN_IP_GSCL_SECURE_SMMU_GSCL0,
818 EN_IP_GSCL_SECURE_SMMU_GSCL1,
819 EN_IP_GSCL_SECURE_SMMU_MSCL0,
820 EN_IP_GSCL_SECURE_SMMU_MSCL1,
821};
822
823PNAME(mout_aclk_gscl_333_user_p) = {"fin_pll", "dout_aclk_gscl_333"};
824PNAME(mout_aclk_m2m_400_user_p) = {"fin_pll", "dout_aclk_gscl_400"};
825PNAME(mout_aclk_gscl_fimc_user_p) = {"fin_pll", "dout_aclk_gscl_400"};
826PNAME(mout_aclk_csis_p) = {"dout_aclk_csis_200", "mout_aclk_gscl_fimc_user"};
827
828struct samsung_mux_clock gscl_mux_clks[] __initdata = {
829 MUX(GSCL_MOUT_ACLK_GSCL_333_USER, "mout_aclk_gscl_333_user",
830 mout_aclk_gscl_333_user_p,
831 MUX_SEL_GSCL, 0, 1),
832 MUX(GSCL_MOUT_ACLK_M2M_400_USER, "mout_aclk_m2m_400_user",
833 mout_aclk_m2m_400_user_p,
834 MUX_SEL_GSCL, 4, 1),
835 MUX(GSCL_MOUT_ACLK_GSCL_FIMC_USER, "mout_aclk_gscl_fimc_user",
836 mout_aclk_gscl_fimc_user_p,
837 MUX_SEL_GSCL, 8, 1),
838 MUX(GSCL_MOUT_ACLK_CSIS, "mout_aclk_csis", mout_aclk_csis_p,
839 MUX_SEL_GSCL, 24, 1),
840};
841
842struct samsung_div_clock gscl_div_clks[] __initdata = {
843 DIV(GSCL_DOUT_PCLK_M2M_100, "dout_pclk_m2m_100",
844 "mout_aclk_m2m_400_user",
845 DIV_GSCL, 0, 3),
846 DIV(GSCL_DOUT_ACLK_CSIS_200, "dout_aclk_csis_200",
847 "mout_aclk_m2m_400_user",
848 DIV_GSCL, 4, 3),
849};
850
851struct samsung_gate_clock gscl_gate_clks[] __initdata = {
852 GATE(GSCL_SCLK_CSIS0_WRAP, "sclk_csis0_wrap", "dout_aclk_csis_200",
853 EN_SCLK_GSCL_FIMC, 0, CLK_SET_RATE_PARENT, 0),
854 GATE(GSCL_SCLK_CSIS1_WRAP, "sclk_csis1_wrap", "dout_aclk_csis_200",
855 EN_SCLK_GSCL_FIMC, 1, CLK_SET_RATE_PARENT, 0),
856
857 GATE(GSCL_CLK_GSCL0, "clk_gscl0", "mout_aclk_gscl_333_user",
858 EN_IP_GSCL, 2, 0, 0),
859 GATE(GSCL_CLK_GSCL1, "clk_gscl1", "mout_aclk_gscl_333_user",
860 EN_IP_GSCL, 3, 0, 0),
861 GATE(GSCL_CLK_MSCL0, "clk_mscl0", "mout_aclk_gscl_333_user",
862 EN_IP_GSCL, 4, 0, 0),
863 GATE(GSCL_CLK_MSCL1, "clk_mscl1", "mout_aclk_gscl_333_user",
864 EN_IP_GSCL, 5, 0, 0),
865 GATE(GSCL_CLK_PIXEL_GSCL0, "clk_pixel_gscl0",
866 "mout_aclk_gscl_333_user",
867 EN_IP_GSCL, 8, 0, 0),
868 GATE(GSCL_CLK_PIXEL_GSCL1, "clk_pixel_gscl1",
869 "mout_aclk_gscl_333_user",
870 EN_IP_GSCL, 9, 0, 0),
871
872 GATE(GSCL_CLK_SMMU3_LITE_A, "clk_smmu3_lite_a",
873 "mout_aclk_gscl_fimc_user",
874 EN_IP_GSCL_FIMC, 5, 0, 0),
875 GATE(GSCL_CLK_SMMU3_LITE_B, "clk_smmu3_lite_b",
876 "mout_aclk_gscl_fimc_user",
877 EN_IP_GSCL_FIMC, 6, 0, 0),
878 GATE(GSCL_CLK_SMMU3_LITE_D, "clk_smmu3_lite_d",
879 "mout_aclk_gscl_fimc_user",
880 EN_IP_GSCL_FIMC, 7, 0, 0),
881 GATE(GSCL_CLK_CSIS0, "clk_csis0", "mout_aclk_gscl_fimc_user",
882 EN_IP_GSCL_FIMC, 8, 0, 0),
883 GATE(GSCL_CLK_CSIS1, "clk_csis1", "mout_aclk_gscl_fimc_user",
884 EN_IP_GSCL_FIMC, 9, 0, 0),
885 GATE(GSCL_CLK_FIMC_LITE_A, "clk_fimc_lite_a",
886 "mout_aclk_gscl_fimc_user",
887 EN_IP_GSCL_FIMC, 10, 0, 0),
888 GATE(GSCL_CLK_FIMC_LITE_B, "clk_fimc_lite_b",
889 "mout_aclk_gscl_fimc_user",
890 EN_IP_GSCL_FIMC, 11, 0, 0),
891 GATE(GSCL_CLK_FIMC_LITE_D, "clk_fimc_lite_d",
892 "mout_aclk_gscl_fimc_user",
893 EN_IP_GSCL_FIMC, 12, 0, 0),
894
895 GATE(GSCL_CLK_SMMU3_GSCL0, "clk_smmu3_gscl0",
896 "mout_aclk_gscl_333_user",
897 EN_IP_GSCL_SECURE_SMMU_GSCL0, 17, 0, 0),
898 GATE(GSCL_CLK_SMMU3_GSCL1, "clk_smmu3_gscl1", "mout_aclk_gscl_333_user",
899 EN_IP_GSCL_SECURE_SMMU_GSCL1, 18, 0, 0),
900 GATE(GSCL_CLK_SMMU3_MSCL0, "clk_smmu3_mscl0",
901 "mout_aclk_m2m_400_user",
902 EN_IP_GSCL_SECURE_SMMU_MSCL0, 19, 0, 0),
903 GATE(GSCL_CLK_SMMU3_MSCL1, "clk_smmu3_mscl1",
904 "mout_aclk_m2m_400_user",
905 EN_IP_GSCL_SECURE_SMMU_MSCL1, 20, 0, 0),
906};
907
908static void __init exynos5260_clk_gscl_init(struct device_node *np)
909{
910 struct exynos5260_cmu_info cmu = {0};
911
912 cmu.mux_clks = gscl_mux_clks;
913 cmu.nr_mux_clks = ARRAY_SIZE(gscl_mux_clks);
914 cmu.div_clks = gscl_div_clks;
915 cmu.nr_div_clks = ARRAY_SIZE(gscl_div_clks);
916 cmu.gate_clks = gscl_gate_clks;
917 cmu.nr_gate_clks = ARRAY_SIZE(gscl_gate_clks);
918 cmu.nr_clk_ids = GSCL_NR_CLK;
919 cmu.clk_regs = gscl_clk_regs;
920 cmu.nr_clk_regs = ARRAY_SIZE(gscl_clk_regs);
921
922 exynos5260_cmu_register_one(np, &cmu);
923}
924
925CLK_OF_DECLARE(exynos5260_clk_gscl, "samsung,exynos5260-clock-gscl",
926 exynos5260_clk_gscl_init);
927
928
929/* CMU_ISP */
930
931static unsigned long isp_clk_regs[] __initdata = {
932 MUX_SEL_ISP0,
933 MUX_SEL_ISP1,
934 DIV_ISP,
935 EN_ACLK_ISP0,
936 EN_ACLK_ISP1,
937 EN_PCLK_ISP0,
938 EN_PCLK_ISP1,
939 EN_SCLK_ISP,
940 EN_IP_ISP0,
941 EN_IP_ISP1,
942};
943
944PNAME(mout_isp_400_user_p) = {"fin_pll", "dout_aclk_isp1_400"};
945PNAME(mout_isp_266_user_p) = {"fin_pll", "dout_aclk_isp1_266"};
946
947struct samsung_mux_clock isp_mux_clks[] __initdata = {
948 MUX(ISP_MOUT_ISP_266_USER, "mout_isp_266_user", mout_isp_266_user_p,
949 MUX_SEL_ISP0, 0, 1),
950 MUX(ISP_MOUT_ISP_400_USER, "mout_isp_400_user", mout_isp_400_user_p,
951 MUX_SEL_ISP0, 4, 1),
952};
953
954struct samsung_div_clock isp_div_clks[] __initdata = {
955 DIV(ISP_DOUT_PCLK_ISP_66, "dout_pclk_isp_66", "mout_kfc",
956 DIV_ISP, 0, 3),
957 DIV(ISP_DOUT_PCLK_ISP_133, "dout_pclk_isp_133", "mout_kfc",
958 DIV_ISP, 4, 4),
959 DIV(ISP_DOUT_CA5_ATCLKIN, "dout_ca5_atclkin", "mout_kfc",
960 DIV_ISP, 12, 3),
961 DIV(ISP_DOUT_CA5_PCLKDBG, "dout_ca5_pclkdbg", "mout_kfc",
962 DIV_ISP, 16, 4),
963 DIV(ISP_DOUT_SCLK_MPWM, "dout_sclk_mpwm", "mout_kfc", DIV_ISP, 20, 2),
964};
965
966struct samsung_gate_clock isp_gate_clks[] __initdata = {
967 GATE(ISP_CLK_GIC, "clk_isp_gic", "mout_aclk_isp1_266",
968 EN_IP_ISP0, 15, 0, 0),
969
970 GATE(ISP_CLK_CA5, "clk_isp_ca5", "mout_aclk_isp1_266",
971 EN_IP_ISP1, 1, 0, 0),
972 GATE(ISP_CLK_FIMC_DRC, "clk_isp_fimc_drc", "mout_aclk_isp1_266",
973 EN_IP_ISP1, 2, 0, 0),
974 GATE(ISP_CLK_FIMC_FD, "clk_isp_fimc_fd", "mout_aclk_isp1_266",
975 EN_IP_ISP1, 3, 0, 0),
976 GATE(ISP_CLK_FIMC, "clk_isp_fimc", "mout_aclk_isp1_266",
977 EN_IP_ISP1, 4, 0, 0),
978 GATE(ISP_CLK_FIMC_SCALERC, "clk_isp_fimc_scalerc",
979 "mout_aclk_isp1_266",
980 EN_IP_ISP1, 5, 0, 0),
981 GATE(ISP_CLK_FIMC_SCALERP, "clk_isp_fimc_scalerp",
982 "mout_aclk_isp1_266",
983 EN_IP_ISP1, 6, 0, 0),
984 GATE(ISP_CLK_I2C0, "clk_isp_i2c0", "mout_aclk_isp1_266",
985 EN_IP_ISP1, 7, 0, 0),
986 GATE(ISP_CLK_I2C1, "clk_isp_i2c1", "mout_aclk_isp1_266",
987 EN_IP_ISP1, 8, 0, 0),
988 GATE(ISP_CLK_MCUCTL, "clk_isp_mcuctl", "mout_aclk_isp1_266",
989 EN_IP_ISP1, 9, 0, 0),
990 GATE(ISP_CLK_MPWM, "clk_isp_mpwm", "mout_aclk_isp1_266",
991 EN_IP_ISP1, 10, 0, 0),
992 GATE(ISP_CLK_MTCADC, "clk_isp_mtcadc", "mout_aclk_isp1_266",
993 EN_IP_ISP1, 11, 0, 0),
994 GATE(ISP_CLK_PWM, "clk_isp_pwm", "mout_aclk_isp1_266",
995 EN_IP_ISP1, 14, 0, 0),
996 GATE(ISP_CLK_SMMU_DRC, "clk_smmu_drc", "mout_aclk_isp1_266",
997 EN_IP_ISP1, 21, 0, 0),
998 GATE(ISP_CLK_SMMU_FD, "clk_smmu_fd", "mout_aclk_isp1_266",
999 EN_IP_ISP1, 22, 0, 0),
1000 GATE(ISP_CLK_SMMU_ISP, "clk_smmu_isp", "mout_aclk_isp1_266",
1001 EN_IP_ISP1, 23, 0, 0),
1002 GATE(ISP_CLK_SMMU_ISPCX, "clk_smmu_ispcx", "mout_aclk_isp1_266",
1003 EN_IP_ISP1, 24, 0, 0),
1004 GATE(ISP_CLK_SMMU_SCALERC, "clk_isp_smmu_scalerc",
1005 "mout_aclk_isp1_266",
1006 EN_IP_ISP1, 25, 0, 0),
1007 GATE(ISP_CLK_SMMU_SCALERP, "clk_isp_smmu_scalerp",
1008 "mout_aclk_isp1_266",
1009 EN_IP_ISP1, 26, 0, 0),
1010 GATE(ISP_CLK_SPI0, "clk_isp_spi0", "mout_aclk_isp1_266",
1011 EN_IP_ISP1, 27, 0, 0),
1012 GATE(ISP_CLK_SPI1, "clk_isp_spi1", "mout_aclk_isp1_266",
1013 EN_IP_ISP1, 28, 0, 0),
1014 GATE(ISP_CLK_WDT, "clk_isp_wdt", "mout_aclk_isp1_266",
1015 EN_IP_ISP1, 31, 0, 0),
1016 GATE(ISP_CLK_UART, "clk_isp_uart", "mout_aclk_isp1_266",
1017 EN_IP_ISP1, 30, 0, 0),
1018
1019 GATE(ISP_SCLK_UART_EXT, "sclk_isp_uart_ext", "fin_pll",
1020 EN_SCLK_ISP, 7, CLK_SET_RATE_PARENT, 0),
1021 GATE(ISP_SCLK_SPI1_EXT, "sclk_isp_spi1_ext", "fin_pll",
1022 EN_SCLK_ISP, 8, CLK_SET_RATE_PARENT, 0),
1023 GATE(ISP_SCLK_SPI0_EXT, "sclk_isp_spi0_ext", "fin_pll",
1024 EN_SCLK_ISP, 9, CLK_SET_RATE_PARENT, 0),
1025};
1026
1027static void __init exynos5260_clk_isp_init(struct device_node *np)
1028{
1029 struct exynos5260_cmu_info cmu = {0};
1030
1031 cmu.mux_clks = isp_mux_clks;
1032 cmu.nr_mux_clks = ARRAY_SIZE(isp_mux_clks);
1033 cmu.div_clks = isp_div_clks;
1034 cmu.nr_div_clks = ARRAY_SIZE(isp_div_clks);
1035 cmu.gate_clks = isp_gate_clks;
1036 cmu.nr_gate_clks = ARRAY_SIZE(isp_gate_clks);
1037 cmu.nr_clk_ids = ISP_NR_CLK;
1038 cmu.clk_regs = isp_clk_regs;
1039 cmu.nr_clk_regs = ARRAY_SIZE(isp_clk_regs);
1040
1041 exynos5260_cmu_register_one(np, &cmu);
1042}
1043
1044CLK_OF_DECLARE(exynos5260_clk_isp, "samsung,exynos5260-clock-isp",
1045 exynos5260_clk_isp_init);
1046
1047
1048/* CMU_KFC */
1049
1050static unsigned long kfc_clk_regs[] __initdata = {
1051 KFC_PLL_LOCK,
1052 KFC_PLL_CON0,
1053 KFC_PLL_CON1,
1054 KFC_PLL_FDET,
1055 MUX_SEL_KFC0,
1056 MUX_SEL_KFC2,
1057 DIV_KFC,
1058 DIV_KFC_PLL_FDET,
1059 EN_ACLK_KFC,
1060 EN_PCLK_KFC,
1061 EN_SCLK_KFC,
1062 EN_IP_KFC,
1063};
1064
1065PNAME(mout_kfc_pll_p) = {"fin_pll", "fout_kfc_pll"};
1066PNAME(mout_kfc_p) = {"mout_kfc_pll", "dout_media_pll"};
1067
1068struct samsung_mux_clock kfc_mux_clks[] __initdata = {
1069 MUX(KFC_MOUT_KFC_PLL, "mout_kfc_pll", mout_kfc_pll_p,
1070 MUX_SEL_KFC0, 0, 1),
1071 MUX(KFC_MOUT_KFC, "mout_kfc", mout_kfc_p, MUX_SEL_KFC2, 0, 1),
1072};
1073
1074struct samsung_div_clock kfc_div_clks[] __initdata = {
1075 DIV(KFC_DOUT_KFC1, "dout_kfc1", "mout_kfc", DIV_KFC, 0, 3),
1076 DIV(KFC_DOUT_KFC2, "dout_kfc2", "dout_kfc1", DIV_KFC, 4, 3),
1077 DIV(KFC_DOUT_KFC_ATCLK, "dout_kfc_atclk", "dout_kfc2", DIV_KFC, 8, 3),
1078 DIV(KFC_DOUT_KFC_PCLK_DBG, "dout_kfc_pclk_dbg", "dout_kfc2",
1079 DIV_KFC, 12, 3),
1080 DIV(KFC_DOUT_ACLK_KFC, "dout_aclk_kfc", "dout_kfc2", DIV_KFC, 16, 3),
1081 DIV(KFC_DOUT_PCLK_KFC, "dout_pclk_kfc", "dout_kfc2", DIV_KFC, 20, 3),
1082 DIV(KFC_DOUT_KFC_PLL, "dout_kfc_pll", "mout_kfc", DIV_KFC, 24, 3),
1083};
1084
1085static struct samsung_pll_clock kfc_pll_clks[] __initdata = {
1086 PLL(pll_2550xx, KFC_FOUT_KFC_PLL, "fout_kfc_pll", "fin_pll",
1087 KFC_PLL_LOCK, KFC_PLL_CON0,
1088 pll2550_24mhz_tbl),
1089};
1090
1091static void __init exynos5260_clk_kfc_init(struct device_node *np)
1092{
1093 struct exynos5260_cmu_info cmu = {0};
1094
1095 cmu.pll_clks = kfc_pll_clks;
1096 cmu.nr_pll_clks = ARRAY_SIZE(kfc_pll_clks);
1097 cmu.mux_clks = kfc_mux_clks;
1098 cmu.nr_mux_clks = ARRAY_SIZE(kfc_mux_clks);
1099 cmu.div_clks = kfc_div_clks;
1100 cmu.nr_div_clks = ARRAY_SIZE(kfc_div_clks);
1101 cmu.nr_clk_ids = KFC_NR_CLK;
1102 cmu.clk_regs = kfc_clk_regs;
1103 cmu.nr_clk_regs = ARRAY_SIZE(kfc_clk_regs);
1104
1105 exynos5260_cmu_register_one(np, &cmu);
1106}
1107
1108CLK_OF_DECLARE(exynos5260_clk_kfc, "samsung,exynos5260-clock-kfc",
1109 exynos5260_clk_kfc_init);
1110
1111
1112/* CMU_MFC */
1113
1114static unsigned long mfc_clk_regs[] __initdata = {
1115 MUX_SEL_MFC,
1116 DIV_MFC,
1117 EN_ACLK_MFC,
1118 EN_ACLK_SECURE_SMMU2_MFC,
1119 EN_PCLK_MFC,
1120 EN_PCLK_SECURE_SMMU2_MFC,
1121 EN_IP_MFC,
1122 EN_IP_MFC_SECURE_SMMU2_MFC,
1123};
1124
1125PNAME(mout_aclk_mfc_333_user_p) = {"fin_pll", "dout_aclk_mfc_333"};
1126
1127struct samsung_mux_clock mfc_mux_clks[] __initdata = {
1128 MUX(MFC_MOUT_ACLK_MFC_333_USER, "mout_aclk_mfc_333_user",
1129 mout_aclk_mfc_333_user_p,
1130 MUX_SEL_MFC, 0, 1),
1131};
1132
1133struct samsung_div_clock mfc_div_clks[] __initdata = {
1134 DIV(MFC_DOUT_PCLK_MFC_83, "dout_pclk_mfc_83", "mout_aclk_mfc_333_user",
1135 DIV_MFC, 0, 3),
1136};
1137
1138struct samsung_gate_clock mfc_gate_clks[] __initdata = {
1139 GATE(MFC_CLK_MFC, "clk_mfc", "mout_aclk_mfc_333_user",
1140 EN_IP_MFC, 1, 0, 0),
1141 GATE(MFC_CLK_SMMU2_MFCM0, "clk_smmu2_mfcm0", "mout_aclk_mfc_333_user",
1142 EN_IP_MFC_SECURE_SMMU2_MFC, 6, 0, 0),
1143 GATE(MFC_CLK_SMMU2_MFCM1, "clk_smmu2_mfcm1", "mout_aclk_mfc_333_user",
1144 EN_IP_MFC_SECURE_SMMU2_MFC, 7, 0, 0),
1145};
1146
1147static void __init exynos5260_clk_mfc_init(struct device_node *np)
1148{
1149 struct exynos5260_cmu_info cmu = {0};
1150
1151 cmu.mux_clks = mfc_mux_clks;
1152 cmu.nr_mux_clks = ARRAY_SIZE(mfc_mux_clks);
1153 cmu.div_clks = mfc_div_clks;
1154 cmu.nr_div_clks = ARRAY_SIZE(mfc_div_clks);
1155 cmu.gate_clks = mfc_gate_clks;
1156 cmu.nr_gate_clks = ARRAY_SIZE(mfc_gate_clks);
1157 cmu.nr_clk_ids = MFC_NR_CLK;
1158 cmu.clk_regs = mfc_clk_regs;
1159 cmu.nr_clk_regs = ARRAY_SIZE(mfc_clk_regs);
1160
1161 exynos5260_cmu_register_one(np, &cmu);
1162}
1163
1164CLK_OF_DECLARE(exynos5260_clk_mfc, "samsung,exynos5260-clock-mfc",
1165 exynos5260_clk_mfc_init);
1166
1167
1168/* CMU_MIF */
1169
1170static unsigned long mif_clk_regs[] __initdata = {
1171 MEM_PLL_LOCK,
1172 BUS_PLL_LOCK,
1173 MEDIA_PLL_LOCK,
1174 MEM_PLL_CON0,
1175 MEM_PLL_CON1,
1176 MEM_PLL_FDET,
1177 BUS_PLL_CON0,
1178 BUS_PLL_CON1,
1179 BUS_PLL_FDET,
1180 MEDIA_PLL_CON0,
1181 MEDIA_PLL_CON1,
1182 MEDIA_PLL_FDET,
1183 MUX_SEL_MIF,
1184 DIV_MIF,
1185 DIV_MIF_PLL_FDET,
1186 EN_ACLK_MIF,
1187 EN_ACLK_MIF_SECURE_DREX1_TZ,
1188 EN_ACLK_MIF_SECURE_DREX0_TZ,
1189 EN_ACLK_MIF_SECURE_INTMEM,
1190 EN_PCLK_MIF,
1191 EN_PCLK_MIF_SECURE_MONOCNT,
1192 EN_PCLK_MIF_SECURE_RTC_APBIF,
1193 EN_PCLK_MIF_SECURE_DREX1_TZ,
1194 EN_PCLK_MIF_SECURE_DREX0_TZ,
1195 EN_SCLK_MIF,
1196 EN_IP_MIF,
1197 EN_IP_MIF_SECURE_MONOCNT,
1198 EN_IP_MIF_SECURE_RTC_APBIF,
1199 EN_IP_MIF_SECURE_DREX1_TZ,
1200 EN_IP_MIF_SECURE_DREX0_TZ,
1201 EN_IP_MIF_SECURE_INTEMEM,
1202};
1203
1204PNAME(mout_mem_pll_p) = {"fin_pll", "fout_mem_pll"};
1205PNAME(mout_bus_pll_p) = {"fin_pll", "fout_bus_pll"};
1206PNAME(mout_media_pll_p) = {"fin_pll", "fout_media_pll"};
1207PNAME(mout_mif_drex_p) = {"dout_mem_pll", "dout_bus_pll"};
1208PNAME(mout_mif_drex2x_p) = {"dout_mem_pll", "dout_bus_pll"};
1209PNAME(mout_clkm_phy_p) = {"mout_mif_drex", "dout_media_pll"};
1210PNAME(mout_clk2x_phy_p) = {"mout_mif_drex2x", "dout_media_pll"};
1211
1212struct samsung_mux_clock mif_mux_clks[] __initdata = {
1213 MUX(MIF_MOUT_MEM_PLL, "mout_mem_pll", mout_mem_pll_p,
1214 MUX_SEL_MIF, 0, 1),
1215 MUX(MIF_MOUT_BUS_PLL, "mout_bus_pll", mout_bus_pll_p,
1216 MUX_SEL_MIF, 4, 1),
1217 MUX(MIF_MOUT_MEDIA_PLL, "mout_media_pll", mout_media_pll_p,
1218 MUX_SEL_MIF, 8, 1),
1219 MUX(MIF_MOUT_MIF_DREX, "mout_mif_drex", mout_mif_drex_p,
1220 MUX_SEL_MIF, 12, 1),
1221 MUX(MIF_MOUT_CLKM_PHY, "mout_clkm_phy", mout_clkm_phy_p,
1222 MUX_SEL_MIF, 16, 1),
1223 MUX(MIF_MOUT_MIF_DREX2X, "mout_mif_drex2x", mout_mif_drex2x_p,
1224 MUX_SEL_MIF, 20, 1),
1225 MUX(MIF_MOUT_CLK2X_PHY, "mout_clk2x_phy", mout_clk2x_phy_p,
1226 MUX_SEL_MIF, 24, 1),
1227};
1228
1229struct samsung_div_clock mif_div_clks[] __initdata = {
1230 DIV(MIF_DOUT_MEDIA_PLL, "dout_media_pll", "mout_media_pll",
1231 DIV_MIF, 0, 3),
1232 DIV(MIF_DOUT_MEM_PLL, "dout_mem_pll", "mout_mem_pll",
1233 DIV_MIF, 4, 3),
1234 DIV(MIF_DOUT_BUS_PLL, "dout_bus_pll", "mout_bus_pll",
1235 DIV_MIF, 8, 3),
1236 DIV(MIF_DOUT_CLKM_PHY, "dout_clkm_phy", "mout_clkm_phy",
1237 DIV_MIF, 12, 3),
1238 DIV(MIF_DOUT_CLK2X_PHY, "dout_clk2x_phy", "mout_clk2x_phy",
1239 DIV_MIF, 16, 4),
1240 DIV(MIF_DOUT_ACLK_MIF_466, "dout_aclk_mif_466", "dout_clk2x_phy",
1241 DIV_MIF, 20, 3),
1242 DIV(MIF_DOUT_ACLK_BUS_200, "dout_aclk_bus_200", "dout_bus_pll",
1243 DIV_MIF, 24, 3),
1244 DIV(MIF_DOUT_ACLK_BUS_100, "dout_aclk_bus_100", "dout_bus_pll",
1245 DIV_MIF, 28, 4),
1246};
1247
1248struct samsung_gate_clock mif_gate_clks[] __initdata = {
1249 GATE(MIF_CLK_LPDDR3PHY_WRAP0, "clk_lpddr3phy_wrap0", "dout_clk2x_phy",
1250 EN_IP_MIF, 12, CLK_IGNORE_UNUSED, 0),
1251 GATE(MIF_CLK_LPDDR3PHY_WRAP1, "clk_lpddr3phy_wrap1", "dout_clk2x_phy",
1252 EN_IP_MIF, 13, CLK_IGNORE_UNUSED, 0),
1253
1254 GATE(MIF_CLK_MONOCNT, "clk_monocnt", "dout_aclk_bus_100",
1255 EN_IP_MIF_SECURE_MONOCNT, 22,
1256 CLK_IGNORE_UNUSED, 0),
1257
1258 GATE(MIF_CLK_MIF_RTC, "clk_mif_rtc", "dout_aclk_bus_100",
1259 EN_IP_MIF_SECURE_RTC_APBIF, 23,
1260 CLK_IGNORE_UNUSED, 0),
1261
1262 GATE(MIF_CLK_DREX1, "clk_drex1", "dout_aclk_mif_466",
1263 EN_IP_MIF_SECURE_DREX1_TZ, 9,
1264 CLK_IGNORE_UNUSED, 0),
1265
1266 GATE(MIF_CLK_DREX0, "clk_drex0", "dout_aclk_mif_466",
1267 EN_IP_MIF_SECURE_DREX0_TZ, 9,
1268 CLK_IGNORE_UNUSED, 0),
1269
1270 GATE(MIF_CLK_INTMEM, "clk_intmem", "dout_aclk_bus_200",
1271 EN_IP_MIF_SECURE_INTEMEM, 11,
1272 CLK_IGNORE_UNUSED, 0),
1273
1274 GATE(MIF_SCLK_LPDDR3PHY_WRAP_U0, "sclk_lpddr3phy_wrap_u0",
1275 "dout_clkm_phy", EN_SCLK_MIF, 0,
1276 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0),
1277 GATE(MIF_SCLK_LPDDR3PHY_WRAP_U1, "sclk_lpddr3phy_wrap_u1",
1278 "dout_clkm_phy", EN_SCLK_MIF, 1,
1279 CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0),
1280};
1281
1282static struct samsung_pll_clock mif_pll_clks[] __initdata = {
1283 PLL(pll_2550xx, MIF_FOUT_MEM_PLL, "fout_mem_pll", "fin_pll",
1284 MEM_PLL_LOCK, MEM_PLL_CON0,
1285 pll2550_24mhz_tbl),
1286 PLL(pll_2550xx, MIF_FOUT_BUS_PLL, "fout_bus_pll", "fin_pll",
1287 BUS_PLL_LOCK, BUS_PLL_CON0,
1288 pll2550_24mhz_tbl),
1289 PLL(pll_2550xx, MIF_FOUT_MEDIA_PLL, "fout_media_pll", "fin_pll",
1290 MEDIA_PLL_LOCK, MEDIA_PLL_CON0,
1291 pll2550_24mhz_tbl),
1292};
1293
1294static void __init exynos5260_clk_mif_init(struct device_node *np)
1295{
1296 struct exynos5260_cmu_info cmu = {0};
1297
1298 cmu.pll_clks = mif_pll_clks;
1299 cmu.nr_pll_clks = ARRAY_SIZE(mif_pll_clks);
1300 cmu.mux_clks = mif_mux_clks;
1301 cmu.nr_mux_clks = ARRAY_SIZE(mif_mux_clks);
1302 cmu.div_clks = mif_div_clks;
1303 cmu.nr_div_clks = ARRAY_SIZE(mif_div_clks);
1304 cmu.gate_clks = mif_gate_clks;
1305 cmu.nr_gate_clks = ARRAY_SIZE(mif_gate_clks);
1306 cmu.nr_clk_ids = MIF_NR_CLK;
1307 cmu.clk_regs = mif_clk_regs;
1308 cmu.nr_clk_regs = ARRAY_SIZE(mif_clk_regs);
1309
1310 exynos5260_cmu_register_one(np, &cmu);
1311}
1312
1313CLK_OF_DECLARE(exynos5260_clk_mif, "samsung,exynos5260-clock-mif",
1314 exynos5260_clk_mif_init);
1315
1316
1317/* CMU_PERI */
1318
1319static unsigned long peri_clk_regs[] __initdata = {
1320 MUX_SEL_PERI,
1321 MUX_SEL_PERI1,
1322 DIV_PERI,
1323 EN_PCLK_PERI0,
1324 EN_PCLK_PERI1,
1325 EN_PCLK_PERI2,
1326 EN_PCLK_PERI3,
1327 EN_PCLK_PERI_SECURE_CHIPID,
1328 EN_PCLK_PERI_SECURE_PROVKEY0,
1329 EN_PCLK_PERI_SECURE_PROVKEY1,
1330 EN_PCLK_PERI_SECURE_SECKEY,
1331 EN_PCLK_PERI_SECURE_ANTIRBKCNT,
1332 EN_PCLK_PERI_SECURE_TOP_RTC,
1333 EN_PCLK_PERI_SECURE_TZPC,
1334 EN_SCLK_PERI,
1335 EN_SCLK_PERI_SECURE_TOP_RTC,
1336 EN_IP_PERI0,
1337 EN_IP_PERI1,
1338 EN_IP_PERI2,
1339 EN_IP_PERI_SECURE_CHIPID,
1340 EN_IP_PERI_SECURE_PROVKEY0,
1341 EN_IP_PERI_SECURE_PROVKEY1,
1342 EN_IP_PERI_SECURE_SECKEY,
1343 EN_IP_PERI_SECURE_ANTIRBKCNT,
1344 EN_IP_PERI_SECURE_TOP_RTC,
1345 EN_IP_PERI_SECURE_TZPC,
1346};
1347
1348PNAME(mout_sclk_pcm_p) = {"ioclk_pcm_extclk", "fin_pll", "dout_aclk_peri_aud",
1349 "phyclk_hdmi_phy_ref_cko"};
1350PNAME(mout_sclk_i2scod_p) = {"ioclk_i2s_cdclk", "fin_pll", "dout_aclk_peri_aud",
1351 "phyclk_hdmi_phy_ref_cko"};
1352PNAME(mout_sclk_spdif_p) = {"ioclk_spdif_extclk", "fin_pll",
1353 "dout_aclk_peri_aud", "phyclk_hdmi_phy_ref_cko"};
1354
1355struct samsung_mux_clock peri_mux_clks[] __initdata = {
1356 MUX(PERI_MOUT_SCLK_PCM, "mout_sclk_pcm", mout_sclk_pcm_p,
1357 MUX_SEL_PERI1, 4, 2),
1358 MUX(PERI_MOUT_SCLK_I2SCOD, "mout_sclk_i2scod", mout_sclk_i2scod_p,
1359 MUX_SEL_PERI1, 12, 2),
1360 MUX(PERI_MOUT_SCLK_SPDIF, "mout_sclk_spdif", mout_sclk_spdif_p,
1361 MUX_SEL_PERI1, 20, 2),
1362};
1363
1364struct samsung_div_clock peri_div_clks[] __initdata = {
1365 DIV(PERI_DOUT_PCM, "dout_pcm", "mout_sclk_pcm", DIV_PERI, 0, 8),
1366 DIV(PERI_DOUT_I2S, "dout_i2s", "mout_sclk_i2scod", DIV_PERI, 8, 6),
1367};
1368
1369struct samsung_gate_clock peri_gate_clks[] __initdata = {
1370 GATE(PERI_SCLK_PCM1, "sclk_pcm1", "dout_pcm", EN_SCLK_PERI, 0,
1371 CLK_SET_RATE_PARENT, 0),
1372 GATE(PERI_SCLK_I2S, "sclk_i2s", "dout_i2s", EN_SCLK_PERI, 1,
1373 CLK_SET_RATE_PARENT, 0),
1374 GATE(PERI_SCLK_SPDIF, "sclk_spdif", "dout_sclk_peri_spi0_b",
1375 EN_SCLK_PERI, 2, CLK_SET_RATE_PARENT, 0),
1376 GATE(PERI_SCLK_SPI0, "sclk_spi0", "dout_sclk_peri_spi0_b",
1377 EN_SCLK_PERI, 7, CLK_SET_RATE_PARENT, 0),
1378 GATE(PERI_SCLK_SPI1, "sclk_spi1", "dout_sclk_peri_spi1_b",
1379 EN_SCLK_PERI, 8, CLK_SET_RATE_PARENT, 0),
1380 GATE(PERI_SCLK_SPI2, "sclk_spi2", "dout_sclk_peri_spi2_b",
1381 EN_SCLK_PERI, 9, CLK_SET_RATE_PARENT, 0),
1382 GATE(PERI_SCLK_UART0, "sclk_uart0", "dout_sclk_peri_uart0",
1383 EN_SCLK_PERI, 10, CLK_SET_RATE_PARENT, 0),
1384 GATE(PERI_SCLK_UART1, "sclk_uart1", "dout_sclk_peri_uart1",
1385 EN_SCLK_PERI, 11, CLK_SET_RATE_PARENT, 0),
1386 GATE(PERI_SCLK_UART2, "sclk_uart2", "dout_sclk_peri_uart2",
1387 EN_SCLK_PERI, 12, CLK_SET_RATE_PARENT, 0),
1388
1389 GATE(PERI_CLK_ABB, "clk_abb", "dout_aclk_peri_66",
1390 EN_IP_PERI0, 1, 0, 0),
1391 GATE(PERI_CLK_EFUSE_WRITER, "clk_efuse_writer", "dout_aclk_peri_66",
1392 EN_IP_PERI0, 5, 0, 0),
1393 GATE(PERI_CLK_HDMICEC, "clk_hdmicec", "dout_aclk_peri_66",
1394 EN_IP_PERI0, 6, 0, 0),
1395 GATE(PERI_CLK_I2C10, "clk_i2c10", "dout_aclk_peri_66",
1396 EN_IP_PERI0, 7, 0, 0),
1397 GATE(PERI_CLK_I2C11, "clk_i2c11", "dout_aclk_peri_66",
1398 EN_IP_PERI0, 8, 0, 0),
1399 GATE(PERI_CLK_I2C8, "clk_i2c8", "dout_aclk_peri_66",
1400 EN_IP_PERI0, 9, 0, 0),
1401 GATE(PERI_CLK_I2C9, "clk_i2c9", "dout_aclk_peri_66",
1402 EN_IP_PERI0, 10, 0, 0),
1403 GATE(PERI_CLK_I2C4, "clk_i2c4", "dout_aclk_peri_66",
1404 EN_IP_PERI0, 11, 0, 0),
1405 GATE(PERI_CLK_I2C5, "clk_i2c5", "dout_aclk_peri_66",
1406 EN_IP_PERI0, 12, 0, 0),
1407 GATE(PERI_CLK_I2C6, "clk_i2c6", "dout_aclk_peri_66",
1408 EN_IP_PERI0, 13, 0, 0),
1409 GATE(PERI_CLK_I2C7, "clk_i2c7", "dout_aclk_peri_66",
1410 EN_IP_PERI0, 14, 0, 0),
1411 GATE(PERI_CLK_I2CHDMI, "clk_i2chdmi", "dout_aclk_peri_66",
1412 EN_IP_PERI0, 15, 0, 0),
1413 GATE(PERI_CLK_I2S, "clk_peri_i2s", "dout_aclk_peri_66",
1414 EN_IP_PERI0, 16, 0, 0),
1415 GATE(PERI_CLK_MCT, "clk_mct", "dout_aclk_peri_66",
1416 EN_IP_PERI0, 17, 0, 0),
1417 GATE(PERI_CLK_PCM, "clk_peri_pcm", "dout_aclk_peri_66",
1418 EN_IP_PERI0, 18, 0, 0),
1419 GATE(PERI_CLK_HSIC0, "clk_hsic0", "dout_aclk_peri_66",
1420 EN_IP_PERI0, 20, 0, 0),
1421 GATE(PERI_CLK_HSIC1, "clk_hsic1", "dout_aclk_peri_66",
1422 EN_IP_PERI0, 21, 0, 0),
1423 GATE(PERI_CLK_HSIC2, "clk_hsic2", "dout_aclk_peri_66",
1424 EN_IP_PERI0, 22, 0, 0),
1425 GATE(PERI_CLK_HSIC3, "clk_hsic3", "dout_aclk_peri_66",
1426 EN_IP_PERI0, 23, 0, 0),
1427 GATE(PERI_CLK_WDT_EGL, "clk_wdt_egl", "dout_aclk_peri_66",
1428 EN_IP_PERI0, 24, 0, 0),
1429 GATE(PERI_CLK_WDT_KFC, "clk_wdt_kfc", "dout_aclk_peri_66",
1430 EN_IP_PERI0, 25, 0, 0),
1431
1432 GATE(PERI_CLK_UART4, "clk_uart4", "dout_aclk_peri_66",
1433 EN_IP_PERI2, 0, 0, 0),
1434 GATE(PERI_CLK_PWM, "clk_pwm", "dout_aclk_peri_66",
1435 EN_IP_PERI2, 3, 0, 0),
1436 GATE(PERI_CLK_SPDIF, "clk_spdif", "dout_aclk_peri_66",
1437 EN_IP_PERI2, 6, 0, 0),
1438 GATE(PERI_CLK_SPI0, "clk_spi0", "dout_aclk_peri_66",
1439 EN_IP_PERI2, 7, 0, 0),
1440 GATE(PERI_CLK_SPI1, "clk_spi1", "dout_aclk_peri_66",
1441 EN_IP_PERI2, 8, 0, 0),
1442 GATE(PERI_CLK_SPI2, "clk_spi2", "dout_aclk_peri_66",
1443 EN_IP_PERI2, 9, 0, 0),
1444 GATE(PERI_CLK_TMU0, "clk_tmu0", "dout_aclk_peri_66",
1445 EN_IP_PERI2, 10, 0, 0),
1446 GATE(PERI_CLK_TMU1, "clk_tmu1", "dout_aclk_peri_66",
1447 EN_IP_PERI2, 11, 0, 0),
1448 GATE(PERI_CLK_TMU2, "clk_tmu2", "dout_aclk_peri_66",
1449 EN_IP_PERI2, 12, 0, 0),
1450 GATE(PERI_CLK_TMU3, "clk_tmu3", "dout_aclk_peri_66",
1451 EN_IP_PERI2, 13, 0, 0),
1452 GATE(PERI_CLK_TMU4, "clk_tmu4", "dout_aclk_peri_66",
1453 EN_IP_PERI2, 14, 0, 0),
1454 GATE(PERI_CLK_ADC, "clk_adc", "dout_aclk_peri_66",
1455 EN_IP_PERI2, 18, 0, 0),
1456 GATE(PERI_CLK_UART0, "clk_uart0", "dout_aclk_peri_66",
1457 EN_IP_PERI2, 19, 0, 0),
1458 GATE(PERI_CLK_UART1, "clk_uart1", "dout_aclk_peri_66",
1459 EN_IP_PERI2, 20, 0, 0),
1460 GATE(PERI_CLK_UART2, "clk_uart2", "dout_aclk_peri_66",
1461 EN_IP_PERI2, 21, 0, 0),
1462
1463 GATE(PERI_CLK_CHIPID, "clk_chipid", "dout_aclk_peri_66",
1464 EN_IP_PERI_SECURE_CHIPID, 2, 0, 0),
1465
1466 GATE(PERI_CLK_PROVKEY0, "clk_provkey0", "dout_aclk_peri_66",
1467 EN_IP_PERI_SECURE_PROVKEY0, 1, 0, 0),
1468
1469 GATE(PERI_CLK_PROVKEY1, "clk_provkey1", "dout_aclk_peri_66",
1470 EN_IP_PERI_SECURE_PROVKEY1, 2, 0, 0),
1471
1472 GATE(PERI_CLK_SECKEY, "clk_seckey", "dout_aclk_peri_66",
1473 EN_IP_PERI_SECURE_SECKEY, 5, 0, 0),
1474
1475 GATE(PERI_CLK_TOP_RTC, "clk_top_rtc", "dout_aclk_peri_66",
1476 EN_IP_PERI_SECURE_TOP_RTC, 5, 0, 0),
1477
1478 GATE(PERI_CLK_TZPC0, "clk_tzpc0", "dout_aclk_peri_66",
1479 EN_IP_PERI_SECURE_TZPC, 10, 0, 0),
1480 GATE(PERI_CLK_TZPC1, "clk_tzpc1", "dout_aclk_peri_66",
1481 EN_IP_PERI_SECURE_TZPC, 11, 0, 0),
1482 GATE(PERI_CLK_TZPC2, "clk_tzpc2", "dout_aclk_peri_66",
1483 EN_IP_PERI_SECURE_TZPC, 12, 0, 0),
1484 GATE(PERI_CLK_TZPC3, "clk_tzpc3", "dout_aclk_peri_66",
1485 EN_IP_PERI_SECURE_TZPC, 13, 0, 0),
1486 GATE(PERI_CLK_TZPC4, "clk_tzpc4", "dout_aclk_peri_66",
1487 EN_IP_PERI_SECURE_TZPC, 14, 0, 0),
1488 GATE(PERI_CLK_TZPC5, "clk_tzpc5", "dout_aclk_peri_66",
1489 EN_IP_PERI_SECURE_TZPC, 15, 0, 0),
1490 GATE(PERI_CLK_TZPC6, "clk_tzpc6", "dout_aclk_peri_66",
1491 EN_IP_PERI_SECURE_TZPC, 16, 0, 0),
1492 GATE(PERI_CLK_TZPC7, "clk_tzpc7", "dout_aclk_peri_66",
1493 EN_IP_PERI_SECURE_TZPC, 17, 0, 0),
1494 GATE(PERI_CLK_TZPC8, "clk_tzpc8", "dout_aclk_peri_66",
1495 EN_IP_PERI_SECURE_TZPC, 18, 0, 0),
1496 GATE(PERI_CLK_TZPC9, "clk_tzpc9", "dout_aclk_peri_66",
1497 EN_IP_PERI_SECURE_TZPC, 19, 0, 0),
1498 GATE(PERI_CLK_TZPC10, "clk_tzpc10", "dout_aclk_peri_66",
1499 EN_IP_PERI_SECURE_TZPC, 20, 0, 0),
1500};
1501
1502static void __init exynos5260_clk_peri_init(struct device_node *np)
1503{
1504 struct exynos5260_cmu_info cmu = {0};
1505
1506 cmu.mux_clks = peri_mux_clks;
1507 cmu.nr_mux_clks = ARRAY_SIZE(peri_mux_clks);
1508 cmu.div_clks = peri_div_clks;
1509 cmu.nr_div_clks = ARRAY_SIZE(peri_div_clks);
1510 cmu.gate_clks = peri_gate_clks;
1511 cmu.nr_gate_clks = ARRAY_SIZE(peri_gate_clks);
1512 cmu.nr_clk_ids = PERI_NR_CLK;
1513 cmu.clk_regs = peri_clk_regs;
1514 cmu.nr_clk_regs = ARRAY_SIZE(peri_clk_regs);
1515
1516 exynos5260_cmu_register_one(np, &cmu);
1517}
1518
1519CLK_OF_DECLARE(exynos5260_clk_peri, "samsung,exynos5260-clock-peri",
1520 exynos5260_clk_peri_init);
1521
1522
1523/* CMU_TOP */
1524
1525static unsigned long top_clk_regs[] __initdata = {
1526 DISP_PLL_LOCK,
1527 AUD_PLL_LOCK,
1528 DISP_PLL_CON0,
1529 DISP_PLL_CON1,
1530 DISP_PLL_FDET,
1531 AUD_PLL_CON0,
1532 AUD_PLL_CON1,
1533 AUD_PLL_CON2,
1534 AUD_PLL_FDET,
1535 MUX_SEL_TOP_PLL0,
1536 MUX_SEL_TOP_MFC,
1537 MUX_SEL_TOP_G2D,
1538 MUX_SEL_TOP_GSCL,
1539 MUX_SEL_TOP_ISP10,
1540 MUX_SEL_TOP_ISP11,
1541 MUX_SEL_TOP_DISP0,
1542 MUX_SEL_TOP_DISP1,
1543 MUX_SEL_TOP_BUS,
1544 MUX_SEL_TOP_PERI0,
1545 MUX_SEL_TOP_PERI1,
1546 MUX_SEL_TOP_FSYS,
1547 DIV_TOP_G2D_MFC,
1548 DIV_TOP_GSCL_ISP0,
1549 DIV_TOP_ISP10,
1550 DIV_TOP_ISP11,
1551 DIV_TOP_DISP,
1552 DIV_TOP_BUS,
1553 DIV_TOP_PERI0,
1554 DIV_TOP_PERI1,
1555 DIV_TOP_PERI2,
1556 DIV_TOP_FSYS0,
1557 DIV_TOP_FSYS1,
1558 DIV_TOP_HPM,
1559 DIV_TOP_PLL_FDET,
1560 EN_ACLK_TOP,
1561 EN_SCLK_TOP,
1562 EN_IP_TOP,
1563};
1564
1565/* fixed rate clocks generated inside the soc */
1566struct samsung_fixed_rate_clock fixed_rate_clks[] __initdata = {
1567 FRATE(PHYCLK_DPTX_PHY_CH3_TXD_CLK, "phyclk_dptx_phy_ch3_txd_clk", NULL,
1568 CLK_IS_ROOT, 270000000),
1569 FRATE(PHYCLK_DPTX_PHY_CH2_TXD_CLK, "phyclk_dptx_phy_ch2_txd_clk", NULL,
1570 CLK_IS_ROOT, 270000000),
1571 FRATE(PHYCLK_DPTX_PHY_CH1_TXD_CLK, "phyclk_dptx_phy_ch1_txd_clk", NULL,
1572 CLK_IS_ROOT, 270000000),
1573 FRATE(PHYCLK_DPTX_PHY_CH0_TXD_CLK, "phyclk_dptx_phy_ch0_txd_clk", NULL,
1574 CLK_IS_ROOT, 270000000),
1575 FRATE(phyclk_hdmi_phy_tmds_clko, "phyclk_hdmi_phy_tmds_clko", NULL,
1576 CLK_IS_ROOT, 250000000),
1577 FRATE(PHYCLK_HDMI_PHY_PIXEL_CLKO, "phyclk_hdmi_phy_pixel_clko", NULL,
1578 CLK_IS_ROOT, 1660000000),
1579 FRATE(PHYCLK_HDMI_LINK_O_TMDS_CLKHI, "phyclk_hdmi_link_o_tmds_clkhi",
1580 NULL, CLK_IS_ROOT, 125000000),
1581 FRATE(PHYCLK_MIPI_DPHY_4L_M_TXBYTECLKHS,
1582 "phyclk_mipi_dphy_4l_m_txbyteclkhs" , NULL,
1583 CLK_IS_ROOT, 187500000),
1584 FRATE(PHYCLK_DPTX_PHY_O_REF_CLK_24M, "phyclk_dptx_phy_o_ref_clk_24m",
1585 NULL, CLK_IS_ROOT, 24000000),
1586 FRATE(PHYCLK_DPTX_PHY_CLK_DIV2, "phyclk_dptx_phy_clk_div2", NULL,
1587 CLK_IS_ROOT, 135000000),
1588 FRATE(PHYCLK_MIPI_DPHY_4L_M_RXCLKESC0,
1589 "phyclk_mipi_dphy_4l_m_rxclkesc0", NULL,
1590 CLK_IS_ROOT, 20000000),
1591 FRATE(PHYCLK_USBHOST20_PHY_PHYCLOCK, "phyclk_usbhost20_phy_phyclock",
1592 NULL, CLK_IS_ROOT, 60000000),
1593 FRATE(PHYCLK_USBHOST20_PHY_FREECLK, "phyclk_usbhost20_phy_freeclk",
1594 NULL, CLK_IS_ROOT, 60000000),
1595 FRATE(PHYCLK_USBHOST20_PHY_CLK48MOHCI,
1596 "phyclk_usbhost20_phy_clk48mohci",
1597 NULL, CLK_IS_ROOT, 48000000),
1598 FRATE(PHYCLK_USBDRD30_UDRD30_PIPE_PCLK,
1599 "phyclk_usbdrd30_udrd30_pipe_pclk", NULL,
1600 CLK_IS_ROOT, 125000000),
1601 FRATE(PHYCLK_USBDRD30_UDRD30_PHYCLOCK,
1602 "phyclk_usbdrd30_udrd30_phyclock", NULL,
1603 CLK_IS_ROOT, 60000000),
1604};
1605
1606PNAME(mout_memtop_pll_user_p) = {"fin_pll", "dout_mem_pll"};
1607PNAME(mout_bustop_pll_user_p) = {"fin_pll", "dout_bus_pll"};
1608PNAME(mout_mediatop_pll_user_p) = {"fin_pll", "dout_media_pll"};
1609PNAME(mout_audtop_pll_user_p) = {"fin_pll", "mout_aud_pll"};
1610PNAME(mout_aud_pll_p) = {"fin_pll", "fout_aud_pll"};
1611PNAME(mout_disp_pll_p) = {"fin_pll", "fout_disp_pll"};
1612PNAME(mout_mfc_bustop_333_p) = {"mout_bustop_pll_user", "mout_disp_pll"};
1613PNAME(mout_aclk_mfc_333_p) = {"mout_mediatop_pll_user", "mout_mfc_bustop_333"};
1614PNAME(mout_g2d_bustop_333_p) = {"mout_bustop_pll_user", "mout_disp_pll"};
1615PNAME(mout_aclk_g2d_333_p) = {"mout_mediatop_pll_user", "mout_g2d_bustop_333"};
1616PNAME(mout_gscl_bustop_333_p) = {"mout_bustop_pll_user", "mout_disp_pll"};
1617PNAME(mout_aclk_gscl_333_p) = {"mout_mediatop_pll_user",
1618 "mout_gscl_bustop_333"};
1619PNAME(mout_m2m_mediatop_400_p) = {"mout_mediatop_pll_user", "mout_disp_pll"};
1620PNAME(mout_aclk_gscl_400_p) = {"mout_bustop_pll_user",
1621 "mout_m2m_mediatop_400"};
1622PNAME(mout_gscl_bustop_fimc_p) = {"mout_bustop_pll_user", "mout_disp_pll"};
1623PNAME(mout_aclk_gscl_fimc_p) = {"mout_mediatop_pll_user",
1624 "mout_gscl_bustop_fimc"};
1625PNAME(mout_isp1_media_266_p) = {"mout_mediatop_pll_user",
1626 "mout_memtop_pll_user"};
1627PNAME(mout_aclk_isp1_266_p) = {"mout_bustop_pll_user", "mout_isp1_media_266"};
1628PNAME(mout_isp1_media_400_p) = {"mout_mediatop_pll_user", "mout_disp_pll"};
1629PNAME(mout_aclk_isp1_400_p) = {"mout_bustop_pll_user", "mout_isp1_media_400"};
1630PNAME(mout_sclk_isp_spi_p) = {"fin_pll", "mout_bustop_pll_user"};
1631PNAME(mout_sclk_isp_uart_p) = {"fin_pll", "mout_bustop_pll_user"};
1632PNAME(mout_sclk_isp_sensor_p) = {"fin_pll", "mout_bustop_pll_user"};
1633PNAME(mout_disp_disp_333_p) = {"mout_disp_pll", "mout_bustop_pll_user"};
1634PNAME(mout_aclk_disp_333_p) = {"mout_mediatop_pll_user", "mout_disp_disp_333"};
1635PNAME(mout_disp_disp_222_p) = {"mout_disp_pll", "mout_bustop_pll_user"};
1636PNAME(mout_aclk_disp_222_p) = {"mout_mediatop_pll_user", "mout_disp_disp_222"};
1637PNAME(mout_disp_media_pixel_p) = {"mout_mediatop_pll_user",
1638 "mout_bustop_pll_user"};
1639PNAME(mout_sclk_disp_pixel_p) = {"mout_disp_pll", "mout_disp_media_pixel"};
1640PNAME(mout_bus_bustop_400_p) = {"mout_bustop_pll_user", "mout_memtop_pll_user"};
1641PNAME(mout_bus_bustop_100_p) = {"mout_bustop_pll_user", "mout_memtop_pll_user"};
1642PNAME(mout_sclk_peri_spi_clk_p) = {"fin_pll", "mout_bustop_pll_user"};
1643PNAME(mout_sclk_peri_uart_uclk_p) = {"fin_pll", "mout_bustop_pll_user"};
1644PNAME(mout_sclk_fsys_usb_p) = {"fin_pll", "mout_bustop_pll_user"};
1645PNAME(mout_sclk_fsys_mmc_sdclkin_a_p) = {"fin_pll", "mout_bustop_pll_user"};
1646PNAME(mout_sclk_fsys_mmc0_sdclkin_b_p) = {"mout_sclk_fsys_mmc0_sdclkin_a",
1647 "mout_mediatop_pll_user"};
1648PNAME(mout_sclk_fsys_mmc1_sdclkin_b_p) = {"mout_sclk_fsys_mmc1_sdclkin_a",
1649 "mout_mediatop_pll_user"};
1650PNAME(mout_sclk_fsys_mmc2_sdclkin_b_p) = {"mout_sclk_fsys_mmc2_sdclkin_a",
1651 "mout_mediatop_pll_user"};
1652
1653struct samsung_mux_clock top_mux_clks[] __initdata = {
1654 MUX(TOP_MOUT_MEDIATOP_PLL_USER, "mout_mediatop_pll_user",
1655 mout_mediatop_pll_user_p,
1656 MUX_SEL_TOP_PLL0, 0, 1),
1657 MUX(TOP_MOUT_MEMTOP_PLL_USER, "mout_memtop_pll_user",
1658 mout_memtop_pll_user_p,
1659 MUX_SEL_TOP_PLL0, 4, 1),
1660 MUX(TOP_MOUT_BUSTOP_PLL_USER, "mout_bustop_pll_user",
1661 mout_bustop_pll_user_p,
1662 MUX_SEL_TOP_PLL0, 8, 1),
1663 MUX(TOP_MOUT_DISP_PLL, "mout_disp_pll", mout_disp_pll_p,
1664 MUX_SEL_TOP_PLL0, 12, 1),
1665 MUX(TOP_MOUT_AUD_PLL, "mout_aud_pll", mout_aud_pll_p,
1666 MUX_SEL_TOP_PLL0, 16, 1),
1667 MUX(TOP_MOUT_AUDTOP_PLL_USER, "mout_audtop_pll_user",
1668 mout_audtop_pll_user_p,
1669 MUX_SEL_TOP_PLL0, 24, 1),
1670
1671 MUX(TOP_MOUT_DISP_DISP_333, "mout_disp_disp_333", mout_disp_disp_333_p,
1672 MUX_SEL_TOP_DISP0, 0, 1),
1673 MUX(TOP_MOUT_ACLK_DISP_333, "mout_aclk_disp_333", mout_aclk_disp_333_p,
1674 MUX_SEL_TOP_DISP0, 8, 1),
1675 MUX(TOP_MOUT_DISP_DISP_222, "mout_disp_disp_222", mout_disp_disp_222_p,
1676 MUX_SEL_TOP_DISP0, 12, 1),
1677 MUX(TOP_MOUT_ACLK_DISP_222, "mout_aclk_disp_222", mout_aclk_disp_222_p,
1678 MUX_SEL_TOP_DISP0, 20, 1),
1679
1680 MUX(TOP_MOUT_FIMD1, "mout_sclk_disp_pixel", mout_sclk_disp_pixel_p,
1681 MUX_SEL_TOP_DISP1, 0, 1),
1682 MUX(TOP_MOUT_DISP_MEDIA_PIXEL, "mout_disp_media_pixel",
1683 mout_disp_media_pixel_p,
1684 MUX_SEL_TOP_DISP1, 8, 1),
1685
1686 MUX(TOP_MOUT_SCLK_PERI_SPI2_CLK, "mout_sclk_peri_spi2_clk",
1687 mout_sclk_peri_spi_clk_p,
1688 MUX_SEL_TOP_PERI1, 0, 1),
1689 MUX(TOP_MOUT_SCLK_PERI_SPI1_CLK, "mout_sclk_peri_spi1_clk",
1690 mout_sclk_peri_spi_clk_p,
1691 MUX_SEL_TOP_PERI1, 4, 1),
1692 MUX(TOP_MOUT_SCLK_PERI_SPI0_CLK, "mout_sclk_peri_spi0_clk",
1693 mout_sclk_peri_spi_clk_p,
1694 MUX_SEL_TOP_PERI1, 8, 1),
1695 MUX(TOP_MOUT_SCLK_PERI_UART1_UCLK, "mout_sclk_peri_uart1_uclk",
1696 mout_sclk_peri_uart_uclk_p,
1697 MUX_SEL_TOP_PERI1, 12, 1),
1698 MUX(TOP_MOUT_SCLK_PERI_UART2_UCLK, "mout_sclk_peri_uart2_uclk",
1699 mout_sclk_peri_uart_uclk_p,
1700 MUX_SEL_TOP_PERI1, 16, 1),
1701 MUX(TOP_MOUT_SCLK_PERI_UART0_UCLK, "mout_sclk_peri_uart0_uclk",
1702 mout_sclk_peri_uart_uclk_p,
1703 MUX_SEL_TOP_PERI1, 20, 1),
1704
1705
1706 MUX(TOP_MOUT_BUS1_BUSTOP_400, "mout_bus1_bustop_400",
1707 mout_bus_bustop_400_p,
1708 MUX_SEL_TOP_BUS, 0, 1),
1709 MUX(TOP_MOUT_BUS1_BUSTOP_100, "mout_bus1_bustop_100",
1710 mout_bus_bustop_100_p,
1711 MUX_SEL_TOP_BUS, 4, 1),
1712 MUX(TOP_MOUT_BUS2_BUSTOP_100, "mout_bus2_bustop_100",
1713 mout_bus_bustop_100_p,
1714 MUX_SEL_TOP_BUS, 8, 1),
1715 MUX(TOP_MOUT_BUS2_BUSTOP_400, "mout_bus2_bustop_400",
1716 mout_bus_bustop_400_p,
1717 MUX_SEL_TOP_BUS, 12, 1),
1718 MUX(TOP_MOUT_BUS3_BUSTOP_400, "mout_bus3_bustop_400",
1719 mout_bus_bustop_400_p,
1720 MUX_SEL_TOP_BUS, 16, 1),
1721 MUX(TOP_MOUT_BUS3_BUSTOP_100, "mout_bus3_bustop_100",
1722 mout_bus_bustop_100_p,
1723 MUX_SEL_TOP_BUS, 20, 1),
1724 MUX(TOP_MOUT_BUS4_BUSTOP_400, "mout_bus4_bustop_400",
1725 mout_bus_bustop_400_p,
1726 MUX_SEL_TOP_BUS, 24, 1),
1727 MUX(TOP_MOUT_BUS4_BUSTOP_100, "mout_bus4_bustop_100",
1728 mout_bus_bustop_100_p,
1729 MUX_SEL_TOP_BUS, 28, 1),
1730
1731 MUX(TOP_MOUT_SCLK_FSYS_USB, "mout_sclk_fsys_usb",
1732 mout_sclk_fsys_usb_p,
1733 MUX_SEL_TOP_FSYS, 0, 1),
1734 MUX(TOP_MOUT_SCLK_FSYS_MMC2_SDCLKIN_A, "mout_sclk_fsys_mmc2_sdclkin_a",
1735 mout_sclk_fsys_mmc_sdclkin_a_p,
1736 MUX_SEL_TOP_FSYS, 4, 1),
1737 MUX(TOP_MOUT_SCLK_FSYS_MMC2_SDCLKIN_B, "mout_sclk_fsys_mmc2_sdclkin_b",
1738 mout_sclk_fsys_mmc2_sdclkin_b_p,
1739 MUX_SEL_TOP_FSYS, 8, 1),
1740 MUX(TOP_MOUT_SCLK_FSYS_MMC1_SDCLKIN_A, "mout_sclk_fsys_mmc1_sdclkin_a",
1741 mout_sclk_fsys_mmc_sdclkin_a_p,
1742 MUX_SEL_TOP_FSYS, 12, 1),
1743 MUX(TOP_MOUT_SCLK_FSYS_MMC1_SDCLKIN_B, "mout_sclk_fsys_mmc1_sdclkin_b",
1744 mout_sclk_fsys_mmc1_sdclkin_b_p,
1745 MUX_SEL_TOP_FSYS, 16, 1),
1746 MUX(TOP_MOUT_SCLK_FSYS_MMC0_SDCLKIN_A, "mout_sclk_fsys_mmc0_sdclkin_a",
1747 mout_sclk_fsys_mmc_sdclkin_a_p,
1748 MUX_SEL_TOP_FSYS, 20, 1),
1749 MUX(TOP_MOUT_SCLK_FSYS_MMC0_SDCLKIN_B, "mout_sclk_fsys_mmc0_sdclkin_b",
1750 mout_sclk_fsys_mmc0_sdclkin_b_p,
1751 MUX_SEL_TOP_FSYS, 24, 1),
1752
1753 MUX(TOP_MOUT_ISP1_MEDIA_400, "mout_isp1_media_400",
1754 mout_isp1_media_400_p,
1755 MUX_SEL_TOP_ISP10, 4, 1),
1756 MUX(TOP_MOUT_ACLK_ISP1_400, "mout_aclk_isp1_400", mout_aclk_isp1_400_p,
1757 MUX_SEL_TOP_ISP10, 8 , 1),
1758 MUX(TOP_MOUT_ISP1_MEDIA_266, "mout_isp1_media_266",
1759 mout_isp1_media_266_p,
1760 MUX_SEL_TOP_ISP10, 16, 1),
1761 MUX(TOP_MOUT_ACLK_ISP1_266, "mout_aclk_isp1_266", mout_aclk_isp1_266_p,
1762 MUX_SEL_TOP_ISP10, 20, 1),
1763
1764 MUX(TOP_MOUT_SCLK_ISP1_SPI0, "mout_sclk_isp1_spi0", mout_sclk_isp_spi_p,
1765 MUX_SEL_TOP_ISP11, 4, 1),
1766 MUX(TOP_MOUT_SCLK_ISP1_SPI1, "mout_sclk_isp1_spi1", mout_sclk_isp_spi_p,
1767 MUX_SEL_TOP_ISP11, 8, 1),
1768 MUX(TOP_MOUT_SCLK_ISP1_UART, "mout_sclk_isp1_uart",
1769 mout_sclk_isp_uart_p,
1770 MUX_SEL_TOP_ISP11, 12, 1),
1771 MUX(TOP_MOUT_SCLK_ISP1_SENSOR0, "mout_sclk_isp1_sensor0",
1772 mout_sclk_isp_sensor_p,
1773 MUX_SEL_TOP_ISP11, 16, 1),
1774 MUX(TOP_MOUT_SCLK_ISP1_SENSOR1, "mout_sclk_isp1_sensor1",
1775 mout_sclk_isp_sensor_p,
1776 MUX_SEL_TOP_ISP11, 20, 1),
1777 MUX(TOP_MOUT_SCLK_ISP1_SENSOR2, "mout_sclk_isp1_sensor2",
1778 mout_sclk_isp_sensor_p,
1779 MUX_SEL_TOP_ISP11, 24, 1),
1780
1781 MUX(TOP_MOUT_MFC_BUSTOP_333, "mout_mfc_bustop_333",
1782 mout_mfc_bustop_333_p,
1783 MUX_SEL_TOP_MFC, 4, 1),
1784 MUX(TOP_MOUT_ACLK_MFC_333, "mout_aclk_mfc_333", mout_aclk_mfc_333_p,
1785 MUX_SEL_TOP_MFC, 8, 1),
1786
1787 MUX(TOP_MOUT_G2D_BUSTOP_333, "mout_g2d_bustop_333",
1788 mout_g2d_bustop_333_p,
1789 MUX_SEL_TOP_G2D, 4, 1),
1790 MUX(TOP_MOUT_ACLK_G2D_333, "mout_aclk_g2d_333", mout_aclk_g2d_333_p,
1791 MUX_SEL_TOP_G2D, 8, 1),
1792
1793 MUX(TOP_MOUT_M2M_MEDIATOP_400, "mout_m2m_mediatop_400",
1794 mout_m2m_mediatop_400_p,
1795 MUX_SEL_TOP_GSCL, 0, 1),
1796 MUX(TOP_MOUT_ACLK_GSCL_400, "mout_aclk_gscl_400",
1797 mout_aclk_gscl_400_p,
1798 MUX_SEL_TOP_GSCL, 4, 1),
1799 MUX(TOP_MOUT_GSCL_BUSTOP_333, "mout_gscl_bustop_333",
1800 mout_gscl_bustop_333_p,
1801 MUX_SEL_TOP_GSCL, 8, 1),
1802 MUX(TOP_MOUT_ACLK_GSCL_333, "mout_aclk_gscl_333",
1803 mout_aclk_gscl_333_p,
1804 MUX_SEL_TOP_GSCL, 12, 1),
1805 MUX(TOP_MOUT_GSCL_BUSTOP_FIMC, "mout_gscl_bustop_fimc",
1806 mout_gscl_bustop_fimc_p,
1807 MUX_SEL_TOP_GSCL, 16, 1),
1808 MUX(TOP_MOUT_ACLK_GSCL_FIMC, "mout_aclk_gscl_fimc",
1809 mout_aclk_gscl_fimc_p,
1810 MUX_SEL_TOP_GSCL, 20, 1),
1811};
1812
1813struct samsung_div_clock top_div_clks[] __initdata = {
1814 DIV(TOP_DOUT_ACLK_G2D_333, "dout_aclk_g2d_333", "mout_aclk_g2d_333",
1815 DIV_TOP_G2D_MFC, 0, 3),
1816 DIV(TOP_DOUT_ACLK_MFC_333, "dout_aclk_mfc_333", "mout_aclk_mfc_333",
1817 DIV_TOP_G2D_MFC, 4, 3),
1818
1819 DIV(TOP_DOUT_ACLK_GSCL_333, "dout_aclk_gscl_333", "mout_aclk_gscl_333",
1820 DIV_TOP_GSCL_ISP0, 0, 3),
1821 DIV(TOP_DOUT_ACLK_GSCL_400, "dout_aclk_gscl_400", "mout_aclk_gscl_400",
1822 DIV_TOP_GSCL_ISP0, 4, 3),
1823 DIV(TOP_DOUT_ACLK_GSCL_FIMC, "dout_aclk_gscl_fimc",
1824 "mout_aclk_gscl_fimc", DIV_TOP_GSCL_ISP0, 8, 3),
1825 DIV(TOP_DOUT_SCLK_ISP1_SENSOR0_A, "dout_sclk_isp1_sensor0_a",
1826 "mout_aclk_gscl_fimc", DIV_TOP_GSCL_ISP0, 16, 4),
1827 DIV(TOP_DOUT_SCLK_ISP1_SENSOR1_A, "dout_sclk_isp1_sensor1_a",
1828 "mout_aclk_gscl_400", DIV_TOP_GSCL_ISP0, 20, 4),
1829 DIV(TOP_DOUT_SCLK_ISP1_SENSOR2_A, "dout_sclk_isp1_sensor2_a",
1830 "mout_aclk_gscl_fimc", DIV_TOP_GSCL_ISP0, 24, 4),
1831
1832 DIV(TOP_DOUT_ACLK_ISP1_266, "dout_aclk_isp1_266", "mout_aclk_isp1_266",
1833 DIV_TOP_ISP10, 0, 3),
1834 DIV(TOP_DOUT_ACLK_ISP1_400, "dout_aclk_isp1_400", "mout_aclk_isp1_400",
1835 DIV_TOP_ISP10, 4, 3),
1836 DIV(TOP_DOUT_SCLK_ISP1_SPI0_A, "dout_sclk_isp1_spi0_a",
1837 "mout_sclk_isp1_spi0", DIV_TOP_ISP10, 12, 4),
1838 DIV(TOP_DOUT_SCLK_ISP1_SPI0_B, "dout_sclk_isp1_spi0_b",
1839 "dout_sclk_isp1_spi0_a", DIV_TOP_ISP10, 16, 8),
1840
1841 DIV(TOP_DOUT_SCLK_ISP1_SPI1_A, "dout_sclk_isp1_spi1_a",
1842 "mout_sclk_isp1_spi1", DIV_TOP_ISP11, 0, 4),
1843 DIV(TOP_DOUT_SCLK_ISP1_SPI1_B, "dout_sclk_isp1_spi1_b",
1844 "dout_sclk_isp1_spi1_a", DIV_TOP_ISP11, 4, 8),
1845 DIV(TOP_DOUT_SCLK_ISP1_UART, "dout_sclk_isp1_uart",
1846 "mout_sclk_isp1_uart", DIV_TOP_ISP11, 12, 4),
1847 DIV(TOP_DOUT_SCLK_ISP1_SENSOR0_B, "dout_sclk_isp1_sensor0_b",
1848 "dout_sclk_isp1_sensor0_a", DIV_TOP_ISP11, 16, 4),
1849 DIV(TOP_DOUT_SCLK_ISP1_SENSOR1_B, "dout_sclk_isp1_sensor1_b",
1850 "dout_sclk_isp1_sensor1_a", DIV_TOP_ISP11, 20, 4),
1851 DIV(TOP_DOUT_SCLK_ISP1_SENSOR2_B, "dout_sclk_isp1_sensor2_b",
1852 "dout_sclk_isp1_sensor2_a", DIV_TOP_ISP11, 24, 4),
1853
1854 DIV(TOP_DOUTTOP__SCLK_HPM_TARGETCLK, "dout_sclk_hpm_targetclk",
1855 "mout_bustop_pll_user", DIV_TOP_HPM, 0, 3),
1856
1857 DIV(TOP_DOUT_ACLK_DISP_333, "dout_aclk_disp_333", "mout_aclk_disp_333",
1858 DIV_TOP_DISP, 0, 3),
1859 DIV(TOP_DOUT_ACLK_DISP_222, "dout_aclk_disp_222", "mout_aclk_disp_222",
1860 DIV_TOP_DISP, 4, 3),
1861 DIV(TOP_DOUT_SCLK_DISP_PIXEL, "dout_sclk_disp_pixel",
1862 "mout_sclk_disp_pixel", DIV_TOP_DISP, 8, 3),
1863
1864 DIV(TOP_DOUT_ACLK_BUS1_400, "dout_aclk_bus1_400",
1865 "mout_bus1_bustop_400", DIV_TOP_BUS, 0, 3),
1866 DIV(TOP_DOUT_ACLK_BUS1_100, "dout_aclk_bus1_100",
1867 "mout_bus1_bustop_100", DIV_TOP_BUS, 4, 4),
1868 DIV(TOP_DOUT_ACLK_BUS2_400, "dout_aclk_bus2_400",
1869 "mout_bus2_bustop_400", DIV_TOP_BUS, 8, 3),
1870 DIV(TOP_DOUT_ACLK_BUS2_100, "dout_aclk_bus2_100",
1871 "mout_bus2_bustop_100", DIV_TOP_BUS, 12, 4),
1872 DIV(TOP_DOUT_ACLK_BUS3_400, "dout_aclk_bus3_400",
1873 "mout_bus3_bustop_400", DIV_TOP_BUS, 16, 3),
1874 DIV(TOP_DOUT_ACLK_BUS3_100, "dout_aclk_bus3_100",
1875 "mout_bus3_bustop_100", DIV_TOP_BUS, 20, 4),
1876 DIV(TOP_DOUT_ACLK_BUS4_400, "dout_aclk_bus4_400",
1877 "mout_bus4_bustop_400", DIV_TOP_BUS, 24, 3),
1878 DIV(TOP_DOUT_ACLK_BUS4_100, "dout_aclk_bus4_100",
1879 "mout_bus4_bustop_100", DIV_TOP_BUS, 28, 4),
1880
1881 DIV(TOP_DOUT_SCLK_PERI_SPI0_A, "dout_sclk_peri_spi0_a",
1882 "mout_sclk_peri_spi0_clk", DIV_TOP_PERI0, 4, 4),
1883 DIV(TOP_DOUT_SCLK_PERI_SPI0_B, "dout_sclk_peri_spi0_b",
1884 "dout_sclk_peri_spi0_a", DIV_TOP_PERI0, 8, 8),
1885 DIV(TOP_DOUT_SCLK_PERI_SPI1_A, "dout_sclk_peri_spi1_a",
1886 "mout_sclk_peri_spi1_clk", DIV_TOP_PERI0, 16, 4),
1887 DIV(TOP_DOUT_SCLK_PERI_SPI1_B, "dout_sclk_peri_spi1_b",
1888 "dout_sclk_peri_spi1_a", DIV_TOP_PERI0, 20, 8),
1889
1890 DIV(TOP_DOUT_SCLK_PERI_SPI2_A, "dout_sclk_peri_spi2_a",
1891 "mout_sclk_peri_spi2_clk", DIV_TOP_PERI1, 0, 4),
1892 DIV(TOP_DOUT_SCLK_PERI_SPI2_B, "dout_sclk_peri_spi2_b",
1893 "dout_sclk_peri_spi2_a", DIV_TOP_PERI1, 4, 8),
1894 DIV(TOP_DOUT_SCLK_PERI_UART1, "dout_sclk_peri_uart1",
1895 "mout_sclk_peri_uart1_uclk", DIV_TOP_PERI1, 16, 4),
1896 DIV(TOP_DOUT_SCLK_PERI_UART2, "dout_sclk_peri_uart2",
1897 "mout_sclk_peri_uart2_uclk", DIV_TOP_PERI1, 20, 4),
1898 DIV(TOP_DOUT_SCLK_PERI_UART0, "dout_sclk_peri_uart0",
1899 "mout_sclk_peri_uart0_uclk", DIV_TOP_PERI1, 24, 4),
1900
1901 DIV(TOP_DOUT_ACLK_PERI_66, "dout_aclk_peri_66", "mout_bustop_pll_user",
1902 DIV_TOP_PERI2, 20, 4),
1903 DIV(TOP_DOUT_ACLK_PERI_AUD, "dout_aclk_peri_aud",
1904 "mout_audtop_pll_user", DIV_TOP_PERI2, 24, 3),
1905
1906 DIV(TOP_DOUT_ACLK_FSYS_200, "dout_aclk_fsys_200",
1907 "mout_bustop_pll_user", DIV_TOP_FSYS0, 0, 3),
1908 DIV(TOP_DOUT_SCLK_FSYS_USBDRD30_SUSPEND_CLK,
1909 "dout_sclk_fsys_usbdrd30_suspend_clk",
1910 "mout_sclk_fsys_usb", DIV_TOP_FSYS0, 4, 4),
1911 DIV(TOP_DOUT_SCLK_FSYS_MMC0_SDCLKIN_A, "dout_sclk_fsys_mmc0_sdclkin_a",
1912 "mout_sclk_fsys_mmc0_sdclkin_b",
1913 DIV_TOP_FSYS0, 12, 4),
1914 DIV(TOP_DOUT_SCLK_FSYS_MMC0_SDCLKIN_B, "dout_sclk_fsys_mmc0_sdclkin_b",
1915 "dout_sclk_fsys_mmc0_sdclkin_a",
1916 DIV_TOP_FSYS0, 16, 8),
1917
1918
1919 DIV(TOP_DOUT_SCLK_FSYS_MMC1_SDCLKIN_A, "dout_sclk_fsys_mmc1_sdclkin_a",
1920 "mout_sclk_fsys_mmc1_sdclkin_b",
1921 DIV_TOP_FSYS1, 0, 4),
1922 DIV(TOP_DOUT_SCLK_FSYS_MMC1_SDCLKIN_B, "dout_sclk_fsys_mmc1_sdclkin_b",
1923 "dout_sclk_fsys_mmc1_sdclkin_a",
1924 DIV_TOP_FSYS1, 4, 8),
1925 DIV(TOP_DOUT_SCLK_FSYS_MMC2_SDCLKIN_A, "dout_sclk_fsys_mmc2_sdclkin_a",
1926 "mout_sclk_fsys_mmc2_sdclkin_b",
1927 DIV_TOP_FSYS1, 12, 4),
1928 DIV(TOP_DOUT_SCLK_FSYS_MMC2_SDCLKIN_B, "dout_sclk_fsys_mmc2_sdclkin_b",
1929 "dout_sclk_fsys_mmc2_sdclkin_a",
1930 DIV_TOP_FSYS1, 16, 8),
1931
1932};
1933
1934struct samsung_gate_clock top_gate_clks[] __initdata = {
1935 GATE(TOP_SCLK_MMC0, "sclk_fsys_mmc0_sdclkin",
1936 "dout_sclk_fsys_mmc0_sdclkin_b",
1937 EN_SCLK_TOP, 7, CLK_SET_RATE_PARENT, 0),
1938 GATE(TOP_SCLK_MMC1, "sclk_fsys_mmc1_sdclkin",
1939 "dout_sclk_fsys_mmc1_sdclkin_b",
1940 EN_SCLK_TOP, 8, CLK_SET_RATE_PARENT, 0),
1941 GATE(TOP_SCLK_MMC2, "sclk_fsys_mmc2_sdclkin",
1942 "dout_sclk_fsys_mmc2_sdclkin_b",
1943 EN_SCLK_TOP, 9, CLK_SET_RATE_PARENT, 0),
1944 GATE(TOP_SCLK_FIMD1, "sclk_disp_pixel", "dout_sclk_disp_pixel",
1945 EN_ACLK_TOP, 10, CLK_IGNORE_UNUSED |
1946 CLK_SET_RATE_PARENT, 0),
1947};
1948
1949static struct samsung_pll_clock top_pll_clks[] __initdata = {
1950 PLL(pll_2550xx, TOP_FOUT_DISP_PLL, "fout_disp_pll", "fin_pll",
1951 DISP_PLL_LOCK, DISP_PLL_CON0,
1952 pll2550_24mhz_tbl),
1953 PLL(pll_2650xx, TOP_FOUT_AUD_PLL, "fout_aud_pll", "fin_pll",
1954 AUD_PLL_LOCK, AUD_PLL_CON0,
1955 pll2650_24mhz_tbl),
1956};
1957
1958static void __init exynos5260_clk_top_init(struct device_node *np)
1959{
1960 struct exynos5260_cmu_info cmu = {0};
1961
1962 cmu.pll_clks = top_pll_clks;
1963 cmu.nr_pll_clks = ARRAY_SIZE(top_pll_clks);
1964 cmu.mux_clks = top_mux_clks;
1965 cmu.nr_mux_clks = ARRAY_SIZE(top_mux_clks);
1966 cmu.div_clks = top_div_clks;
1967 cmu.nr_div_clks = ARRAY_SIZE(top_div_clks);
1968 cmu.gate_clks = top_gate_clks;
1969 cmu.nr_gate_clks = ARRAY_SIZE(top_gate_clks);
1970 cmu.fixed_clks = fixed_rate_clks;
1971 cmu.nr_fixed_clks = ARRAY_SIZE(fixed_rate_clks);
1972 cmu.nr_clk_ids = TOP_NR_CLK;
1973 cmu.clk_regs = top_clk_regs;
1974 cmu.nr_clk_regs = ARRAY_SIZE(top_clk_regs);
1975
1976 exynos5260_cmu_register_one(np, &cmu);
1977}
1978
1979CLK_OF_DECLARE(exynos5260_clk_top, "samsung,exynos5260-clock-top",
1980 exynos5260_clk_top_init);
diff --git a/drivers/clk/samsung/clk-exynos5260.h b/drivers/clk/samsung/clk-exynos5260.h
new file mode 100644
index 000000000000..d739716d6ea1
--- /dev/null
+++ b/drivers/clk/samsung/clk-exynos5260.h
@@ -0,0 +1,459 @@
1/*
2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 * Author: Rahul Sharma <rahul.sharma@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Common Clock Framework support for Exynos5260 SoC.
10 */
11
12#ifndef __CLK_EXYNOS5260_H
13#define __CLK_EXYNOS5260_H
14
15/*
16*Registers for CMU_AUD
17*/
18#define MUX_SEL_AUD 0x0200
19#define MUX_ENABLE_AUD 0x0300
20#define MUX_STAT_AUD 0x0400
21#define MUX_IGNORE_AUD 0x0500
22#define DIV_AUD0 0x0600
23#define DIV_AUD1 0x0604
24#define DIV_STAT_AUD0 0x0700
25#define DIV_STAT_AUD1 0x0704
26#define EN_ACLK_AUD 0x0800
27#define EN_PCLK_AUD 0x0900
28#define EN_SCLK_AUD 0x0a00
29#define EN_IP_AUD 0x0b00
30
31/*
32*Registers for CMU_DISP
33*/
34#define MUX_SEL_DISP0 0x0200
35#define MUX_SEL_DISP1 0x0204
36#define MUX_SEL_DISP2 0x0208
37#define MUX_SEL_DISP3 0x020C
38#define MUX_SEL_DISP4 0x0210
39#define MUX_ENABLE_DISP0 0x0300
40#define MUX_ENABLE_DISP1 0x0304
41#define MUX_ENABLE_DISP2 0x0308
42#define MUX_ENABLE_DISP3 0x030c
43#define MUX_ENABLE_DISP4 0x0310
44#define MUX_STAT_DISP0 0x0400
45#define MUX_STAT_DISP1 0x0404
46#define MUX_STAT_DISP2 0x0408
47#define MUX_STAT_DISP3 0x040c
48#define MUX_STAT_DISP4 0x0410
49#define MUX_IGNORE_DISP0 0x0500
50#define MUX_IGNORE_DISP1 0x0504
51#define MUX_IGNORE_DISP2 0x0508
52#define MUX_IGNORE_DISP3 0x050c
53#define MUX_IGNORE_DISP4 0x0510
54#define DIV_DISP 0x0600
55#define DIV_STAT_DISP 0x0700
56#define EN_ACLK_DISP 0x0800
57#define EN_PCLK_DISP 0x0900
58#define EN_SCLK_DISP0 0x0a00
59#define EN_SCLK_DISP1 0x0a04
60#define EN_IP_DISP 0x0b00
61#define EN_IP_DISP_BUS 0x0b04
62
63
64/*
65*Registers for CMU_EGL
66*/
67#define EGL_PLL_LOCK 0x0000
68#define EGL_DPLL_LOCK 0x0004
69#define EGL_PLL_CON0 0x0100
70#define EGL_PLL_CON1 0x0104
71#define EGL_PLL_FREQ_DET 0x010c
72#define EGL_DPLL_CON0 0x0110
73#define EGL_DPLL_CON1 0x0114
74#define EGL_DPLL_FREQ_DET 0x011c
75#define MUX_SEL_EGL 0x0200
76#define MUX_ENABLE_EGL 0x0300
77#define MUX_STAT_EGL 0x0400
78#define DIV_EGL 0x0600
79#define DIV_EGL_PLL_FDET 0x0604
80#define DIV_STAT_EGL 0x0700
81#define DIV_STAT_EGL_PLL_FDET 0x0704
82#define EN_ACLK_EGL 0x0800
83#define EN_PCLK_EGL 0x0900
84#define EN_SCLK_EGL 0x0a00
85#define EN_IP_EGL 0x0b00
86#define CLKOUT_CMU_EGL 0x0c00
87#define CLKOUT_CMU_EGL_DIV_STAT 0x0c04
88#define ARMCLK_STOPCTRL 0x1000
89#define EAGLE_EMA_CTRL 0x1008
90#define EAGLE_EMA_STATUS 0x100c
91#define PWR_CTRL 0x1020
92#define PWR_CTRL2 0x1024
93#define CLKSTOP_CTRL 0x1028
94#define INTR_SPREAD_EN 0x1080
95#define INTR_SPREAD_USE_STANDBYWFI 0x1084
96#define INTR_SPREAD_BLOCKING_DURATION 0x1088
97#define CMU_EGL_SPARE0 0x2000
98#define CMU_EGL_SPARE1 0x2004
99#define CMU_EGL_SPARE2 0x2008
100#define CMU_EGL_SPARE3 0x200c
101#define CMU_EGL_SPARE4 0x2010
102
103/*
104*Registers for CMU_FSYS
105*/
106
107#define MUX_SEL_FSYS0 0x0200
108#define MUX_SEL_FSYS1 0x0204
109#define MUX_ENABLE_FSYS0 0x0300
110#define MUX_ENABLE_FSYS1 0x0304
111#define MUX_STAT_FSYS0 0x0400
112#define MUX_STAT_FSYS1 0x0404
113#define MUX_IGNORE_FSYS0 0x0500
114#define MUX_IGNORE_FSYS1 0x0504
115#define EN_ACLK_FSYS 0x0800
116#define EN_ACLK_FSYS_SECURE_RTIC 0x0804
117#define EN_ACLK_FSYS_SECURE_SMMU_RTIC 0x0808
118#define EN_PCLK_FSYS 0x0900
119#define EN_SCLK_FSYS 0x0a00
120#define EN_IP_FSYS 0x0b00
121#define EN_IP_FSYS_SECURE_RTIC 0x0b04
122#define EN_IP_FSYS_SECURE_SMMU_RTIC 0x0b08
123
124/*
125*Registers for CMU_G2D
126*/
127
128#define MUX_SEL_G2D 0x0200
129#define MUX_ENABLE_G2D 0x0300
130#define MUX_STAT_G2D 0x0400
131#define DIV_G2D 0x0600
132#define DIV_STAT_G2D 0x0700
133#define EN_ACLK_G2D 0x0800
134#define EN_ACLK_G2D_SECURE_SSS 0x0804
135#define EN_ACLK_G2D_SECURE_SLIM_SSS 0x0808
136#define EN_ACLK_G2D_SECURE_SMMU_SLIM_SSS 0x080c
137#define EN_ACLK_G2D_SECURE_SMMU_SSS 0x0810
138#define EN_ACLK_G2D_SECURE_SMMU_MDMA 0x0814
139#define EN_ACLK_G2D_SECURE_SMMU_G2D 0x0818
140#define EN_PCLK_G2D 0x0900
141#define EN_PCLK_G2D_SECURE_SMMU_SLIM_SSS 0x0904
142#define EN_PCLK_G2D_SECURE_SMMU_SSS 0x0908
143#define EN_PCLK_G2D_SECURE_SMMU_MDMA 0x090c
144#define EN_PCLK_G2D_SECURE_SMMU_G2D 0x0910
145#define EN_IP_G2D 0x0b00
146#define EN_IP_G2D_SECURE_SSS 0x0b04
147#define EN_IP_G2D_SECURE_SLIM_SSS 0x0b08
148#define EN_IP_G2D_SECURE_SMMU_SLIM_SSS 0x0b0c
149#define EN_IP_G2D_SECURE_SMMU_SSS 0x0b10
150#define EN_IP_G2D_SECURE_SMMU_MDMA 0x0b14
151#define EN_IP_G2D_SECURE_SMMU_G2D 0x0b18
152
153/*
154*Registers for CMU_G3D
155*/
156
157#define G3D_PLL_LOCK 0x0000
158#define G3D_PLL_CON0 0x0100
159#define G3D_PLL_CON1 0x0104
160#define G3D_PLL_FDET 0x010c
161#define MUX_SEL_G3D 0x0200
162#define MUX_EN_G3D 0x0300
163#define MUX_STAT_G3D 0x0400
164#define MUX_IGNORE_G3D 0x0500
165#define DIV_G3D 0x0600
166#define DIV_G3D_PLL_FDET 0x0604
167#define DIV_STAT_G3D 0x0700
168#define DIV_STAT_G3D_PLL_FDET 0x0704
169#define EN_ACLK_G3D 0x0800
170#define EN_PCLK_G3D 0x0900
171#define EN_SCLK_G3D 0x0a00
172#define EN_IP_G3D 0x0b00
173#define CLKOUT_CMU_G3D 0x0c00
174#define CLKOUT_CMU_G3D_DIV_STAT 0x0c04
175#define G3DCLK_STOPCTRL 0x1000
176#define G3D_EMA_CTRL 0x1008
177#define G3D_EMA_STATUS 0x100c
178
179/*
180*Registers for CMU_GSCL
181*/
182
183#define MUX_SEL_GSCL 0x0200
184#define MUX_EN_GSCL 0x0300
185#define MUX_STAT_GSCL 0x0400
186#define MUX_IGNORE_GSCL 0x0500
187#define DIV_GSCL 0x0600
188#define DIV_STAT_GSCL 0x0700
189#define EN_ACLK_GSCL 0x0800
190#define EN_ACLK_GSCL_FIMC 0x0804
191#define EN_ACLK_GSCL_SECURE_SMMU_GSCL0 0x0808
192#define EN_ACLK_GSCL_SECURE_SMMU_GSCL1 0x080c
193#define EN_ACLK_GSCL_SECURE_SMMU_MSCL0 0x0810
194#define EN_ACLK_GSCL_SECURE_SMMU_MSCL1 0x0814
195#define EN_PCLK_GSCL 0x0900
196#define EN_PCLK_GSCL_FIMC 0x0904
197#define EN_PCLK_GSCL_SECURE_SMMU_GSCL0 0x0908
198#define EN_PCLK_GSCL_SECURE_SMMU_GSCL1 0x090c
199#define EN_PCLK_GSCL_SECURE_SMMU_MSCL0 0x0910
200#define EN_PCLK_GSCL_SECURE_SMMU_MSCL1 0x0914
201#define EN_SCLK_GSCL 0x0a00
202#define EN_SCLK_GSCL_FIMC 0x0a04
203#define EN_IP_GSCL 0x0b00
204#define EN_IP_GSCL_FIMC 0x0b04
205#define EN_IP_GSCL_SECURE_SMMU_GSCL0 0x0b08
206#define EN_IP_GSCL_SECURE_SMMU_GSCL1 0x0b0c
207#define EN_IP_GSCL_SECURE_SMMU_MSCL0 0x0b10
208#define EN_IP_GSCL_SECURE_SMMU_MSCL1 0x0b14
209
210/*
211*Registers for CMU_ISP
212*/
213#define MUX_SEL_ISP0 0x0200
214#define MUX_SEL_ISP1 0x0204
215#define MUX_ENABLE_ISP0 0x0300
216#define MUX_ENABLE_ISP1 0x0304
217#define MUX_STAT_ISP0 0x0400
218#define MUX_STAT_ISP1 0x0404
219#define MUX_IGNORE_ISP0 0x0500
220#define MUX_IGNORE_ISP1 0x0504
221#define DIV_ISP 0x0600
222#define DIV_STAT_ISP 0x0700
223#define EN_ACLK_ISP0 0x0800
224#define EN_ACLK_ISP1 0x0804
225#define EN_PCLK_ISP0 0x0900
226#define EN_PCLK_ISP1 0x0904
227#define EN_SCLK_ISP 0x0a00
228#define EN_IP_ISP0 0x0b00
229#define EN_IP_ISP1 0x0b04
230
231/*
232*Registers for CMU_KFC
233*/
234#define KFC_PLL_LOCK 0x0000
235#define KFC_PLL_CON0 0x0100
236#define KFC_PLL_CON1 0x0104
237#define KFC_PLL_FDET 0x010c
238#define MUX_SEL_KFC0 0x0200
239#define MUX_SEL_KFC2 0x0208
240#define MUX_ENABLE_KFC0 0x0300
241#define MUX_ENABLE_KFC2 0x0308
242#define MUX_STAT_KFC0 0x0400
243#define MUX_STAT_KFC2 0x0408
244#define DIV_KFC 0x0600
245#define DIV_KFC_PLL_FDET 0x0604
246#define DIV_STAT_KFC 0x0700
247#define DIV_STAT_KFC_PLL_FDET 0x0704
248#define EN_ACLK_KFC 0x0800
249#define EN_PCLK_KFC 0x0900
250#define EN_SCLK_KFC 0x0a00
251#define EN_IP_KFC 0x0b00
252#define CLKOUT_CMU_KFC 0x0c00
253#define CLKOUT_CMU_KFC_DIV_STAT 0x0c04
254#define ARMCLK_STOPCTRL_KFC 0x1000
255#define ARM_EMA_CTRL 0x1008
256#define ARM_EMA_STATUS 0x100c
257#define PWR_CTRL_KFC 0x1020
258#define PWR_CTRL2_KFC 0x1024
259#define CLKSTOP_CTRL_KFC 0x1028
260#define INTR_SPREAD_ENABLE_KFC 0x1080
261#define INTR_SPREAD_USE_STANDBYWFI_KFC 0x1084
262#define INTR_SPREAD_BLOCKING_DURATION_KFC 0x1088
263#define CMU_KFC_SPARE0 0x2000
264#define CMU_KFC_SPARE1 0x2004
265#define CMU_KFC_SPARE2 0x2008
266#define CMU_KFC_SPARE3 0x200c
267#define CMU_KFC_SPARE4 0x2010
268
269/*
270*Registers for CMU_MFC
271*/
272#define MUX_SEL_MFC 0x0200
273#define MUX_ENABLE_MFC 0x0300
274#define MUX_STAT_MFC 0x0400
275#define DIV_MFC 0x0600
276#define DIV_STAT_MFC 0x0700
277#define EN_ACLK_MFC 0x0800
278#define EN_ACLK_SECURE_SMMU2_MFC 0x0804
279#define EN_PCLK_MFC 0x0900
280#define EN_PCLK_SECURE_SMMU2_MFC 0x0904
281#define EN_IP_MFC 0x0b00
282#define EN_IP_MFC_SECURE_SMMU2_MFC 0x0b04
283
284/*
285*Registers for CMU_MIF
286*/
287#define MEM_PLL_LOCK 0x0000
288#define BUS_PLL_LOCK 0x0004
289#define MEDIA_PLL_LOCK 0x0008
290#define MEM_PLL_CON0 0x0100
291#define MEM_PLL_CON1 0x0104
292#define MEM_PLL_FDET 0x010c
293#define BUS_PLL_CON0 0x0110
294#define BUS_PLL_CON1 0x0114
295#define BUS_PLL_FDET 0x011c
296#define MEDIA_PLL_CON0 0x0120
297#define MEDIA_PLL_CON1 0x0124
298#define MEDIA_PLL_FDET 0x012c
299#define MUX_SEL_MIF 0x0200
300#define MUX_ENABLE_MIF 0x0300
301#define MUX_STAT_MIF 0x0400
302#define MUX_IGNORE_MIF 0x0500
303#define DIV_MIF 0x0600
304#define DIV_MIF_PLL_FDET 0x0604
305#define DIV_STAT_MIF 0x0700
306#define DIV_STAT_MIF_PLL_FDET 0x0704
307#define EN_ACLK_MIF 0x0800
308#define EN_ACLK_MIF_SECURE_DREX1_TZ 0x0804
309#define EN_ACLK_MIF_SECURE_DREX0_TZ 0x0808
310#define EN_ACLK_MIF_SECURE_INTMEM 0x080c
311#define EN_PCLK_MIF 0x0900
312#define EN_PCLK_MIF_SECURE_MONOCNT 0x0904
313#define EN_PCLK_MIF_SECURE_RTC_APBIF 0x0908
314#define EN_PCLK_MIF_SECURE_DREX1_TZ 0x090c
315#define EN_PCLK_MIF_SECURE_DREX0_TZ 0x0910
316#define EN_SCLK_MIF 0x0a00
317#define EN_IP_MIF 0x0b00
318#define EN_IP_MIF_SECURE_MONOCNT 0x0b04
319#define EN_IP_MIF_SECURE_RTC_APBIF 0x0b08
320#define EN_IP_MIF_SECURE_DREX1_TZ 0x0b0c
321#define EN_IP_MIF_SECURE_DREX0_TZ 0x0b10
322#define EN_IP_MIF_SECURE_INTEMEM 0x0b14
323#define CLKOUT_CMU_MIF_DIV_STAT 0x0c04
324#define DREX_FREQ_CTRL 0x1000
325#define PAUSE 0x1004
326#define DDRPHY_LOCK_CTRL 0x1008
327#define CLKOUT_CMU_MIF 0xcb00
328
329/*
330*Registers for CMU_PERI
331*/
332#define MUX_SEL_PERI 0x0200
333#define MUX_SEL_PERI1 0x0204
334#define MUX_ENABLE_PERI 0x0300
335#define MUX_ENABLE_PERI1 0x0304
336#define MUX_STAT_PERI 0x0400
337#define MUX_STAT_PERI1 0x0404
338#define MUX_IGNORE_PERI 0x0500
339#define MUX_IGNORE_PERI1 0x0504
340#define DIV_PERI 0x0600
341#define DIV_STAT_PERI 0x0700
342#define EN_PCLK_PERI0 0x0800
343#define EN_PCLK_PERI1 0x0804
344#define EN_PCLK_PERI2 0x0808
345#define EN_PCLK_PERI3 0x080c
346#define EN_PCLK_PERI_SECURE_CHIPID 0x0810
347#define EN_PCLK_PERI_SECURE_PROVKEY0 0x0814
348#define EN_PCLK_PERI_SECURE_PROVKEY1 0x0818
349#define EN_PCLK_PERI_SECURE_SECKEY 0x081c
350#define EN_PCLK_PERI_SECURE_ANTIRBKCNT 0x0820
351#define EN_PCLK_PERI_SECURE_TOP_RTC 0x0824
352#define EN_PCLK_PERI_SECURE_TZPC 0x0828
353#define EN_SCLK_PERI 0x0a00
354#define EN_SCLK_PERI_SECURE_TOP_RTC 0x0a04
355#define EN_IP_PERI0 0x0b00
356#define EN_IP_PERI1 0x0b04
357#define EN_IP_PERI2 0x0b08
358#define EN_IP_PERI_SECURE_CHIPID 0x0b0c
359#define EN_IP_PERI_SECURE_PROVKEY0 0x0b10
360#define EN_IP_PERI_SECURE_PROVKEY1 0x0b14
361#define EN_IP_PERI_SECURE_SECKEY 0x0b18
362#define EN_IP_PERI_SECURE_ANTIRBKCNT 0x0b1c
363#define EN_IP_PERI_SECURE_TOP_RTC 0x0b20
364#define EN_IP_PERI_SECURE_TZPC 0x0b24
365
366/*
367*Registers for CMU_TOP
368*/
369#define DISP_PLL_LOCK 0x0000
370#define AUD_PLL_LOCK 0x0004
371#define DISP_PLL_CON0 0x0100
372#define DISP_PLL_CON1 0x0104
373#define DISP_PLL_FDET 0x0108
374#define AUD_PLL_CON0 0x0110
375#define AUD_PLL_CON1 0x0114
376#define AUD_PLL_CON2 0x0118
377#define AUD_PLL_FDET 0x011c
378#define MUX_SEL_TOP_PLL0 0x0200
379#define MUX_SEL_TOP_MFC 0x0204
380#define MUX_SEL_TOP_G2D 0x0208
381#define MUX_SEL_TOP_GSCL 0x020c
382#define MUX_SEL_TOP_ISP10 0x0214
383#define MUX_SEL_TOP_ISP11 0x0218
384#define MUX_SEL_TOP_DISP0 0x021c
385#define MUX_SEL_TOP_DISP1 0x0220
386#define MUX_SEL_TOP_BUS 0x0224
387#define MUX_SEL_TOP_PERI0 0x0228
388#define MUX_SEL_TOP_PERI1 0x022c
389#define MUX_SEL_TOP_FSYS 0x0230
390#define MUX_ENABLE_TOP_PLL0 0x0300
391#define MUX_ENABLE_TOP_MFC 0x0304
392#define MUX_ENABLE_TOP_G2D 0x0308
393#define MUX_ENABLE_TOP_GSCL 0x030c
394#define MUX_ENABLE_TOP_ISP10 0x0314
395#define MUX_ENABLE_TOP_ISP11 0x0318
396#define MUX_ENABLE_TOP_DISP0 0x031c
397#define MUX_ENABLE_TOP_DISP1 0x0320
398#define MUX_ENABLE_TOP_BUS 0x0324
399#define MUX_ENABLE_TOP_PERI0 0x0328
400#define MUX_ENABLE_TOP_PERI1 0x032c
401#define MUX_ENABLE_TOP_FSYS 0x0330
402#define MUX_STAT_TOP_PLL0 0x0400
403#define MUX_STAT_TOP_MFC 0x0404
404#define MUX_STAT_TOP_G2D 0x0408
405#define MUX_STAT_TOP_GSCL 0x040c
406#define MUX_STAT_TOP_ISP10 0x0414
407#define MUX_STAT_TOP_ISP11 0x0418
408#define MUX_STAT_TOP_DISP0 0x041c
409#define MUX_STAT_TOP_DISP1 0x0420
410#define MUX_STAT_TOP_BUS 0x0424
411#define MUX_STAT_TOP_PERI0 0x0428
412#define MUX_STAT_TOP_PERI1 0x042c
413#define MUX_STAT_TOP_FSYS 0x0430
414#define MUX_IGNORE_TOP_PLL0 0x0500
415#define MUX_IGNORE_TOP_MFC 0x0504
416#define MUX_IGNORE_TOP_G2D 0x0508
417#define MUX_IGNORE_TOP_GSCL 0x050c
418#define MUX_IGNORE_TOP_ISP10 0x0514
419#define MUX_IGNORE_TOP_ISP11 0x0518
420#define MUX_IGNORE_TOP_DISP0 0x051c
421#define MUX_IGNORE_TOP_DISP1 0x0520
422#define MUX_IGNORE_TOP_BUS 0x0524
423#define MUX_IGNORE_TOP_PERI0 0x0528
424#define MUX_IGNORE_TOP_PERI1 0x052c
425#define MUX_IGNORE_TOP_FSYS 0x0530
426#define DIV_TOP_G2D_MFC 0x0600
427#define DIV_TOP_GSCL_ISP0 0x0604
428#define DIV_TOP_ISP10 0x0608
429#define DIV_TOP_ISP11 0x060c
430#define DIV_TOP_DISP 0x0610
431#define DIV_TOP_BUS 0x0614
432#define DIV_TOP_PERI0 0x0618
433#define DIV_TOP_PERI1 0x061c
434#define DIV_TOP_PERI2 0x0620
435#define DIV_TOP_FSYS0 0x0624
436#define DIV_TOP_FSYS1 0x0628
437#define DIV_TOP_HPM 0x062c
438#define DIV_TOP_PLL_FDET 0x0630
439#define DIV_STAT_TOP_G2D_MFC 0x0700
440#define DIV_STAT_TOP_GSCL_ISP0 0x0704
441#define DIV_STAT_TOP_ISP10 0x0708
442#define DIV_STAT_TOP_ISP11 0x070c
443#define DIV_STAT_TOP_DISP 0x0710
444#define DIV_STAT_TOP_BUS 0x0714
445#define DIV_STAT_TOP_PERI0 0x0718
446#define DIV_STAT_TOP_PERI1 0x071c
447#define DIV_STAT_TOP_PERI2 0x0720
448#define DIV_STAT_TOP_FSYS0 0x0724
449#define DIV_STAT_TOP_FSYS1 0x0728
450#define DIV_STAT_TOP_HPM 0x072c
451#define DIV_STAT_TOP_PLL_FDET 0x0730
452#define EN_ACLK_TOP 0x0800
453#define EN_SCLK_TOP 0x0a00
454#define EN_IP_TOP 0x0b00
455#define CLKOUT_CMU_TOP 0x0c00
456#define CLKOUT_CMU_TOP_DIV_STAT 0x0c04
457
458#endif /*__CLK_EXYNOS5260_H */
459
diff --git a/drivers/clk/samsung/clk-exynos5410.c b/drivers/clk/samsung/clk-exynos5410.c
new file mode 100644
index 000000000000..c9505ab9ee70
--- /dev/null
+++ b/drivers/clk/samsung/clk-exynos5410.c
@@ -0,0 +1,209 @@
1/*
2 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 * Author: Tarek Dakhran <t.dakhran@samsung.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Common Clock Framework support for Exynos5410 SoC.
10*/
11
12#include <dt-bindings/clock/exynos5410.h>
13
14#include <linux/clk.h>
15#include <linux/clkdev.h>
16#include <linux/clk-provider.h>
17#include <linux/of.h>
18#include <linux/of_address.h>
19
20#include "clk.h"
21
22#define APLL_LOCK 0x0
23#define APLL_CON0 0x100
24#define CPLL_LOCK 0x10020
25#define CPLL_CON0 0x10120
26#define MPLL_LOCK 0x4000
27#define MPLL_CON0 0x4100
28#define BPLL_LOCK 0x20010
29#define BPLL_CON0 0x20110
30#define KPLL_LOCK 0x28000
31#define KPLL_CON0 0x28100
32
33#define SRC_CPU 0x200
34#define DIV_CPU0 0x500
35#define SRC_CPERI1 0x4204
36#define DIV_TOP0 0x10510
37#define DIV_TOP1 0x10514
38#define DIV_FSYS1 0x1054c
39#define DIV_FSYS2 0x10550
40#define DIV_PERIC0 0x10558
41#define SRC_TOP0 0x10210
42#define SRC_TOP1 0x10214
43#define SRC_TOP2 0x10218
44#define SRC_FSYS 0x10244
45#define SRC_PERIC0 0x10250
46#define SRC_MASK_FSYS 0x10340
47#define SRC_MASK_PERIC0 0x10350
48#define GATE_BUS_FSYS0 0x10740
49#define GATE_IP_FSYS 0x10944
50#define GATE_IP_PERIC 0x10950
51#define GATE_IP_PERIS 0x10960
52#define SRC_CDREX 0x20200
53#define SRC_KFC 0x28200
54#define DIV_KFC0 0x28500
55
56/* list of PLLs */
57enum exynos5410_plls {
58 apll, cpll, mpll,
59 bpll, kpll,
60 nr_plls /* number of PLLs */
61};
62
63/* list of all parent clocks */
64PNAME(apll_p) = { "fin_pll", "fout_apll", };
65PNAME(bpll_p) = { "fin_pll", "fout_bpll", };
66PNAME(cpll_p) = { "fin_pll", "fout_cpll" };
67PNAME(mpll_p) = { "fin_pll", "fout_mpll", };
68PNAME(kpll_p) = { "fin_pll", "fout_kpll", };
69
70PNAME(mout_cpu_p) = { "mout_apll", "sclk_mpll", };
71PNAME(mout_kfc_p) = { "mout_kpll", "sclk_mpll", };
72
73PNAME(mpll_user_p) = { "fin_pll", "sclk_mpll", };
74PNAME(bpll_user_p) = { "fin_pll", "sclk_bpll", };
75PNAME(mpll_bpll_p) = { "sclk_mpll_muxed", "sclk_bpll_muxed", };
76
77PNAME(group2_p) = { "fin_pll", "fin_pll", "none", "none",
78 "none", "none", "sclk_mpll_bpll",
79 "none", "none", "sclk_cpll" };
80
81static struct samsung_mux_clock exynos5410_mux_clks[] __initdata = {
82 MUX(0, "mout_apll", apll_p, SRC_CPU, 0, 1),
83 MUX(0, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1),
84
85 MUX(0, "mout_kpll", kpll_p, SRC_KFC, 0, 1),
86 MUX(0, "mout_kfc", mout_kfc_p, SRC_KFC, 16, 1),
87
88 MUX(0, "sclk_mpll", mpll_p, SRC_CPERI1, 8, 1),
89 MUX(0, "sclk_mpll_muxed", mpll_user_p, SRC_TOP2, 20, 1),
90
91 MUX(0, "sclk_bpll", bpll_p, SRC_CDREX, 0, 1),
92 MUX(0, "sclk_bpll_muxed", bpll_user_p, SRC_TOP2, 24, 1),
93
94 MUX(0, "sclk_cpll", cpll_p, SRC_TOP2, 8, 1),
95
96 MUX(0, "sclk_mpll_bpll", mpll_bpll_p, SRC_TOP1, 20, 1),
97
98 MUX(0, "mout_mmc0", group2_p, SRC_FSYS, 0, 4),
99 MUX(0, "mout_mmc1", group2_p, SRC_FSYS, 4, 4),
100 MUX(0, "mout_mmc2", group2_p, SRC_FSYS, 8, 4),
101
102 MUX(0, "mout_uart0", group2_p, SRC_PERIC0, 0, 4),
103 MUX(0, "mout_uart1", group2_p, SRC_PERIC0, 4, 4),
104 MUX(0, "mout_uart2", group2_p, SRC_PERIC0, 8, 4),
105
106 MUX(0, "mout_aclk200", mpll_bpll_p, SRC_TOP0, 12, 1),
107 MUX(0, "mout_aclk400", mpll_bpll_p, SRC_TOP0, 20, 1),
108};
109
110static struct samsung_div_clock exynos5410_div_clks[] __initdata = {
111 DIV(0, "div_arm", "mout_cpu", DIV_CPU0, 0, 3),
112 DIV(0, "div_arm2", "div_arm", DIV_CPU0, 28, 3),
113
114 DIV(0, "div_acp", "div_arm2", DIV_CPU0, 8, 3),
115 DIV(0, "div_cpud", "div_arm2", DIV_CPU0, 4, 3),
116 DIV(0, "div_atb", "div_arm2", DIV_CPU0, 16, 3),
117 DIV(0, "pclk_dbg", "div_arm2", DIV_CPU0, 20, 3),
118
119 DIV(0, "div_kfc", "mout_kfc", DIV_KFC0, 0, 3),
120 DIV(0, "div_aclk", "div_kfc", DIV_KFC0, 4, 3),
121 DIV(0, "div_pclk", "div_kfc", DIV_KFC0, 20, 3),
122
123 DIV(0, "aclk66_pre", "sclk_mpll_muxed", DIV_TOP1, 24, 3),
124 DIV(0, "aclk66", "aclk66_pre", DIV_TOP0, 0, 3),
125
126 DIV(0, "div_mmc0", "mout_mmc0", DIV_FSYS1, 0, 4),
127 DIV(0, "div_mmc1", "mout_mmc1", DIV_FSYS1, 16, 4),
128 DIV(0, "div_mmc2", "mout_mmc2", DIV_FSYS2, 0, 4),
129
130 DIV_F(0, "div_mmc_pre0", "div_mmc0",
131 DIV_FSYS1, 8, 8, CLK_SET_RATE_PARENT, 0),
132 DIV_F(0, "div_mmc_pre1", "div_mmc1",
133 DIV_FSYS1, 24, 8, CLK_SET_RATE_PARENT, 0),
134 DIV_F(0, "div_mmc_pre2", "div_mmc2",
135 DIV_FSYS2, 8, 8, CLK_SET_RATE_PARENT, 0),
136
137 DIV(0, "div_uart0", "mout_uart0", DIV_PERIC0, 0, 4),
138 DIV(0, "div_uart1", "mout_uart1", DIV_PERIC0, 4, 4),
139 DIV(0, "div_uart2", "mout_uart2", DIV_PERIC0, 8, 4),
140 DIV(0, "div_uart3", "mout_uart3", DIV_PERIC0, 12, 4),
141
142 DIV(0, "aclk200", "mout_aclk200", DIV_TOP0, 12, 3),
143 DIV(0, "aclk400", "mout_aclk400", DIV_TOP0, 24, 3),
144};
145
146static struct samsung_gate_clock exynos5410_gate_clks[] __initdata = {
147 GATE(CLK_MCT, "mct", "aclk66", GATE_IP_PERIS, 18, 0, 0),
148
149 GATE(CLK_SCLK_MMC0, "sclk_mmc0", "div_mmc_pre0",
150 SRC_MASK_FSYS, 0, CLK_SET_RATE_PARENT, 0),
151 GATE(CLK_SCLK_MMC1, "sclk_mmc1", "div_mmc_pre1",
152 SRC_MASK_FSYS, 4, CLK_SET_RATE_PARENT, 0),
153 GATE(CLK_SCLK_MMC2, "sclk_mmc2", "div_mmc_pre2",
154 SRC_MASK_FSYS, 8, CLK_SET_RATE_PARENT, 0),
155
156 GATE(CLK_MMC0, "sdmmc0", "aclk200", GATE_BUS_FSYS0, 12, 0, 0),
157 GATE(CLK_MMC1, "sdmmc1", "aclk200", GATE_BUS_FSYS0, 13, 0, 0),
158 GATE(CLK_MMC2, "sdmmc2", "aclk200", GATE_BUS_FSYS0, 14, 0, 0),
159
160 GATE(CLK_UART0, "uart0", "aclk66", GATE_IP_PERIC, 0, 0, 0),
161 GATE(CLK_UART1, "uart1", "aclk66", GATE_IP_PERIC, 1, 0, 0),
162 GATE(CLK_UART2, "uart2", "aclk66", GATE_IP_PERIC, 2, 0, 0),
163
164 GATE(CLK_SCLK_UART0, "sclk_uart0", "div_uart0",
165 SRC_MASK_PERIC0, 0, CLK_SET_RATE_PARENT, 0),
166 GATE(CLK_SCLK_UART1, "sclk_uart1", "div_uart1",
167 SRC_MASK_PERIC0, 4, CLK_SET_RATE_PARENT, 0),
168 GATE(CLK_SCLK_UART2, "sclk_uart2", "div_uart2",
169 SRC_MASK_PERIC0, 8, CLK_SET_RATE_PARENT, 0),
170};
171
172static struct samsung_pll_clock exynos5410_plls[nr_plls] __initdata = {
173 [apll] = PLL(pll_35xx, CLK_FOUT_APLL, "fout_apll", "fin_pll", APLL_LOCK,
174 APLL_CON0, NULL),
175 [cpll] = PLL(pll_35xx, CLK_FOUT_CPLL, "fout_cpll", "fin_pll", CPLL_LOCK,
176 CPLL_CON0, NULL),
177 [mpll] = PLL(pll_35xx, CLK_FOUT_MPLL, "fout_mpll", "fin_pll", MPLL_LOCK,
178 MPLL_CON0, NULL),
179 [bpll] = PLL(pll_35xx, CLK_FOUT_BPLL, "fout_bpll", "fin_pll", BPLL_LOCK,
180 BPLL_CON0, NULL),
181 [kpll] = PLL(pll_35xx, CLK_FOUT_KPLL, "fout_kpll", "fin_pll", KPLL_LOCK,
182 KPLL_CON0, NULL),
183};
184
185/* register exynos5410 clocks */
186static void __init exynos5410_clk_init(struct device_node *np)
187{
188 struct samsung_clk_provider *ctx;
189 void __iomem *reg_base;
190
191 reg_base = of_iomap(np, 0);
192 if (!reg_base)
193 panic("%s: failed to map registers\n", __func__);
194
195 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
196
197 samsung_clk_register_pll(ctx, exynos5410_plls,
198 ARRAY_SIZE(exynos5410_plls), reg_base);
199
200 samsung_clk_register_mux(ctx, exynos5410_mux_clks,
201 ARRAY_SIZE(exynos5410_mux_clks));
202 samsung_clk_register_div(ctx, exynos5410_div_clks,
203 ARRAY_SIZE(exynos5410_div_clks));
204 samsung_clk_register_gate(ctx, exynos5410_gate_clks,
205 ARRAY_SIZE(exynos5410_gate_clks));
206
207 pr_debug("Exynos5410: clock setup completed.\n");
208}
209CLK_OF_DECLARE(exynos5410_clk, "samsung,exynos5410-clock", exynos5410_clk_init);
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c
index 60b26819bed5..9d7d7eed03fd 100644
--- a/drivers/clk/samsung/clk-exynos5420.c
+++ b/drivers/clk/samsung/clk-exynos5420.c
@@ -27,18 +27,24 @@
27#define DIV_CPU1 0x504 27#define DIV_CPU1 0x504
28#define GATE_BUS_CPU 0x700 28#define GATE_BUS_CPU 0x700
29#define GATE_SCLK_CPU 0x800 29#define GATE_SCLK_CPU 0x800
30#define CLKOUT_CMU_CPU 0xa00
31#define GATE_IP_G2D 0x8800
30#define CPLL_LOCK 0x10020 32#define CPLL_LOCK 0x10020
31#define DPLL_LOCK 0x10030 33#define DPLL_LOCK 0x10030
32#define EPLL_LOCK 0x10040 34#define EPLL_LOCK 0x10040
33#define RPLL_LOCK 0x10050 35#define RPLL_LOCK 0x10050
34#define IPLL_LOCK 0x10060 36#define IPLL_LOCK 0x10060
35#define SPLL_LOCK 0x10070 37#define SPLL_LOCK 0x10070
36#define VPLL_LOCK 0x10070 38#define VPLL_LOCK 0x10080
37#define MPLL_LOCK 0x10090 39#define MPLL_LOCK 0x10090
38#define CPLL_CON0 0x10120 40#define CPLL_CON0 0x10120
39#define DPLL_CON0 0x10128 41#define DPLL_CON0 0x10128
40#define EPLL_CON0 0x10130 42#define EPLL_CON0 0x10130
43#define EPLL_CON1 0x10134
44#define EPLL_CON2 0x10138
41#define RPLL_CON0 0x10140 45#define RPLL_CON0 0x10140
46#define RPLL_CON1 0x10144
47#define RPLL_CON2 0x10148
42#define IPLL_CON0 0x10150 48#define IPLL_CON0 0x10150
43#define SPLL_CON0 0x10160 49#define SPLL_CON0 0x10160
44#define VPLL_CON0 0x10170 50#define VPLL_CON0 0x10170
@@ -51,21 +57,31 @@
51#define SRC_TOP5 0x10214 57#define SRC_TOP5 0x10214
52#define SRC_TOP6 0x10218 58#define SRC_TOP6 0x10218
53#define SRC_TOP7 0x1021c 59#define SRC_TOP7 0x1021c
60#define SRC_TOP8 0x10220 /* 5800 specific */
61#define SRC_TOP9 0x10224 /* 5800 specific */
54#define SRC_DISP10 0x1022c 62#define SRC_DISP10 0x1022c
55#define SRC_MAU 0x10240 63#define SRC_MAU 0x10240
56#define SRC_FSYS 0x10244 64#define SRC_FSYS 0x10244
57#define SRC_PERIC0 0x10250 65#define SRC_PERIC0 0x10250
58#define SRC_PERIC1 0x10254 66#define SRC_PERIC1 0x10254
67#define SRC_ISP 0x10270
68#define SRC_CAM 0x10274 /* 5800 specific */
59#define SRC_TOP10 0x10280 69#define SRC_TOP10 0x10280
60#define SRC_TOP11 0x10284 70#define SRC_TOP11 0x10284
61#define SRC_TOP12 0x10288 71#define SRC_TOP12 0x10288
62#define SRC_MASK_DISP10 0x1032c 72#define SRC_TOP13 0x1028c /* 5800 specific */
73#define SRC_MASK_TOP2 0x10308
74#define SRC_MASK_TOP7 0x1031c
75#define SRC_MASK_DISP10 0x1032c
76#define SRC_MASK_MAU 0x10334
63#define SRC_MASK_FSYS 0x10340 77#define SRC_MASK_FSYS 0x10340
64#define SRC_MASK_PERIC0 0x10350 78#define SRC_MASK_PERIC0 0x10350
65#define SRC_MASK_PERIC1 0x10354 79#define SRC_MASK_PERIC1 0x10354
66#define DIV_TOP0 0x10500 80#define DIV_TOP0 0x10500
67#define DIV_TOP1 0x10504 81#define DIV_TOP1 0x10504
68#define DIV_TOP2 0x10508 82#define DIV_TOP2 0x10508
83#define DIV_TOP8 0x10520 /* 5800 specific */
84#define DIV_TOP9 0x10524 /* 5800 specific */
69#define DIV_DISP10 0x1052c 85#define DIV_DISP10 0x1052c
70#define DIV_MAU 0x10544 86#define DIV_MAU 0x10544
71#define DIV_FSYS0 0x10548 87#define DIV_FSYS0 0x10548
@@ -76,54 +92,82 @@
76#define DIV_PERIC2 0x10560 92#define DIV_PERIC2 0x10560
77#define DIV_PERIC3 0x10564 93#define DIV_PERIC3 0x10564
78#define DIV_PERIC4 0x10568 94#define DIV_PERIC4 0x10568
95#define DIV_CAM 0x10574 /* 5800 specific */
96#define SCLK_DIV_ISP0 0x10580
97#define SCLK_DIV_ISP1 0x10584
98#define DIV2_RATIO0 0x10590
99#define DIV4_RATIO 0x105a0
79#define GATE_BUS_TOP 0x10700 100#define GATE_BUS_TOP 0x10700
101#define GATE_BUS_GEN 0x1073c
80#define GATE_BUS_FSYS0 0x10740 102#define GATE_BUS_FSYS0 0x10740
103#define GATE_BUS_FSYS2 0x10748
81#define GATE_BUS_PERIC 0x10750 104#define GATE_BUS_PERIC 0x10750
82#define GATE_BUS_PERIC1 0x10754 105#define GATE_BUS_PERIC1 0x10754
83#define GATE_BUS_PERIS0 0x10760 106#define GATE_BUS_PERIS0 0x10760
84#define GATE_BUS_PERIS1 0x10764 107#define GATE_BUS_PERIS1 0x10764
108#define GATE_BUS_NOC 0x10770
109#define GATE_TOP_SCLK_ISP 0x10870
85#define GATE_IP_GSCL0 0x10910 110#define GATE_IP_GSCL0 0x10910
86#define GATE_IP_GSCL1 0x10920 111#define GATE_IP_GSCL1 0x10920
112#define GATE_IP_CAM 0x10924 /* 5800 specific */
87#define GATE_IP_MFC 0x1092c 113#define GATE_IP_MFC 0x1092c
88#define GATE_IP_DISP1 0x10928 114#define GATE_IP_DISP1 0x10928
89#define GATE_IP_G3D 0x10930 115#define GATE_IP_G3D 0x10930
90#define GATE_IP_GEN 0x10934 116#define GATE_IP_GEN 0x10934
117#define GATE_IP_FSYS 0x10944
118#define GATE_IP_PERIC 0x10950
119#define GATE_IP_PERIS 0x10960
91#define GATE_IP_MSCL 0x10970 120#define GATE_IP_MSCL 0x10970
92#define GATE_TOP_SCLK_GSCL 0x10820 121#define GATE_TOP_SCLK_GSCL 0x10820
93#define GATE_TOP_SCLK_DISP1 0x10828 122#define GATE_TOP_SCLK_DISP1 0x10828
94#define GATE_TOP_SCLK_MAU 0x1083c 123#define GATE_TOP_SCLK_MAU 0x1083c
95#define GATE_TOP_SCLK_FSYS 0x10840 124#define GATE_TOP_SCLK_FSYS 0x10840
96#define GATE_TOP_SCLK_PERIC 0x10850 125#define GATE_TOP_SCLK_PERIC 0x10850
126#define TOP_SPARE2 0x10b08
97#define BPLL_LOCK 0x20010 127#define BPLL_LOCK 0x20010
98#define BPLL_CON0 0x20110 128#define BPLL_CON0 0x20110
99#define SRC_CDREX 0x20200
100#define KPLL_LOCK 0x28000 129#define KPLL_LOCK 0x28000
101#define KPLL_CON0 0x28100 130#define KPLL_CON0 0x28100
102#define SRC_KFC 0x28200 131#define SRC_KFC 0x28200
103#define DIV_KFC0 0x28500 132#define DIV_KFC0 0x28500
104 133
134/* Exynos5x SoC type */
135enum exynos5x_soc {
136 EXYNOS5420,
137 EXYNOS5800,
138};
139
105/* list of PLLs */ 140/* list of PLLs */
106enum exynos5420_plls { 141enum exynos5x_plls {
107 apll, cpll, dpll, epll, rpll, ipll, spll, vpll, mpll, 142 apll, cpll, dpll, epll, rpll, ipll, spll, vpll, mpll,
108 bpll, kpll, 143 bpll, kpll,
109 nr_plls /* number of PLLs */ 144 nr_plls /* number of PLLs */
110}; 145};
111 146
112static void __iomem *reg_base; 147static void __iomem *reg_base;
148static enum exynos5x_soc exynos5x_soc;
113 149
114#ifdef CONFIG_PM_SLEEP 150#ifdef CONFIG_PM_SLEEP
115static struct samsung_clk_reg_dump *exynos5420_save; 151static struct samsung_clk_reg_dump *exynos5x_save;
152static struct samsung_clk_reg_dump *exynos5800_save;
116 153
117/* 154/*
118 * list of controller registers to be saved and restored during a 155 * list of controller registers to be saved and restored during a
119 * suspend/resume cycle. 156 * suspend/resume cycle.
120 */ 157 */
121static unsigned long exynos5420_clk_regs[] __initdata = { 158static unsigned long exynos5x_clk_regs[] __initdata = {
122 SRC_CPU, 159 SRC_CPU,
123 DIV_CPU0, 160 DIV_CPU0,
124 DIV_CPU1, 161 DIV_CPU1,
125 GATE_BUS_CPU, 162 GATE_BUS_CPU,
126 GATE_SCLK_CPU, 163 GATE_SCLK_CPU,
164 CLKOUT_CMU_CPU,
165 EPLL_CON0,
166 EPLL_CON1,
167 EPLL_CON2,
168 RPLL_CON0,
169 RPLL_CON1,
170 RPLL_CON2,
127 SRC_TOP0, 171 SRC_TOP0,
128 SRC_TOP1, 172 SRC_TOP1,
129 SRC_TOP2, 173 SRC_TOP2,
@@ -140,10 +184,13 @@ static unsigned long exynos5420_clk_regs[] __initdata = {
140 SRC_TOP10, 184 SRC_TOP10,
141 SRC_TOP11, 185 SRC_TOP11,
142 SRC_TOP12, 186 SRC_TOP12,
187 SRC_MASK_TOP2,
188 SRC_MASK_TOP7,
143 SRC_MASK_DISP10, 189 SRC_MASK_DISP10,
144 SRC_MASK_FSYS, 190 SRC_MASK_FSYS,
145 SRC_MASK_PERIC0, 191 SRC_MASK_PERIC0,
146 SRC_MASK_PERIC1, 192 SRC_MASK_PERIC1,
193 SRC_ISP,
147 DIV_TOP0, 194 DIV_TOP0,
148 DIV_TOP1, 195 DIV_TOP1,
149 DIV_TOP2, 196 DIV_TOP2,
@@ -157,41 +204,71 @@ static unsigned long exynos5420_clk_regs[] __initdata = {
157 DIV_PERIC2, 204 DIV_PERIC2,
158 DIV_PERIC3, 205 DIV_PERIC3,
159 DIV_PERIC4, 206 DIV_PERIC4,
207 SCLK_DIV_ISP0,
208 SCLK_DIV_ISP1,
209 DIV2_RATIO0,
210 DIV4_RATIO,
160 GATE_BUS_TOP, 211 GATE_BUS_TOP,
212 GATE_BUS_GEN,
161 GATE_BUS_FSYS0, 213 GATE_BUS_FSYS0,
214 GATE_BUS_FSYS2,
162 GATE_BUS_PERIC, 215 GATE_BUS_PERIC,
163 GATE_BUS_PERIC1, 216 GATE_BUS_PERIC1,
164 GATE_BUS_PERIS0, 217 GATE_BUS_PERIS0,
165 GATE_BUS_PERIS1, 218 GATE_BUS_PERIS1,
219 GATE_BUS_NOC,
220 GATE_TOP_SCLK_ISP,
166 GATE_IP_GSCL0, 221 GATE_IP_GSCL0,
167 GATE_IP_GSCL1, 222 GATE_IP_GSCL1,
168 GATE_IP_MFC, 223 GATE_IP_MFC,
169 GATE_IP_DISP1, 224 GATE_IP_DISP1,
170 GATE_IP_G3D, 225 GATE_IP_G3D,
171 GATE_IP_GEN, 226 GATE_IP_GEN,
227 GATE_IP_FSYS,
228 GATE_IP_PERIC,
229 GATE_IP_PERIS,
172 GATE_IP_MSCL, 230 GATE_IP_MSCL,
173 GATE_TOP_SCLK_GSCL, 231 GATE_TOP_SCLK_GSCL,
174 GATE_TOP_SCLK_DISP1, 232 GATE_TOP_SCLK_DISP1,
175 GATE_TOP_SCLK_MAU, 233 GATE_TOP_SCLK_MAU,
176 GATE_TOP_SCLK_FSYS, 234 GATE_TOP_SCLK_FSYS,
177 GATE_TOP_SCLK_PERIC, 235 GATE_TOP_SCLK_PERIC,
178 SRC_CDREX, 236 TOP_SPARE2,
179 SRC_KFC, 237 SRC_KFC,
180 DIV_KFC0, 238 DIV_KFC0,
181}; 239};
182 240
241static unsigned long exynos5800_clk_regs[] __initdata = {
242 SRC_TOP8,
243 SRC_TOP9,
244 SRC_CAM,
245 SRC_TOP1,
246 DIV_TOP8,
247 DIV_TOP9,
248 DIV_CAM,
249 GATE_IP_CAM,
250};
251
183static int exynos5420_clk_suspend(void) 252static int exynos5420_clk_suspend(void)
184{ 253{
185 samsung_clk_save(reg_base, exynos5420_save, 254 samsung_clk_save(reg_base, exynos5x_save,
186 ARRAY_SIZE(exynos5420_clk_regs)); 255 ARRAY_SIZE(exynos5x_clk_regs));
256
257 if (exynos5x_soc == EXYNOS5800)
258 samsung_clk_save(reg_base, exynos5800_save,
259 ARRAY_SIZE(exynos5800_clk_regs));
187 260
188 return 0; 261 return 0;
189} 262}
190 263
191static void exynos5420_clk_resume(void) 264static void exynos5420_clk_resume(void)
192{ 265{
193 samsung_clk_restore(reg_base, exynos5420_save, 266 samsung_clk_restore(reg_base, exynos5x_save,
194 ARRAY_SIZE(exynos5420_clk_regs)); 267 ARRAY_SIZE(exynos5x_clk_regs));
268
269 if (exynos5x_soc == EXYNOS5800)
270 samsung_clk_restore(reg_base, exynos5800_save,
271 ARRAY_SIZE(exynos5800_clk_regs));
195} 272}
196 273
197static struct syscore_ops exynos5420_clk_syscore_ops = { 274static struct syscore_ops exynos5420_clk_syscore_ops = {
@@ -201,108 +278,183 @@ static struct syscore_ops exynos5420_clk_syscore_ops = {
201 278
202static void exynos5420_clk_sleep_init(void) 279static void exynos5420_clk_sleep_init(void)
203{ 280{
204 exynos5420_save = samsung_clk_alloc_reg_dump(exynos5420_clk_regs, 281 exynos5x_save = samsung_clk_alloc_reg_dump(exynos5x_clk_regs,
205 ARRAY_SIZE(exynos5420_clk_regs)); 282 ARRAY_SIZE(exynos5x_clk_regs));
206 if (!exynos5420_save) { 283 if (!exynos5x_save) {
207 pr_warn("%s: failed to allocate sleep save data, no sleep support!\n", 284 pr_warn("%s: failed to allocate sleep save data, no sleep support!\n",
208 __func__); 285 __func__);
209 return; 286 return;
210 } 287 }
211 288
289 if (exynos5x_soc == EXYNOS5800) {
290 exynos5800_save =
291 samsung_clk_alloc_reg_dump(exynos5800_clk_regs,
292 ARRAY_SIZE(exynos5800_clk_regs));
293 if (!exynos5800_save)
294 goto err_soc;
295 }
296
212 register_syscore_ops(&exynos5420_clk_syscore_ops); 297 register_syscore_ops(&exynos5420_clk_syscore_ops);
298 return;
299err_soc:
300 kfree(exynos5x_save);
301 pr_warn("%s: failed to allocate sleep save data, no sleep support!\n",
302 __func__);
303 return;
213} 304}
214#else 305#else
215static void exynos5420_clk_sleep_init(void) {} 306static void exynos5420_clk_sleep_init(void) {}
216#endif 307#endif
217 308
218/* list of all parent clocks */ 309/* list of all parent clocks */
219PNAME(mspll_cpu_p) = { "sclk_cpll", "sclk_dpll", 310PNAME(mout_mspll_cpu_p) = {"mout_sclk_cpll", "mout_sclk_dpll",
220 "sclk_mpll", "sclk_spll" }; 311 "mout_sclk_mpll", "mout_sclk_spll"};
221PNAME(cpu_p) = { "mout_apll" , "mout_mspll_cpu" }; 312PNAME(mout_cpu_p) = {"mout_apll" , "mout_mspll_cpu"};
222PNAME(kfc_p) = { "mout_kpll" , "mout_mspll_kfc" }; 313PNAME(mout_kfc_p) = {"mout_kpll" , "mout_mspll_kfc"};
223PNAME(apll_p) = { "fin_pll", "fout_apll", }; 314PNAME(mout_apll_p) = {"fin_pll", "fout_apll"};
224PNAME(bpll_p) = { "fin_pll", "fout_bpll", }; 315PNAME(mout_bpll_p) = {"fin_pll", "fout_bpll"};
225PNAME(cpll_p) = { "fin_pll", "fout_cpll", }; 316PNAME(mout_cpll_p) = {"fin_pll", "fout_cpll"};
226PNAME(dpll_p) = { "fin_pll", "fout_dpll", }; 317PNAME(mout_dpll_p) = {"fin_pll", "fout_dpll"};
227PNAME(epll_p) = { "fin_pll", "fout_epll", }; 318PNAME(mout_epll_p) = {"fin_pll", "fout_epll"};
228PNAME(ipll_p) = { "fin_pll", "fout_ipll", }; 319PNAME(mout_ipll_p) = {"fin_pll", "fout_ipll"};
229PNAME(kpll_p) = { "fin_pll", "fout_kpll", }; 320PNAME(mout_kpll_p) = {"fin_pll", "fout_kpll"};
230PNAME(mpll_p) = { "fin_pll", "fout_mpll", }; 321PNAME(mout_mpll_p) = {"fin_pll", "fout_mpll"};
231PNAME(rpll_p) = { "fin_pll", "fout_rpll", }; 322PNAME(mout_rpll_p) = {"fin_pll", "fout_rpll"};
232PNAME(spll_p) = { "fin_pll", "fout_spll", }; 323PNAME(mout_spll_p) = {"fin_pll", "fout_spll"};
233PNAME(vpll_p) = { "fin_pll", "fout_vpll", }; 324PNAME(mout_vpll_p) = {"fin_pll", "fout_vpll"};
234 325
235PNAME(group1_p) = { "sclk_cpll", "sclk_dpll", "sclk_mpll" }; 326PNAME(mout_group1_p) = {"mout_sclk_cpll", "mout_sclk_dpll",
236PNAME(group2_p) = { "fin_pll", "sclk_cpll", "sclk_dpll", "sclk_mpll", 327 "mout_sclk_mpll"};
237 "sclk_spll", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 328PNAME(mout_group2_p) = {"fin_pll", "mout_sclk_cpll",
238PNAME(group3_p) = { "sclk_rpll", "sclk_spll" }; 329 "mout_sclk_dpll", "mout_sclk_mpll", "mout_sclk_spll",
239PNAME(group4_p) = { "sclk_ipll", "sclk_dpll", "sclk_mpll" }; 330 "mout_sclk_ipll", "mout_sclk_epll", "mout_sclk_rpll"};
240PNAME(group5_p) = { "sclk_vpll", "sclk_dpll" }; 331PNAME(mout_group3_p) = {"mout_sclk_rpll", "mout_sclk_spll"};
241 332PNAME(mout_group4_p) = {"mout_sclk_ipll", "mout_sclk_dpll", "mout_sclk_mpll"};
242PNAME(sw_aclk66_p) = { "dout_aclk66", "sclk_spll" }; 333PNAME(mout_group5_p) = {"mout_sclk_vpll", "mout_sclk_dpll"};
243PNAME(aclk66_peric_p) = { "fin_pll", "mout_sw_aclk66" }; 334
244 335PNAME(mout_fimd1_final_p) = {"mout_fimd1", "mout_fimd1_opt"};
245PNAME(sw_aclk200_fsys_p) = { "dout_aclk200_fsys", "sclk_spll"}; 336PNAME(mout_sw_aclk66_p) = {"dout_aclk66", "mout_sclk_spll"};
246PNAME(user_aclk200_fsys_p) = { "fin_pll", "mout_sw_aclk200_fsys" }; 337PNAME(mout_user_aclk66_peric_p) = { "fin_pll", "mout_sw_aclk66"};
247 338PNAME(mout_user_pclk66_gpio_p) = {"mout_sw_aclk66", "ff_sw_aclk66"};
248PNAME(sw_aclk200_fsys2_p) = { "dout_aclk200_fsys2", "sclk_spll"}; 339
249PNAME(user_aclk200_fsys2_p) = { "fin_pll", "mout_sw_aclk200_fsys2" }; 340PNAME(mout_sw_aclk200_fsys_p) = {"dout_aclk200_fsys", "mout_sclk_spll"};
250 341PNAME(mout_sw_pclk200_fsys_p) = {"dout_pclk200_fsys", "mout_sclk_spll"};
251PNAME(sw_aclk200_p) = { "dout_aclk200", "sclk_spll"}; 342PNAME(mout_user_pclk200_fsys_p) = {"fin_pll", "mout_sw_pclk200_fsys"};
252PNAME(aclk200_disp1_p) = { "fin_pll", "mout_sw_aclk200" }; 343PNAME(mout_user_aclk200_fsys_p) = {"fin_pll", "mout_sw_aclk200_fsys"};
253 344
254PNAME(sw_aclk400_mscl_p) = { "dout_aclk400_mscl", "sclk_spll"}; 345PNAME(mout_sw_aclk200_fsys2_p) = {"dout_aclk200_fsys2", "mout_sclk_spll"};
255PNAME(user_aclk400_mscl_p) = { "fin_pll", "mout_sw_aclk400_mscl" }; 346PNAME(mout_user_aclk200_fsys2_p) = {"fin_pll", "mout_sw_aclk200_fsys2"};
256 347PNAME(mout_sw_aclk100_noc_p) = {"dout_aclk100_noc", "mout_sclk_spll"};
257PNAME(sw_aclk333_p) = { "dout_aclk333", "sclk_spll"}; 348PNAME(mout_user_aclk100_noc_p) = {"fin_pll", "mout_sw_aclk100_noc"};
258PNAME(user_aclk333_p) = { "fin_pll", "mout_sw_aclk333" }; 349
259 350PNAME(mout_sw_aclk400_wcore_p) = {"dout_aclk400_wcore", "mout_sclk_spll"};
260PNAME(sw_aclk166_p) = { "dout_aclk166", "sclk_spll"}; 351PNAME(mout_aclk400_wcore_bpll_p) = {"mout_aclk400_wcore", "sclk_bpll"};
261PNAME(user_aclk166_p) = { "fin_pll", "mout_sw_aclk166" }; 352PNAME(mout_user_aclk400_wcore_p) = {"fin_pll", "mout_sw_aclk400_wcore"};
262 353
263PNAME(sw_aclk266_p) = { "dout_aclk266", "sclk_spll"}; 354PNAME(mout_sw_aclk400_isp_p) = {"dout_aclk400_isp", "mout_sclk_spll"};
264PNAME(user_aclk266_p) = { "fin_pll", "mout_sw_aclk266" }; 355PNAME(mout_user_aclk400_isp_p) = {"fin_pll", "mout_sw_aclk400_isp"};
265 356
266PNAME(sw_aclk333_432_gscl_p) = { "dout_aclk333_432_gscl", "sclk_spll"}; 357PNAME(mout_sw_aclk333_432_isp0_p) = {"dout_aclk333_432_isp0",
267PNAME(user_aclk333_432_gscl_p) = { "fin_pll", "mout_sw_aclk333_432_gscl" }; 358 "mout_sclk_spll"};
268 359PNAME(mout_user_aclk333_432_isp0_p) = {"fin_pll", "mout_sw_aclk333_432_isp0"};
269PNAME(sw_aclk300_gscl_p) = { "dout_aclk300_gscl", "sclk_spll"}; 360
270PNAME(user_aclk300_gscl_p) = { "fin_pll", "mout_sw_aclk300_gscl" }; 361PNAME(mout_sw_aclk333_432_isp_p) = {"dout_aclk333_432_isp", "mout_sclk_spll"};
271 362PNAME(mout_user_aclk333_432_isp_p) = {"fin_pll", "mout_sw_aclk333_432_isp"};
272PNAME(sw_aclk300_disp1_p) = { "dout_aclk300_disp1", "sclk_spll"}; 363
273PNAME(user_aclk300_disp1_p) = { "fin_pll", "mout_sw_aclk300_disp1" }; 364PNAME(mout_sw_aclk200_p) = {"dout_aclk200", "mout_sclk_spll"};
274 365PNAME(mout_user_aclk200_disp1_p) = {"fin_pll", "mout_sw_aclk200"};
275PNAME(sw_aclk300_jpeg_p) = { "dout_aclk300_jpeg", "sclk_spll"}; 366
276PNAME(user_aclk300_jpeg_p) = { "fin_pll", "mout_sw_aclk300_jpeg" }; 367PNAME(mout_sw_aclk400_mscl_p) = {"dout_aclk400_mscl", "mout_sclk_spll"};
277 368PNAME(mout_user_aclk400_mscl_p) = {"fin_pll", "mout_sw_aclk400_mscl"};
278PNAME(sw_aclk_g3d_p) = { "dout_aclk_g3d", "sclk_spll"}; 369
279PNAME(user_aclk_g3d_p) = { "fin_pll", "mout_sw_aclk_g3d" }; 370PNAME(mout_sw_aclk333_p) = {"dout_aclk333", "mout_sclk_spll"};
280 371PNAME(mout_user_aclk333_p) = {"fin_pll", "mout_sw_aclk333"};
281PNAME(sw_aclk266_g2d_p) = { "dout_aclk266_g2d", "sclk_spll"}; 372
282PNAME(user_aclk266_g2d_p) = { "fin_pll", "mout_sw_aclk266_g2d" }; 373PNAME(mout_sw_aclk166_p) = {"dout_aclk166", "mout_sclk_spll"};
283 374PNAME(mout_user_aclk166_p) = {"fin_pll", "mout_sw_aclk166"};
284PNAME(sw_aclk333_g2d_p) = { "dout_aclk333_g2d", "sclk_spll"}; 375
285PNAME(user_aclk333_g2d_p) = { "fin_pll", "mout_sw_aclk333_g2d" }; 376PNAME(mout_sw_aclk266_p) = {"dout_aclk266", "mout_sclk_spll"};
286 377PNAME(mout_user_aclk266_p) = {"fin_pll", "mout_sw_aclk266"};
287PNAME(audio0_p) = { "fin_pll", "cdclk0", "sclk_dpll", "sclk_mpll", 378PNAME(mout_user_aclk266_isp_p) = {"fin_pll", "mout_sw_aclk266"};
288 "sclk_spll", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 379
289PNAME(audio1_p) = { "fin_pll", "cdclk1", "sclk_dpll", "sclk_mpll", 380PNAME(mout_sw_aclk333_432_gscl_p) = {"dout_aclk333_432_gscl", "mout_sclk_spll"};
290 "sclk_spll", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 381PNAME(mout_user_aclk333_432_gscl_p) = {"fin_pll", "mout_sw_aclk333_432_gscl"};
291PNAME(audio2_p) = { "fin_pll", "cdclk2", "sclk_dpll", "sclk_mpll", 382
292 "sclk_spll", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 383PNAME(mout_sw_aclk300_gscl_p) = {"dout_aclk300_gscl", "mout_sclk_spll"};
293PNAME(spdif_p) = { "fin_pll", "dout_audio0", "dout_audio1", "dout_audio2", 384PNAME(mout_user_aclk300_gscl_p) = {"fin_pll", "mout_sw_aclk300_gscl"};
294 "spdif_extclk", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 385
295PNAME(hdmi_p) = { "dout_hdmi_pixel", "sclk_hdmiphy" }; 386PNAME(mout_sw_aclk300_disp1_p) = {"dout_aclk300_disp1", "mout_sclk_spll"};
296PNAME(maudio0_p) = { "fin_pll", "maudio_clk", "sclk_dpll", "sclk_mpll", 387PNAME(mout_sw_aclk400_disp1_p) = {"dout_aclk400_disp1", "mout_sclk_spll"};
297 "sclk_spll", "sclk_ipll", "sclk_epll", "sclk_rpll" }; 388PNAME(mout_user_aclk300_disp1_p) = {"fin_pll", "mout_sw_aclk300_disp1"};
389PNAME(mout_user_aclk400_disp1_p) = {"fin_pll", "mout_sw_aclk400_disp1"};
390
391PNAME(mout_sw_aclk300_jpeg_p) = {"dout_aclk300_jpeg", "mout_sclk_spll"};
392PNAME(mout_user_aclk300_jpeg_p) = {"fin_pll", "mout_sw_aclk300_jpeg"};
393
394PNAME(mout_sw_aclk_g3d_p) = {"dout_aclk_g3d", "mout_sclk_spll"};
395PNAME(mout_user_aclk_g3d_p) = {"fin_pll", "mout_sw_aclk_g3d"};
396
397PNAME(mout_sw_aclk266_g2d_p) = {"dout_aclk266_g2d", "mout_sclk_spll"};
398PNAME(mout_user_aclk266_g2d_p) = {"fin_pll", "mout_sw_aclk266_g2d"};
399
400PNAME(mout_sw_aclk333_g2d_p) = {"dout_aclk333_g2d", "mout_sclk_spll"};
401PNAME(mout_user_aclk333_g2d_p) = {"fin_pll", "mout_sw_aclk333_g2d"};
402
403PNAME(mout_audio0_p) = {"fin_pll", "cdclk0", "mout_sclk_dpll",
404 "mout_sclk_mpll", "mout_sclk_spll", "mout_sclk_ipll",
405 "mout_sclk_epll", "mout_sclk_rpll"};
406PNAME(mout_audio1_p) = {"fin_pll", "cdclk1", "mout_sclk_dpll",
407 "mout_sclk_mpll", "mout_sclk_spll", "mout_sclk_ipll",
408 "mout_sclk_epll", "mout_sclk_rpll"};
409PNAME(mout_audio2_p) = {"fin_pll", "cdclk2", "mout_sclk_dpll",
410 "mout_sclk_mpll", "mout_sclk_spll", "mout_sclk_ipll",
411 "mout_sclk_epll", "mout_sclk_rpll"};
412PNAME(mout_spdif_p) = {"fin_pll", "dout_audio0", "dout_audio1",
413 "dout_audio2", "spdif_extclk", "mout_sclk_ipll",
414 "mout_sclk_epll", "mout_sclk_rpll"};
415PNAME(mout_hdmi_p) = {"dout_hdmi_pixel", "sclk_hdmiphy"};
416PNAME(mout_maudio0_p) = {"fin_pll", "maudio_clk", "mout_sclk_dpll",
417 "mout_sclk_mpll", "mout_sclk_spll", "mout_sclk_ipll",
418 "mout_sclk_epll", "mout_sclk_rpll"};
419PNAME(mout_mau_epll_clk_p) = {"mout_sclk_epll", "mout_sclk_dpll",
420 "mout_sclk_mpll", "mout_sclk_spll"};
421/* List of parents specific to exynos5800 */
422PNAME(mout_epll2_5800_p) = { "mout_sclk_epll", "ff_dout_epll2" };
423PNAME(mout_group1_5800_p) = { "mout_sclk_cpll", "mout_sclk_dpll",
424 "mout_sclk_mpll", "ff_dout_spll2" };
425PNAME(mout_group2_5800_p) = { "mout_sclk_cpll", "mout_sclk_dpll",
426 "mout_sclk_mpll", "ff_dout_spll2",
427 "mout_epll2", "mout_sclk_ipll" };
428PNAME(mout_group3_5800_p) = { "mout_sclk_cpll", "mout_sclk_dpll",
429 "mout_sclk_mpll", "ff_dout_spll2",
430 "mout_epll2" };
431PNAME(mout_group5_5800_p) = { "mout_sclk_cpll", "mout_sclk_dpll",
432 "mout_sclk_mpll", "mout_sclk_spll" };
433PNAME(mout_group6_5800_p) = { "mout_sclk_ipll", "mout_sclk_dpll",
434 "mout_sclk_mpll", "ff_dout_spll2" };
435PNAME(mout_group7_5800_p) = { "mout_sclk_cpll", "mout_sclk_dpll",
436 "mout_sclk_mpll", "mout_sclk_spll",
437 "mout_epll2", "mout_sclk_ipll" };
438PNAME(mout_mau_epll_clk_5800_p) = { "mout_sclk_epll", "mout_sclk_dpll",
439 "mout_sclk_mpll",
440 "ff_dout_spll2" };
441PNAME(mout_group8_5800_p) = { "dout_aclk432_scaler", "dout_sclk_sw" };
442PNAME(mout_group9_5800_p) = { "dout_osc_div", "mout_sw_aclk432_scaler" };
443PNAME(mout_group10_5800_p) = { "dout_aclk432_cam", "dout_sclk_sw" };
444PNAME(mout_group11_5800_p) = { "dout_osc_div", "mout_sw_aclk432_cam" };
445PNAME(mout_group12_5800_p) = { "dout_aclkfl1_550_cam", "dout_sclk_sw" };
446PNAME(mout_group13_5800_p) = { "dout_osc_div", "mout_sw_aclkfl1_550_cam" };
447PNAME(mout_group14_5800_p) = { "dout_aclk550_cam", "dout_sclk_sw" };
448PNAME(mout_group15_5800_p) = { "dout_osc_div", "mout_sw_aclk550_cam" };
298 449
299/* fixed rate clocks generated outside the soc */ 450/* fixed rate clocks generated outside the soc */
300static struct samsung_fixed_rate_clock exynos5420_fixed_rate_ext_clks[] __initdata = { 451static struct samsung_fixed_rate_clock
452 exynos5x_fixed_rate_ext_clks[] __initdata = {
301 FRATE(CLK_FIN_PLL, "fin_pll", NULL, CLK_IS_ROOT, 0), 453 FRATE(CLK_FIN_PLL, "fin_pll", NULL, CLK_IS_ROOT, 0),
302}; 454};
303 455
304/* fixed rate clocks generated inside the soc */ 456/* fixed rate clocks generated inside the soc */
305static struct samsung_fixed_rate_clock exynos5420_fixed_rate_clks[] __initdata = { 457static struct samsung_fixed_rate_clock exynos5x_fixed_rate_clks[] __initdata = {
306 FRATE(CLK_SCLK_HDMIPHY, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 24000000), 458 FRATE(CLK_SCLK_HDMIPHY, "sclk_hdmiphy", NULL, CLK_IS_ROOT, 24000000),
307 FRATE(0, "sclk_pwi", NULL, CLK_IS_ROOT, 24000000), 459 FRATE(0, "sclk_pwi", NULL, CLK_IS_ROOT, 24000000),
308 FRATE(0, "sclk_usbh20", NULL, CLK_IS_ROOT, 48000000), 460 FRATE(0, "sclk_usbh20", NULL, CLK_IS_ROOT, 48000000),
@@ -310,146 +462,309 @@ static struct samsung_fixed_rate_clock exynos5420_fixed_rate_clks[] __initdata =
310 FRATE(0, "sclk_usbh20_scan_clk", NULL, CLK_IS_ROOT, 480000000), 462 FRATE(0, "sclk_usbh20_scan_clk", NULL, CLK_IS_ROOT, 480000000),
311}; 463};
312 464
313static struct samsung_fixed_factor_clock exynos5420_fixed_factor_clks[] __initdata = { 465static struct samsung_fixed_factor_clock
314 FFACTOR(0, "sclk_hsic_12m", "fin_pll", 1, 2, 0), 466 exynos5x_fixed_factor_clks[] __initdata = {
467 FFACTOR(0, "ff_hsic_12m", "fin_pll", 1, 2, 0),
468 FFACTOR(0, "ff_sw_aclk66", "mout_sw_aclk66", 1, 2, 0),
315}; 469};
316 470
317static struct samsung_mux_clock exynos5420_mux_clks[] __initdata = { 471static struct samsung_fixed_factor_clock
318 MUX(0, "mout_mspll_kfc", mspll_cpu_p, SRC_TOP7, 8, 2), 472 exynos5800_fixed_factor_clks[] __initdata = {
319 MUX(0, "mout_mspll_cpu", mspll_cpu_p, SRC_TOP7, 12, 2), 473 FFACTOR(0, "ff_dout_epll2", "mout_sclk_epll", 1, 2, 0),
320 MUX(0, "mout_apll", apll_p, SRC_CPU, 0, 1), 474 FFACTOR(0, "ff_dout_spll2", "mout_sclk_spll", 1, 2, 0),
321 MUX(0, "mout_cpu", cpu_p, SRC_CPU, 16, 1), 475};
322 MUX(0, "mout_kpll", kpll_p, SRC_KFC, 0, 1), 476
323 MUX(0, "mout_cpu_kfc", kfc_p, SRC_KFC, 16, 1), 477struct samsung_mux_clock exynos5800_mux_clks[] __initdata = {
324 478 MUX(0, "mout_aclk400_isp", mout_group3_5800_p, SRC_TOP0, 0, 3),
325 MUX(0, "sclk_bpll", bpll_p, SRC_CDREX, 0, 1), 479 MUX(0, "mout_aclk400_mscl", mout_group3_5800_p, SRC_TOP0, 4, 3),
326 480 MUX(0, "mout_aclk400_wcore", mout_group2_5800_p, SRC_TOP0, 16, 3),
327 MUX_A(0, "mout_aclk400_mscl", group1_p, 481 MUX(0, "mout_aclk100_noc", mout_group1_5800_p, SRC_TOP0, 20, 2),
328 SRC_TOP0, 4, 2, "aclk400_mscl"), 482
329 MUX(0, "mout_aclk200", group1_p, SRC_TOP0, 8, 2), 483 MUX(0, "mout_aclk333_432_gscl", mout_group6_5800_p, SRC_TOP1, 0, 2),
330 MUX(0, "mout_aclk200_fsys2", group1_p, SRC_TOP0, 12, 2), 484 MUX(0, "mout_aclk333_432_isp", mout_group6_5800_p, SRC_TOP1, 4, 2),
331 MUX(0, "mout_aclk200_fsys", group1_p, SRC_TOP0, 28, 2), 485 MUX(0, "mout_aclk333_432_isp0", mout_group6_5800_p, SRC_TOP1, 12, 2),
332 486 MUX(0, "mout_aclk266", mout_group5_5800_p, SRC_TOP1, 20, 2),
333 MUX(0, "mout_aclk333_432_gscl", group4_p, SRC_TOP1, 0, 2), 487 MUX(0, "mout_aclk333", mout_group1_5800_p, SRC_TOP1, 28, 2),
334 MUX(0, "mout_aclk66", group1_p, SRC_TOP1, 8, 2), 488
335 MUX(0, "mout_aclk266", group1_p, SRC_TOP1, 20, 2), 489 MUX(0, "mout_aclk400_disp1", mout_group7_5800_p, SRC_TOP2, 4, 3),
336 MUX(0, "mout_aclk166", group1_p, SRC_TOP1, 24, 2), 490 MUX(0, "mout_aclk333_g2d", mout_group5_5800_p, SRC_TOP2, 8, 2),
337 MUX(0, "mout_aclk333", group1_p, SRC_TOP1, 28, 2), 491 MUX(0, "mout_aclk266_g2d", mout_group5_5800_p, SRC_TOP2, 12, 2),
338 492 MUX(0, "mout_aclk300_jpeg", mout_group5_5800_p, SRC_TOP2, 20, 2),
339 MUX(0, "mout_aclk333_g2d", group1_p, SRC_TOP2, 8, 2), 493 MUX(0, "mout_aclk300_disp1", mout_group5_5800_p, SRC_TOP2, 24, 2),
340 MUX(0, "mout_aclk266_g2d", group1_p, SRC_TOP2, 12, 2), 494 MUX(0, "mout_aclk300_gscl", mout_group5_5800_p, SRC_TOP2, 28, 2),
341 MUX(0, "mout_aclk_g3d", group5_p, SRC_TOP2, 16, 1), 495
342 MUX(0, "mout_aclk300_jpeg", group1_p, SRC_TOP2, 20, 2), 496 MUX(0, "mout_mau_epll_clk", mout_mau_epll_clk_5800_p, SRC_TOP7,
343 MUX(0, "mout_aclk300_disp1", group1_p, SRC_TOP2, 24, 2), 497 20, 2),
344 MUX(0, "mout_aclk300_gscl", group1_p, SRC_TOP2, 28, 2), 498 MUX(0, "sclk_bpll", mout_bpll_p, SRC_TOP7, 24, 1),
345 499 MUX(0, "mout_epll2", mout_epll2_5800_p, SRC_TOP7, 28, 1),
346 MUX(0, "mout_user_aclk400_mscl", user_aclk400_mscl_p, 500
501 MUX(0, "mout_aclk550_cam", mout_group3_5800_p, SRC_TOP8, 16, 3),
502 MUX(0, "mout_aclkfl1_550_cam", mout_group3_5800_p, SRC_TOP8, 20, 3),
503 MUX(0, "mout_aclk432_cam", mout_group6_5800_p, SRC_TOP8, 24, 2),
504 MUX(0, "mout_aclk432_scaler", mout_group6_5800_p, SRC_TOP8, 28, 2),
505
506 MUX(0, "mout_user_aclk550_cam", mout_group15_5800_p,
507 SRC_TOP9, 16, 1),
508 MUX(0, "mout_user_aclkfl1_550_cam", mout_group13_5800_p,
509 SRC_TOP9, 20, 1),
510 MUX(0, "mout_user_aclk432_cam", mout_group11_5800_p,
511 SRC_TOP9, 24, 1),
512 MUX(0, "mout_user_aclk432_scaler", mout_group9_5800_p,
513 SRC_TOP9, 28, 1),
514
515 MUX(0, "mout_sw_aclk550_cam", mout_group14_5800_p, SRC_TOP13, 16, 1),
516 MUX(0, "mout_sw_aclkfl1_550_cam", mout_group12_5800_p,
517 SRC_TOP13, 20, 1),
518 MUX(0, "mout_sw_aclk432_cam", mout_group10_5800_p,
519 SRC_TOP13, 24, 1),
520 MUX(0, "mout_sw_aclk432_scaler", mout_group8_5800_p,
521 SRC_TOP13, 28, 1),
522
523 MUX(0, "mout_fimd1", mout_group2_p, SRC_DISP10, 4, 3),
524};
525
526struct samsung_div_clock exynos5800_div_clks[] __initdata = {
527 DIV(0, "dout_aclk400_wcore", "mout_aclk400_wcore", DIV_TOP0, 16, 3),
528
529 DIV(0, "dout_aclk550_cam", "mout_aclk550_cam",
530 DIV_TOP8, 16, 3),
531 DIV(0, "dout_aclkfl1_550_cam", "mout_aclkfl1_550_cam",
532 DIV_TOP8, 20, 3),
533 DIV(0, "dout_aclk432_cam", "mout_aclk432_cam",
534 DIV_TOP8, 24, 3),
535 DIV(0, "dout_aclk432_scaler", "mout_aclk432_scaler",
536 DIV_TOP8, 28, 3),
537
538 DIV(0, "dout_osc_div", "fin_pll", DIV_TOP9, 20, 3),
539 DIV(0, "dout_sclk_sw", "sclk_spll", DIV_TOP9, 24, 6),
540};
541
542struct samsung_gate_clock exynos5800_gate_clks[] __initdata = {
543 GATE(CLK_ACLK550_CAM, "aclk550_cam", "mout_user_aclk550_cam",
544 GATE_BUS_TOP, 24, 0, 0),
545 GATE(CLK_ACLK432_SCALER, "aclk432_scaler", "mout_user_aclk432_scaler",
546 GATE_BUS_TOP, 27, 0, 0),
547};
548
549struct samsung_mux_clock exynos5420_mux_clks[] __initdata = {
550 MUX(0, "sclk_bpll", mout_bpll_p, TOP_SPARE2, 0, 1),
551 MUX(0, "mout_aclk400_wcore_bpll", mout_aclk400_wcore_bpll_p,
552 TOP_SPARE2, 4, 1),
553
554 MUX(0, "mout_aclk400_isp", mout_group1_p, SRC_TOP0, 0, 2),
555 MUX_A(0, "mout_aclk400_mscl", mout_group1_p,
556 SRC_TOP0, 4, 2, "aclk400_mscl"),
557 MUX(0, "mout_aclk400_wcore", mout_group1_p, SRC_TOP0, 16, 2),
558 MUX(0, "mout_aclk100_noc", mout_group1_p, SRC_TOP0, 20, 2),
559
560 MUX(0, "mout_aclk333_432_gscl", mout_group4_p, SRC_TOP1, 0, 2),
561 MUX(0, "mout_aclk333_432_isp", mout_group4_p,
562 SRC_TOP1, 4, 2),
563 MUX(0, "mout_aclk333_432_isp0", mout_group4_p, SRC_TOP1, 12, 2),
564 MUX(0, "mout_aclk266", mout_group1_p, SRC_TOP1, 20, 2),
565 MUX(0, "mout_aclk333", mout_group1_p, SRC_TOP1, 28, 2),
566
567 MUX(0, "mout_aclk400_disp1", mout_group1_p, SRC_TOP2, 4, 2),
568 MUX(0, "mout_aclk333_g2d", mout_group1_p, SRC_TOP2, 8, 2),
569 MUX(0, "mout_aclk266_g2d", mout_group1_p, SRC_TOP2, 12, 2),
570 MUX(0, "mout_aclk300_jpeg", mout_group1_p, SRC_TOP2, 20, 2),
571 MUX(0, "mout_aclk300_disp1", mout_group1_p, SRC_TOP2, 24, 2),
572 MUX(0, "mout_aclk300_gscl", mout_group1_p, SRC_TOP2, 28, 2),
573
574 MUX(0, "mout_mau_epll_clk", mout_mau_epll_clk_p, SRC_TOP7, 20, 2),
575
576 MUX(0, "mout_fimd1", mout_group3_p, SRC_DISP10, 4, 1),
577};
578
579struct samsung_div_clock exynos5420_div_clks[] __initdata = {
580 DIV(0, "dout_aclk400_wcore", "mout_aclk400_wcore_bpll",
581 DIV_TOP0, 16, 3),
582};
583
584static struct samsung_mux_clock exynos5x_mux_clks[] __initdata = {
585 MUX(0, "mout_user_pclk66_gpio", mout_user_pclk66_gpio_p,
586 SRC_TOP7, 4, 1),
587 MUX(0, "mout_mspll_kfc", mout_mspll_cpu_p, SRC_TOP7, 8, 2),
588 MUX(0, "mout_mspll_cpu", mout_mspll_cpu_p, SRC_TOP7, 12, 2),
589
590 MUX(0, "mout_apll", mout_apll_p, SRC_CPU, 0, 1),
591 MUX(0, "mout_cpu", mout_cpu_p, SRC_CPU, 16, 1),
592 MUX(0, "mout_kpll", mout_kpll_p, SRC_KFC, 0, 1),
593 MUX(0, "mout_kfc", mout_kfc_p, SRC_KFC, 16, 1),
594
595 MUX(0, "mout_aclk200", mout_group1_p, SRC_TOP0, 8, 2),
596 MUX(0, "mout_aclk200_fsys2", mout_group1_p, SRC_TOP0, 12, 2),
597 MUX(0, "mout_pclk200_fsys", mout_group1_p, SRC_TOP0, 24, 2),
598 MUX(0, "mout_aclk200_fsys", mout_group1_p, SRC_TOP0, 28, 2),
599
600 MUX(0, "mout_aclk66", mout_group1_p, SRC_TOP1, 8, 2),
601 MUX(0, "mout_aclk166", mout_group1_p, SRC_TOP1, 24, 2),
602
603 MUX(0, "mout_aclk_g3d", mout_group5_p, SRC_TOP2, 16, 1),
604
605 MUX(0, "mout_user_aclk400_isp", mout_user_aclk400_isp_p,
606 SRC_TOP3, 0, 1),
607 MUX(0, "mout_user_aclk400_mscl", mout_user_aclk400_mscl_p,
347 SRC_TOP3, 4, 1), 608 SRC_TOP3, 4, 1),
348 MUX_A(0, "mout_aclk200_disp1", aclk200_disp1_p, 609 MUX(0, "mout_user_aclk200_disp1", mout_user_aclk200_disp1_p,
349 SRC_TOP3, 8, 1, "aclk200_disp1"), 610 SRC_TOP3, 8, 1),
350 MUX(0, "mout_user_aclk200_fsys2", user_aclk200_fsys2_p, 611 MUX(0, "mout_user_aclk200_fsys2", mout_user_aclk200_fsys2_p,
351 SRC_TOP3, 12, 1), 612 SRC_TOP3, 12, 1),
352 MUX(0, "mout_user_aclk200_fsys", user_aclk200_fsys_p, 613 MUX(0, "mout_user_aclk400_wcore", mout_user_aclk400_wcore_p,
614 SRC_TOP3, 16, 1),
615 MUX(0, "mout_user_aclk100_noc", mout_user_aclk100_noc_p,
616 SRC_TOP3, 20, 1),
617 MUX(0, "mout_user_pclk200_fsys", mout_user_pclk200_fsys_p,
618 SRC_TOP3, 24, 1),
619 MUX(0, "mout_user_aclk200_fsys", mout_user_aclk200_fsys_p,
353 SRC_TOP3, 28, 1), 620 SRC_TOP3, 28, 1),
354 621
355 MUX(0, "mout_user_aclk333_432_gscl", user_aclk333_432_gscl_p, 622 MUX(0, "mout_user_aclk333_432_gscl", mout_user_aclk333_432_gscl_p,
356 SRC_TOP4, 0, 1), 623 SRC_TOP4, 0, 1),
357 MUX(0, "mout_aclk66_peric", aclk66_peric_p, SRC_TOP4, 8, 1), 624 MUX(0, "mout_user_aclk333_432_isp", mout_user_aclk333_432_isp_p,
358 MUX(0, "mout_user_aclk266", user_aclk266_p, SRC_TOP4, 20, 1), 625 SRC_TOP4, 4, 1),
359 MUX(0, "mout_user_aclk166", user_aclk166_p, SRC_TOP4, 24, 1), 626 MUX(0, "mout_user_aclk66_peric", mout_user_aclk66_peric_p,
360 MUX(0, "mout_user_aclk333", user_aclk333_p, SRC_TOP4, 28, 1), 627 SRC_TOP4, 8, 1),
361 628 MUX(0, "mout_user_aclk333_432_isp0", mout_user_aclk333_432_isp0_p,
362 MUX(0, "mout_aclk66_psgen", aclk66_peric_p, SRC_TOP5, 4, 1), 629 SRC_TOP4, 12, 1),
363 MUX(0, "mout_user_aclk333_g2d", user_aclk333_g2d_p, SRC_TOP5, 8, 1), 630 MUX(0, "mout_user_aclk266_isp", mout_user_aclk266_isp_p,
364 MUX(0, "mout_user_aclk266_g2d", user_aclk266_g2d_p, SRC_TOP5, 12, 1), 631 SRC_TOP4, 16, 1),
365 MUX_A(0, "mout_user_aclk_g3d", user_aclk_g3d_p, 632 MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1),
366 SRC_TOP5, 16, 1, "aclkg3d"), 633 MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1),
367 MUX(0, "mout_user_aclk300_jpeg", user_aclk300_jpeg_p, 634 MUX(0, "mout_user_aclk333", mout_user_aclk333_p, SRC_TOP4, 28, 1),
635
636 MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p,
637 SRC_TOP5, 0, 1),
638 MUX(0, "mout_user_aclk66_psgen", mout_user_aclk66_peric_p,
639 SRC_TOP5, 4, 1),
640 MUX(0, "mout_user_aclk333_g2d", mout_user_aclk333_g2d_p,
641 SRC_TOP5, 8, 1),
642 MUX(0, "mout_user_aclk266_g2d", mout_user_aclk266_g2d_p,
643 SRC_TOP5, 12, 1),
644 MUX(CLK_MOUT_G3D, "mout_user_aclk_g3d", mout_user_aclk_g3d_p,
645 SRC_TOP5, 16, 1),
646 MUX(0, "mout_user_aclk300_jpeg", mout_user_aclk300_jpeg_p,
368 SRC_TOP5, 20, 1), 647 SRC_TOP5, 20, 1),
369 MUX(0, "mout_user_aclk300_disp1", user_aclk300_disp1_p, 648 MUX(0, "mout_user_aclk300_disp1", mout_user_aclk300_disp1_p,
370 SRC_TOP5, 24, 1), 649 SRC_TOP5, 24, 1),
371 MUX(0, "mout_user_aclk300_gscl", user_aclk300_gscl_p, 650 MUX(0, "mout_user_aclk300_gscl", mout_user_aclk300_gscl_p,
372 SRC_TOP5, 28, 1), 651 SRC_TOP5, 28, 1),
373 652
374 MUX(0, "sclk_mpll", mpll_p, SRC_TOP6, 0, 1), 653 MUX(0, "mout_sclk_mpll", mout_mpll_p, SRC_TOP6, 0, 1),
375 MUX(0, "sclk_vpll", vpll_p, SRC_TOP6, 4, 1), 654 MUX(CLK_MOUT_VPLL, "mout_sclk_vpll", mout_vpll_p, SRC_TOP6, 4, 1),
376 MUX(0, "sclk_spll", spll_p, SRC_TOP6, 8, 1), 655 MUX(0, "mout_sclk_spll", mout_spll_p, SRC_TOP6, 8, 1),
377 MUX(0, "sclk_ipll", ipll_p, SRC_TOP6, 12, 1), 656 MUX(0, "mout_sclk_ipll", mout_ipll_p, SRC_TOP6, 12, 1),
378 MUX(0, "sclk_rpll", rpll_p, SRC_TOP6, 16, 1), 657 MUX(0, "mout_sclk_rpll", mout_rpll_p, SRC_TOP6, 16, 1),
379 MUX(0, "sclk_epll", epll_p, SRC_TOP6, 20, 1), 658 MUX(0, "mout_sclk_epll", mout_epll_p, SRC_TOP6, 20, 1),
380 MUX(0, "sclk_dpll", dpll_p, SRC_TOP6, 24, 1), 659 MUX(0, "mout_sclk_dpll", mout_dpll_p, SRC_TOP6, 24, 1),
381 MUX(0, "sclk_cpll", cpll_p, SRC_TOP6, 28, 1), 660 MUX(0, "mout_sclk_cpll", mout_cpll_p, SRC_TOP6, 28, 1),
382 661
383 MUX(0, "mout_sw_aclk400_mscl", sw_aclk400_mscl_p, SRC_TOP10, 4, 1), 662 MUX(0, "mout_sw_aclk400_isp", mout_sw_aclk400_isp_p,
384 MUX(0, "mout_sw_aclk200", sw_aclk200_p, SRC_TOP10, 8, 1), 663 SRC_TOP10, 0, 1),
385 MUX(0, "mout_sw_aclk200_fsys2", sw_aclk200_fsys2_p, 664 MUX(0, "mout_sw_aclk400_mscl", mout_sw_aclk400_mscl_p,
665 SRC_TOP10, 4, 1),
666 MUX(0, "mout_sw_aclk200", mout_sw_aclk200_p, SRC_TOP10, 8, 1),
667 MUX(0, "mout_sw_aclk200_fsys2", mout_sw_aclk200_fsys2_p,
386 SRC_TOP10, 12, 1), 668 SRC_TOP10, 12, 1),
387 MUX(0, "mout_sw_aclk200_fsys", sw_aclk200_fsys_p, SRC_TOP10, 28, 1), 669 MUX(0, "mout_sw_aclk400_wcore", mout_sw_aclk400_wcore_p,
388 670 SRC_TOP10, 16, 1),
389 MUX(0, "mout_sw_aclk333_432_gscl", sw_aclk333_432_gscl_p, 671 MUX(0, "mout_sw_aclk100_noc", mout_sw_aclk100_noc_p,
672 SRC_TOP10, 20, 1),
673 MUX(0, "mout_sw_pclk200_fsys", mout_sw_pclk200_fsys_p,
674 SRC_TOP10, 24, 1),
675 MUX(0, "mout_sw_aclk200_fsys", mout_sw_aclk200_fsys_p,
676 SRC_TOP10, 28, 1),
677
678 MUX(0, "mout_sw_aclk333_432_gscl", mout_sw_aclk333_432_gscl_p,
390 SRC_TOP11, 0, 1), 679 SRC_TOP11, 0, 1),
391 MUX(0, "mout_sw_aclk66", sw_aclk66_p, SRC_TOP11, 8, 1), 680 MUX(0, "mout_sw_aclk333_432_isp", mout_sw_aclk333_432_isp_p,
392 MUX(0, "mout_sw_aclk266", sw_aclk266_p, SRC_TOP11, 20, 1), 681 SRC_TOP11, 4, 1),
393 MUX(0, "mout_sw_aclk166", sw_aclk166_p, SRC_TOP11, 24, 1), 682 MUX(0, "mout_sw_aclk66", mout_sw_aclk66_p, SRC_TOP11, 8, 1),
394 MUX(0, "mout_sw_aclk333", sw_aclk333_p, SRC_TOP11, 28, 1), 683 MUX(0, "mout_sw_aclk333_432_isp0", mout_sw_aclk333_432_isp0_p,
395 684 SRC_TOP11, 12, 1),
396 MUX(0, "mout_sw_aclk333_g2d", sw_aclk333_g2d_p, SRC_TOP12, 8, 1), 685 MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1),
397 MUX(0, "mout_sw_aclk266_g2d", sw_aclk266_g2d_p, SRC_TOP12, 12, 1), 686 MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1),
398 MUX(0, "mout_sw_aclk_g3d", sw_aclk_g3d_p, SRC_TOP12, 16, 1), 687 MUX(0, "mout_sw_aclk333", mout_sw_aclk333_p, SRC_TOP11, 28, 1),
399 MUX(0, "mout_sw_aclk300_jpeg", sw_aclk300_jpeg_p, SRC_TOP12, 20, 1), 688
400 MUX(0, "mout_sw_aclk300_disp1", sw_aclk300_disp1_p, 689 MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p,
690 SRC_TOP12, 4, 1),
691 MUX(0, "mout_sw_aclk333_g2d", mout_sw_aclk333_g2d_p,
692 SRC_TOP12, 8, 1),
693 MUX(0, "mout_sw_aclk266_g2d", mout_sw_aclk266_g2d_p,
694 SRC_TOP12, 12, 1),
695 MUX(0, "mout_sw_aclk_g3d", mout_sw_aclk_g3d_p, SRC_TOP12, 16, 1),
696 MUX(0, "mout_sw_aclk300_jpeg", mout_sw_aclk300_jpeg_p,
697 SRC_TOP12, 20, 1),
698 MUX(0, "mout_sw_aclk300_disp1", mout_sw_aclk300_disp1_p,
401 SRC_TOP12, 24, 1), 699 SRC_TOP12, 24, 1),
402 MUX(0, "mout_sw_aclk300_gscl", sw_aclk300_gscl_p, SRC_TOP12, 28, 1), 700 MUX(0, "mout_sw_aclk300_gscl", mout_sw_aclk300_gscl_p,
701 SRC_TOP12, 28, 1),
403 702
404 /* DISP1 Block */ 703 /* DISP1 Block */
405 MUX(0, "mout_fimd1", group3_p, SRC_DISP10, 4, 1), 704 MUX(0, "mout_mipi1", mout_group2_p, SRC_DISP10, 16, 3),
406 MUX(0, "mout_mipi1", group2_p, SRC_DISP10, 16, 3), 705 MUX(0, "mout_dp1", mout_group2_p, SRC_DISP10, 20, 3),
407 MUX(0, "mout_dp1", group2_p, SRC_DISP10, 20, 3), 706 MUX(0, "mout_pixel", mout_group2_p, SRC_DISP10, 24, 3),
408 MUX(0, "mout_pixel", group2_p, SRC_DISP10, 24, 3), 707 MUX(CLK_MOUT_HDMI, "mout_hdmi", mout_hdmi_p, SRC_DISP10, 28, 1),
409 MUX(CLK_MOUT_HDMI, "mout_hdmi", hdmi_p, SRC_DISP10, 28, 1), 708 MUX(0, "mout_fimd1_opt", mout_group2_p, SRC_DISP10, 8, 3),
709
710 MUX(0, "mout_fimd1_final", mout_fimd1_final_p, TOP_SPARE2, 8, 1),
410 711
411 /* MAU Block */ 712 /* MAU Block */
412 MUX(0, "mout_maudio0", maudio0_p, SRC_MAU, 28, 3), 713 MUX(CLK_MOUT_MAUDIO0, "mout_maudio0", mout_maudio0_p, SRC_MAU, 28, 3),
413 714
414 /* FSYS Block */ 715 /* FSYS Block */
415 MUX(0, "mout_usbd301", group2_p, SRC_FSYS, 4, 3), 716 MUX(0, "mout_usbd301", mout_group2_p, SRC_FSYS, 4, 3),
416 MUX(0, "mout_mmc0", group2_p, SRC_FSYS, 8, 3), 717 MUX(0, "mout_mmc0", mout_group2_p, SRC_FSYS, 8, 3),
417 MUX(0, "mout_mmc1", group2_p, SRC_FSYS, 12, 3), 718 MUX(0, "mout_mmc1", mout_group2_p, SRC_FSYS, 12, 3),
418 MUX(0, "mout_mmc2", group2_p, SRC_FSYS, 16, 3), 719 MUX(0, "mout_mmc2", mout_group2_p, SRC_FSYS, 16, 3),
419 MUX(0, "mout_usbd300", group2_p, SRC_FSYS, 20, 3), 720 MUX(0, "mout_usbd300", mout_group2_p, SRC_FSYS, 20, 3),
420 MUX(0, "mout_unipro", group2_p, SRC_FSYS, 24, 3), 721 MUX(0, "mout_unipro", mout_group2_p, SRC_FSYS, 24, 3),
722 MUX(0, "mout_mphy_refclk", mout_group2_p, SRC_FSYS, 28, 3),
421 723
422 /* PERIC Block */ 724 /* PERIC Block */
423 MUX(0, "mout_uart0", group2_p, SRC_PERIC0, 4, 3), 725 MUX(0, "mout_uart0", mout_group2_p, SRC_PERIC0, 4, 3),
424 MUX(0, "mout_uart1", group2_p, SRC_PERIC0, 8, 3), 726 MUX(0, "mout_uart1", mout_group2_p, SRC_PERIC0, 8, 3),
425 MUX(0, "mout_uart2", group2_p, SRC_PERIC0, 12, 3), 727 MUX(0, "mout_uart2", mout_group2_p, SRC_PERIC0, 12, 3),
426 MUX(0, "mout_uart3", group2_p, SRC_PERIC0, 16, 3), 728 MUX(0, "mout_uart3", mout_group2_p, SRC_PERIC0, 16, 3),
427 MUX(0, "mout_pwm", group2_p, SRC_PERIC0, 24, 3), 729 MUX(0, "mout_pwm", mout_group2_p, SRC_PERIC0, 24, 3),
428 MUX(0, "mout_spdif", spdif_p, SRC_PERIC0, 28, 3), 730 MUX(0, "mout_spdif", mout_spdif_p, SRC_PERIC0, 28, 3),
429 MUX(0, "mout_audio0", audio0_p, SRC_PERIC1, 8, 3), 731 MUX(0, "mout_audio0", mout_audio0_p, SRC_PERIC1, 8, 3),
430 MUX(0, "mout_audio1", audio1_p, SRC_PERIC1, 12, 3), 732 MUX(0, "mout_audio1", mout_audio1_p, SRC_PERIC1, 12, 3),
431 MUX(0, "mout_audio2", audio2_p, SRC_PERIC1, 16, 3), 733 MUX(0, "mout_audio2", mout_audio2_p, SRC_PERIC1, 16, 3),
432 MUX(0, "mout_spi0", group2_p, SRC_PERIC1, 20, 3), 734 MUX(0, "mout_spi0", mout_group2_p, SRC_PERIC1, 20, 3),
433 MUX(0, "mout_spi1", group2_p, SRC_PERIC1, 24, 3), 735 MUX(0, "mout_spi1", mout_group2_p, SRC_PERIC1, 24, 3),
434 MUX(0, "mout_spi2", group2_p, SRC_PERIC1, 28, 3), 736 MUX(0, "mout_spi2", mout_group2_p, SRC_PERIC1, 28, 3),
737
738 /* ISP Block */
739 MUX(0, "mout_pwm_isp", mout_group2_p, SRC_ISP, 24, 3),
740 MUX(0, "mout_uart_isp", mout_group2_p, SRC_ISP, 20, 3),
741 MUX(0, "mout_spi0_isp", mout_group2_p, SRC_ISP, 12, 3),
742 MUX(0, "mout_spi1_isp", mout_group2_p, SRC_ISP, 16, 3),
743 MUX(0, "mout_isp_sensor", mout_group2_p, SRC_ISP, 28, 3),
435}; 744};
436 745
437static struct samsung_div_clock exynos5420_div_clks[] __initdata = { 746static struct samsung_div_clock exynos5x_div_clks[] __initdata = {
438 DIV(0, "div_arm", "mout_cpu", DIV_CPU0, 0, 3), 747 DIV(0, "div_arm", "mout_cpu", DIV_CPU0, 0, 3),
439 DIV(0, "sclk_apll", "mout_apll", DIV_CPU0, 24, 3), 748 DIV(0, "sclk_apll", "mout_apll", DIV_CPU0, 24, 3),
440 DIV(0, "armclk2", "div_arm", DIV_CPU0, 28, 3), 749 DIV(0, "armclk2", "div_arm", DIV_CPU0, 28, 3),
441 DIV(0, "div_kfc", "mout_cpu_kfc", DIV_KFC0, 0, 3), 750 DIV(0, "div_kfc", "mout_kfc", DIV_KFC0, 0, 3),
442 DIV(0, "sclk_kpll", "mout_kpll", DIV_KFC0, 24, 3), 751 DIV(0, "sclk_kpll", "mout_kpll", DIV_KFC0, 24, 3),
443 752
753 DIV(0, "dout_aclk400_isp", "mout_aclk400_isp", DIV_TOP0, 0, 3),
444 DIV(0, "dout_aclk400_mscl", "mout_aclk400_mscl", DIV_TOP0, 4, 3), 754 DIV(0, "dout_aclk400_mscl", "mout_aclk400_mscl", DIV_TOP0, 4, 3),
445 DIV(0, "dout_aclk200", "mout_aclk200", DIV_TOP0, 8, 3), 755 DIV(0, "dout_aclk200", "mout_aclk200", DIV_TOP0, 8, 3),
446 DIV(0, "dout_aclk200_fsys2", "mout_aclk200_fsys2", DIV_TOP0, 12, 3), 756 DIV(0, "dout_aclk200_fsys2", "mout_aclk200_fsys2", DIV_TOP0, 12, 3),
757 DIV(0, "dout_aclk100_noc", "mout_aclk100_noc", DIV_TOP0, 20, 3),
447 DIV(0, "dout_pclk200_fsys", "mout_pclk200_fsys", DIV_TOP0, 24, 3), 758 DIV(0, "dout_pclk200_fsys", "mout_pclk200_fsys", DIV_TOP0, 24, 3),
448 DIV(0, "dout_aclk200_fsys", "mout_aclk200_fsys", DIV_TOP0, 28, 3), 759 DIV(0, "dout_aclk200_fsys", "mout_aclk200_fsys", DIV_TOP0, 28, 3),
449 760
450 DIV(0, "dout_aclk333_432_gscl", "mout_aclk333_432_gscl", 761 DIV(0, "dout_aclk333_432_gscl", "mout_aclk333_432_gscl",
451 DIV_TOP1, 0, 3), 762 DIV_TOP1, 0, 3),
763 DIV(0, "dout_aclk333_432_isp", "mout_aclk333_432_isp",
764 DIV_TOP1, 4, 3),
452 DIV(0, "dout_aclk66", "mout_aclk66", DIV_TOP1, 8, 6), 765 DIV(0, "dout_aclk66", "mout_aclk66", DIV_TOP1, 8, 6),
766 DIV(0, "dout_aclk333_432_isp0", "mout_aclk333_432_isp0",
767 DIV_TOP1, 16, 3),
453 DIV(0, "dout_aclk266", "mout_aclk266", DIV_TOP1, 20, 3), 768 DIV(0, "dout_aclk266", "mout_aclk266", DIV_TOP1, 20, 3),
454 DIV(0, "dout_aclk166", "mout_aclk166", DIV_TOP1, 24, 3), 769 DIV(0, "dout_aclk166", "mout_aclk166", DIV_TOP1, 24, 3),
455 DIV(0, "dout_aclk333", "mout_aclk333", DIV_TOP1, 28, 3), 770 DIV(0, "dout_aclk333", "mout_aclk333", DIV_TOP1, 28, 3),
@@ -458,15 +773,16 @@ static struct samsung_div_clock exynos5420_div_clks[] __initdata = {
458 DIV(0, "dout_aclk266_g2d", "mout_aclk266_g2d", DIV_TOP2, 12, 3), 773 DIV(0, "dout_aclk266_g2d", "mout_aclk266_g2d", DIV_TOP2, 12, 3),
459 DIV(0, "dout_aclk_g3d", "mout_aclk_g3d", DIV_TOP2, 16, 3), 774 DIV(0, "dout_aclk_g3d", "mout_aclk_g3d", DIV_TOP2, 16, 3),
460 DIV(0, "dout_aclk300_jpeg", "mout_aclk300_jpeg", DIV_TOP2, 20, 3), 775 DIV(0, "dout_aclk300_jpeg", "mout_aclk300_jpeg", DIV_TOP2, 20, 3),
461 DIV_A(0, "dout_aclk300_disp1", "mout_aclk300_disp1", 776 DIV(0, "dout_aclk300_disp1", "mout_aclk300_disp1", DIV_TOP2, 24, 3),
462 DIV_TOP2, 24, 3, "aclk300_disp1"),
463 DIV(0, "dout_aclk300_gscl", "mout_aclk300_gscl", DIV_TOP2, 28, 3), 777 DIV(0, "dout_aclk300_gscl", "mout_aclk300_gscl", DIV_TOP2, 28, 3),
464 778
465 /* DISP1 Block */ 779 /* DISP1 Block */
466 DIV(0, "dout_fimd1", "mout_fimd1", DIV_DISP10, 0, 4), 780 DIV(0, "dout_fimd1", "mout_fimd1_final", DIV_DISP10, 0, 4),
467 DIV(0, "dout_mipi1", "mout_mipi1", DIV_DISP10, 16, 8), 781 DIV(0, "dout_mipi1", "mout_mipi1", DIV_DISP10, 16, 8),
468 DIV(0, "dout_dp1", "mout_dp1", DIV_DISP10, 24, 4), 782 DIV(0, "dout_dp1", "mout_dp1", DIV_DISP10, 24, 4),
469 DIV(CLK_DOUT_PIXEL, "dout_hdmi_pixel", "mout_pixel", DIV_DISP10, 28, 4), 783 DIV(CLK_DOUT_PIXEL, "dout_hdmi_pixel", "mout_pixel", DIV_DISP10, 28, 4),
784 DIV(0, "dout_disp1_blk", "aclk200_disp1", DIV2_RATIO0, 16, 2),
785 DIV(0, "dout_aclk400_disp1", "mout_aclk400_disp1", DIV_TOP2, 4, 3),
470 786
471 /* Audio Block */ 787 /* Audio Block */
472 DIV(0, "dout_maudio0", "mout_maudio0", DIV_MAU, 20, 4), 788 DIV(0, "dout_maudio0", "mout_maudio0", DIV_MAU, 20, 4),
@@ -484,6 +800,7 @@ static struct samsung_div_clock exynos5420_div_clks[] __initdata = {
484 DIV(0, "dout_mmc2", "mout_mmc2", DIV_FSYS1, 20, 10), 800 DIV(0, "dout_mmc2", "mout_mmc2", DIV_FSYS1, 20, 10),
485 801
486 DIV(0, "dout_unipro", "mout_unipro", DIV_FSYS2, 24, 8), 802 DIV(0, "dout_unipro", "mout_unipro", DIV_FSYS2, 24, 8),
803 DIV(0, "dout_mphy_refclk", "mout_mphy_refclk", DIV_FSYS2, 16, 8),
487 804
488 /* UART and PWM */ 805 /* UART and PWM */
489 DIV(0, "dout_uart0", "mout_uart0", DIV_PERIC0, 8, 4), 806 DIV(0, "dout_uart0", "mout_uart0", DIV_PERIC0, 8, 4),
@@ -497,6 +814,9 @@ static struct samsung_div_clock exynos5420_div_clks[] __initdata = {
497 DIV(0, "dout_spi1", "mout_spi1", DIV_PERIC1, 24, 4), 814 DIV(0, "dout_spi1", "mout_spi1", DIV_PERIC1, 24, 4),
498 DIV(0, "dout_spi2", "mout_spi2", DIV_PERIC1, 28, 4), 815 DIV(0, "dout_spi2", "mout_spi2", DIV_PERIC1, 28, 4),
499 816
817 /* Mfc Block */
818 DIV(0, "dout_mfc_blk", "mout_user_aclk333", DIV4_RATIO, 0, 2),
819
500 /* PCM */ 820 /* PCM */
501 DIV(0, "dout_pcm1", "dout_audio1", DIV_PERIC2, 16, 8), 821 DIV(0, "dout_pcm1", "dout_audio1", DIV_PERIC2, 16, 8),
502 DIV(0, "dout_pcm2", "dout_audio2", DIV_PERIC2, 24, 8), 822 DIV(0, "dout_pcm2", "dout_audio2", DIV_PERIC2, 24, 8),
@@ -509,15 +829,43 @@ static struct samsung_div_clock exynos5420_div_clks[] __initdata = {
509 DIV(0, "dout_audio2", "mout_audio2", DIV_PERIC3, 28, 4), 829 DIV(0, "dout_audio2", "mout_audio2", DIV_PERIC3, 28, 4),
510 830
511 /* SPI Pre-Ratio */ 831 /* SPI Pre-Ratio */
512 DIV(0, "dout_pre_spi0", "dout_spi0", DIV_PERIC4, 8, 8), 832 DIV(0, "dout_spi0_pre", "dout_spi0", DIV_PERIC4, 8, 8),
513 DIV(0, "dout_pre_spi1", "dout_spi1", DIV_PERIC4, 16, 8), 833 DIV(0, "dout_spi1_pre", "dout_spi1", DIV_PERIC4, 16, 8),
514 DIV(0, "dout_pre_spi2", "dout_spi2", DIV_PERIC4, 24, 8), 834 DIV(0, "dout_spi2_pre", "dout_spi2", DIV_PERIC4, 24, 8),
835
836 /* GSCL Block */
837 DIV(0, "dout_gscl_blk_300", "mout_user_aclk300_gscl",
838 DIV2_RATIO0, 4, 2),
839 DIV(0, "dout_gscl_blk_333", "aclk333_432_gscl", DIV2_RATIO0, 6, 2),
840
841 /* MSCL Block */
842 DIV(0, "dout_mscl_blk", "aclk400_mscl", DIV2_RATIO0, 28, 2),
843
844 /* PSGEN */
845 DIV(0, "dout_gen_blk", "mout_user_aclk266", DIV2_RATIO0, 8, 1),
846 DIV(0, "dout_jpg_blk", "aclk166", DIV2_RATIO0, 20, 1),
847
848 /* ISP Block */
849 DIV(0, "dout_isp_sensor0", "mout_isp_sensor", SCLK_DIV_ISP0, 8, 8),
850 DIV(0, "dout_isp_sensor1", "mout_isp_sensor", SCLK_DIV_ISP0, 16, 8),
851 DIV(0, "dout_isp_sensor2", "mout_isp_sensor", SCLK_DIV_ISP0, 24, 8),
852 DIV(0, "dout_pwm_isp", "mout_pwm_isp", SCLK_DIV_ISP1, 28, 4),
853 DIV(0, "dout_uart_isp", "mout_uart_isp", SCLK_DIV_ISP1, 24, 4),
854 DIV(0, "dout_spi0_isp", "mout_spi0_isp", SCLK_DIV_ISP1, 16, 4),
855 DIV(0, "dout_spi1_isp", "mout_spi1_isp", SCLK_DIV_ISP1, 20, 4),
856 DIV_F(0, "dout_spi0_isp_pre", "dout_spi0_isp", SCLK_DIV_ISP1, 0, 8,
857 CLK_SET_RATE_PARENT, 0),
858 DIV_F(0, "dout_spi1_isp_pre", "dout_spi1_isp", SCLK_DIV_ISP1, 8, 8,
859 CLK_SET_RATE_PARENT, 0),
515}; 860};
516 861
517static struct samsung_gate_clock exynos5420_gate_clks[] __initdata = { 862static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = {
518 /* TODO: Re-verify the CG bits for all the gate clocks */ 863 /* G2D */
519 GATE_A(CLK_MCT, "pclk_st", "aclk66_psgen", GATE_BUS_PERIS1, 2, 0, 0, 864 GATE(CLK_MDMA0, "mdma0", "aclk266_g2d", GATE_IP_G2D, 1, 0, 0),
520 "mct"), 865 GATE(CLK_SSS, "sss", "aclk266_g2d", GATE_IP_G2D, 2, 0, 0),
866 GATE(CLK_G2D, "g2d", "aclk333_g2d", GATE_IP_G2D, 3, 0, 0),
867 GATE(CLK_SMMU_MDMA0, "smmu_mdma0", "aclk266_g2d", GATE_IP_G2D, 5, 0, 0),
868 GATE(CLK_SMMU_G2D, "smmu_g2d", "aclk333_g2d", GATE_IP_G2D, 7, 0, 0),
521 869
522 GATE(0, "aclk200_fsys", "mout_user_aclk200_fsys", 870 GATE(0, "aclk200_fsys", "mout_user_aclk200_fsys",
523 GATE_BUS_FSYS0, 9, CLK_IGNORE_UNUSED, 0), 871 GATE_BUS_FSYS0, 9, CLK_IGNORE_UNUSED, 0),
@@ -530,20 +878,42 @@ static struct samsung_gate_clock exynos5420_gate_clks[] __initdata = {
530 GATE_BUS_TOP, 1, CLK_IGNORE_UNUSED, 0), 878 GATE_BUS_TOP, 1, CLK_IGNORE_UNUSED, 0),
531 GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg", 879 GATE(0, "aclk300_jpeg", "mout_user_aclk300_jpeg",
532 GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0), 880 GATE_BUS_TOP, 4, CLK_IGNORE_UNUSED, 0),
881 GATE(0, "aclk333_432_isp0", "mout_user_aclk333_432_isp0",
882 GATE_BUS_TOP, 5, 0, 0),
533 GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl", 883 GATE(0, "aclk300_gscl", "mout_user_aclk300_gscl",
534 GATE_BUS_TOP, 6, CLK_IGNORE_UNUSED, 0), 884 GATE_BUS_TOP, 6, CLK_IGNORE_UNUSED, 0),
535 GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl", 885 GATE(0, "aclk333_432_gscl", "mout_user_aclk333_432_gscl",
536 GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0), 886 GATE_BUS_TOP, 7, CLK_IGNORE_UNUSED, 0),
537 GATE(0, "pclk66_gpio", "mout_sw_aclk66", 887 GATE(0, "aclk333_432_isp", "mout_user_aclk333_432_isp",
888 GATE_BUS_TOP, 8, 0, 0),
889 GATE(CLK_PCLK66_GPIO, "pclk66_gpio", "mout_user_pclk66_gpio",
538 GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0), 890 GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0),
539 GATE(0, "aclk66_psgen", "mout_aclk66_psgen", 891 GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen",
540 GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0), 892 GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0),
541 GATE(0, "aclk66_peric", "mout_aclk66_peric", 893 GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric",
542 GATE_BUS_TOP, 11, 0, 0), 894 GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0),
895 GATE(0, "aclk266_isp", "mout_user_aclk266_isp",
896 GATE_BUS_TOP, 13, 0, 0),
543 GATE(0, "aclk166", "mout_user_aclk166", 897 GATE(0, "aclk166", "mout_user_aclk166",
544 GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0), 898 GATE_BUS_TOP, 14, CLK_IGNORE_UNUSED, 0),
545 GATE(0, "aclk333", "mout_aclk333", 899 GATE(0, "aclk333", "mout_aclk333",
546 GATE_BUS_TOP, 15, CLK_IGNORE_UNUSED, 0), 900 GATE_BUS_TOP, 15, CLK_IGNORE_UNUSED, 0),
901 GATE(0, "aclk400_isp", "mout_user_aclk400_isp",
902 GATE_BUS_TOP, 16, 0, 0),
903 GATE(0, "aclk400_mscl", "mout_user_aclk400_mscl",
904 GATE_BUS_TOP, 17, 0, 0),
905 GATE(0, "aclk200_disp1", "mout_user_aclk200_disp1",
906 GATE_BUS_TOP, 18, 0, 0),
907 GATE(CLK_SCLK_MPHY_IXTAL24, "sclk_mphy_ixtal24", "mphy_refclk_ixtal24",
908 GATE_BUS_TOP, 28, 0, 0),
909 GATE(CLK_SCLK_HSIC_12M, "sclk_hsic_12m", "ff_hsic_12m",
910 GATE_BUS_TOP, 29, 0, 0),
911
912 GATE(0, "aclk300_disp1", "mout_user_aclk300_disp1",
913 SRC_MASK_TOP2, 24, 0, 0),
914
915 GATE(CLK_MAU_EPLL, "mau_epll", "mout_mau_epll_clk",
916 SRC_MASK_TOP7, 20, 0, 0),
547 917
548 /* sclk */ 918 /* sclk */
549 GATE(CLK_SCLK_UART0, "sclk_uart0", "dout_uart0", 919 GATE(CLK_SCLK_UART0, "sclk_uart0", "dout_uart0",
@@ -554,11 +924,11 @@ static struct samsung_gate_clock exynos5420_gate_clks[] __initdata = {
554 GATE_TOP_SCLK_PERIC, 2, CLK_SET_RATE_PARENT, 0), 924 GATE_TOP_SCLK_PERIC, 2, CLK_SET_RATE_PARENT, 0),
555 GATE(CLK_SCLK_UART3, "sclk_uart3", "dout_uart3", 925 GATE(CLK_SCLK_UART3, "sclk_uart3", "dout_uart3",
556 GATE_TOP_SCLK_PERIC, 3, CLK_SET_RATE_PARENT, 0), 926 GATE_TOP_SCLK_PERIC, 3, CLK_SET_RATE_PARENT, 0),
557 GATE(CLK_SCLK_SPI0, "sclk_spi0", "dout_pre_spi0", 927 GATE(CLK_SCLK_SPI0, "sclk_spi0", "dout_spi0_pre",
558 GATE_TOP_SCLK_PERIC, 6, CLK_SET_RATE_PARENT, 0), 928 GATE_TOP_SCLK_PERIC, 6, CLK_SET_RATE_PARENT, 0),
559 GATE(CLK_SCLK_SPI1, "sclk_spi1", "dout_pre_spi1", 929 GATE(CLK_SCLK_SPI1, "sclk_spi1", "dout_spi1_pre",
560 GATE_TOP_SCLK_PERIC, 7, CLK_SET_RATE_PARENT, 0), 930 GATE_TOP_SCLK_PERIC, 7, CLK_SET_RATE_PARENT, 0),
561 GATE(CLK_SCLK_SPI2, "sclk_spi2", "dout_pre_spi2", 931 GATE(CLK_SCLK_SPI2, "sclk_spi2", "dout_spi2_pre",
562 GATE_TOP_SCLK_PERIC, 8, CLK_SET_RATE_PARENT, 0), 932 GATE_TOP_SCLK_PERIC, 8, CLK_SET_RATE_PARENT, 0),
563 GATE(CLK_SCLK_SPDIF, "sclk_spdif", "mout_spdif", 933 GATE(CLK_SCLK_SPDIF, "sclk_spdif", "mout_spdif",
564 GATE_TOP_SCLK_PERIC, 9, CLK_SET_RATE_PARENT, 0), 934 GATE_TOP_SCLK_PERIC, 9, CLK_SET_RATE_PARENT, 0),
@@ -588,164 +958,191 @@ static struct samsung_gate_clock exynos5420_gate_clks[] __initdata = {
588 GATE(CLK_SCLK_USBD301, "sclk_usbd301", "dout_usbd301", 958 GATE(CLK_SCLK_USBD301, "sclk_usbd301", "dout_usbd301",
589 GATE_TOP_SCLK_FSYS, 10, CLK_SET_RATE_PARENT, 0), 959 GATE_TOP_SCLK_FSYS, 10, CLK_SET_RATE_PARENT, 0),
590 960
591 GATE(CLK_SCLK_USBD301, "sclk_unipro", "dout_unipro",
592 SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0),
593
594 GATE(CLK_SCLK_GSCL_WA, "sclk_gscl_wa", "aclK333_432_gscl",
595 GATE_TOP_SCLK_GSCL, 6, CLK_SET_RATE_PARENT, 0),
596 GATE(CLK_SCLK_GSCL_WB, "sclk_gscl_wb", "aclk333_432_gscl",
597 GATE_TOP_SCLK_GSCL, 7, CLK_SET_RATE_PARENT, 0),
598
599 /* Display */ 961 /* Display */
600 GATE(CLK_SCLK_FIMD1, "sclk_fimd1", "dout_fimd1", 962 GATE(CLK_SCLK_FIMD1, "sclk_fimd1", "dout_fimd1",
601 GATE_TOP_SCLK_DISP1, 0, CLK_SET_RATE_PARENT, 0), 963 GATE_TOP_SCLK_DISP1, 0, CLK_SET_RATE_PARENT, 0),
602 GATE(CLK_SCLK_MIPI1, "sclk_mipi1", "dout_mipi1", 964 GATE(CLK_SCLK_MIPI1, "sclk_mipi1", "dout_mipi1",
603 GATE_TOP_SCLK_DISP1, 3, CLK_SET_RATE_PARENT, 0), 965 GATE_TOP_SCLK_DISP1, 3, CLK_SET_RATE_PARENT, 0),
604 GATE(CLK_SCLK_HDMI, "sclk_hdmi", "mout_hdmi", 966 GATE(CLK_SCLK_HDMI, "sclk_hdmi", "mout_hdmi",
605 GATE_TOP_SCLK_DISP1, 9, CLK_SET_RATE_PARENT, 0), 967 GATE_TOP_SCLK_DISP1, 9, 0, 0),
606 GATE(CLK_SCLK_PIXEL, "sclk_pixel", "dout_hdmi_pixel", 968 GATE(CLK_SCLK_PIXEL, "sclk_pixel", "dout_hdmi_pixel",
607 GATE_TOP_SCLK_DISP1, 10, CLK_SET_RATE_PARENT, 0), 969 GATE_TOP_SCLK_DISP1, 10, CLK_SET_RATE_PARENT, 0),
608 GATE(CLK_SCLK_DP1, "sclk_dp1", "dout_dp1", 970 GATE(CLK_SCLK_DP1, "sclk_dp1", "dout_dp1",
609 GATE_TOP_SCLK_DISP1, 20, CLK_SET_RATE_PARENT, 0), 971 GATE_TOP_SCLK_DISP1, 20, CLK_SET_RATE_PARENT, 0),
610 972
611 /* Maudio Block */ 973 /* Maudio Block */
612 GATE(CLK_SCLK_MAUDIO0, "sclk_maudio0", "dout_maudio0", 974 GATE(CLK_SCLK_MAUDIO0, "sclk_maudio0", "dout_maudio0",
613 GATE_TOP_SCLK_MAU, 0, CLK_SET_RATE_PARENT, 0), 975 GATE_TOP_SCLK_MAU, 0, CLK_SET_RATE_PARENT, 0),
614 GATE(CLK_SCLK_MAUPCM0, "sclk_maupcm0", "dout_maupcm0", 976 GATE(CLK_SCLK_MAUPCM0, "sclk_maupcm0", "dout_maupcm0",
615 GATE_TOP_SCLK_MAU, 1, CLK_SET_RATE_PARENT, 0), 977 GATE_TOP_SCLK_MAU, 1, CLK_SET_RATE_PARENT, 0),
616 /* FSYS */ 978
979 /* FSYS Block */
617 GATE(CLK_TSI, "tsi", "aclk200_fsys", GATE_BUS_FSYS0, 0, 0, 0), 980 GATE(CLK_TSI, "tsi", "aclk200_fsys", GATE_BUS_FSYS0, 0, 0, 0),
618 GATE(CLK_PDMA0, "pdma0", "aclk200_fsys", GATE_BUS_FSYS0, 1, 0, 0), 981 GATE(CLK_PDMA0, "pdma0", "aclk200_fsys", GATE_BUS_FSYS0, 1, 0, 0),
619 GATE(CLK_PDMA1, "pdma1", "aclk200_fsys", GATE_BUS_FSYS0, 2, 0, 0), 982 GATE(CLK_PDMA1, "pdma1", "aclk200_fsys", GATE_BUS_FSYS0, 2, 0, 0),
620 GATE(CLK_UFS, "ufs", "aclk200_fsys2", GATE_BUS_FSYS0, 3, 0, 0), 983 GATE(CLK_UFS, "ufs", "aclk200_fsys2", GATE_BUS_FSYS0, 3, 0, 0),
621 GATE(CLK_RTIC, "rtic", "aclk200_fsys", GATE_BUS_FSYS0, 5, 0, 0), 984 GATE(CLK_RTIC, "rtic", "aclk200_fsys", GATE_IP_FSYS, 9, 0, 0),
622 GATE(CLK_MMC0, "mmc0", "aclk200_fsys2", GATE_BUS_FSYS0, 12, 0, 0), 985 GATE(CLK_MMC0, "mmc0", "aclk200_fsys2", GATE_IP_FSYS, 12, 0, 0),
623 GATE(CLK_MMC1, "mmc1", "aclk200_fsys2", GATE_BUS_FSYS0, 13, 0, 0), 986 GATE(CLK_MMC1, "mmc1", "aclk200_fsys2", GATE_IP_FSYS, 13, 0, 0),
624 GATE(CLK_MMC2, "mmc2", "aclk200_fsys2", GATE_BUS_FSYS0, 14, 0, 0), 987 GATE(CLK_MMC2, "mmc2", "aclk200_fsys2", GATE_IP_FSYS, 14, 0, 0),
625 GATE(CLK_SROMC, "sromc", "aclk200_fsys2", 988 GATE(CLK_SROMC, "sromc", "aclk200_fsys2",
626 GATE_BUS_FSYS0, 19, CLK_IGNORE_UNUSED, 0), 989 GATE_IP_FSYS, 17, CLK_IGNORE_UNUSED, 0),
627 GATE(CLK_USBH20, "usbh20", "aclk200_fsys", GATE_BUS_FSYS0, 20, 0, 0), 990 GATE(CLK_USBH20, "usbh20", "aclk200_fsys", GATE_IP_FSYS, 18, 0, 0),
628 GATE(CLK_USBD300, "usbd300", "aclk200_fsys", GATE_BUS_FSYS0, 21, 0, 0), 991 GATE(CLK_USBD300, "usbd300", "aclk200_fsys", GATE_IP_FSYS, 19, 0, 0),
629 GATE(CLK_USBD301, "usbd301", "aclk200_fsys", GATE_BUS_FSYS0, 28, 0, 0), 992 GATE(CLK_USBD301, "usbd301", "aclk200_fsys", GATE_IP_FSYS, 20, 0, 0),
630 993 GATE(CLK_SCLK_UNIPRO, "sclk_unipro", "dout_unipro",
631 /* UART */ 994 SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0),
632 GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_BUS_PERIC, 4, 0, 0),
633 GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_BUS_PERIC, 5, 0, 0),
634 GATE_A(CLK_UART2, "uart2", "aclk66_peric",
635 GATE_BUS_PERIC, 6, CLK_IGNORE_UNUSED, 0, "uart2"),
636 GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_BUS_PERIC, 7, 0, 0),
637 /* I2C */
638 GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_BUS_PERIC, 9, 0, 0),
639 GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_BUS_PERIC, 10, 0, 0),
640 GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_BUS_PERIC, 11, 0, 0),
641 GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_BUS_PERIC, 12, 0, 0),
642 GATE(CLK_I2C4, "i2c4", "aclk66_peric", GATE_BUS_PERIC, 13, 0, 0),
643 GATE(CLK_I2C5, "i2c5", "aclk66_peric", GATE_BUS_PERIC, 14, 0, 0),
644 GATE(CLK_I2C6, "i2c6", "aclk66_peric", GATE_BUS_PERIC, 15, 0, 0),
645 GATE(CLK_I2C7, "i2c7", "aclk66_peric", GATE_BUS_PERIC, 16, 0, 0),
646 GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_BUS_PERIC, 17, 0,
647 0),
648 GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_BUS_PERIC, 18, 0, 0),
649 /* SPI */
650 GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_BUS_PERIC, 19, 0, 0),
651 GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_BUS_PERIC, 20, 0, 0),
652 GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_BUS_PERIC, 21, 0, 0),
653 GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0),
654 /* I2S */
655 GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_BUS_PERIC, 23, 0, 0),
656 GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_BUS_PERIC, 24, 0, 0),
657 /* PCM */
658 GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_BUS_PERIC, 25, 0, 0),
659 GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_BUS_PERIC, 26, 0, 0),
660 /* PWM */
661 GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_BUS_PERIC, 27, 0, 0),
662 /* SPDIF */
663 GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_BUS_PERIC, 29, 0, 0),
664 995
665 GATE(CLK_I2C8, "i2c8", "aclk66_peric", GATE_BUS_PERIC1, 0, 0, 0), 996 /* PERIC Block */
666 GATE(CLK_I2C9, "i2c9", "aclk66_peric", GATE_BUS_PERIC1, 1, 0, 0), 997 GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_IP_PERIC, 0, 0, 0),
667 GATE(CLK_I2C10, "i2c10", "aclk66_peric", GATE_BUS_PERIC1, 2, 0, 0), 998 GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_IP_PERIC, 1, 0, 0),
999 GATE(CLK_UART2, "uart2", "aclk66_peric", GATE_IP_PERIC, 2, 0, 0),
1000 GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_IP_PERIC, 3, 0, 0),
1001 GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_IP_PERIC, 6, 0, 0),
1002 GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_IP_PERIC, 7, 0, 0),
1003 GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_IP_PERIC, 8, 0, 0),
1004 GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_IP_PERIC, 9, 0, 0),
1005 GATE(CLK_USI0, "usi0", "aclk66_peric", GATE_IP_PERIC, 10, 0, 0),
1006 GATE(CLK_USI1, "usi1", "aclk66_peric", GATE_IP_PERIC, 11, 0, 0),
1007 GATE(CLK_USI2, "usi2", "aclk66_peric", GATE_IP_PERIC, 12, 0, 0),
1008 GATE(CLK_USI3, "usi3", "aclk66_peric", GATE_IP_PERIC, 13, 0, 0),
1009 GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_IP_PERIC, 14, 0, 0),
1010 GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_IP_PERIC, 15, 0, 0),
1011 GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_IP_PERIC, 16, 0, 0),
1012 GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_IP_PERIC, 17, 0, 0),
1013 GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_IP_PERIC, 18, 0, 0),
1014 GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_IP_PERIC, 20, 0, 0),
1015 GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_IP_PERIC, 21, 0, 0),
1016 GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_IP_PERIC, 22, 0, 0),
1017 GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_IP_PERIC, 23, 0, 0),
1018 GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_IP_PERIC, 24, 0, 0),
1019 GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_IP_PERIC, 26, 0, 0),
1020 GATE(CLK_USI4, "usi4", "aclk66_peric", GATE_IP_PERIC, 28, 0, 0),
1021 GATE(CLK_USI5, "usi5", "aclk66_peric", GATE_IP_PERIC, 30, 0, 0),
1022 GATE(CLK_USI6, "usi6", "aclk66_peric", GATE_IP_PERIC, 31, 0, 0),
668 1023
1024 GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0),
1025
1026 /* PERIS Block */
669 GATE(CLK_CHIPID, "chipid", "aclk66_psgen", 1027 GATE(CLK_CHIPID, "chipid", "aclk66_psgen",
670 GATE_BUS_PERIS0, 12, CLK_IGNORE_UNUSED, 0), 1028 GATE_IP_PERIS, 0, CLK_IGNORE_UNUSED, 0),
671 GATE(CLK_SYSREG, "sysreg", "aclk66_psgen", 1029 GATE(CLK_SYSREG, "sysreg", "aclk66_psgen",
672 GATE_BUS_PERIS0, 13, CLK_IGNORE_UNUSED, 0), 1030 GATE_IP_PERIS, 1, CLK_IGNORE_UNUSED, 0),
673 GATE(CLK_TZPC0, "tzpc0", "aclk66_psgen", GATE_BUS_PERIS0, 18, 0, 0), 1031 GATE(CLK_TZPC0, "tzpc0", "aclk66_psgen", GATE_IP_PERIS, 6, 0, 0),
674 GATE(CLK_TZPC1, "tzpc1", "aclk66_psgen", GATE_BUS_PERIS0, 19, 0, 0), 1032 GATE(CLK_TZPC1, "tzpc1", "aclk66_psgen", GATE_IP_PERIS, 7, 0, 0),
675 GATE(CLK_TZPC2, "tzpc2", "aclk66_psgen", GATE_BUS_PERIS0, 20, 0, 0), 1033 GATE(CLK_TZPC2, "tzpc2", "aclk66_psgen", GATE_IP_PERIS, 8, 0, 0),
676 GATE(CLK_TZPC3, "tzpc3", "aclk66_psgen", GATE_BUS_PERIS0, 21, 0, 0), 1034 GATE(CLK_TZPC3, "tzpc3", "aclk66_psgen", GATE_IP_PERIS, 9, 0, 0),
677 GATE(CLK_TZPC4, "tzpc4", "aclk66_psgen", GATE_BUS_PERIS0, 22, 0, 0), 1035 GATE(CLK_TZPC4, "tzpc4", "aclk66_psgen", GATE_IP_PERIS, 10, 0, 0),
678 GATE(CLK_TZPC5, "tzpc5", "aclk66_psgen", GATE_BUS_PERIS0, 23, 0, 0), 1036 GATE(CLK_TZPC5, "tzpc5", "aclk66_psgen", GATE_IP_PERIS, 11, 0, 0),
679 GATE(CLK_TZPC6, "tzpc6", "aclk66_psgen", GATE_BUS_PERIS0, 24, 0, 0), 1037 GATE(CLK_TZPC6, "tzpc6", "aclk66_psgen", GATE_IP_PERIS, 12, 0, 0),
680 GATE(CLK_TZPC7, "tzpc7", "aclk66_psgen", GATE_BUS_PERIS0, 25, 0, 0), 1038 GATE(CLK_TZPC7, "tzpc7", "aclk66_psgen", GATE_IP_PERIS, 13, 0, 0),
681 GATE(CLK_TZPC8, "tzpc8", "aclk66_psgen", GATE_BUS_PERIS0, 26, 0, 0), 1039 GATE(CLK_TZPC8, "tzpc8", "aclk66_psgen", GATE_IP_PERIS, 14, 0, 0),
682 GATE(CLK_TZPC9, "tzpc9", "aclk66_psgen", GATE_BUS_PERIS0, 27, 0, 0), 1040 GATE(CLK_TZPC9, "tzpc9", "aclk66_psgen", GATE_IP_PERIS, 15, 0, 0),
683 1041 GATE(CLK_HDMI_CEC, "hdmi_cec", "aclk66_psgen", GATE_IP_PERIS, 16, 0, 0),
684 GATE(CLK_HDMI_CEC, "hdmi_cec", "aclk66_psgen", GATE_BUS_PERIS1, 0, 0, 1042 GATE(CLK_MCT, "mct", "aclk66_psgen", GATE_IP_PERIS, 18, 0, 0),
685 0), 1043 GATE(CLK_WDT, "wdt", "aclk66_psgen", GATE_IP_PERIS, 19, 0, 0),
1044 GATE(CLK_RTC, "rtc", "aclk66_psgen", GATE_IP_PERIS, 20, 0, 0),
1045 GATE(CLK_TMU, "tmu", "aclk66_psgen", GATE_IP_PERIS, 21, 0, 0),
1046 GATE(CLK_TMU_GPU, "tmu_gpu", "aclk66_psgen", GATE_IP_PERIS, 22, 0, 0),
1047
686 GATE(CLK_SECKEY, "seckey", "aclk66_psgen", GATE_BUS_PERIS1, 1, 0, 0), 1048 GATE(CLK_SECKEY, "seckey", "aclk66_psgen", GATE_BUS_PERIS1, 1, 0, 0),
687 GATE(CLK_WDT, "wdt", "aclk66_psgen", GATE_BUS_PERIS1, 3, 0, 0), 1049
688 GATE(CLK_RTC, "rtc", "aclk66_psgen", GATE_BUS_PERIS1, 4, 0, 0), 1050 /* GEN Block */
689 GATE(CLK_TMU, "tmu", "aclk66_psgen", GATE_BUS_PERIS1, 5, 0, 0), 1051 GATE(CLK_ROTATOR, "rotator", "mout_user_aclk266", GATE_IP_GEN, 1, 0, 0),
690 GATE(CLK_TMU_GPU, "tmu_gpu", "aclk66_psgen", GATE_BUS_PERIS1, 6, 0, 0), 1052 GATE(CLK_JPEG, "jpeg", "aclk300_jpeg", GATE_IP_GEN, 2, 0, 0),
1053 GATE(CLK_JPEG2, "jpeg2", "aclk300_jpeg", GATE_IP_GEN, 3, 0, 0),
1054 GATE(CLK_MDMA1, "mdma1", "mout_user_aclk266", GATE_IP_GEN, 4, 0, 0),
1055 GATE(CLK_TOP_RTC, "top_rtc", "aclk66_psgen", GATE_IP_GEN, 5, 0, 0),
1056 GATE(CLK_SMMU_ROTATOR, "smmu_rotator", "dout_gen_blk",
1057 GATE_IP_GEN, 6, 0, 0),
1058 GATE(CLK_SMMU_JPEG, "smmu_jpeg", "dout_jpg_blk", GATE_IP_GEN, 7, 0, 0),
1059 GATE(CLK_SMMU_MDMA1, "smmu_mdma1", "dout_gen_blk",
1060 GATE_IP_GEN, 9, 0, 0),
1061
1062 /* GATE_IP_GEN doesn't list gates for smmu_jpeg2 and mc */
1063 GATE(CLK_SMMU_JPEG2, "smmu_jpeg2", "dout_jpg_blk",
1064 GATE_BUS_GEN, 28, 0, 0),
1065 GATE(CLK_MC, "mc", "aclk66_psgen", GATE_BUS_GEN, 12, 0, 0),
1066
1067 /* GSCL Block */
1068 GATE(CLK_SCLK_GSCL_WA, "sclk_gscl_wa", "mout_user_aclk333_432_gscl",
1069 GATE_TOP_SCLK_GSCL, 6, 0, 0),
1070 GATE(CLK_SCLK_GSCL_WB, "sclk_gscl_wb", "mout_user_aclk333_432_gscl",
1071 GATE_TOP_SCLK_GSCL, 7, 0, 0),
691 1072
692 GATE(CLK_GSCL0, "gscl0", "aclk300_gscl", GATE_IP_GSCL0, 0, 0, 0), 1073 GATE(CLK_GSCL0, "gscl0", "aclk300_gscl", GATE_IP_GSCL0, 0, 0, 0),
693 GATE(CLK_GSCL1, "gscl1", "aclk300_gscl", GATE_IP_GSCL0, 1, 0, 0), 1074 GATE(CLK_GSCL1, "gscl1", "aclk300_gscl", GATE_IP_GSCL0, 1, 0, 0),
694 GATE(CLK_CLK_3AA, "clk_3aa", "aclk300_gscl", GATE_IP_GSCL0, 4, 0, 0), 1075 GATE(CLK_FIMC_3AA, "fimc_3aa", "aclk333_432_gscl",
695 1076 GATE_IP_GSCL0, 4, 0, 0),
696 GATE(CLK_SMMU_3AA, "smmu_3aa", "aclk333_432_gscl", GATE_IP_GSCL1, 2, 0, 1077 GATE(CLK_FIMC_LITE0, "fimc_lite0", "aclk333_432_gscl",
697 0), 1078 GATE_IP_GSCL0, 5, 0, 0),
698 GATE(CLK_SMMU_FIMCL0, "smmu_fimcl0", "aclk333_432_gscl", 1079 GATE(CLK_FIMC_LITE1, "fimc_lite1", "aclk333_432_gscl",
1080 GATE_IP_GSCL0, 6, 0, 0),
1081
1082 GATE(CLK_SMMU_3AA, "smmu_3aa", "dout_gscl_blk_333",
1083 GATE_IP_GSCL1, 2, 0, 0),
1084 GATE(CLK_SMMU_FIMCL0, "smmu_fimcl0", "dout_gscl_blk_333",
699 GATE_IP_GSCL1, 3, 0, 0), 1085 GATE_IP_GSCL1, 3, 0, 0),
700 GATE(CLK_SMMU_FIMCL1, "smmu_fimcl1", "aclk333_432_gscl", 1086 GATE(CLK_SMMU_FIMCL1, "smmu_fimcl1", "dout_gscl_blk_333",
701 GATE_IP_GSCL1, 4, 0, 0), 1087 GATE_IP_GSCL1, 4, 0, 0),
702 GATE(CLK_SMMU_GSCL0, "smmu_gscl0", "aclk300_gscl", GATE_IP_GSCL1, 6, 0, 1088 GATE(CLK_SMMU_GSCL0, "smmu_gscl0", "dout_gscl_blk_300",
703 0), 1089 GATE_IP_GSCL1, 6, 0, 0),
704 GATE(CLK_SMMU_GSCL1, "smmu_gscl1", "aclk300_gscl", GATE_IP_GSCL1, 7, 0, 1090 GATE(CLK_SMMU_GSCL1, "smmu_gscl1", "dout_gscl_blk_300",
705 0), 1091 GATE_IP_GSCL1, 7, 0, 0),
706 GATE(CLK_GSCL_WA, "gscl_wa", "aclk300_gscl", GATE_IP_GSCL1, 12, 0, 0), 1092 GATE(CLK_GSCL_WA, "gscl_wa", "sclk_gscl_wa", GATE_IP_GSCL1, 12, 0, 0),
707 GATE(CLK_GSCL_WB, "gscl_wb", "aclk300_gscl", GATE_IP_GSCL1, 13, 0, 0), 1093 GATE(CLK_GSCL_WB, "gscl_wb", "sclk_gscl_wb", GATE_IP_GSCL1, 13, 0, 0),
708 GATE(CLK_SMMU_FIMCL3, "smmu_fimcl3,", "aclk333_432_gscl", 1094 GATE(CLK_SMMU_FIMCL3, "smmu_fimcl3,", "dout_gscl_blk_333",
709 GATE_IP_GSCL1, 16, 0, 0), 1095 GATE_IP_GSCL1, 16, 0, 0),
710 GATE(CLK_FIMC_LITE3, "fimc_lite3", "aclk333_432_gscl", 1096 GATE(CLK_FIMC_LITE3, "fimc_lite3", "aclk333_432_gscl",
711 GATE_IP_GSCL1, 17, 0, 0), 1097 GATE_IP_GSCL1, 17, 0, 0),
712 1098
1099 /* MSCL Block */
1100 GATE(CLK_MSCL0, "mscl0", "aclk400_mscl", GATE_IP_MSCL, 0, 0, 0),
1101 GATE(CLK_MSCL1, "mscl1", "aclk400_mscl", GATE_IP_MSCL, 1, 0, 0),
1102 GATE(CLK_MSCL2, "mscl2", "aclk400_mscl", GATE_IP_MSCL, 2, 0, 0),
1103 GATE(CLK_SMMU_MSCL0, "smmu_mscl0", "dout_mscl_blk",
1104 GATE_IP_MSCL, 8, 0, 0),
1105 GATE(CLK_SMMU_MSCL1, "smmu_mscl1", "dout_mscl_blk",
1106 GATE_IP_MSCL, 9, 0, 0),
1107 GATE(CLK_SMMU_MSCL2, "smmu_mscl2", "dout_mscl_blk",
1108 GATE_IP_MSCL, 10, 0, 0),
1109
713 GATE(CLK_FIMD1, "fimd1", "aclk300_disp1", GATE_IP_DISP1, 0, 0, 0), 1110 GATE(CLK_FIMD1, "fimd1", "aclk300_disp1", GATE_IP_DISP1, 0, 0, 0),
714 GATE(CLK_DSIM1, "dsim1", "aclk200_disp1", GATE_IP_DISP1, 3, 0, 0), 1111 GATE(CLK_DSIM1, "dsim1", "aclk200_disp1", GATE_IP_DISP1, 3, 0, 0),
715 GATE(CLK_DP1, "dp1", "aclk200_disp1", GATE_IP_DISP1, 4, 0, 0), 1112 GATE(CLK_DP1, "dp1", "aclk200_disp1", GATE_IP_DISP1, 4, 0, 0),
716 GATE(CLK_MIXER, "mixer", "aclk166", GATE_IP_DISP1, 5, 0, 0), 1113 GATE(CLK_MIXER, "mixer", "aclk200_disp1", GATE_IP_DISP1, 5, 0, 0),
717 GATE(CLK_HDMI, "hdmi", "aclk200_disp1", GATE_IP_DISP1, 6, 0, 0), 1114 GATE(CLK_HDMI, "hdmi", "aclk200_disp1", GATE_IP_DISP1, 6, 0, 0),
718 GATE(CLK_SMMU_FIMD1, "smmu_fimd1", "aclk300_disp1", GATE_IP_DISP1, 8, 0, 1115 GATE(CLK_SMMU_FIMD1M0, "smmu_fimd1m0", "dout_disp1_blk",
719 0), 1116 GATE_IP_DISP1, 7, 0, 0),
1117 GATE(CLK_SMMU_FIMD1M1, "smmu_fimd1m1", "dout_disp1_blk",
1118 GATE_IP_DISP1, 8, 0, 0),
1119 GATE(CLK_SMMU_MIXER, "smmu_mixer", "aclk200_disp1",
1120 GATE_IP_DISP1, 9, 0, 0),
1121
1122 /* ISP */
1123 GATE(CLK_SCLK_UART_ISP, "sclk_uart_isp", "dout_uart_isp",
1124 GATE_TOP_SCLK_ISP, 0, CLK_SET_RATE_PARENT, 0),
1125 GATE(CLK_SCLK_SPI0_ISP, "sclk_spi0_isp", "dout_spi0_isp_pre",
1126 GATE_TOP_SCLK_ISP, 1, CLK_SET_RATE_PARENT, 0),
1127 GATE(CLK_SCLK_SPI1_ISP, "sclk_spi1_isp", "dout_spi1_isp_pre",
1128 GATE_TOP_SCLK_ISP, 2, CLK_SET_RATE_PARENT, 0),
1129 GATE(CLK_SCLK_PWM_ISP, "sclk_pwm_isp", "dout_pwm_isp",
1130 GATE_TOP_SCLK_ISP, 3, CLK_SET_RATE_PARENT, 0),
1131 GATE(CLK_SCLK_ISP_SENSOR0, "sclk_isp_sensor0", "dout_isp_sensor0",
1132 GATE_TOP_SCLK_ISP, 4, CLK_SET_RATE_PARENT, 0),
1133 GATE(CLK_SCLK_ISP_SENSOR1, "sclk_isp_sensor1", "dout_isp_sensor1",
1134 GATE_TOP_SCLK_ISP, 8, CLK_SET_RATE_PARENT, 0),
1135 GATE(CLK_SCLK_ISP_SENSOR2, "sclk_isp_sensor2", "dout_isp_sensor2",
1136 GATE_TOP_SCLK_ISP, 12, CLK_SET_RATE_PARENT, 0),
720 1137
721 GATE(CLK_MFC, "mfc", "aclk333", GATE_IP_MFC, 0, 0, 0), 1138 GATE(CLK_MFC, "mfc", "aclk333", GATE_IP_MFC, 0, 0, 0),
722 GATE(CLK_SMMU_MFCL, "smmu_mfcl", "aclk333", GATE_IP_MFC, 1, 0, 0), 1139 GATE(CLK_SMMU_MFCL, "smmu_mfcl", "dout_mfc_blk", GATE_IP_MFC, 1, 0, 0),
723 GATE(CLK_SMMU_MFCR, "smmu_mfcr", "aclk333", GATE_IP_MFC, 2, 0, 0), 1140 GATE(CLK_SMMU_MFCR, "smmu_mfcr", "dout_mfc_blk", GATE_IP_MFC, 2, 0, 0),
724
725 GATE(CLK_G3D, "g3d", "aclkg3d", GATE_IP_G3D, 9, 0, 0),
726 1141
727 GATE(CLK_ROTATOR, "rotator", "aclk266", GATE_IP_GEN, 1, 0, 0), 1142 GATE(CLK_G3D, "g3d", "mout_user_aclk_g3d", GATE_IP_G3D, 9, 0, 0),
728 GATE(CLK_JPEG, "jpeg", "aclk300_jpeg", GATE_IP_GEN, 2, 0, 0),
729 GATE(CLK_JPEG2, "jpeg2", "aclk300_jpeg", GATE_IP_GEN, 3, 0, 0),
730 GATE(CLK_MDMA1, "mdma1", "aclk266", GATE_IP_GEN, 4, 0, 0),
731 GATE(CLK_SMMU_ROTATOR, "smmu_rotator", "aclk266", GATE_IP_GEN, 6, 0, 0),
732 GATE(CLK_SMMU_JPEG, "smmu_jpeg", "aclk300_jpeg", GATE_IP_GEN, 7, 0, 0),
733 GATE(CLK_SMMU_MDMA1, "smmu_mdma1", "aclk266", GATE_IP_GEN, 9, 0, 0),
734
735 GATE(CLK_MSCL0, "mscl0", "aclk400_mscl", GATE_IP_MSCL, 0, 0, 0),
736 GATE(CLK_MSCL1, "mscl1", "aclk400_mscl", GATE_IP_MSCL, 1, 0, 0),
737 GATE(CLK_MSCL2, "mscl2", "aclk400_mscl", GATE_IP_MSCL, 2, 0, 0),
738 GATE(CLK_SMMU_MSCL0, "smmu_mscl0", "aclk400_mscl", GATE_IP_MSCL, 8, 0,
739 0),
740 GATE(CLK_SMMU_MSCL1, "smmu_mscl1", "aclk400_mscl", GATE_IP_MSCL, 9, 0,
741 0),
742 GATE(CLK_SMMU_MSCL2, "smmu_mscl2", "aclk400_mscl", GATE_IP_MSCL, 10, 0,
743 0),
744 GATE(CLK_SMMU_MIXER, "smmu_mixer", "aclk200_disp1", GATE_IP_DISP1, 9, 0,
745 0),
746}; 1143};
747 1144
748static struct samsung_pll_clock exynos5420_plls[nr_plls] __initdata = { 1145static struct samsung_pll_clock exynos5x_plls[nr_plls] __initdata = {
749 [apll] = PLL(pll_2550, CLK_FOUT_APLL, "fout_apll", "fin_pll", APLL_LOCK, 1146 [apll] = PLL(pll_2550, CLK_FOUT_APLL, "fout_apll", "fin_pll", APLL_LOCK,
750 APLL_CON0, NULL), 1147 APLL_CON0, NULL),
751 [cpll] = PLL(pll_2550, CLK_FOUT_CPLL, "fout_cpll", "fin_pll", CPLL_LOCK, 1148 [cpll] = PLL(pll_2550, CLK_FOUT_CPLL, "fout_cpll", "fin_pll", CPLL_LOCK,
@@ -776,8 +1173,11 @@ static struct of_device_id ext_clk_match[] __initdata = {
776}; 1173};
777 1174
778/* register exynos5420 clocks */ 1175/* register exynos5420 clocks */
779static void __init exynos5420_clk_init(struct device_node *np) 1176static void __init exynos5x_clk_init(struct device_node *np,
1177 enum exynos5x_soc soc)
780{ 1178{
1179 struct samsung_clk_provider *ctx;
1180
781 if (np) { 1181 if (np) {
782 reg_base = of_iomap(np, 0); 1182 reg_base = of_iomap(np, 0);
783 if (!reg_base) 1183 if (!reg_base)
@@ -786,23 +1186,56 @@ static void __init exynos5420_clk_init(struct device_node *np)
786 panic("%s: unable to determine soc\n", __func__); 1186 panic("%s: unable to determine soc\n", __func__);
787 } 1187 }
788 1188
789 samsung_clk_init(np, reg_base, CLK_NR_CLKS); 1189 exynos5x_soc = soc;
790 samsung_clk_of_register_fixed_ext(exynos5420_fixed_rate_ext_clks, 1190
791 ARRAY_SIZE(exynos5420_fixed_rate_ext_clks), 1191 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
1192 if (!ctx)
1193 panic("%s: unable to allocate context.\n", __func__);
1194
1195 samsung_clk_of_register_fixed_ext(ctx, exynos5x_fixed_rate_ext_clks,
1196 ARRAY_SIZE(exynos5x_fixed_rate_ext_clks),
792 ext_clk_match); 1197 ext_clk_match);
793 samsung_clk_register_pll(exynos5420_plls, ARRAY_SIZE(exynos5420_plls), 1198 samsung_clk_register_pll(ctx, exynos5x_plls, ARRAY_SIZE(exynos5x_plls),
794 reg_base); 1199 reg_base);
795 samsung_clk_register_fixed_rate(exynos5420_fixed_rate_clks, 1200 samsung_clk_register_fixed_rate(ctx, exynos5x_fixed_rate_clks,
796 ARRAY_SIZE(exynos5420_fixed_rate_clks)); 1201 ARRAY_SIZE(exynos5x_fixed_rate_clks));
797 samsung_clk_register_fixed_factor(exynos5420_fixed_factor_clks, 1202 samsung_clk_register_fixed_factor(ctx, exynos5x_fixed_factor_clks,
798 ARRAY_SIZE(exynos5420_fixed_factor_clks)); 1203 ARRAY_SIZE(exynos5x_fixed_factor_clks));
799 samsung_clk_register_mux(exynos5420_mux_clks, 1204 samsung_clk_register_mux(ctx, exynos5x_mux_clks,
800 ARRAY_SIZE(exynos5420_mux_clks)); 1205 ARRAY_SIZE(exynos5x_mux_clks));
801 samsung_clk_register_div(exynos5420_div_clks, 1206 samsung_clk_register_div(ctx, exynos5x_div_clks,
802 ARRAY_SIZE(exynos5420_div_clks)); 1207 ARRAY_SIZE(exynos5x_div_clks));
803 samsung_clk_register_gate(exynos5420_gate_clks, 1208 samsung_clk_register_gate(ctx, exynos5x_gate_clks,
804 ARRAY_SIZE(exynos5420_gate_clks)); 1209 ARRAY_SIZE(exynos5x_gate_clks));
1210
1211 if (soc == EXYNOS5420) {
1212 samsung_clk_register_mux(ctx, exynos5420_mux_clks,
1213 ARRAY_SIZE(exynos5420_mux_clks));
1214 samsung_clk_register_div(ctx, exynos5420_div_clks,
1215 ARRAY_SIZE(exynos5420_div_clks));
1216 } else {
1217 samsung_clk_register_fixed_factor(
1218 ctx, exynos5800_fixed_factor_clks,
1219 ARRAY_SIZE(exynos5800_fixed_factor_clks));
1220 samsung_clk_register_mux(ctx, exynos5800_mux_clks,
1221 ARRAY_SIZE(exynos5800_mux_clks));
1222 samsung_clk_register_div(ctx, exynos5800_div_clks,
1223 ARRAY_SIZE(exynos5800_div_clks));
1224 samsung_clk_register_gate(ctx, exynos5800_gate_clks,
1225 ARRAY_SIZE(exynos5800_gate_clks));
1226 }
805 1227
806 exynos5420_clk_sleep_init(); 1228 exynos5420_clk_sleep_init();
807} 1229}
1230
1231static void __init exynos5420_clk_init(struct device_node *np)
1232{
1233 exynos5x_clk_init(np, EXYNOS5420);
1234}
808CLK_OF_DECLARE(exynos5420_clk, "samsung,exynos5420-clock", exynos5420_clk_init); 1235CLK_OF_DECLARE(exynos5420_clk, "samsung,exynos5420-clock", exynos5420_clk_init);
1236
1237static void __init exynos5800_clk_init(struct device_node *np)
1238{
1239 exynos5x_clk_init(np, EXYNOS5800);
1240}
1241CLK_OF_DECLARE(exynos5800_clk, "samsung,exynos5800-clock", exynos5800_clk_init);
diff --git a/drivers/clk/samsung/clk-exynos5440.c b/drivers/clk/samsung/clk-exynos5440.c
index 2bfad5a993d0..647f1440aa6a 100644
--- a/drivers/clk/samsung/clk-exynos5440.c
+++ b/drivers/clk/samsung/clk-exynos5440.c
@@ -93,6 +93,7 @@ static struct of_device_id ext_clk_match[] __initdata = {
93static void __init exynos5440_clk_init(struct device_node *np) 93static void __init exynos5440_clk_init(struct device_node *np)
94{ 94{
95 void __iomem *reg_base; 95 void __iomem *reg_base;
96 struct samsung_clk_provider *ctx;
96 97
97 reg_base = of_iomap(np, 0); 98 reg_base = of_iomap(np, 0);
98 if (!reg_base) { 99 if (!reg_base) {
@@ -101,22 +102,25 @@ static void __init exynos5440_clk_init(struct device_node *np)
101 return; 102 return;
102 } 103 }
103 104
104 samsung_clk_init(np, reg_base, CLK_NR_CLKS); 105 ctx = samsung_clk_init(np, reg_base, CLK_NR_CLKS);
105 samsung_clk_of_register_fixed_ext(exynos5440_fixed_rate_ext_clks, 106 if (!ctx)
107 panic("%s: unable to allocate context.\n", __func__);
108
109 samsung_clk_of_register_fixed_ext(ctx, exynos5440_fixed_rate_ext_clks,
106 ARRAY_SIZE(exynos5440_fixed_rate_ext_clks), ext_clk_match); 110 ARRAY_SIZE(exynos5440_fixed_rate_ext_clks), ext_clk_match);
107 111
108 samsung_clk_register_pll2550x("cplla", "xtal", reg_base + 0x1c, 0x10); 112 samsung_clk_register_pll2550x("cplla", "xtal", reg_base + 0x1c, 0x10);
109 samsung_clk_register_pll2550x("cpllb", "xtal", reg_base + 0x20, 0x10); 113 samsung_clk_register_pll2550x("cpllb", "xtal", reg_base + 0x20, 0x10);
110 114
111 samsung_clk_register_fixed_rate(exynos5440_fixed_rate_clks, 115 samsung_clk_register_fixed_rate(ctx, exynos5440_fixed_rate_clks,
112 ARRAY_SIZE(exynos5440_fixed_rate_clks)); 116 ARRAY_SIZE(exynos5440_fixed_rate_clks));
113 samsung_clk_register_fixed_factor(exynos5440_fixed_factor_clks, 117 samsung_clk_register_fixed_factor(ctx, exynos5440_fixed_factor_clks,
114 ARRAY_SIZE(exynos5440_fixed_factor_clks)); 118 ARRAY_SIZE(exynos5440_fixed_factor_clks));
115 samsung_clk_register_mux(exynos5440_mux_clks, 119 samsung_clk_register_mux(ctx, exynos5440_mux_clks,
116 ARRAY_SIZE(exynos5440_mux_clks)); 120 ARRAY_SIZE(exynos5440_mux_clks));
117 samsung_clk_register_div(exynos5440_div_clks, 121 samsung_clk_register_div(ctx, exynos5440_div_clks,
118 ARRAY_SIZE(exynos5440_div_clks)); 122 ARRAY_SIZE(exynos5440_div_clks));
119 samsung_clk_register_gate(exynos5440_gate_clks, 123 samsung_clk_register_gate(ctx, exynos5440_gate_clks,
120 ARRAY_SIZE(exynos5440_gate_clks)); 124 ARRAY_SIZE(exynos5440_gate_clks));
121 125
122 pr_info("Exynos5440: arm_clk = %ldHz\n", _get_rate("arm_clk")); 126 pr_info("Exynos5440: arm_clk = %ldHz\n", _get_rate("arm_clk"));
diff --git a/drivers/clk/samsung/clk-pll.c b/drivers/clk/samsung/clk-pll.c
index 7fb0a28e65d5..b07fad2a9167 100644
--- a/drivers/clk/samsung/clk-pll.c
+++ b/drivers/clk/samsung/clk-pll.c
@@ -947,8 +947,206 @@ struct clk * __init samsung_clk_register_pll2550x(const char *name,
947 return clk; 947 return clk;
948} 948}
949 949
950static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk, 950/*
951 void __iomem *base) 951 * PLL2550xx Clock Type
952 */
953
954/* Maximum lock time can be 270 * PDIV cycles */
955#define PLL2550XX_LOCK_FACTOR 270
956
957#define PLL2550XX_M_MASK 0x3FF
958#define PLL2550XX_P_MASK 0x3F
959#define PLL2550XX_S_MASK 0x7
960#define PLL2550XX_LOCK_STAT_MASK 0x1
961#define PLL2550XX_M_SHIFT 9
962#define PLL2550XX_P_SHIFT 3
963#define PLL2550XX_S_SHIFT 0
964#define PLL2550XX_LOCK_STAT_SHIFT 21
965
966static unsigned long samsung_pll2550xx_recalc_rate(struct clk_hw *hw,
967 unsigned long parent_rate)
968{
969 struct samsung_clk_pll *pll = to_clk_pll(hw);
970 u32 mdiv, pdiv, sdiv, pll_con;
971 u64 fvco = parent_rate;
972
973 pll_con = __raw_readl(pll->con_reg);
974 mdiv = (pll_con >> PLL2550XX_M_SHIFT) & PLL2550XX_M_MASK;
975 pdiv = (pll_con >> PLL2550XX_P_SHIFT) & PLL2550XX_P_MASK;
976 sdiv = (pll_con >> PLL2550XX_S_SHIFT) & PLL2550XX_S_MASK;
977
978 fvco *= mdiv;
979 do_div(fvco, (pdiv << sdiv));
980
981 return (unsigned long)fvco;
982}
983
984static inline bool samsung_pll2550xx_mp_change(u32 mdiv, u32 pdiv, u32 pll_con)
985{
986 u32 old_mdiv, old_pdiv;
987
988 old_mdiv = (pll_con >> PLL2550XX_M_SHIFT) & PLL2550XX_M_MASK;
989 old_pdiv = (pll_con >> PLL2550XX_P_SHIFT) & PLL2550XX_P_MASK;
990
991 return mdiv != old_mdiv || pdiv != old_pdiv;
992}
993
994static int samsung_pll2550xx_set_rate(struct clk_hw *hw, unsigned long drate,
995 unsigned long prate)
996{
997 struct samsung_clk_pll *pll = to_clk_pll(hw);
998 const struct samsung_pll_rate_table *rate;
999 u32 tmp;
1000
1001 /* Get required rate settings from table */
1002 rate = samsung_get_pll_settings(pll, drate);
1003 if (!rate) {
1004 pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__,
1005 drate, __clk_get_name(hw->clk));
1006 return -EINVAL;
1007 }
1008
1009 tmp = __raw_readl(pll->con_reg);
1010
1011 if (!(samsung_pll2550xx_mp_change(rate->mdiv, rate->pdiv, tmp))) {
1012 /* If only s change, change just s value only*/
1013 tmp &= ~(PLL2550XX_S_MASK << PLL2550XX_S_SHIFT);
1014 tmp |= rate->sdiv << PLL2550XX_S_SHIFT;
1015 __raw_writel(tmp, pll->con_reg);
1016
1017 return 0;
1018 }
1019
1020 /* Set PLL lock time. */
1021 __raw_writel(rate->pdiv * PLL2550XX_LOCK_FACTOR, pll->lock_reg);
1022
1023 /* Change PLL PMS values */
1024 tmp &= ~((PLL2550XX_M_MASK << PLL2550XX_M_SHIFT) |
1025 (PLL2550XX_P_MASK << PLL2550XX_P_SHIFT) |
1026 (PLL2550XX_S_MASK << PLL2550XX_S_SHIFT));
1027 tmp |= (rate->mdiv << PLL2550XX_M_SHIFT) |
1028 (rate->pdiv << PLL2550XX_P_SHIFT) |
1029 (rate->sdiv << PLL2550XX_S_SHIFT);
1030 __raw_writel(tmp, pll->con_reg);
1031
1032 /* wait_lock_time */
1033 do {
1034 cpu_relax();
1035 tmp = __raw_readl(pll->con_reg);
1036 } while (!(tmp & (PLL2550XX_LOCK_STAT_MASK
1037 << PLL2550XX_LOCK_STAT_SHIFT)));
1038
1039 return 0;
1040}
1041
1042static const struct clk_ops samsung_pll2550xx_clk_ops = {
1043 .recalc_rate = samsung_pll2550xx_recalc_rate,
1044 .round_rate = samsung_pll_round_rate,
1045 .set_rate = samsung_pll2550xx_set_rate,
1046};
1047
1048static const struct clk_ops samsung_pll2550xx_clk_min_ops = {
1049 .recalc_rate = samsung_pll2550xx_recalc_rate,
1050};
1051
1052/*
1053 * PLL2650XX Clock Type
1054 */
1055
1056/* Maximum lock time can be 3000 * PDIV cycles */
1057#define PLL2650XX_LOCK_FACTOR 3000
1058
1059#define PLL2650XX_MDIV_SHIFT 9
1060#define PLL2650XX_PDIV_SHIFT 3
1061#define PLL2650XX_SDIV_SHIFT 0
1062#define PLL2650XX_KDIV_SHIFT 0
1063#define PLL2650XX_MDIV_MASK 0x1ff
1064#define PLL2650XX_PDIV_MASK 0x3f
1065#define PLL2650XX_SDIV_MASK 0x7
1066#define PLL2650XX_KDIV_MASK 0xffff
1067#define PLL2650XX_PLL_ENABLE_SHIFT 23
1068#define PLL2650XX_PLL_LOCKTIME_SHIFT 21
1069#define PLL2650XX_PLL_FOUTMASK_SHIFT 31
1070
1071static unsigned long samsung_pll2650xx_recalc_rate(struct clk_hw *hw,
1072 unsigned long parent_rate)
1073{
1074 struct samsung_clk_pll *pll = to_clk_pll(hw);
1075 u32 mdiv, pdiv, sdiv, pll_con0, pll_con2;
1076 s16 kdiv;
1077 u64 fvco = parent_rate;
1078
1079 pll_con0 = __raw_readl(pll->con_reg);
1080 pll_con2 = __raw_readl(pll->con_reg + 8);
1081 mdiv = (pll_con0 >> PLL2650XX_MDIV_SHIFT) & PLL2650XX_MDIV_MASK;
1082 pdiv = (pll_con0 >> PLL2650XX_PDIV_SHIFT) & PLL2650XX_PDIV_MASK;
1083 sdiv = (pll_con0 >> PLL2650XX_SDIV_SHIFT) & PLL2650XX_SDIV_MASK;
1084 kdiv = (s16)(pll_con2 & PLL2650XX_KDIV_MASK);
1085
1086 fvco *= (mdiv << 16) + kdiv;
1087 do_div(fvco, (pdiv << sdiv));
1088 fvco >>= 16;
1089
1090 return (unsigned long)fvco;
1091}
1092
1093static int samsung_pll2650xx_set_rate(struct clk_hw *hw, unsigned long drate,
1094 unsigned long parent_rate)
1095{
1096 struct samsung_clk_pll *pll = to_clk_pll(hw);
1097 u32 tmp, pll_con0, pll_con2;
1098 const struct samsung_pll_rate_table *rate;
1099
1100 rate = samsung_get_pll_settings(pll, drate);
1101 if (!rate) {
1102 pr_err("%s: Invalid rate : %lu for pll clk %s\n", __func__,
1103 drate, __clk_get_name(hw->clk));
1104 return -EINVAL;
1105 }
1106
1107 pll_con0 = __raw_readl(pll->con_reg);
1108 pll_con2 = __raw_readl(pll->con_reg + 8);
1109
1110 /* Change PLL PMS values */
1111 pll_con0 &= ~(PLL2650XX_MDIV_MASK << PLL2650XX_MDIV_SHIFT |
1112 PLL2650XX_PDIV_MASK << PLL2650XX_PDIV_SHIFT |
1113 PLL2650XX_SDIV_MASK << PLL2650XX_SDIV_SHIFT);
1114 pll_con0 |= rate->mdiv << PLL2650XX_MDIV_SHIFT;
1115 pll_con0 |= rate->pdiv << PLL2650XX_PDIV_SHIFT;
1116 pll_con0 |= rate->sdiv << PLL2650XX_SDIV_SHIFT;
1117 pll_con0 |= 1 << PLL2650XX_PLL_ENABLE_SHIFT;
1118 pll_con0 |= 1 << PLL2650XX_PLL_FOUTMASK_SHIFT;
1119
1120 pll_con2 &= ~(PLL2650XX_KDIV_MASK << PLL2650XX_KDIV_SHIFT);
1121 pll_con2 |= ((~(rate->kdiv) + 1) & PLL2650XX_KDIV_MASK)
1122 << PLL2650XX_KDIV_SHIFT;
1123
1124 /* Set PLL lock time. */
1125 __raw_writel(PLL2650XX_LOCK_FACTOR * rate->pdiv, pll->lock_reg);
1126
1127 __raw_writel(pll_con0, pll->con_reg);
1128 __raw_writel(pll_con2, pll->con_reg + 8);
1129
1130 do {
1131 tmp = __raw_readl(pll->con_reg);
1132 } while (!(tmp & (0x1 << PLL2650XX_PLL_LOCKTIME_SHIFT)));
1133
1134 return 0;
1135}
1136
1137static const struct clk_ops samsung_pll2650xx_clk_ops = {
1138 .recalc_rate = samsung_pll2650xx_recalc_rate,
1139 .set_rate = samsung_pll2650xx_set_rate,
1140 .round_rate = samsung_pll_round_rate,
1141};
1142
1143static const struct clk_ops samsung_pll2650xx_clk_min_ops = {
1144 .recalc_rate = samsung_pll2650xx_recalc_rate,
1145};
1146
1147static void __init _samsung_clk_register_pll(struct samsung_clk_provider *ctx,
1148 struct samsung_pll_clock *pll_clk,
1149 void __iomem *base)
952{ 1150{
953 struct samsung_clk_pll *pll; 1151 struct samsung_clk_pll *pll;
954 struct clk *clk; 1152 struct clk *clk;
@@ -1048,6 +1246,18 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
1048 else 1246 else
1049 init.ops = &samsung_s3c2440_mpll_clk_ops; 1247 init.ops = &samsung_s3c2440_mpll_clk_ops;
1050 break; 1248 break;
1249 case pll_2550xx:
1250 if (!pll->rate_table)
1251 init.ops = &samsung_pll2550xx_clk_min_ops;
1252 else
1253 init.ops = &samsung_pll2550xx_clk_ops;
1254 break;
1255 case pll_2650xx:
1256 if (!pll->rate_table)
1257 init.ops = &samsung_pll2650xx_clk_min_ops;
1258 else
1259 init.ops = &samsung_pll2650xx_clk_ops;
1260 break;
1051 default: 1261 default:
1052 pr_warn("%s: Unknown pll type for pll clk %s\n", 1262 pr_warn("%s: Unknown pll type for pll clk %s\n",
1053 __func__, pll_clk->name); 1263 __func__, pll_clk->name);
@@ -1066,7 +1276,7 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
1066 return; 1276 return;
1067 } 1277 }
1068 1278
1069 samsung_clk_add_lookup(clk, pll_clk->id); 1279 samsung_clk_add_lookup(ctx, clk, pll_clk->id);
1070 1280
1071 if (!pll_clk->alias) 1281 if (!pll_clk->alias)
1072 return; 1282 return;
@@ -1077,11 +1287,12 @@ static void __init _samsung_clk_register_pll(struct samsung_pll_clock *pll_clk,
1077 __func__, pll_clk->name, ret); 1287 __func__, pll_clk->name, ret);
1078} 1288}
1079 1289
1080void __init samsung_clk_register_pll(struct samsung_pll_clock *pll_list, 1290void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx,
1081 unsigned int nr_pll, void __iomem *base) 1291 struct samsung_pll_clock *pll_list,
1292 unsigned int nr_pll, void __iomem *base)
1082{ 1293{
1083 int cnt; 1294 int cnt;
1084 1295
1085 for (cnt = 0; cnt < nr_pll; cnt++) 1296 for (cnt = 0; cnt < nr_pll; cnt++)
1086 _samsung_clk_register_pll(&pll_list[cnt], base); 1297 _samsung_clk_register_pll(ctx, &pll_list[cnt], base);
1087} 1298}
diff --git a/drivers/clk/samsung/clk-pll.h b/drivers/clk/samsung/clk-pll.h
index 6428bcc6df6f..c0ed4d41fd90 100644
--- a/drivers/clk/samsung/clk-pll.h
+++ b/drivers/clk/samsung/clk-pll.h
@@ -31,6 +31,8 @@ enum samsung_pll_type {
31 pll_s3c2410_mpll, 31 pll_s3c2410_mpll,
32 pll_s3c2410_upll, 32 pll_s3c2410_upll,
33 pll_s3c2440_mpll, 33 pll_s3c2440_mpll,
34 pll_2550xx,
35 pll_2650xx,
34}; 36};
35 37
36#define PLL_35XX_RATE(_rate, _m, _p, _s) \ 38#define PLL_35XX_RATE(_rate, _m, _p, _s) \
diff --git a/drivers/clk/samsung/clk-s3c2410.c b/drivers/clk/samsung/clk-s3c2410.c
index 7b4182186a30..ba0716801db2 100644
--- a/drivers/clk/samsung/clk-s3c2410.c
+++ b/drivers/clk/samsung/clk-s3c2410.c
@@ -344,21 +344,24 @@ struct samsung_fixed_rate_clock s3c2410_common_frate_clks[] __initdata = {
344 FRATE(XTI, "xti", NULL, CLK_IS_ROOT, 0), 344 FRATE(XTI, "xti", NULL, CLK_IS_ROOT, 0),
345}; 345};
346 346
347static void __init s3c2410_common_clk_register_fixed_ext(unsigned long xti_f) 347static void __init s3c2410_common_clk_register_fixed_ext(
348 struct samsung_clk_provider *ctx,
349 unsigned long xti_f)
348{ 350{
349 struct samsung_clock_alias xti_alias = ALIAS(XTI, NULL, "xtal"); 351 struct samsung_clock_alias xti_alias = ALIAS(XTI, NULL, "xtal");
350 352
351 s3c2410_common_frate_clks[0].fixed_rate = xti_f; 353 s3c2410_common_frate_clks[0].fixed_rate = xti_f;
352 samsung_clk_register_fixed_rate(s3c2410_common_frate_clks, 354 samsung_clk_register_fixed_rate(ctx, s3c2410_common_frate_clks,
353 ARRAY_SIZE(s3c2410_common_frate_clks)); 355 ARRAY_SIZE(s3c2410_common_frate_clks));
354 356
355 samsung_clk_register_alias(&xti_alias, 1); 357 samsung_clk_register_alias(ctx, &xti_alias, 1);
356} 358}
357 359
358void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f, 360void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
359 int current_soc, 361 int current_soc,
360 void __iomem *base) 362 void __iomem *base)
361{ 363{
364 struct samsung_clk_provider *ctx;
362 reg_base = base; 365 reg_base = base;
363 366
364 if (np) { 367 if (np) {
@@ -367,11 +370,13 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
367 panic("%s: failed to map registers\n", __func__); 370 panic("%s: failed to map registers\n", __func__);
368 } 371 }
369 372
370 samsung_clk_init(np, reg_base, NR_CLKS); 373 ctx = samsung_clk_init(np, reg_base, NR_CLKS);
374 if (!ctx)
375 panic("%s: unable to allocate context.\n", __func__);
371 376
372 /* Register external clocks only in non-dt cases */ 377 /* Register external clocks only in non-dt cases */
373 if (!np) 378 if (!np)
374 s3c2410_common_clk_register_fixed_ext(xti_f); 379 s3c2410_common_clk_register_fixed_ext(ctx, xti_f);
375 380
376 if (current_soc == 2410) { 381 if (current_soc == 2410) {
377 if (_get_rate("xti") == 12 * MHZ) { 382 if (_get_rate("xti") == 12 * MHZ) {
@@ -380,7 +385,7 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
380 } 385 }
381 386
382 /* Register PLLs. */ 387 /* Register PLLs. */
383 samsung_clk_register_pll(s3c2410_plls, 388 samsung_clk_register_pll(ctx, s3c2410_plls,
384 ARRAY_SIZE(s3c2410_plls), reg_base); 389 ARRAY_SIZE(s3c2410_plls), reg_base);
385 390
386 } else { /* S3C2440, S3C2442 */ 391 } else { /* S3C2440, S3C2442 */
@@ -396,49 +401,49 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
396 } 401 }
397 402
398 /* Register PLLs. */ 403 /* Register PLLs. */
399 samsung_clk_register_pll(s3c244x_common_plls, 404 samsung_clk_register_pll(ctx, s3c244x_common_plls,
400 ARRAY_SIZE(s3c244x_common_plls), reg_base); 405 ARRAY_SIZE(s3c244x_common_plls), reg_base);
401 } 406 }
402 407
403 /* Register common internal clocks. */ 408 /* Register common internal clocks. */
404 samsung_clk_register_mux(s3c2410_common_muxes, 409 samsung_clk_register_mux(ctx, s3c2410_common_muxes,
405 ARRAY_SIZE(s3c2410_common_muxes)); 410 ARRAY_SIZE(s3c2410_common_muxes));
406 samsung_clk_register_div(s3c2410_common_dividers, 411 samsung_clk_register_div(ctx, s3c2410_common_dividers,
407 ARRAY_SIZE(s3c2410_common_dividers)); 412 ARRAY_SIZE(s3c2410_common_dividers));
408 samsung_clk_register_gate(s3c2410_common_gates, 413 samsung_clk_register_gate(ctx, s3c2410_common_gates,
409 ARRAY_SIZE(s3c2410_common_gates)); 414 ARRAY_SIZE(s3c2410_common_gates));
410 415
411 if (current_soc == S3C2440 || current_soc == S3C2442) { 416 if (current_soc == S3C2440 || current_soc == S3C2442) {
412 samsung_clk_register_div(s3c244x_common_dividers, 417 samsung_clk_register_div(ctx, s3c244x_common_dividers,
413 ARRAY_SIZE(s3c244x_common_dividers)); 418 ARRAY_SIZE(s3c244x_common_dividers));
414 samsung_clk_register_gate(s3c244x_common_gates, 419 samsung_clk_register_gate(ctx, s3c244x_common_gates,
415 ARRAY_SIZE(s3c244x_common_gates)); 420 ARRAY_SIZE(s3c244x_common_gates));
416 samsung_clk_register_mux(s3c244x_common_muxes, 421 samsung_clk_register_mux(ctx, s3c244x_common_muxes,
417 ARRAY_SIZE(s3c244x_common_muxes)); 422 ARRAY_SIZE(s3c244x_common_muxes));
418 samsung_clk_register_fixed_factor(s3c244x_common_ffactor, 423 samsung_clk_register_fixed_factor(ctx, s3c244x_common_ffactor,
419 ARRAY_SIZE(s3c244x_common_ffactor)); 424 ARRAY_SIZE(s3c244x_common_ffactor));
420 } 425 }
421 426
422 /* Register SoC-specific clocks. */ 427 /* Register SoC-specific clocks. */
423 switch (current_soc) { 428 switch (current_soc) {
424 case S3C2410: 429 case S3C2410:
425 samsung_clk_register_div(s3c2410_dividers, 430 samsung_clk_register_div(ctx, s3c2410_dividers,
426 ARRAY_SIZE(s3c2410_dividers)); 431 ARRAY_SIZE(s3c2410_dividers));
427 samsung_clk_register_fixed_factor(s3c2410_ffactor, 432 samsung_clk_register_fixed_factor(ctx, s3c2410_ffactor,
428 ARRAY_SIZE(s3c2410_ffactor)); 433 ARRAY_SIZE(s3c2410_ffactor));
429 samsung_clk_register_alias(s3c2410_aliases, 434 samsung_clk_register_alias(ctx, s3c2410_aliases,
430 ARRAY_SIZE(s3c2410_common_aliases)); 435 ARRAY_SIZE(s3c2410_common_aliases));
431 break; 436 break;
432 case S3C2440: 437 case S3C2440:
433 samsung_clk_register_mux(s3c2440_muxes, 438 samsung_clk_register_mux(ctx, s3c2440_muxes,
434 ARRAY_SIZE(s3c2440_muxes)); 439 ARRAY_SIZE(s3c2440_muxes));
435 samsung_clk_register_gate(s3c2440_gates, 440 samsung_clk_register_gate(ctx, s3c2440_gates,
436 ARRAY_SIZE(s3c2440_gates)); 441 ARRAY_SIZE(s3c2440_gates));
437 break; 442 break;
438 case S3C2442: 443 case S3C2442:
439 samsung_clk_register_mux(s3c2442_muxes, 444 samsung_clk_register_mux(ctx, s3c2442_muxes,
440 ARRAY_SIZE(s3c2442_muxes)); 445 ARRAY_SIZE(s3c2442_muxes));
441 samsung_clk_register_fixed_factor(s3c2442_ffactor, 446 samsung_clk_register_fixed_factor(ctx, s3c2442_ffactor,
442 ARRAY_SIZE(s3c2442_ffactor)); 447 ARRAY_SIZE(s3c2442_ffactor));
443 break; 448 break;
444 } 449 }
@@ -447,11 +452,11 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
447 * Register common aliases at the end, as some of the aliased clocks 452 * Register common aliases at the end, as some of the aliased clocks
448 * are SoC specific. 453 * are SoC specific.
449 */ 454 */
450 samsung_clk_register_alias(s3c2410_common_aliases, 455 samsung_clk_register_alias(ctx, s3c2410_common_aliases,
451 ARRAY_SIZE(s3c2410_common_aliases)); 456 ARRAY_SIZE(s3c2410_common_aliases));
452 457
453 if (current_soc == S3C2440 || current_soc == S3C2442) { 458 if (current_soc == S3C2440 || current_soc == S3C2442) {
454 samsung_clk_register_alias(s3c244x_common_aliases, 459 samsung_clk_register_alias(ctx, s3c244x_common_aliases,
455 ARRAY_SIZE(s3c244x_common_aliases)); 460 ARRAY_SIZE(s3c244x_common_aliases));
456 } 461 }
457 462
diff --git a/drivers/clk/samsung/clk-s3c2412.c b/drivers/clk/samsung/clk-s3c2412.c
index 0f11a07d5c01..23e4313f625e 100644
--- a/drivers/clk/samsung/clk-s3c2412.c
+++ b/drivers/clk/samsung/clk-s3c2412.c
@@ -214,23 +214,25 @@ struct samsung_fixed_rate_clock s3c2412_common_frate_clks[] __initdata = {
214 FRATE(0, "ext", NULL, CLK_IS_ROOT, 0), 214 FRATE(0, "ext", NULL, CLK_IS_ROOT, 0),
215}; 215};
216 216
217static void __init s3c2412_common_clk_register_fixed_ext(unsigned long xti_f, 217static void __init s3c2412_common_clk_register_fixed_ext(
218 unsigned long ext_f) 218 struct samsung_clk_provider *ctx,
219 unsigned long xti_f, unsigned long ext_f)
219{ 220{
220 /* xtal alias is necessary for the current cpufreq driver */ 221 /* xtal alias is necessary for the current cpufreq driver */
221 struct samsung_clock_alias xti_alias = ALIAS(XTI, NULL, "xtal"); 222 struct samsung_clock_alias xti_alias = ALIAS(XTI, NULL, "xtal");
222 223
223 s3c2412_common_frate_clks[0].fixed_rate = xti_f; 224 s3c2412_common_frate_clks[0].fixed_rate = xti_f;
224 s3c2412_common_frate_clks[1].fixed_rate = ext_f; 225 s3c2412_common_frate_clks[1].fixed_rate = ext_f;
225 samsung_clk_register_fixed_rate(s3c2412_common_frate_clks, 226 samsung_clk_register_fixed_rate(ctx, s3c2412_common_frate_clks,
226 ARRAY_SIZE(s3c2412_common_frate_clks)); 227 ARRAY_SIZE(s3c2412_common_frate_clks));
227 228
228 samsung_clk_register_alias(&xti_alias, 1); 229 samsung_clk_register_alias(ctx, &xti_alias, 1);
229} 230}
230 231
231void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f, 232void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
232 unsigned long ext_f, void __iomem *base) 233 unsigned long ext_f, void __iomem *base)
233{ 234{
235 struct samsung_clk_provider *ctx;
234 reg_base = base; 236 reg_base = base;
235 237
236 if (np) { 238 if (np) {
@@ -239,24 +241,27 @@ void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
239 panic("%s: failed to map registers\n", __func__); 241 panic("%s: failed to map registers\n", __func__);
240 } 242 }
241 243
242 samsung_clk_init(np, reg_base, NR_CLKS); 244 ctx = samsung_clk_init(np, reg_base, NR_CLKS);
245 if (!ctx)
246 panic("%s: unable to allocate context.\n", __func__);
243 247
244 /* Register external clocks only in non-dt cases */ 248 /* Register external clocks only in non-dt cases */
245 if (!np) 249 if (!np)
246 s3c2412_common_clk_register_fixed_ext(xti_f, ext_f); 250 s3c2412_common_clk_register_fixed_ext(ctx, xti_f, ext_f);
247 251
248 /* Register PLLs. */ 252 /* Register PLLs. */
249 samsung_clk_register_pll(s3c2412_plls, ARRAY_SIZE(s3c2412_plls), 253 samsung_clk_register_pll(ctx, s3c2412_plls, ARRAY_SIZE(s3c2412_plls),
250 reg_base); 254 reg_base);
251 255
252 /* Register common internal clocks. */ 256 /* Register common internal clocks. */
253 samsung_clk_register_mux(s3c2412_muxes, ARRAY_SIZE(s3c2412_muxes)); 257 samsung_clk_register_mux(ctx, s3c2412_muxes, ARRAY_SIZE(s3c2412_muxes));
254 samsung_clk_register_div(s3c2412_dividers, 258 samsung_clk_register_div(ctx, s3c2412_dividers,
255 ARRAY_SIZE(s3c2412_dividers)); 259 ARRAY_SIZE(s3c2412_dividers));
256 samsung_clk_register_gate(s3c2412_gates, ARRAY_SIZE(s3c2412_gates)); 260 samsung_clk_register_gate(ctx, s3c2412_gates,
257 samsung_clk_register_fixed_factor(s3c2412_ffactor, 261 ARRAY_SIZE(s3c2412_gates));
262 samsung_clk_register_fixed_factor(ctx, s3c2412_ffactor,
258 ARRAY_SIZE(s3c2412_ffactor)); 263 ARRAY_SIZE(s3c2412_ffactor));
259 samsung_clk_register_alias(s3c2412_aliases, 264 samsung_clk_register_alias(ctx, s3c2412_aliases,
260 ARRAY_SIZE(s3c2412_aliases)); 265 ARRAY_SIZE(s3c2412_aliases));
261 266
262 s3c2412_clk_sleep_init(); 267 s3c2412_clk_sleep_init();
diff --git a/drivers/clk/samsung/clk-s3c2443.c b/drivers/clk/samsung/clk-s3c2443.c
index 8e4f4517e95c..c4bbdabebaa4 100644
--- a/drivers/clk/samsung/clk-s3c2443.c
+++ b/drivers/clk/samsung/clk-s3c2443.c
@@ -365,10 +365,11 @@ struct samsung_fixed_rate_clock s3c2443_common_frate_clks[] __initdata = {
365 FRATE(0, "ext_uart", NULL, CLK_IS_ROOT, 0), 365 FRATE(0, "ext_uart", NULL, CLK_IS_ROOT, 0),
366}; 366};
367 367
368static void __init s3c2443_common_clk_register_fixed_ext(unsigned long xti_f) 368static void __init s3c2443_common_clk_register_fixed_ext(
369 struct samsung_clk_provider *ctx, unsigned long xti_f)
369{ 370{
370 s3c2443_common_frate_clks[0].fixed_rate = xti_f; 371 s3c2443_common_frate_clks[0].fixed_rate = xti_f;
371 samsung_clk_register_fixed_rate(s3c2443_common_frate_clks, 372 samsung_clk_register_fixed_rate(ctx, s3c2443_common_frate_clks,
372 ARRAY_SIZE(s3c2443_common_frate_clks)); 373 ARRAY_SIZE(s3c2443_common_frate_clks));
373} 374}
374 375
@@ -376,6 +377,7 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
376 int current_soc, 377 int current_soc,
377 void __iomem *base) 378 void __iomem *base)
378{ 379{
380 struct samsung_clk_provider *ctx;
379 reg_base = base; 381 reg_base = base;
380 382
381 if (np) { 383 if (np) {
@@ -384,58 +386,60 @@ void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
384 panic("%s: failed to map registers\n", __func__); 386 panic("%s: failed to map registers\n", __func__);
385 } 387 }
386 388
387 samsung_clk_init(np, reg_base, NR_CLKS); 389 ctx = samsung_clk_init(np, reg_base, NR_CLKS);
390 if (!ctx)
391 panic("%s: unable to allocate context.\n", __func__);
388 392
389 /* Register external clocks only in non-dt cases */ 393 /* Register external clocks only in non-dt cases */
390 if (!np) 394 if (!np)
391 s3c2443_common_clk_register_fixed_ext(xti_f); 395 s3c2443_common_clk_register_fixed_ext(ctx, xti_f);
392 396
393 /* Register PLLs. */ 397 /* Register PLLs. */
394 if (current_soc == S3C2416 || current_soc == S3C2450) 398 if (current_soc == S3C2416 || current_soc == S3C2450)
395 samsung_clk_register_pll(s3c2416_pll_clks, 399 samsung_clk_register_pll(ctx, s3c2416_pll_clks,
396 ARRAY_SIZE(s3c2416_pll_clks), reg_base); 400 ARRAY_SIZE(s3c2416_pll_clks), reg_base);
397 else 401 else
398 samsung_clk_register_pll(s3c2443_pll_clks, 402 samsung_clk_register_pll(ctx, s3c2443_pll_clks,
399 ARRAY_SIZE(s3c2443_pll_clks), reg_base); 403 ARRAY_SIZE(s3c2443_pll_clks), reg_base);
400 404
401 /* Register common internal clocks. */ 405 /* Register common internal clocks. */
402 samsung_clk_register_mux(s3c2443_common_muxes, 406 samsung_clk_register_mux(ctx, s3c2443_common_muxes,
403 ARRAY_SIZE(s3c2443_common_muxes)); 407 ARRAY_SIZE(s3c2443_common_muxes));
404 samsung_clk_register_div(s3c2443_common_dividers, 408 samsung_clk_register_div(ctx, s3c2443_common_dividers,
405 ARRAY_SIZE(s3c2443_common_dividers)); 409 ARRAY_SIZE(s3c2443_common_dividers));
406 samsung_clk_register_gate(s3c2443_common_gates, 410 samsung_clk_register_gate(ctx, s3c2443_common_gates,
407 ARRAY_SIZE(s3c2443_common_gates)); 411 ARRAY_SIZE(s3c2443_common_gates));
408 samsung_clk_register_alias(s3c2443_common_aliases, 412 samsung_clk_register_alias(ctx, s3c2443_common_aliases,
409 ARRAY_SIZE(s3c2443_common_aliases)); 413 ARRAY_SIZE(s3c2443_common_aliases));
410 414
411 /* Register SoC-specific clocks. */ 415 /* Register SoC-specific clocks. */
412 switch (current_soc) { 416 switch (current_soc) {
413 case S3C2450: 417 case S3C2450:
414 samsung_clk_register_div(s3c2450_dividers, 418 samsung_clk_register_div(ctx, s3c2450_dividers,
415 ARRAY_SIZE(s3c2450_dividers)); 419 ARRAY_SIZE(s3c2450_dividers));
416 samsung_clk_register_mux(s3c2450_muxes, 420 samsung_clk_register_mux(ctx, s3c2450_muxes,
417 ARRAY_SIZE(s3c2450_muxes)); 421 ARRAY_SIZE(s3c2450_muxes));
418 samsung_clk_register_gate(s3c2450_gates, 422 samsung_clk_register_gate(ctx, s3c2450_gates,
419 ARRAY_SIZE(s3c2450_gates)); 423 ARRAY_SIZE(s3c2450_gates));
420 samsung_clk_register_alias(s3c2450_aliases, 424 samsung_clk_register_alias(ctx, s3c2450_aliases,
421 ARRAY_SIZE(s3c2450_aliases)); 425 ARRAY_SIZE(s3c2450_aliases));
422 /* fall through, as s3c2450 extends the s3c2416 clocks */ 426 /* fall through, as s3c2450 extends the s3c2416 clocks */
423 case S3C2416: 427 case S3C2416:
424 samsung_clk_register_div(s3c2416_dividers, 428 samsung_clk_register_div(ctx, s3c2416_dividers,
425 ARRAY_SIZE(s3c2416_dividers)); 429 ARRAY_SIZE(s3c2416_dividers));
426 samsung_clk_register_mux(s3c2416_muxes, 430 samsung_clk_register_mux(ctx, s3c2416_muxes,
427 ARRAY_SIZE(s3c2416_muxes)); 431 ARRAY_SIZE(s3c2416_muxes));
428 samsung_clk_register_gate(s3c2416_gates, 432 samsung_clk_register_gate(ctx, s3c2416_gates,
429 ARRAY_SIZE(s3c2416_gates)); 433 ARRAY_SIZE(s3c2416_gates));
430 samsung_clk_register_alias(s3c2416_aliases, 434 samsung_clk_register_alias(ctx, s3c2416_aliases,
431 ARRAY_SIZE(s3c2416_aliases)); 435 ARRAY_SIZE(s3c2416_aliases));
432 break; 436 break;
433 case S3C2443: 437 case S3C2443:
434 samsung_clk_register_div(s3c2443_dividers, 438 samsung_clk_register_div(ctx, s3c2443_dividers,
435 ARRAY_SIZE(s3c2443_dividers)); 439 ARRAY_SIZE(s3c2443_dividers));
436 samsung_clk_register_gate(s3c2443_gates, 440 samsung_clk_register_gate(ctx, s3c2443_gates,
437 ARRAY_SIZE(s3c2443_gates)); 441 ARRAY_SIZE(s3c2443_gates));
438 samsung_clk_register_alias(s3c2443_aliases, 442 samsung_clk_register_alias(ctx, s3c2443_aliases,
439 ARRAY_SIZE(s3c2443_aliases)); 443 ARRAY_SIZE(s3c2443_aliases));
440 break; 444 break;
441 } 445 }
diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c
index 8bda658137a8..efa16ee592c8 100644
--- a/drivers/clk/samsung/clk-s3c64xx.c
+++ b/drivers/clk/samsung/clk-s3c64xx.c
@@ -442,12 +442,14 @@ static struct samsung_clock_alias s3c6410_clock_aliases[] = {
442 ALIAS(MEM0_SROM, NULL, "srom"), 442 ALIAS(MEM0_SROM, NULL, "srom"),
443}; 443};
444 444
445static void __init s3c64xx_clk_register_fixed_ext(unsigned long fin_pll_f, 445static void __init s3c64xx_clk_register_fixed_ext(
446 unsigned long xusbxti_f) 446 struct samsung_clk_provider *ctx,
447 unsigned long fin_pll_f,
448 unsigned long xusbxti_f)
447{ 449{
448 s3c64xx_fixed_rate_ext_clks[0].fixed_rate = fin_pll_f; 450 s3c64xx_fixed_rate_ext_clks[0].fixed_rate = fin_pll_f;
449 s3c64xx_fixed_rate_ext_clks[1].fixed_rate = xusbxti_f; 451 s3c64xx_fixed_rate_ext_clks[1].fixed_rate = xusbxti_f;
450 samsung_clk_register_fixed_rate(s3c64xx_fixed_rate_ext_clks, 452 samsung_clk_register_fixed_rate(ctx, s3c64xx_fixed_rate_ext_clks,
451 ARRAY_SIZE(s3c64xx_fixed_rate_ext_clks)); 453 ARRAY_SIZE(s3c64xx_fixed_rate_ext_clks));
452} 454}
453 455
@@ -456,6 +458,8 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,
456 unsigned long xusbxti_f, bool s3c6400, 458 unsigned long xusbxti_f, bool s3c6400,
457 void __iomem *base) 459 void __iomem *base)
458{ 460{
461 struct samsung_clk_provider *ctx;
462
459 reg_base = base; 463 reg_base = base;
460 is_s3c6400 = s3c6400; 464 is_s3c6400 = s3c6400;
461 465
@@ -465,48 +469,50 @@ void __init s3c64xx_clk_init(struct device_node *np, unsigned long xtal_f,
465 panic("%s: failed to map registers\n", __func__); 469 panic("%s: failed to map registers\n", __func__);
466 } 470 }
467 471
468 samsung_clk_init(np, reg_base, NR_CLKS); 472 ctx = samsung_clk_init(np, reg_base, NR_CLKS);
473 if (!ctx)
474 panic("%s: unable to allocate context.\n", __func__);
469 475
470 /* Register external clocks. */ 476 /* Register external clocks. */
471 if (!np) 477 if (!np)
472 s3c64xx_clk_register_fixed_ext(xtal_f, xusbxti_f); 478 s3c64xx_clk_register_fixed_ext(ctx, xtal_f, xusbxti_f);
473 479
474 /* Register PLLs. */ 480 /* Register PLLs. */
475 samsung_clk_register_pll(s3c64xx_pll_clks, 481 samsung_clk_register_pll(ctx, s3c64xx_pll_clks,
476 ARRAY_SIZE(s3c64xx_pll_clks), reg_base); 482 ARRAY_SIZE(s3c64xx_pll_clks), reg_base);
477 483
478 /* Register common internal clocks. */ 484 /* Register common internal clocks. */
479 samsung_clk_register_fixed_rate(s3c64xx_fixed_rate_clks, 485 samsung_clk_register_fixed_rate(ctx, s3c64xx_fixed_rate_clks,
480 ARRAY_SIZE(s3c64xx_fixed_rate_clks)); 486 ARRAY_SIZE(s3c64xx_fixed_rate_clks));
481 samsung_clk_register_mux(s3c64xx_mux_clks, 487 samsung_clk_register_mux(ctx, s3c64xx_mux_clks,
482 ARRAY_SIZE(s3c64xx_mux_clks)); 488 ARRAY_SIZE(s3c64xx_mux_clks));
483 samsung_clk_register_div(s3c64xx_div_clks, 489 samsung_clk_register_div(ctx, s3c64xx_div_clks,
484 ARRAY_SIZE(s3c64xx_div_clks)); 490 ARRAY_SIZE(s3c64xx_div_clks));
485 samsung_clk_register_gate(s3c64xx_gate_clks, 491 samsung_clk_register_gate(ctx, s3c64xx_gate_clks,
486 ARRAY_SIZE(s3c64xx_gate_clks)); 492 ARRAY_SIZE(s3c64xx_gate_clks));
487 493
488 /* Register SoC-specific clocks. */ 494 /* Register SoC-specific clocks. */
489 if (is_s3c6400) { 495 if (is_s3c6400) {
490 samsung_clk_register_mux(s3c6400_mux_clks, 496 samsung_clk_register_mux(ctx, s3c6400_mux_clks,
491 ARRAY_SIZE(s3c6400_mux_clks)); 497 ARRAY_SIZE(s3c6400_mux_clks));
492 samsung_clk_register_div(s3c6400_div_clks, 498 samsung_clk_register_div(ctx, s3c6400_div_clks,
493 ARRAY_SIZE(s3c6400_div_clks)); 499 ARRAY_SIZE(s3c6400_div_clks));
494 samsung_clk_register_gate(s3c6400_gate_clks, 500 samsung_clk_register_gate(ctx, s3c6400_gate_clks,
495 ARRAY_SIZE(s3c6400_gate_clks)); 501 ARRAY_SIZE(s3c6400_gate_clks));
496 samsung_clk_register_alias(s3c6400_clock_aliases, 502 samsung_clk_register_alias(ctx, s3c6400_clock_aliases,
497 ARRAY_SIZE(s3c6400_clock_aliases)); 503 ARRAY_SIZE(s3c6400_clock_aliases));
498 } else { 504 } else {
499 samsung_clk_register_mux(s3c6410_mux_clks, 505 samsung_clk_register_mux(ctx, s3c6410_mux_clks,
500 ARRAY_SIZE(s3c6410_mux_clks)); 506 ARRAY_SIZE(s3c6410_mux_clks));
501 samsung_clk_register_div(s3c6410_div_clks, 507 samsung_clk_register_div(ctx, s3c6410_div_clks,
502 ARRAY_SIZE(s3c6410_div_clks)); 508 ARRAY_SIZE(s3c6410_div_clks));
503 samsung_clk_register_gate(s3c6410_gate_clks, 509 samsung_clk_register_gate(ctx, s3c6410_gate_clks,
504 ARRAY_SIZE(s3c6410_gate_clks)); 510 ARRAY_SIZE(s3c6410_gate_clks));
505 samsung_clk_register_alias(s3c6410_clock_aliases, 511 samsung_clk_register_alias(ctx, s3c6410_clock_aliases,
506 ARRAY_SIZE(s3c6410_clock_aliases)); 512 ARRAY_SIZE(s3c6410_clock_aliases));
507 } 513 }
508 514
509 samsung_clk_register_alias(s3c64xx_clock_aliases, 515 samsung_clk_register_alias(ctx, s3c64xx_clock_aliases,
510 ARRAY_SIZE(s3c64xx_clock_aliases)); 516 ARRAY_SIZE(s3c64xx_clock_aliases));
511 s3c64xx_clk_sleep_init(); 517 s3c64xx_clk_sleep_init();
512 518
diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c
index 91bec3ebdc8f..49629c71c9e7 100644
--- a/drivers/clk/samsung/clk.c
+++ b/drivers/clk/samsung/clk.c
@@ -14,13 +14,6 @@
14#include <linux/syscore_ops.h> 14#include <linux/syscore_ops.h>
15#include "clk.h" 15#include "clk.h"
16 16
17static DEFINE_SPINLOCK(lock);
18static struct clk **clk_table;
19static void __iomem *reg_base;
20#ifdef CONFIG_OF
21static struct clk_onecell_data clk_data;
22#endif
23
24void samsung_clk_save(void __iomem *base, 17void samsung_clk_save(void __iomem *base,
25 struct samsung_clk_reg_dump *rd, 18 struct samsung_clk_reg_dump *rd,
26 unsigned int num_regs) 19 unsigned int num_regs)
@@ -55,40 +48,58 @@ struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump(
55} 48}
56 49
57/* setup the essentials required to support clock lookup using ccf */ 50/* setup the essentials required to support clock lookup using ccf */
58void __init samsung_clk_init(struct device_node *np, void __iomem *base, 51struct samsung_clk_provider *__init samsung_clk_init(struct device_node *np,
59 unsigned long nr_clks) 52 void __iomem *base, unsigned long nr_clks)
60{ 53{
61 reg_base = base; 54 struct samsung_clk_provider *ctx;
55 struct clk **clk_table;
56 int ret;
57 int i;
62 58
63 clk_table = kzalloc(sizeof(struct clk *) * nr_clks, GFP_KERNEL); 59 ctx = kzalloc(sizeof(struct samsung_clk_provider), GFP_KERNEL);
60 if (!ctx)
61 panic("could not allocate clock provider context.\n");
62
63 clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
64 if (!clk_table) 64 if (!clk_table)
65 panic("could not allocate clock lookup table\n"); 65 panic("could not allocate clock lookup table\n");
66 66
67 for (i = 0; i < nr_clks; ++i)
68 clk_table[i] = ERR_PTR(-ENOENT);
69
70 ctx->reg_base = base;
71 ctx->clk_data.clks = clk_table;
72 ctx->clk_data.clk_num = nr_clks;
73 spin_lock_init(&ctx->lock);
74
67 if (!np) 75 if (!np)
68 return; 76 return ctx;
69 77
70#ifdef CONFIG_OF 78 ret = of_clk_add_provider(np, of_clk_src_onecell_get,
71 clk_data.clks = clk_table; 79 &ctx->clk_data);
72 clk_data.clk_num = nr_clks; 80 if (ret)
73 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); 81 panic("could not register clock provide\n");
74#endif 82
83 return ctx;
75} 84}
76 85
77/* add a clock instance to the clock lookup table used for dt based lookup */ 86/* add a clock instance to the clock lookup table used for dt based lookup */
78void samsung_clk_add_lookup(struct clk *clk, unsigned int id) 87void samsung_clk_add_lookup(struct samsung_clk_provider *ctx, struct clk *clk,
88 unsigned int id)
79{ 89{
80 if (clk_table && id) 90 if (ctx->clk_data.clks && id)
81 clk_table[id] = clk; 91 ctx->clk_data.clks[id] = clk;
82} 92}
83 93
84/* register a list of aliases */ 94/* register a list of aliases */
85void __init samsung_clk_register_alias(struct samsung_clock_alias *list, 95void __init samsung_clk_register_alias(struct samsung_clk_provider *ctx,
86 unsigned int nr_clk) 96 struct samsung_clock_alias *list,
97 unsigned int nr_clk)
87{ 98{
88 struct clk *clk; 99 struct clk *clk;
89 unsigned int idx, ret; 100 unsigned int idx, ret;
90 101
91 if (!clk_table) { 102 if (!ctx->clk_data.clks) {
92 pr_err("%s: clock table missing\n", __func__); 103 pr_err("%s: clock table missing\n", __func__);
93 return; 104 return;
94 } 105 }
@@ -100,7 +111,7 @@ void __init samsung_clk_register_alias(struct samsung_clock_alias *list,
100 continue; 111 continue;
101 } 112 }
102 113
103 clk = clk_table[list->id]; 114 clk = ctx->clk_data.clks[list->id];
104 if (!clk) { 115 if (!clk) {
105 pr_err("%s: failed to find clock %d\n", __func__, 116 pr_err("%s: failed to find clock %d\n", __func__,
106 list->id); 117 list->id);
@@ -115,7 +126,7 @@ void __init samsung_clk_register_alias(struct samsung_clock_alias *list,
115} 126}
116 127
117/* register a list of fixed clocks */ 128/* register a list of fixed clocks */
118void __init samsung_clk_register_fixed_rate( 129void __init samsung_clk_register_fixed_rate(struct samsung_clk_provider *ctx,
119 struct samsung_fixed_rate_clock *list, unsigned int nr_clk) 130 struct samsung_fixed_rate_clock *list, unsigned int nr_clk)
120{ 131{
121 struct clk *clk; 132 struct clk *clk;
@@ -130,7 +141,7 @@ void __init samsung_clk_register_fixed_rate(
130 continue; 141 continue;
131 } 142 }
132 143
133 samsung_clk_add_lookup(clk, list->id); 144 samsung_clk_add_lookup(ctx, clk, list->id);
134 145
135 /* 146 /*
136 * Unconditionally add a clock lookup for the fixed rate clocks. 147 * Unconditionally add a clock lookup for the fixed rate clocks.
@@ -144,7 +155,7 @@ void __init samsung_clk_register_fixed_rate(
144} 155}
145 156
146/* register a list of fixed factor clocks */ 157/* register a list of fixed factor clocks */
147void __init samsung_clk_register_fixed_factor( 158void __init samsung_clk_register_fixed_factor(struct samsung_clk_provider *ctx,
148 struct samsung_fixed_factor_clock *list, unsigned int nr_clk) 159 struct samsung_fixed_factor_clock *list, unsigned int nr_clk)
149{ 160{
150 struct clk *clk; 161 struct clk *clk;
@@ -159,28 +170,30 @@ void __init samsung_clk_register_fixed_factor(
159 continue; 170 continue;
160 } 171 }
161 172
162 samsung_clk_add_lookup(clk, list->id); 173 samsung_clk_add_lookup(ctx, clk, list->id);
163 } 174 }
164} 175}
165 176
166/* register a list of mux clocks */ 177/* register a list of mux clocks */
167void __init samsung_clk_register_mux(struct samsung_mux_clock *list, 178void __init samsung_clk_register_mux(struct samsung_clk_provider *ctx,
168 unsigned int nr_clk) 179 struct samsung_mux_clock *list,
180 unsigned int nr_clk)
169{ 181{
170 struct clk *clk; 182 struct clk *clk;
171 unsigned int idx, ret; 183 unsigned int idx, ret;
172 184
173 for (idx = 0; idx < nr_clk; idx++, list++) { 185 for (idx = 0; idx < nr_clk; idx++, list++) {
174 clk = clk_register_mux(NULL, list->name, list->parent_names, 186 clk = clk_register_mux(NULL, list->name, list->parent_names,
175 list->num_parents, list->flags, reg_base + list->offset, 187 list->num_parents, list->flags,
176 list->shift, list->width, list->mux_flags, &lock); 188 ctx->reg_base + list->offset,
189 list->shift, list->width, list->mux_flags, &ctx->lock);
177 if (IS_ERR(clk)) { 190 if (IS_ERR(clk)) {
178 pr_err("%s: failed to register clock %s\n", __func__, 191 pr_err("%s: failed to register clock %s\n", __func__,
179 list->name); 192 list->name);
180 continue; 193 continue;
181 } 194 }
182 195
183 samsung_clk_add_lookup(clk, list->id); 196 samsung_clk_add_lookup(ctx, clk, list->id);
184 197
185 /* register a clock lookup only if a clock alias is specified */ 198 /* register a clock lookup only if a clock alias is specified */
186 if (list->alias) { 199 if (list->alias) {
@@ -194,8 +207,9 @@ void __init samsung_clk_register_mux(struct samsung_mux_clock *list,
194} 207}
195 208
196/* register a list of div clocks */ 209/* register a list of div clocks */
197void __init samsung_clk_register_div(struct samsung_div_clock *list, 210void __init samsung_clk_register_div(struct samsung_clk_provider *ctx,
198 unsigned int nr_clk) 211 struct samsung_div_clock *list,
212 unsigned int nr_clk)
199{ 213{
200 struct clk *clk; 214 struct clk *clk;
201 unsigned int idx, ret; 215 unsigned int idx, ret;
@@ -203,22 +217,22 @@ void __init samsung_clk_register_div(struct samsung_div_clock *list,
203 for (idx = 0; idx < nr_clk; idx++, list++) { 217 for (idx = 0; idx < nr_clk; idx++, list++) {
204 if (list->table) 218 if (list->table)
205 clk = clk_register_divider_table(NULL, list->name, 219 clk = clk_register_divider_table(NULL, list->name,
206 list->parent_name, list->flags, 220 list->parent_name, list->flags,
207 reg_base + list->offset, list->shift, 221 ctx->reg_base + list->offset,
208 list->width, list->div_flags, 222 list->shift, list->width, list->div_flags,
209 list->table, &lock); 223 list->table, &ctx->lock);
210 else 224 else
211 clk = clk_register_divider(NULL, list->name, 225 clk = clk_register_divider(NULL, list->name,
212 list->parent_name, list->flags, 226 list->parent_name, list->flags,
213 reg_base + list->offset, list->shift, 227 ctx->reg_base + list->offset, list->shift,
214 list->width, list->div_flags, &lock); 228 list->width, list->div_flags, &ctx->lock);
215 if (IS_ERR(clk)) { 229 if (IS_ERR(clk)) {
216 pr_err("%s: failed to register clock %s\n", __func__, 230 pr_err("%s: failed to register clock %s\n", __func__,
217 list->name); 231 list->name);
218 continue; 232 continue;
219 } 233 }
220 234
221 samsung_clk_add_lookup(clk, list->id); 235 samsung_clk_add_lookup(ctx, clk, list->id);
222 236
223 /* register a clock lookup only if a clock alias is specified */ 237 /* register a clock lookup only if a clock alias is specified */
224 if (list->alias) { 238 if (list->alias) {
@@ -232,16 +246,17 @@ void __init samsung_clk_register_div(struct samsung_div_clock *list,
232} 246}
233 247
234/* register a list of gate clocks */ 248/* register a list of gate clocks */
235void __init samsung_clk_register_gate(struct samsung_gate_clock *list, 249void __init samsung_clk_register_gate(struct samsung_clk_provider *ctx,
236 unsigned int nr_clk) 250 struct samsung_gate_clock *list,
251 unsigned int nr_clk)
237{ 252{
238 struct clk *clk; 253 struct clk *clk;
239 unsigned int idx, ret; 254 unsigned int idx, ret;
240 255
241 for (idx = 0; idx < nr_clk; idx++, list++) { 256 for (idx = 0; idx < nr_clk; idx++, list++) {
242 clk = clk_register_gate(NULL, list->name, list->parent_name, 257 clk = clk_register_gate(NULL, list->name, list->parent_name,
243 list->flags, reg_base + list->offset, 258 list->flags, ctx->reg_base + list->offset,
244 list->bit_idx, list->gate_flags, &lock); 259 list->bit_idx, list->gate_flags, &ctx->lock);
245 if (IS_ERR(clk)) { 260 if (IS_ERR(clk)) {
246 pr_err("%s: failed to register clock %s\n", __func__, 261 pr_err("%s: failed to register clock %s\n", __func__,
247 list->name); 262 list->name);
@@ -257,7 +272,7 @@ void __init samsung_clk_register_gate(struct samsung_gate_clock *list,
257 __func__, list->alias); 272 __func__, list->alias);
258 } 273 }
259 274
260 samsung_clk_add_lookup(clk, list->id); 275 samsung_clk_add_lookup(ctx, clk, list->id);
261 } 276 }
262} 277}
263 278
@@ -266,21 +281,21 @@ void __init samsung_clk_register_gate(struct samsung_gate_clock *list,
266 * tree and register it 281 * tree and register it
267 */ 282 */
268#ifdef CONFIG_OF 283#ifdef CONFIG_OF
269void __init samsung_clk_of_register_fixed_ext( 284void __init samsung_clk_of_register_fixed_ext(struct samsung_clk_provider *ctx,
270 struct samsung_fixed_rate_clock *fixed_rate_clk, 285 struct samsung_fixed_rate_clock *fixed_rate_clk,
271 unsigned int nr_fixed_rate_clk, 286 unsigned int nr_fixed_rate_clk,
272 struct of_device_id *clk_matches) 287 struct of_device_id *clk_matches)
273{ 288{
274 const struct of_device_id *match; 289 const struct of_device_id *match;
275 struct device_node *np; 290 struct device_node *clk_np;
276 u32 freq; 291 u32 freq;
277 292
278 for_each_matching_node_and_match(np, clk_matches, &match) { 293 for_each_matching_node_and_match(clk_np, clk_matches, &match) {
279 if (of_property_read_u32(np, "clock-frequency", &freq)) 294 if (of_property_read_u32(clk_np, "clock-frequency", &freq))
280 continue; 295 continue;
281 fixed_rate_clk[(u32)match->data].fixed_rate = freq; 296 fixed_rate_clk[(unsigned long)match->data].fixed_rate = freq;
282 } 297 }
283 samsung_clk_register_fixed_rate(fixed_rate_clk, nr_fixed_rate_clk); 298 samsung_clk_register_fixed_rate(ctx, fixed_rate_clk, nr_fixed_rate_clk);
284} 299}
285#endif 300#endif
286 301
diff --git a/drivers/clk/samsung/clk.h b/drivers/clk/samsung/clk.h
index c7141ba826e0..9693b80d924f 100644
--- a/drivers/clk/samsung/clk.h
+++ b/drivers/clk/samsung/clk.h
@@ -22,6 +22,18 @@
22#include "clk-pll.h" 22#include "clk-pll.h"
23 23
24/** 24/**
25 * struct samsung_clk_provider: information about clock provider
26 * @reg_base: virtual address for the register base.
27 * @clk_data: holds clock related data like clk* and number of clocks.
28 * @lock: maintains exclusion bwtween callbacks for a given clock-provider.
29 */
30struct samsung_clk_provider {
31 void __iomem *reg_base;
32 struct clk_onecell_data clk_data;
33 spinlock_t lock;
34};
35
36/**
25 * struct samsung_clock_alias: information about mux clock 37 * struct samsung_clock_alias: information about mux clock
26 * @id: platform specific id of the clock. 38 * @id: platform specific id of the clock.
27 * @dev_name: name of the device to which this clock belongs. 39 * @dev_name: name of the device to which this clock belongs.
@@ -312,40 +324,52 @@ struct samsung_pll_clock {
312 __PLL(_typ, _id, NULL, _name, _pname, CLK_GET_RATE_NOCACHE, \ 324 __PLL(_typ, _id, NULL, _name, _pname, CLK_GET_RATE_NOCACHE, \
313 _lock, _con, _rtable, _alias) 325 _lock, _con, _rtable, _alias)
314 326
315extern void __init samsung_clk_init(struct device_node *np, void __iomem *base, 327extern struct samsung_clk_provider *__init samsung_clk_init(
316 unsigned long nr_clks); 328 struct device_node *np, void __iomem *base,
329 unsigned long nr_clks);
317extern void __init samsung_clk_of_register_fixed_ext( 330extern void __init samsung_clk_of_register_fixed_ext(
318 struct samsung_fixed_rate_clock *fixed_rate_clk, 331 struct samsung_clk_provider *ctx,
319 unsigned int nr_fixed_rate_clk, 332 struct samsung_fixed_rate_clock *fixed_rate_clk,
320 struct of_device_id *clk_matches); 333 unsigned int nr_fixed_rate_clk,
334 struct of_device_id *clk_matches);
321 335
322extern void samsung_clk_add_lookup(struct clk *clk, unsigned int id); 336extern void samsung_clk_add_lookup(struct samsung_clk_provider *ctx,
337 struct clk *clk, unsigned int id);
323 338
324extern void samsung_clk_register_alias(struct samsung_clock_alias *list, 339extern void samsung_clk_register_alias(struct samsung_clk_provider *ctx,
325 unsigned int nr_clk); 340 struct samsung_clock_alias *list,
341 unsigned int nr_clk);
326extern void __init samsung_clk_register_fixed_rate( 342extern void __init samsung_clk_register_fixed_rate(
327 struct samsung_fixed_rate_clock *clk_list, unsigned int nr_clk); 343 struct samsung_clk_provider *ctx,
344 struct samsung_fixed_rate_clock *clk_list,
345 unsigned int nr_clk);
328extern void __init samsung_clk_register_fixed_factor( 346extern void __init samsung_clk_register_fixed_factor(
329 struct samsung_fixed_factor_clock *list, unsigned int nr_clk); 347 struct samsung_clk_provider *ctx,
330extern void __init samsung_clk_register_mux(struct samsung_mux_clock *clk_list, 348 struct samsung_fixed_factor_clock *list,
331 unsigned int nr_clk); 349 unsigned int nr_clk);
332extern void __init samsung_clk_register_div(struct samsung_div_clock *clk_list, 350extern void __init samsung_clk_register_mux(struct samsung_clk_provider *ctx,
333 unsigned int nr_clk); 351 struct samsung_mux_clock *clk_list,
334extern void __init samsung_clk_register_gate( 352 unsigned int nr_clk);
335 struct samsung_gate_clock *clk_list, unsigned int nr_clk); 353extern void __init samsung_clk_register_div(struct samsung_clk_provider *ctx,
336extern void __init samsung_clk_register_pll(struct samsung_pll_clock *pll_list, 354 struct samsung_div_clock *clk_list,
337 unsigned int nr_clk, void __iomem *base); 355 unsigned int nr_clk);
356extern void __init samsung_clk_register_gate(struct samsung_clk_provider *ctx,
357 struct samsung_gate_clock *clk_list,
358 unsigned int nr_clk);
359extern void __init samsung_clk_register_pll(struct samsung_clk_provider *ctx,
360 struct samsung_pll_clock *pll_list,
361 unsigned int nr_clk, void __iomem *base);
338 362
339extern unsigned long _get_rate(const char *clk_name); 363extern unsigned long _get_rate(const char *clk_name);
340 364
341extern void samsung_clk_save(void __iomem *base, 365extern void samsung_clk_save(void __iomem *base,
342 struct samsung_clk_reg_dump *rd, 366 struct samsung_clk_reg_dump *rd,
343 unsigned int num_regs); 367 unsigned int num_regs);
344extern void samsung_clk_restore(void __iomem *base, 368extern void samsung_clk_restore(void __iomem *base,
345 const struct samsung_clk_reg_dump *rd, 369 const struct samsung_clk_reg_dump *rd,
346 unsigned int num_regs); 370 unsigned int num_regs);
347extern struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump( 371extern struct samsung_clk_reg_dump *samsung_clk_alloc_reg_dump(
348 const unsigned long *rdump, 372 const unsigned long *rdump,
349 unsigned long nr_rdump); 373 unsigned long nr_rdump);
350 374
351#endif /* __SAMSUNG_CLK_H */ 375#endif /* __SAMSUNG_CLK_H */
diff --git a/drivers/clocksource/cadence_ttc_timer.c b/drivers/clocksource/cadence_ttc_timer.c
index 49fbe2847c84..7a08811df9aa 100644
--- a/drivers/clocksource/cadence_ttc_timer.c
+++ b/drivers/clocksource/cadence_ttc_timer.c
@@ -118,11 +118,11 @@ static void ttc_set_interval(struct ttc_timer *timer,
118 u32 ctrl_reg; 118 u32 ctrl_reg;
119 119
120 /* Disable the counter, set the counter value and re-enable counter */ 120 /* Disable the counter, set the counter value and re-enable counter */
121 ctrl_reg = __raw_readl(timer->base_addr + TTC_CNT_CNTRL_OFFSET); 121 ctrl_reg = readl_relaxed(timer->base_addr + TTC_CNT_CNTRL_OFFSET);
122 ctrl_reg |= TTC_CNT_CNTRL_DISABLE_MASK; 122 ctrl_reg |= TTC_CNT_CNTRL_DISABLE_MASK;
123 __raw_writel(ctrl_reg, timer->base_addr + TTC_CNT_CNTRL_OFFSET); 123 writel_relaxed(ctrl_reg, timer->base_addr + TTC_CNT_CNTRL_OFFSET);
124 124
125 __raw_writel(cycles, timer->base_addr + TTC_INTR_VAL_OFFSET); 125 writel_relaxed(cycles, timer->base_addr + TTC_INTR_VAL_OFFSET);
126 126
127 /* 127 /*
128 * Reset the counter (0x10) so that it starts from 0, one-shot 128 * Reset the counter (0x10) so that it starts from 0, one-shot
@@ -130,7 +130,7 @@ static void ttc_set_interval(struct ttc_timer *timer,
130 */ 130 */
131 ctrl_reg |= CNT_CNTRL_RESET; 131 ctrl_reg |= CNT_CNTRL_RESET;
132 ctrl_reg &= ~TTC_CNT_CNTRL_DISABLE_MASK; 132 ctrl_reg &= ~TTC_CNT_CNTRL_DISABLE_MASK;
133 __raw_writel(ctrl_reg, timer->base_addr + TTC_CNT_CNTRL_OFFSET); 133 writel_relaxed(ctrl_reg, timer->base_addr + TTC_CNT_CNTRL_OFFSET);
134} 134}
135 135
136/** 136/**
@@ -147,7 +147,7 @@ static irqreturn_t ttc_clock_event_interrupt(int irq, void *dev_id)
147 struct ttc_timer *timer = &ttce->ttc; 147 struct ttc_timer *timer = &ttce->ttc;
148 148
149 /* Acknowledge the interrupt and call event handler */ 149 /* Acknowledge the interrupt and call event handler */
150 __raw_readl(timer->base_addr + TTC_ISR_OFFSET); 150 readl_relaxed(timer->base_addr + TTC_ISR_OFFSET);
151 151
152 ttce->ce.event_handler(&ttce->ce); 152 ttce->ce.event_handler(&ttce->ce);
153 153
@@ -163,13 +163,13 @@ static cycle_t __ttc_clocksource_read(struct clocksource *cs)
163{ 163{
164 struct ttc_timer *timer = &to_ttc_timer_clksrc(cs)->ttc; 164 struct ttc_timer *timer = &to_ttc_timer_clksrc(cs)->ttc;
165 165
166 return (cycle_t)__raw_readl(timer->base_addr + 166 return (cycle_t)readl_relaxed(timer->base_addr +
167 TTC_COUNT_VAL_OFFSET); 167 TTC_COUNT_VAL_OFFSET);
168} 168}
169 169
170static u64 notrace ttc_sched_clock_read(void) 170static u64 notrace ttc_sched_clock_read(void)
171{ 171{
172 return __raw_readl(ttc_sched_clock_val_reg); 172 return readl_relaxed(ttc_sched_clock_val_reg);
173} 173}
174 174
175/** 175/**
@@ -211,17 +211,17 @@ static void ttc_set_mode(enum clock_event_mode mode,
211 case CLOCK_EVT_MODE_ONESHOT: 211 case CLOCK_EVT_MODE_ONESHOT:
212 case CLOCK_EVT_MODE_UNUSED: 212 case CLOCK_EVT_MODE_UNUSED:
213 case CLOCK_EVT_MODE_SHUTDOWN: 213 case CLOCK_EVT_MODE_SHUTDOWN:
214 ctrl_reg = __raw_readl(timer->base_addr + 214 ctrl_reg = readl_relaxed(timer->base_addr +
215 TTC_CNT_CNTRL_OFFSET); 215 TTC_CNT_CNTRL_OFFSET);
216 ctrl_reg |= TTC_CNT_CNTRL_DISABLE_MASK; 216 ctrl_reg |= TTC_CNT_CNTRL_DISABLE_MASK;
217 __raw_writel(ctrl_reg, 217 writel_relaxed(ctrl_reg,
218 timer->base_addr + TTC_CNT_CNTRL_OFFSET); 218 timer->base_addr + TTC_CNT_CNTRL_OFFSET);
219 break; 219 break;
220 case CLOCK_EVT_MODE_RESUME: 220 case CLOCK_EVT_MODE_RESUME:
221 ctrl_reg = __raw_readl(timer->base_addr + 221 ctrl_reg = readl_relaxed(timer->base_addr +
222 TTC_CNT_CNTRL_OFFSET); 222 TTC_CNT_CNTRL_OFFSET);
223 ctrl_reg &= ~TTC_CNT_CNTRL_DISABLE_MASK; 223 ctrl_reg &= ~TTC_CNT_CNTRL_DISABLE_MASK;
224 __raw_writel(ctrl_reg, 224 writel_relaxed(ctrl_reg,
225 timer->base_addr + TTC_CNT_CNTRL_OFFSET); 225 timer->base_addr + TTC_CNT_CNTRL_OFFSET);
226 break; 226 break;
227 } 227 }
@@ -266,8 +266,8 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
266 * of an abort. 266 * of an abort.
267 */ 267 */
268 ttccs->scale_clk_ctrl_reg_old = 268 ttccs->scale_clk_ctrl_reg_old =
269 __raw_readl(ttccs->ttc.base_addr + 269 readl_relaxed(ttccs->ttc.base_addr +
270 TTC_CLK_CNTRL_OFFSET); 270 TTC_CLK_CNTRL_OFFSET);
271 271
272 psv = (ttccs->scale_clk_ctrl_reg_old & 272 psv = (ttccs->scale_clk_ctrl_reg_old &
273 TTC_CLK_CNTRL_PSV_MASK) >> 273 TTC_CLK_CNTRL_PSV_MASK) >>
@@ -291,8 +291,8 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
291 return NOTIFY_DONE; 291 return NOTIFY_DONE;
292 292
293 /* scale up: adjust divider now - before frequency change */ 293 /* scale up: adjust divider now - before frequency change */
294 __raw_writel(ttccs->scale_clk_ctrl_reg_new, 294 writel_relaxed(ttccs->scale_clk_ctrl_reg_new,
295 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET); 295 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
296 break; 296 break;
297 } 297 }
298 case POST_RATE_CHANGE: 298 case POST_RATE_CHANGE:
@@ -301,8 +301,8 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
301 return NOTIFY_OK; 301 return NOTIFY_OK;
302 302
303 /* scale down: adjust divider now - after frequency change */ 303 /* scale down: adjust divider now - after frequency change */
304 __raw_writel(ttccs->scale_clk_ctrl_reg_new, 304 writel_relaxed(ttccs->scale_clk_ctrl_reg_new,
305 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET); 305 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
306 break; 306 break;
307 307
308 case ABORT_RATE_CHANGE: 308 case ABORT_RATE_CHANGE:
@@ -311,8 +311,8 @@ static int ttc_rate_change_clocksource_cb(struct notifier_block *nb,
311 return NOTIFY_OK; 311 return NOTIFY_OK;
312 312
313 /* restore original register value */ 313 /* restore original register value */
314 __raw_writel(ttccs->scale_clk_ctrl_reg_old, 314 writel_relaxed(ttccs->scale_clk_ctrl_reg_old,
315 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET); 315 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
316 /* fall through */ 316 /* fall through */
317 default: 317 default:
318 return NOTIFY_DONE; 318 return NOTIFY_DONE;
@@ -359,10 +359,10 @@ static void __init ttc_setup_clocksource(struct clk *clk, void __iomem *base)
359 * with no interrupt and it rolls over at 0xFFFF. Pre-scale 359 * with no interrupt and it rolls over at 0xFFFF. Pre-scale
360 * it by 32 also. Let it start running now. 360 * it by 32 also. Let it start running now.
361 */ 361 */
362 __raw_writel(0x0, ttccs->ttc.base_addr + TTC_IER_OFFSET); 362 writel_relaxed(0x0, ttccs->ttc.base_addr + TTC_IER_OFFSET);
363 __raw_writel(CLK_CNTRL_PRESCALE | CLK_CNTRL_PRESCALE_EN, 363 writel_relaxed(CLK_CNTRL_PRESCALE | CLK_CNTRL_PRESCALE_EN,
364 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET); 364 ttccs->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
365 __raw_writel(CNT_CNTRL_RESET, 365 writel_relaxed(CNT_CNTRL_RESET,
366 ttccs->ttc.base_addr + TTC_CNT_CNTRL_OFFSET); 366 ttccs->ttc.base_addr + TTC_CNT_CNTRL_OFFSET);
367 367
368 err = clocksource_register_hz(&ttccs->cs, ttccs->ttc.freq / PRESCALE); 368 err = clocksource_register_hz(&ttccs->cs, ttccs->ttc.freq / PRESCALE);
@@ -438,10 +438,10 @@ static void __init ttc_setup_clockevent(struct clk *clk,
438 * is prescaled by 32 using the interval interrupt. Leave it 438 * is prescaled by 32 using the interval interrupt. Leave it
439 * disabled for now. 439 * disabled for now.
440 */ 440 */
441 __raw_writel(0x23, ttcce->ttc.base_addr + TTC_CNT_CNTRL_OFFSET); 441 writel_relaxed(0x23, ttcce->ttc.base_addr + TTC_CNT_CNTRL_OFFSET);
442 __raw_writel(CLK_CNTRL_PRESCALE | CLK_CNTRL_PRESCALE_EN, 442 writel_relaxed(CLK_CNTRL_PRESCALE | CLK_CNTRL_PRESCALE_EN,
443 ttcce->ttc.base_addr + TTC_CLK_CNTRL_OFFSET); 443 ttcce->ttc.base_addr + TTC_CLK_CNTRL_OFFSET);
444 __raw_writel(0x1, ttcce->ttc.base_addr + TTC_IER_OFFSET); 444 writel_relaxed(0x1, ttcce->ttc.base_addr + TTC_IER_OFFSET);
445 445
446 err = request_irq(irq, ttc_clock_event_interrupt, 446 err = request_irq(irq, ttc_clock_event_interrupt,
447 IRQF_TIMER, ttcce->ce.name, ttcce); 447 IRQF_TIMER, ttcce->ce.name, ttcce);
@@ -490,7 +490,7 @@ static void __init ttc_timer_init(struct device_node *timer)
490 BUG(); 490 BUG();
491 } 491 }
492 492
493 clksel = __raw_readl(timer_baseaddr + TTC_CLK_CNTRL_OFFSET); 493 clksel = readl_relaxed(timer_baseaddr + TTC_CLK_CNTRL_OFFSET);
494 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK); 494 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK);
495 clk_cs = of_clk_get(timer, clksel); 495 clk_cs = of_clk_get(timer, clksel);
496 if (IS_ERR(clk_cs)) { 496 if (IS_ERR(clk_cs)) {
@@ -498,7 +498,7 @@ static void __init ttc_timer_init(struct device_node *timer)
498 BUG(); 498 BUG();
499 } 499 }
500 500
501 clksel = __raw_readl(timer_baseaddr + 4 + TTC_CLK_CNTRL_OFFSET); 501 clksel = readl_relaxed(timer_baseaddr + 4 + TTC_CLK_CNTRL_OFFSET);
502 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK); 502 clksel = !!(clksel & TTC_CLK_CNTRL_CSRC_MASK);
503 clk_ce = of_clk_get(timer, clksel); 503 clk_ce = of_clk_get(timer, clksel);
504 if (IS_ERR(clk_ce)) { 504 if (IS_ERR(clk_ce)) {
diff --git a/drivers/cpuidle/Kconfig.arm b/drivers/cpuidle/Kconfig.arm
index 97ccc31dbdd8..5bb94780d377 100644
--- a/drivers/cpuidle/Kconfig.arm
+++ b/drivers/cpuidle/Kconfig.arm
@@ -1,6 +1,11 @@
1# 1#
2# ARM CPU Idle drivers 2# ARM CPU Idle drivers
3# 3#
4config ARM_ARMADA_370_XP_CPUIDLE
5 bool "CPU Idle Driver for Armada 370/XP family processors"
6 depends on ARCH_MVEBU
7 help
8 Select this to enable cpuidle on Armada 370/XP processors.
4 9
5config ARM_BIG_LITTLE_CPUIDLE 10config ARM_BIG_LITTLE_CPUIDLE
6 bool "Support for ARM big.LITTLE processors" 11 bool "Support for ARM big.LITTLE processors"
diff --git a/drivers/cpuidle/Makefile b/drivers/cpuidle/Makefile
index f71ae1b373c5..9902d052bd87 100644
--- a/drivers/cpuidle/Makefile
+++ b/drivers/cpuidle/Makefile
@@ -7,6 +7,7 @@ obj-$(CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED) += coupled.o
7 7
8################################################################################## 8##################################################################################
9# ARM SoC drivers 9# ARM SoC drivers
10obj-$(CONFIG_ARM_ARMADA_370_XP_CPUIDLE) += cpuidle-armada-370-xp.o
10obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE) += cpuidle-big_little.o 11obj-$(CONFIG_ARM_BIG_LITTLE_CPUIDLE) += cpuidle-big_little.o
11obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE) += cpuidle-calxeda.o 12obj-$(CONFIG_ARM_HIGHBANK_CPUIDLE) += cpuidle-calxeda.o
12obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o 13obj-$(CONFIG_ARM_KIRKWOOD_CPUIDLE) += cpuidle-kirkwood.o
diff --git a/drivers/cpuidle/cpuidle-armada-370-xp.c b/drivers/cpuidle/cpuidle-armada-370-xp.c
new file mode 100644
index 000000000000..28587d0f3947
--- /dev/null
+++ b/drivers/cpuidle/cpuidle-armada-370-xp.c
@@ -0,0 +1,93 @@
1/*
2 * Marvell Armada 370 and Armada XP SoC cpuidle driver
3 *
4 * Copyright (C) 2014 Marvell
5 *
6 * Nadav Haklai <nadavh@marvell.com>
7 * Gregory CLEMENT <gregory.clement@free-electrons.com>
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 *
13 * Maintainer: Gregory CLEMENT <gregory.clement@free-electrons.com>
14 */
15
16#include <linux/cpu_pm.h>
17#include <linux/cpuidle.h>
18#include <linux/module.h>
19#include <linux/of.h>
20#include <linux/suspend.h>
21#include <linux/platform_device.h>
22#include <asm/cpuidle.h>
23
24#define ARMADA_370_XP_MAX_STATES 3
25#define ARMADA_370_XP_FLAG_DEEP_IDLE 0x10000
26
27static int (*armada_370_xp_cpu_suspend)(int);
28
29static int armada_370_xp_enter_idle(struct cpuidle_device *dev,
30 struct cpuidle_driver *drv,
31 int index)
32{
33 int ret;
34 bool deepidle = false;
35 cpu_pm_enter();
36
37 if (drv->states[index].flags & ARMADA_370_XP_FLAG_DEEP_IDLE)
38 deepidle = true;
39
40 ret = armada_370_xp_cpu_suspend(deepidle);
41 if (ret)
42 return ret;
43
44 cpu_pm_exit();
45
46 return index;
47}
48
49static struct cpuidle_driver armada_370_xp_idle_driver = {
50 .name = "armada_370_xp_idle",
51 .states[0] = ARM_CPUIDLE_WFI_STATE,
52 .states[1] = {
53 .enter = armada_370_xp_enter_idle,
54 .exit_latency = 10,
55 .power_usage = 50,
56 .target_residency = 100,
57 .flags = CPUIDLE_FLAG_TIME_VALID,
58 .name = "MV CPU IDLE",
59 .desc = "CPU power down",
60 },
61 .states[2] = {
62 .enter = armada_370_xp_enter_idle,
63 .exit_latency = 100,
64 .power_usage = 5,
65 .target_residency = 1000,
66 .flags = CPUIDLE_FLAG_TIME_VALID |
67 ARMADA_370_XP_FLAG_DEEP_IDLE,
68 .name = "MV CPU DEEP IDLE",
69 .desc = "CPU and L2 Fabric power down",
70 },
71 .state_count = ARMADA_370_XP_MAX_STATES,
72};
73
74static int armada_370_xp_cpuidle_probe(struct platform_device *pdev)
75{
76
77 armada_370_xp_cpu_suspend = (void *)(pdev->dev.platform_data);
78 return cpuidle_register(&armada_370_xp_idle_driver, NULL);
79}
80
81static struct platform_driver armada_370_xp_cpuidle_plat_driver = {
82 .driver = {
83 .name = "cpuidle-armada-370-xp",
84 .owner = THIS_MODULE,
85 },
86 .probe = armada_370_xp_cpuidle_probe,
87};
88
89module_platform_driver(armada_370_xp_cpuidle_plat_driver);
90
91MODULE_AUTHOR("Gregory CLEMENT <gregory.clement@free-electrons.com>");
92MODULE_DESCRIPTION("Armada 370/XP cpu idle driver");
93MODULE_LICENSE("GPL");
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 89777ed9abd8..3b5bacd4d8da 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -31,7 +31,108 @@
31#include <linux/iio/trigger_consumer.h> 31#include <linux/iio/trigger_consumer.h>
32#include <linux/iio/triggered_buffer.h> 32#include <linux/iio/triggered_buffer.h>
33 33
34#include <mach/at91_adc.h> 34/* Registers */
35#define AT91_ADC_CR 0x00 /* Control Register */
36#define AT91_ADC_SWRST (1 << 0) /* Software Reset */
37#define AT91_ADC_START (1 << 1) /* Start Conversion */
38
39#define AT91_ADC_MR 0x04 /* Mode Register */
40#define AT91_ADC_TSAMOD (3 << 0) /* ADC mode */
41#define AT91_ADC_TSAMOD_ADC_ONLY_MODE (0 << 0) /* ADC Mode */
42#define AT91_ADC_TSAMOD_TS_ONLY_MODE (1 << 0) /* Touch Screen Only Mode */
43#define AT91_ADC_TRGEN (1 << 0) /* Trigger Enable */
44#define AT91_ADC_TRGSEL (7 << 1) /* Trigger Selection */
45#define AT91_ADC_TRGSEL_TC0 (0 << 1)
46#define AT91_ADC_TRGSEL_TC1 (1 << 1)
47#define AT91_ADC_TRGSEL_TC2 (2 << 1)
48#define AT91_ADC_TRGSEL_EXTERNAL (6 << 1)
49#define AT91_ADC_LOWRES (1 << 4) /* Low Resolution */
50#define AT91_ADC_SLEEP (1 << 5) /* Sleep Mode */
51#define AT91_ADC_PENDET (1 << 6) /* Pen contact detection enable */
52#define AT91_ADC_PRESCAL_9260 (0x3f << 8) /* Prescalar Rate Selection */
53#define AT91_ADC_PRESCAL_9G45 (0xff << 8)
54#define AT91_ADC_PRESCAL_(x) ((x) << 8)
55#define AT91_ADC_STARTUP_9260 (0x1f << 16) /* Startup Up Time */
56#define AT91_ADC_STARTUP_9G45 (0x7f << 16)
57#define AT91_ADC_STARTUP_9X5 (0xf << 16)
58#define AT91_ADC_STARTUP_(x) ((x) << 16)
59#define AT91_ADC_SHTIM (0xf << 24) /* Sample & Hold Time */
60#define AT91_ADC_SHTIM_(x) ((x) << 24)
61#define AT91_ADC_PENDBC (0x0f << 28) /* Pen Debounce time */
62#define AT91_ADC_PENDBC_(x) ((x) << 28)
63
64#define AT91_ADC_TSR 0x0C
65#define AT91_ADC_TSR_SHTIM (0xf << 24) /* Sample & Hold Time */
66#define AT91_ADC_TSR_SHTIM_(x) ((x) << 24)
67
68#define AT91_ADC_CHER 0x10 /* Channel Enable Register */
69#define AT91_ADC_CHDR 0x14 /* Channel Disable Register */
70#define AT91_ADC_CHSR 0x18 /* Channel Status Register */
71#define AT91_ADC_CH(n) (1 << (n)) /* Channel Number */
72
73#define AT91_ADC_SR 0x1C /* Status Register */
74#define AT91_ADC_EOC(n) (1 << (n)) /* End of Conversion on Channel N */
75#define AT91_ADC_OVRE(n) (1 << ((n) + 8))/* Overrun Error on Channel N */
76#define AT91_ADC_DRDY (1 << 16) /* Data Ready */
77#define AT91_ADC_GOVRE (1 << 17) /* General Overrun Error */
78#define AT91_ADC_ENDRX (1 << 18) /* End of RX Buffer */
79#define AT91_ADC_RXFUFF (1 << 19) /* RX Buffer Full */
80
81#define AT91_ADC_SR_9X5 0x30 /* Status Register for 9x5 */
82#define AT91_ADC_SR_DRDY_9X5 (1 << 24) /* Data Ready */
83
84#define AT91_ADC_LCDR 0x20 /* Last Converted Data Register */
85#define AT91_ADC_LDATA (0x3ff)
86
87#define AT91_ADC_IER 0x24 /* Interrupt Enable Register */
88#define AT91_ADC_IDR 0x28 /* Interrupt Disable Register */
89#define AT91_ADC_IMR 0x2C /* Interrupt Mask Register */
90#define AT91RL_ADC_IER_PEN (1 << 20)
91#define AT91RL_ADC_IER_NOPEN (1 << 21)
92#define AT91_ADC_IER_PEN (1 << 29)
93#define AT91_ADC_IER_NOPEN (1 << 30)
94#define AT91_ADC_IER_XRDY (1 << 20)
95#define AT91_ADC_IER_YRDY (1 << 21)
96#define AT91_ADC_IER_PRDY (1 << 22)
97#define AT91_ADC_ISR_PENS (1 << 31)
98
99#define AT91_ADC_CHR(n) (0x30 + ((n) * 4)) /* Channel Data Register N */
100#define AT91_ADC_DATA (0x3ff)
101
102#define AT91_ADC_CDR0_9X5 (0x50) /* Channel Data Register 0 for 9X5 */
103
104#define AT91_ADC_ACR 0x94 /* Analog Control Register */
105#define AT91_ADC_ACR_PENDETSENS (0x3 << 0) /* pull-up resistor */
106
107#define AT91_ADC_TSMR 0xB0
108#define AT91_ADC_TSMR_TSMODE (3 << 0) /* Touch Screen Mode */
109#define AT91_ADC_TSMR_TSMODE_NONE (0 << 0)
110#define AT91_ADC_TSMR_TSMODE_4WIRE_NO_PRESS (1 << 0)
111#define AT91_ADC_TSMR_TSMODE_4WIRE_PRESS (2 << 0)
112#define AT91_ADC_TSMR_TSMODE_5WIRE (3 << 0)
113#define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
114#define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
115#define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
116#define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
117#define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
118#define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
119#define AT91_ADC_TSMR_PENDET_DIS (0 << 24) /* Pen contact detection disable */
120#define AT91_ADC_TSMR_PENDET_ENA (1 << 24) /* Pen contact detection enable */
121
122#define AT91_ADC_TSXPOSR 0xB4
123#define AT91_ADC_TSYPOSR 0xB8
124#define AT91_ADC_TSPRESSR 0xBC
125
126#define AT91_ADC_TRGR_9260 AT91_ADC_MR
127#define AT91_ADC_TRGR_9G45 0x08
128#define AT91_ADC_TRGR_9X5 0xC0
129
130/* Trigger Register bit field */
131#define AT91_ADC_TRGR_TRGPER (0xffff << 16)
132#define AT91_ADC_TRGR_TRGPER_(x) ((x) << 16)
133#define AT91_ADC_TRGR_TRGMOD (0x7 << 0)
134#define AT91_ADC_TRGR_NONE (0 << 0)
135#define AT91_ADC_TRGR_MOD_PERIOD_TRIG (5 << 0)
35 136
36#define AT91_ADC_CHAN(st, ch) \ 137#define AT91_ADC_CHAN(st, ch) \
37 (st->registers->channel_base + (ch * 4)) 138 (st->registers->channel_base + (ch * 4))
@@ -46,6 +147,29 @@
46#define TOUCH_SAMPLE_PERIOD_US 2000 /* 2ms */ 147#define TOUCH_SAMPLE_PERIOD_US 2000 /* 2ms */
47#define TOUCH_PEN_DETECT_DEBOUNCE_US 200 148#define TOUCH_PEN_DETECT_DEBOUNCE_US 200
48 149
150#define MAX_RLPOS_BITS 10
151#define TOUCH_SAMPLE_PERIOD_US_RL 10000 /* 10ms, the SoC can't keep up with 2ms */
152#define TOUCH_SHTIM 0xa
153
154/**
155 * struct at91_adc_reg_desc - Various informations relative to registers
156 * @channel_base: Base offset for the channel data registers
157 * @drdy_mask: Mask of the DRDY field in the relevant registers
158 (Interruptions registers mostly)
159 * @status_register: Offset of the Interrupt Status Register
160 * @trigger_register: Offset of the Trigger setup register
161 * @mr_prescal_mask: Mask of the PRESCAL field in the adc MR register
162 * @mr_startup_mask: Mask of the STARTUP field in the adc MR register
163 */
164struct at91_adc_reg_desc {
165 u8 channel_base;
166 u32 drdy_mask;
167 u8 status_register;
168 u8 trigger_register;
169 u32 mr_prescal_mask;
170 u32 mr_startup_mask;
171};
172
49struct at91_adc_caps { 173struct at91_adc_caps {
50 bool has_ts; /* Support touch screen */ 174 bool has_ts; /* Support touch screen */
51 bool has_tsmr; /* only at91sam9x5, sama5d3 have TSMR reg */ 175 bool has_tsmr; /* only at91sam9x5, sama5d3 have TSMR reg */
@@ -64,12 +188,6 @@ struct at91_adc_caps {
64 struct at91_adc_reg_desc registers; 188 struct at91_adc_reg_desc registers;
65}; 189};
66 190
67enum atmel_adc_ts_type {
68 ATMEL_ADC_TOUCHSCREEN_NONE = 0,
69 ATMEL_ADC_TOUCHSCREEN_4WIRE = 4,
70 ATMEL_ADC_TOUCHSCREEN_5WIRE = 5,
71};
72
73struct at91_adc_state { 191struct at91_adc_state {
74 struct clk *adc_clk; 192 struct clk *adc_clk;
75 u16 *buffer; 193 u16 *buffer;
@@ -114,6 +232,11 @@ struct at91_adc_state {
114 232
115 u16 ts_sample_period_val; 233 u16 ts_sample_period_val;
116 u32 ts_pressure_threshold; 234 u32 ts_pressure_threshold;
235 u16 ts_pendbc;
236
237 bool ts_bufferedmeasure;
238 u32 ts_prev_absx;
239 u32 ts_prev_absy;
117}; 240};
118 241
119static irqreturn_t at91_adc_trigger_handler(int irq, void *p) 242static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
@@ -220,7 +343,72 @@ static int at91_ts_sample(struct at91_adc_state *st)
220 return 0; 343 return 0;
221} 344}
222 345
223static irqreturn_t at91_adc_interrupt(int irq, void *private) 346static irqreturn_t at91_adc_rl_interrupt(int irq, void *private)
347{
348 struct iio_dev *idev = private;
349 struct at91_adc_state *st = iio_priv(idev);
350 u32 status = at91_adc_readl(st, st->registers->status_register);
351 unsigned int reg;
352
353 status &= at91_adc_readl(st, AT91_ADC_IMR);
354 if (status & st->registers->drdy_mask)
355 handle_adc_eoc_trigger(irq, idev);
356
357 if (status & AT91RL_ADC_IER_PEN) {
358 /* Disabling pen debounce is required to get a NOPEN irq */
359 reg = at91_adc_readl(st, AT91_ADC_MR);
360 reg &= ~AT91_ADC_PENDBC;
361 at91_adc_writel(st, AT91_ADC_MR, reg);
362
363 at91_adc_writel(st, AT91_ADC_IDR, AT91RL_ADC_IER_PEN);
364 at91_adc_writel(st, AT91_ADC_IER, AT91RL_ADC_IER_NOPEN
365 | AT91_ADC_EOC(3));
366 /* Set up period trigger for sampling */
367 at91_adc_writel(st, st->registers->trigger_register,
368 AT91_ADC_TRGR_MOD_PERIOD_TRIG |
369 AT91_ADC_TRGR_TRGPER_(st->ts_sample_period_val));
370 } else if (status & AT91RL_ADC_IER_NOPEN) {
371 reg = at91_adc_readl(st, AT91_ADC_MR);
372 reg |= AT91_ADC_PENDBC_(st->ts_pendbc) & AT91_ADC_PENDBC;
373 at91_adc_writel(st, AT91_ADC_MR, reg);
374 at91_adc_writel(st, st->registers->trigger_register,
375 AT91_ADC_TRGR_NONE);
376
377 at91_adc_writel(st, AT91_ADC_IDR, AT91RL_ADC_IER_NOPEN
378 | AT91_ADC_EOC(3));
379 at91_adc_writel(st, AT91_ADC_IER, AT91RL_ADC_IER_PEN);
380 st->ts_bufferedmeasure = false;
381 input_report_key(st->ts_input, BTN_TOUCH, 0);
382 input_sync(st->ts_input);
383 } else if (status & AT91_ADC_EOC(3)) {
384 /* Conversion finished */
385 if (st->ts_bufferedmeasure) {
386 /*
387 * Last measurement is always discarded, since it can
388 * be erroneous.
389 * Always report previous measurement
390 */
391 input_report_abs(st->ts_input, ABS_X, st->ts_prev_absx);
392 input_report_abs(st->ts_input, ABS_Y, st->ts_prev_absy);
393 input_report_key(st->ts_input, BTN_TOUCH, 1);
394 input_sync(st->ts_input);
395 } else
396 st->ts_bufferedmeasure = true;
397
398 /* Now make new measurement */
399 st->ts_prev_absx = at91_adc_readl(st, AT91_ADC_CHAN(st, 3))
400 << MAX_RLPOS_BITS;
401 st->ts_prev_absx /= at91_adc_readl(st, AT91_ADC_CHAN(st, 2));
402
403 st->ts_prev_absy = at91_adc_readl(st, AT91_ADC_CHAN(st, 1))
404 << MAX_RLPOS_BITS;
405 st->ts_prev_absy /= at91_adc_readl(st, AT91_ADC_CHAN(st, 0));
406 }
407
408 return IRQ_HANDLED;
409}
410
411static irqreturn_t at91_adc_9x5_interrupt(int irq, void *private)
224{ 412{
225 struct iio_dev *idev = private; 413 struct iio_dev *idev = private;
226 struct at91_adc_state *st = iio_priv(idev); 414 struct at91_adc_state *st = iio_priv(idev);
@@ -653,6 +841,8 @@ static int at91_adc_probe_dt_ts(struct device_node *node,
653 return -EINVAL; 841 return -EINVAL;
654 } 842 }
655 843
844 if (!st->caps->has_tsmr)
845 return 0;
656 prop = 0; 846 prop = 0;
657 of_property_read_u32(node, "atmel,adc-ts-pressure-threshold", &prop); 847 of_property_read_u32(node, "atmel,adc-ts-pressure-threshold", &prop);
658 st->ts_pressure_threshold = prop; 848 st->ts_pressure_threshold = prop;
@@ -776,6 +966,7 @@ static int at91_adc_probe_pdata(struct at91_adc_state *st,
776 st->trigger_number = pdata->trigger_number; 966 st->trigger_number = pdata->trigger_number;
777 st->trigger_list = pdata->trigger_list; 967 st->trigger_list = pdata->trigger_list;
778 st->registers = &st->caps->registers; 968 st->registers = &st->caps->registers;
969 st->touchscreen_type = pdata->touchscreen_type;
779 970
780 return 0; 971 return 0;
781} 972}
@@ -790,7 +981,10 @@ static int atmel_ts_open(struct input_dev *dev)
790{ 981{
791 struct at91_adc_state *st = input_get_drvdata(dev); 982 struct at91_adc_state *st = input_get_drvdata(dev);
792 983
793 at91_adc_writel(st, AT91_ADC_IER, AT91_ADC_IER_PEN); 984 if (st->caps->has_tsmr)
985 at91_adc_writel(st, AT91_ADC_IER, AT91_ADC_IER_PEN);
986 else
987 at91_adc_writel(st, AT91_ADC_IER, AT91RL_ADC_IER_PEN);
794 return 0; 988 return 0;
795} 989}
796 990
@@ -798,45 +992,61 @@ static void atmel_ts_close(struct input_dev *dev)
798{ 992{
799 struct at91_adc_state *st = input_get_drvdata(dev); 993 struct at91_adc_state *st = input_get_drvdata(dev);
800 994
801 at91_adc_writel(st, AT91_ADC_IDR, AT91_ADC_IER_PEN); 995 if (st->caps->has_tsmr)
996 at91_adc_writel(st, AT91_ADC_IDR, AT91_ADC_IER_PEN);
997 else
998 at91_adc_writel(st, AT91_ADC_IDR, AT91RL_ADC_IER_PEN);
802} 999}
803 1000
804static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz) 1001static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
805{ 1002{
806 u32 reg = 0, pendbc; 1003 u32 reg = 0;
807 int i = 0; 1004 int i = 0;
808 1005
809 if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
810 reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
811 else
812 reg = AT91_ADC_TSMR_TSMODE_5WIRE;
813
814 /* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid 1006 /* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
815 * pen detect noise. 1007 * pen detect noise.
816 * The formula is : Pen Detect Debounce Time = (2 ^ pendbc) / ADCClock 1008 * The formula is : Pen Detect Debounce Time = (2 ^ pendbc) / ADCClock
817 */ 1009 */
818 pendbc = round_up(TOUCH_PEN_DETECT_DEBOUNCE_US * adc_clk_khz / 1000, 1); 1010 st->ts_pendbc = round_up(TOUCH_PEN_DETECT_DEBOUNCE_US * adc_clk_khz /
1011 1000, 1);
819 1012
820 while (pendbc >> ++i) 1013 while (st->ts_pendbc >> ++i)
821 ; /* Empty! Find the shift offset */ 1014 ; /* Empty! Find the shift offset */
822 if (abs(pendbc - (1 << i)) < abs(pendbc - (1 << (i - 1)))) 1015 if (abs(st->ts_pendbc - (1 << i)) < abs(st->ts_pendbc - (1 << (i - 1))))
823 pendbc = i; 1016 st->ts_pendbc = i;
824 else 1017 else
825 pendbc = i - 1; 1018 st->ts_pendbc = i - 1;
826 1019
827 if (st->caps->has_tsmr) { 1020 if (!st->caps->has_tsmr) {
828 reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average) 1021 reg = at91_adc_readl(st, AT91_ADC_MR);
829 & AT91_ADC_TSMR_TSAV; 1022 reg |= AT91_ADC_TSAMOD_TS_ONLY_MODE | AT91_ADC_PENDET;
830 reg |= AT91_ADC_TSMR_PENDBC_(pendbc) & AT91_ADC_TSMR_PENDBC; 1023
831 reg |= AT91_ADC_TSMR_NOTSDMA; 1024 reg |= AT91_ADC_PENDBC_(st->ts_pendbc) & AT91_ADC_PENDBC;
832 reg |= AT91_ADC_TSMR_PENDET_ENA; 1025 at91_adc_writel(st, AT91_ADC_MR, reg);
833 reg |= 0x03 << 8; /* TSFREQ, need bigger than TSAV */ 1026
834 1027 reg = AT91_ADC_TSR_SHTIM_(TOUCH_SHTIM) & AT91_ADC_TSR_SHTIM;
835 at91_adc_writel(st, AT91_ADC_TSMR, reg); 1028 at91_adc_writel(st, AT91_ADC_TSR, reg);
836 } else { 1029
837 /* TODO: for 9g45 which has no TSMR */ 1030 st->ts_sample_period_val = round_up((TOUCH_SAMPLE_PERIOD_US_RL *
1031 adc_clk_khz / 1000) - 1, 1);
1032
1033 return 0;
838 } 1034 }
839 1035
1036 if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
1037 reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
1038 else
1039 reg = AT91_ADC_TSMR_TSMODE_5WIRE;
1040
1041 reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
1042 & AT91_ADC_TSMR_TSAV;
1043 reg |= AT91_ADC_TSMR_PENDBC_(st->ts_pendbc) & AT91_ADC_TSMR_PENDBC;
1044 reg |= AT91_ADC_TSMR_NOTSDMA;
1045 reg |= AT91_ADC_TSMR_PENDET_ENA;
1046 reg |= 0x03 << 8; /* TSFREQ, needs to be bigger than TSAV */
1047
1048 at91_adc_writel(st, AT91_ADC_TSMR, reg);
1049
840 /* Change adc internal resistor value for better pen detection, 1050 /* Change adc internal resistor value for better pen detection,
841 * default value is 100 kOhm. 1051 * default value is 100 kOhm.
842 * 0 = 200 kOhm, 1 = 150 kOhm, 2 = 100 kOhm, 3 = 50 kOhm 1052 * 0 = 200 kOhm, 1 = 150 kOhm, 2 = 100 kOhm, 3 = 50 kOhm
@@ -845,7 +1055,7 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
845 at91_adc_writel(st, AT91_ADC_ACR, st->caps->ts_pen_detect_sensitivity 1055 at91_adc_writel(st, AT91_ADC_ACR, st->caps->ts_pen_detect_sensitivity
846 & AT91_ADC_ACR_PENDETSENS); 1056 & AT91_ADC_ACR_PENDETSENS);
847 1057
848 /* Sample Peroid Time = (TRGPER + 1) / ADCClock */ 1058 /* Sample Period Time = (TRGPER + 1) / ADCClock */
849 st->ts_sample_period_val = round_up((TOUCH_SAMPLE_PERIOD_US * 1059 st->ts_sample_period_val = round_up((TOUCH_SAMPLE_PERIOD_US *
850 adc_clk_khz / 1000) - 1, 1); 1060 adc_clk_khz / 1000) - 1, 1);
851 1061
@@ -874,18 +1084,38 @@ static int at91_ts_register(struct at91_adc_state *st,
874 __set_bit(EV_ABS, input->evbit); 1084 __set_bit(EV_ABS, input->evbit);
875 __set_bit(EV_KEY, input->evbit); 1085 __set_bit(EV_KEY, input->evbit);
876 __set_bit(BTN_TOUCH, input->keybit); 1086 __set_bit(BTN_TOUCH, input->keybit);
877 input_set_abs_params(input, ABS_X, 0, (1 << MAX_POS_BITS) - 1, 0, 0); 1087 if (st->caps->has_tsmr) {
878 input_set_abs_params(input, ABS_Y, 0, (1 << MAX_POS_BITS) - 1, 0, 0); 1088 input_set_abs_params(input, ABS_X, 0, (1 << MAX_POS_BITS) - 1,
879 input_set_abs_params(input, ABS_PRESSURE, 0, 0xffffff, 0, 0); 1089 0, 0);
1090 input_set_abs_params(input, ABS_Y, 0, (1 << MAX_POS_BITS) - 1,
1091 0, 0);
1092 input_set_abs_params(input, ABS_PRESSURE, 0, 0xffffff, 0, 0);
1093 } else {
1094 if (st->touchscreen_type != ATMEL_ADC_TOUCHSCREEN_4WIRE) {
1095 dev_err(&pdev->dev,
1096 "This touchscreen controller only support 4 wires\n");
1097 ret = -EINVAL;
1098 goto err;
1099 }
1100
1101 input_set_abs_params(input, ABS_X, 0, (1 << MAX_RLPOS_BITS) - 1,
1102 0, 0);
1103 input_set_abs_params(input, ABS_Y, 0, (1 << MAX_RLPOS_BITS) - 1,
1104 0, 0);
1105 }
880 1106
881 st->ts_input = input; 1107 st->ts_input = input;
882 input_set_drvdata(input, st); 1108 input_set_drvdata(input, st);
883 1109
884 ret = input_register_device(input); 1110 ret = input_register_device(input);
885 if (ret) 1111 if (ret)
886 input_free_device(st->ts_input); 1112 goto err;
887 1113
888 return ret; 1114 return ret;
1115
1116err:
1117 input_free_device(st->ts_input);
1118 return ret;
889} 1119}
890 1120
891static void at91_ts_unregister(struct at91_adc_state *st) 1121static void at91_ts_unregister(struct at91_adc_state *st)
@@ -943,11 +1173,13 @@ static int at91_adc_probe(struct platform_device *pdev)
943 */ 1173 */
944 at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_SWRST); 1174 at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_SWRST);
945 at91_adc_writel(st, AT91_ADC_IDR, 0xFFFFFFFF); 1175 at91_adc_writel(st, AT91_ADC_IDR, 0xFFFFFFFF);
946 ret = request_irq(st->irq, 1176
947 at91_adc_interrupt, 1177 if (st->caps->has_tsmr)
948 0, 1178 ret = request_irq(st->irq, at91_adc_9x5_interrupt, 0,
949 pdev->dev.driver->name, 1179 pdev->dev.driver->name, idev);
950 idev); 1180 else
1181 ret = request_irq(st->irq, at91_adc_rl_interrupt, 0,
1182 pdev->dev.driver->name, idev);
951 if (ret) { 1183 if (ret) {
952 dev_err(&pdev->dev, "Failed to allocate IRQ.\n"); 1184 dev_err(&pdev->dev, "Failed to allocate IRQ.\n");
953 return ret; 1185 return ret;
@@ -1051,12 +1283,6 @@ static int at91_adc_probe(struct platform_device *pdev)
1051 goto error_disable_adc_clk; 1283 goto error_disable_adc_clk;
1052 } 1284 }
1053 } else { 1285 } else {
1054 if (!st->caps->has_tsmr) {
1055 dev_err(&pdev->dev, "We don't support non-TSMR adc\n");
1056 ret = -ENODEV;
1057 goto error_disable_adc_clk;
1058 }
1059
1060 ret = at91_ts_register(st, pdev); 1286 ret = at91_ts_register(st, pdev);
1061 if (ret) 1287 if (ret)
1062 goto error_disable_adc_clk; 1288 goto error_disable_adc_clk;
@@ -1120,6 +1346,20 @@ static struct at91_adc_caps at91sam9260_caps = {
1120 }, 1346 },
1121}; 1347};
1122 1348
1349static struct at91_adc_caps at91sam9rl_caps = {
1350 .has_ts = true,
1351 .calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */
1352 .num_channels = 6,
1353 .registers = {
1354 .channel_base = AT91_ADC_CHR(0),
1355 .drdy_mask = AT91_ADC_DRDY,
1356 .status_register = AT91_ADC_SR,
1357 .trigger_register = AT91_ADC_TRGR_9G45,
1358 .mr_prescal_mask = AT91_ADC_PRESCAL_9260,
1359 .mr_startup_mask = AT91_ADC_STARTUP_9G45,
1360 },
1361};
1362
1123static struct at91_adc_caps at91sam9g45_caps = { 1363static struct at91_adc_caps at91sam9g45_caps = {
1124 .has_ts = true, 1364 .has_ts = true,
1125 .calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */ 1365 .calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */
@@ -1154,6 +1394,7 @@ static struct at91_adc_caps at91sam9x5_caps = {
1154 1394
1155static const struct of_device_id at91_adc_dt_ids[] = { 1395static const struct of_device_id at91_adc_dt_ids[] = {
1156 { .compatible = "atmel,at91sam9260-adc", .data = &at91sam9260_caps }, 1396 { .compatible = "atmel,at91sam9260-adc", .data = &at91sam9260_caps },
1397 { .compatible = "atmel,at91sam9rl-adc", .data = &at91sam9rl_caps },
1157 { .compatible = "atmel,at91sam9g45-adc", .data = &at91sam9g45_caps }, 1398 { .compatible = "atmel,at91sam9g45-adc", .data = &at91sam9g45_caps },
1158 { .compatible = "atmel,at91sam9x5-adc", .data = &at91sam9x5_caps }, 1399 { .compatible = "atmel,at91sam9x5-adc", .data = &at91sam9x5_caps },
1159 {}, 1400 {},
@@ -1165,6 +1406,9 @@ static const struct platform_device_id at91_adc_ids[] = {
1165 .name = "at91sam9260-adc", 1406 .name = "at91sam9260-adc",
1166 .driver_data = (unsigned long)&at91sam9260_caps, 1407 .driver_data = (unsigned long)&at91sam9260_caps,
1167 }, { 1408 }, {
1409 .name = "at91sam9rl-adc",
1410 .driver_data = (unsigned long)&at91sam9rl_caps,
1411 }, {
1168 .name = "at91sam9g45-adc", 1412 .name = "at91sam9g45-adc",
1169 .driver_data = (unsigned long)&at91sam9g45_caps, 1413 .driver_data = (unsigned long)&at91sam9g45_caps,
1170 }, { 1414 }, {
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index b845e9370871..d4e5ab57909f 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -550,18 +550,6 @@ config TOUCHSCREEN_TI_AM335X_TSC
550 To compile this driver as a module, choose M here: the 550 To compile this driver as a module, choose M here: the
551 module will be called ti_am335x_tsc. 551 module will be called ti_am335x_tsc.
552 552
553config TOUCHSCREEN_ATMEL_TSADCC
554 tristate "Atmel Touchscreen Interface"
555 depends on ARCH_AT91
556 help
557 Say Y here if you have a 4-wire touchscreen connected to the
558 ADC Controller on your Atmel SoC.
559
560 If unsure, say N.
561
562 To compile this driver as a module, choose M here: the
563 module will be called atmel_tsadcc.
564
565config TOUCHSCREEN_UCB1400 553config TOUCHSCREEN_UCB1400
566 tristate "Philips UCB1400 touchscreen" 554 tristate "Philips UCB1400 touchscreen"
567 depends on AC97_BUS 555 depends on AC97_BUS
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 4bc954b7c7c3..03f12a1f2218 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -13,7 +13,6 @@ obj-$(CONFIG_TOUCHSCREEN_AD7879_I2C) += ad7879-i2c.o
13obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o 13obj-$(CONFIG_TOUCHSCREEN_AD7879_SPI) += ad7879-spi.o
14obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o 14obj-$(CONFIG_TOUCHSCREEN_ADS7846) += ads7846.o
15obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o 15obj-$(CONFIG_TOUCHSCREEN_ATMEL_MXT) += atmel_mxt_ts.o
16obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) += atmel_tsadcc.o
17obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o 16obj-$(CONFIG_TOUCHSCREEN_AUO_PIXCIR) += auo-pixcir-ts.o
18obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o 17obj-$(CONFIG_TOUCHSCREEN_BU21013) += bu21013_ts.o
19obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o 18obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110) += cy8ctmg110_ts.o
diff --git a/drivers/input/touchscreen/atmel_tsadcc.c b/drivers/input/touchscreen/atmel_tsadcc.c
deleted file mode 100644
index a7c9d6967d1e..000000000000
--- a/drivers/input/touchscreen/atmel_tsadcc.c
+++ /dev/null
@@ -1,358 +0,0 @@
1/*
2 * Atmel Touch Screen Driver
3 *
4 * Copyright (c) 2008 ATMEL
5 * Copyright (c) 2008 Dan Liang
6 * Copyright (c) 2008 TimeSys Corporation
7 * Copyright (c) 2008 Justin Waters
8 *
9 * Based on touchscreen code from Atmel Corporation.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 */
15#include <linux/err.h>
16#include <linux/kernel.h>
17#include <linux/module.h>
18#include <linux/input.h>
19#include <linux/slab.h>
20#include <linux/interrupt.h>
21#include <linux/clk.h>
22#include <linux/platform_device.h>
23#include <linux/io.h>
24#include <linux/platform_data/atmel.h>
25#include <mach/cpu.h>
26
27/* Register definitions based on AT91SAM9RL64 preliminary draft datasheet */
28
29#define ATMEL_TSADCC_CR 0x00 /* Control register */
30#define ATMEL_TSADCC_SWRST (1 << 0) /* Software Reset*/
31#define ATMEL_TSADCC_START (1 << 1) /* Start conversion */
32
33#define ATMEL_TSADCC_MR 0x04 /* Mode register */
34#define ATMEL_TSADCC_TSAMOD (3 << 0) /* ADC mode */
35#define ATMEL_TSADCC_TSAMOD_ADC_ONLY_MODE (0x0) /* ADC Mode */
36#define ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE (0x1) /* Touch Screen Only Mode */
37#define ATMEL_TSADCC_LOWRES (1 << 4) /* Resolution selection */
38#define ATMEL_TSADCC_SLEEP (1 << 5) /* Sleep mode */
39#define ATMEL_TSADCC_PENDET (1 << 6) /* Pen Detect selection */
40#define ATMEL_TSADCC_PRES (1 << 7) /* Pressure Measurement Selection */
41#define ATMEL_TSADCC_PRESCAL (0x3f << 8) /* Prescalar Rate Selection */
42#define ATMEL_TSADCC_EPRESCAL (0xff << 8) /* Prescalar Rate Selection (Extended) */
43#define ATMEL_TSADCC_STARTUP (0x7f << 16) /* Start Up time */
44#define ATMEL_TSADCC_SHTIM (0xf << 24) /* Sample & Hold time */
45#define ATMEL_TSADCC_PENDBC (0xf << 28) /* Pen Detect debouncing time */
46
47#define ATMEL_TSADCC_TRGR 0x08 /* Trigger register */
48#define ATMEL_TSADCC_TRGMOD (7 << 0) /* Trigger mode */
49#define ATMEL_TSADCC_TRGMOD_NONE (0 << 0)
50#define ATMEL_TSADCC_TRGMOD_EXT_RISING (1 << 0)
51#define ATMEL_TSADCC_TRGMOD_EXT_FALLING (2 << 0)
52#define ATMEL_TSADCC_TRGMOD_EXT_ANY (3 << 0)
53#define ATMEL_TSADCC_TRGMOD_PENDET (4 << 0)
54#define ATMEL_TSADCC_TRGMOD_PERIOD (5 << 0)
55#define ATMEL_TSADCC_TRGMOD_CONTINUOUS (6 << 0)
56#define ATMEL_TSADCC_TRGPER (0xffff << 16) /* Trigger period */
57
58#define ATMEL_TSADCC_TSR 0x0C /* Touch Screen register */
59#define ATMEL_TSADCC_TSFREQ (0xf << 0) /* TS Frequency in Interleaved mode */
60#define ATMEL_TSADCC_TSSHTIM (0xf << 24) /* Sample & Hold time */
61
62#define ATMEL_TSADCC_CHER 0x10 /* Channel Enable register */
63#define ATMEL_TSADCC_CHDR 0x14 /* Channel Disable register */
64#define ATMEL_TSADCC_CHSR 0x18 /* Channel Status register */
65#define ATMEL_TSADCC_CH(n) (1 << (n)) /* Channel number */
66
67#define ATMEL_TSADCC_SR 0x1C /* Status register */
68#define ATMEL_TSADCC_EOC(n) (1 << ((n)+0)) /* End of conversion for channel N */
69#define ATMEL_TSADCC_OVRE(n) (1 << ((n)+8)) /* Overrun error for channel N */
70#define ATMEL_TSADCC_DRDY (1 << 16) /* Data Ready */
71#define ATMEL_TSADCC_GOVRE (1 << 17) /* General Overrun Error */
72#define ATMEL_TSADCC_ENDRX (1 << 18) /* End of RX Buffer */
73#define ATMEL_TSADCC_RXBUFF (1 << 19) /* TX Buffer full */
74#define ATMEL_TSADCC_PENCNT (1 << 20) /* Pen contact */
75#define ATMEL_TSADCC_NOCNT (1 << 21) /* No contact */
76
77#define ATMEL_TSADCC_LCDR 0x20 /* Last Converted Data register */
78#define ATMEL_TSADCC_DATA (0x3ff << 0) /* Channel data */
79
80#define ATMEL_TSADCC_IER 0x24 /* Interrupt Enable register */
81#define ATMEL_TSADCC_IDR 0x28 /* Interrupt Disable register */
82#define ATMEL_TSADCC_IMR 0x2C /* Interrupt Mask register */
83#define ATMEL_TSADCC_CDR0 0x30 /* Channel Data 0 */
84#define ATMEL_TSADCC_CDR1 0x34 /* Channel Data 1 */
85#define ATMEL_TSADCC_CDR2 0x38 /* Channel Data 2 */
86#define ATMEL_TSADCC_CDR3 0x3C /* Channel Data 3 */
87#define ATMEL_TSADCC_CDR4 0x40 /* Channel Data 4 */
88#define ATMEL_TSADCC_CDR5 0x44 /* Channel Data 5 */
89
90#define ATMEL_TSADCC_XPOS 0x50
91#define ATMEL_TSADCC_Z1DAT 0x54
92#define ATMEL_TSADCC_Z2DAT 0x58
93
94#define PRESCALER_VAL(x) ((x) >> 8)
95
96#define ADC_DEFAULT_CLOCK 100000
97
98struct atmel_tsadcc {
99 struct input_dev *input;
100 char phys[32];
101 struct clk *clk;
102 int irq;
103 unsigned int prev_absx;
104 unsigned int prev_absy;
105 unsigned char bufferedmeasure;
106};
107
108static void __iomem *tsc_base;
109
110#define atmel_tsadcc_read(reg) __raw_readl(tsc_base + (reg))
111#define atmel_tsadcc_write(reg, val) __raw_writel((val), tsc_base + (reg))
112
113static irqreturn_t atmel_tsadcc_interrupt(int irq, void *dev)
114{
115 struct atmel_tsadcc *ts_dev = (struct atmel_tsadcc *)dev;
116 struct input_dev *input_dev = ts_dev->input;
117
118 unsigned int status;
119 unsigned int reg;
120
121 status = atmel_tsadcc_read(ATMEL_TSADCC_SR);
122 status &= atmel_tsadcc_read(ATMEL_TSADCC_IMR);
123
124 if (status & ATMEL_TSADCC_NOCNT) {
125 /* Contact lost */
126 reg = atmel_tsadcc_read(ATMEL_TSADCC_MR) | ATMEL_TSADCC_PENDBC;
127
128 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
129 atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
130 atmel_tsadcc_write(ATMEL_TSADCC_IDR,
131 ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
132 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
133
134 input_report_key(input_dev, BTN_TOUCH, 0);
135 ts_dev->bufferedmeasure = 0;
136 input_sync(input_dev);
137
138 } else if (status & ATMEL_TSADCC_PENCNT) {
139 /* Pen detected */
140 reg = atmel_tsadcc_read(ATMEL_TSADCC_MR);
141 reg &= ~ATMEL_TSADCC_PENDBC;
142
143 atmel_tsadcc_write(ATMEL_TSADCC_IDR, ATMEL_TSADCC_PENCNT);
144 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
145 atmel_tsadcc_write(ATMEL_TSADCC_IER,
146 ATMEL_TSADCC_EOC(3) | ATMEL_TSADCC_NOCNT);
147 atmel_tsadcc_write(ATMEL_TSADCC_TRGR,
148 ATMEL_TSADCC_TRGMOD_PERIOD | (0x0FFF << 16));
149
150 } else if (status & ATMEL_TSADCC_EOC(3)) {
151 /* Conversion finished */
152
153 if (ts_dev->bufferedmeasure) {
154 /* Last measurement is always discarded, since it can
155 * be erroneous.
156 * Always report previous measurement */
157 input_report_abs(input_dev, ABS_X, ts_dev->prev_absx);
158 input_report_abs(input_dev, ABS_Y, ts_dev->prev_absy);
159 input_report_key(input_dev, BTN_TOUCH, 1);
160 input_sync(input_dev);
161 } else
162 ts_dev->bufferedmeasure = 1;
163
164 /* Now make new measurement */
165 ts_dev->prev_absx = atmel_tsadcc_read(ATMEL_TSADCC_CDR3) << 10;
166 ts_dev->prev_absx /= atmel_tsadcc_read(ATMEL_TSADCC_CDR2);
167
168 ts_dev->prev_absy = atmel_tsadcc_read(ATMEL_TSADCC_CDR1) << 10;
169 ts_dev->prev_absy /= atmel_tsadcc_read(ATMEL_TSADCC_CDR0);
170 }
171
172 return IRQ_HANDLED;
173}
174
175/*
176 * The functions for inserting/removing us as a module.
177 */
178
179static int atmel_tsadcc_probe(struct platform_device *pdev)
180{
181 struct atmel_tsadcc *ts_dev;
182 struct input_dev *input_dev;
183 struct resource *res;
184 struct at91_tsadcc_data *pdata = dev_get_platdata(&pdev->dev);
185 int err;
186 unsigned int prsc;
187 unsigned int reg;
188
189 if (!pdata)
190 return -EINVAL;
191
192 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
193 if (!res) {
194 dev_err(&pdev->dev, "no mmio resource defined.\n");
195 return -ENXIO;
196 }
197
198 /* Allocate memory for device */
199 ts_dev = kzalloc(sizeof(struct atmel_tsadcc), GFP_KERNEL);
200 if (!ts_dev) {
201 dev_err(&pdev->dev, "failed to allocate memory.\n");
202 return -ENOMEM;
203 }
204 platform_set_drvdata(pdev, ts_dev);
205
206 input_dev = input_allocate_device();
207 if (!input_dev) {
208 dev_err(&pdev->dev, "failed to allocate input device.\n");
209 err = -EBUSY;
210 goto err_free_mem;
211 }
212
213 ts_dev->irq = platform_get_irq(pdev, 0);
214 if (ts_dev->irq < 0) {
215 dev_err(&pdev->dev, "no irq ID is designated.\n");
216 err = -ENODEV;
217 goto err_free_dev;
218 }
219
220 if (!request_mem_region(res->start, resource_size(res),
221 "atmel tsadcc regs")) {
222 dev_err(&pdev->dev, "resources is unavailable.\n");
223 err = -EBUSY;
224 goto err_free_dev;
225 }
226
227 tsc_base = ioremap(res->start, resource_size(res));
228 if (!tsc_base) {
229 dev_err(&pdev->dev, "failed to map registers.\n");
230 err = -ENOMEM;
231 goto err_release_mem;
232 }
233
234 err = request_irq(ts_dev->irq, atmel_tsadcc_interrupt, 0,
235 pdev->dev.driver->name, ts_dev);
236 if (err) {
237 dev_err(&pdev->dev, "failed to allocate irq.\n");
238 goto err_unmap_regs;
239 }
240
241 ts_dev->clk = clk_get(&pdev->dev, "tsc_clk");
242 if (IS_ERR(ts_dev->clk)) {
243 dev_err(&pdev->dev, "failed to get ts_clk\n");
244 err = PTR_ERR(ts_dev->clk);
245 goto err_free_irq;
246 }
247
248 ts_dev->input = input_dev;
249 ts_dev->bufferedmeasure = 0;
250
251 snprintf(ts_dev->phys, sizeof(ts_dev->phys),
252 "%s/input0", dev_name(&pdev->dev));
253
254 input_dev->name = "atmel touch screen controller";
255 input_dev->phys = ts_dev->phys;
256 input_dev->dev.parent = &pdev->dev;
257
258 __set_bit(EV_ABS, input_dev->evbit);
259 input_set_abs_params(input_dev, ABS_X, 0, 0x3FF, 0, 0);
260 input_set_abs_params(input_dev, ABS_Y, 0, 0x3FF, 0, 0);
261
262 input_set_capability(input_dev, EV_KEY, BTN_TOUCH);
263
264 /* clk_enable() always returns 0, no need to check it */
265 clk_enable(ts_dev->clk);
266
267 prsc = clk_get_rate(ts_dev->clk);
268 dev_info(&pdev->dev, "Master clock is set at: %d Hz\n", prsc);
269
270 if (!pdata->adc_clock)
271 pdata->adc_clock = ADC_DEFAULT_CLOCK;
272
273 prsc = (prsc / (2 * pdata->adc_clock)) - 1;
274
275 /* saturate if this value is too high */
276 if (cpu_is_at91sam9rl()) {
277 if (prsc > PRESCALER_VAL(ATMEL_TSADCC_PRESCAL))
278 prsc = PRESCALER_VAL(ATMEL_TSADCC_PRESCAL);
279 } else {
280 if (prsc > PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL))
281 prsc = PRESCALER_VAL(ATMEL_TSADCC_EPRESCAL);
282 }
283
284 dev_info(&pdev->dev, "Prescaler is set at: %d\n", prsc);
285
286 reg = ATMEL_TSADCC_TSAMOD_TS_ONLY_MODE |
287 ((0x00 << 5) & ATMEL_TSADCC_SLEEP) | /* Normal Mode */
288 ((0x01 << 6) & ATMEL_TSADCC_PENDET) | /* Enable Pen Detect */
289 (prsc << 8) |
290 ((0x26 << 16) & ATMEL_TSADCC_STARTUP) |
291 ((pdata->pendet_debounce << 28) & ATMEL_TSADCC_PENDBC);
292
293 atmel_tsadcc_write(ATMEL_TSADCC_CR, ATMEL_TSADCC_SWRST);
294 atmel_tsadcc_write(ATMEL_TSADCC_MR, reg);
295 atmel_tsadcc_write(ATMEL_TSADCC_TRGR, ATMEL_TSADCC_TRGMOD_NONE);
296 atmel_tsadcc_write(ATMEL_TSADCC_TSR,
297 (pdata->ts_sample_hold_time << 24) & ATMEL_TSADCC_TSSHTIM);
298
299 atmel_tsadcc_read(ATMEL_TSADCC_SR);
300 atmel_tsadcc_write(ATMEL_TSADCC_IER, ATMEL_TSADCC_PENCNT);
301
302 /* All went ok, so register to the input system */
303 err = input_register_device(input_dev);
304 if (err)
305 goto err_fail;
306
307 return 0;
308
309err_fail:
310 clk_disable(ts_dev->clk);
311 clk_put(ts_dev->clk);
312err_free_irq:
313 free_irq(ts_dev->irq, ts_dev);
314err_unmap_regs:
315 iounmap(tsc_base);
316err_release_mem:
317 release_mem_region(res->start, resource_size(res));
318err_free_dev:
319 input_free_device(input_dev);
320err_free_mem:
321 kfree(ts_dev);
322 return err;
323}
324
325static int atmel_tsadcc_remove(struct platform_device *pdev)
326{
327 struct atmel_tsadcc *ts_dev = platform_get_drvdata(pdev);
328 struct resource *res;
329
330 free_irq(ts_dev->irq, ts_dev);
331
332 input_unregister_device(ts_dev->input);
333
334 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
335 iounmap(tsc_base);
336 release_mem_region(res->start, resource_size(res));
337
338 clk_disable(ts_dev->clk);
339 clk_put(ts_dev->clk);
340
341 kfree(ts_dev);
342
343 return 0;
344}
345
346static struct platform_driver atmel_tsadcc_driver = {
347 .probe = atmel_tsadcc_probe,
348 .remove = atmel_tsadcc_remove,
349 .driver = {
350 .name = "atmel_tsadcc",
351 },
352};
353module_platform_driver(atmel_tsadcc_driver);
354
355MODULE_LICENSE("GPL");
356MODULE_DESCRIPTION("Atmel TouchScreen Driver");
357MODULE_AUTHOR("Dan Liang <dan.liang@atmel.com>");
358
diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c
index 3899ba7821c5..c887e6eebc41 100644
--- a/drivers/irqchip/irq-armada-370-xp.c
+++ b/drivers/irqchip/irq-armada-370-xp.c
@@ -19,6 +19,7 @@
19#include <linux/irq.h> 19#include <linux/irq.h>
20#include <linux/interrupt.h> 20#include <linux/interrupt.h>
21#include <linux/irqchip/chained_irq.h> 21#include <linux/irqchip/chained_irq.h>
22#include <linux/cpu.h>
22#include <linux/io.h> 23#include <linux/io.h>
23#include <linux/of_address.h> 24#include <linux/of_address.h>
24#include <linux/of_irq.h> 25#include <linux/of_irq.h>
@@ -310,7 +311,8 @@ static int armada_370_xp_mpic_irq_map(struct irq_domain *h,
310} 311}
311 312
312#ifdef CONFIG_SMP 313#ifdef CONFIG_SMP
313void armada_mpic_send_doorbell(const struct cpumask *mask, unsigned int irq) 314static void armada_mpic_send_doorbell(const struct cpumask *mask,
315 unsigned int irq)
314{ 316{
315 int cpu; 317 int cpu;
316 unsigned long map = 0; 318 unsigned long map = 0;
@@ -330,7 +332,7 @@ void armada_mpic_send_doorbell(const struct cpumask *mask, unsigned int irq)
330 ARMADA_370_XP_SW_TRIG_INT_OFFS); 332 ARMADA_370_XP_SW_TRIG_INT_OFFS);
331} 333}
332 334
333void armada_xp_mpic_smp_cpu_init(void) 335static void armada_xp_mpic_smp_cpu_init(void)
334{ 336{
335 /* Clear pending IPIs */ 337 /* Clear pending IPIs */
336 writel(0, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS); 338 writel(0, per_cpu_int_base + ARMADA_370_XP_IN_DRBEL_CAUSE_OFFS);
@@ -342,6 +344,20 @@ void armada_xp_mpic_smp_cpu_init(void)
342 /* Unmask IPI interrupt */ 344 /* Unmask IPI interrupt */
343 writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS); 345 writel(0, per_cpu_int_base + ARMADA_370_XP_INT_CLEAR_MASK_OFFS);
344} 346}
347
348static int armada_xp_mpic_secondary_init(struct notifier_block *nfb,
349 unsigned long action, void *hcpu)
350{
351 if (action == CPU_STARTING || action == CPU_STARTING_FROZEN)
352 armada_xp_mpic_smp_cpu_init();
353 return NOTIFY_OK;
354}
355
356static struct notifier_block armada_370_xp_mpic_cpu_notifier = {
357 .notifier_call = armada_xp_mpic_secondary_init,
358 .priority = 100,
359};
360
345#endif /* CONFIG_SMP */ 361#endif /* CONFIG_SMP */
346 362
347static struct irq_domain_ops armada_370_xp_mpic_irq_ops = { 363static struct irq_domain_ops armada_370_xp_mpic_irq_ops = {
@@ -497,6 +513,10 @@ static int __init armada_370_xp_mpic_of_init(struct device_node *node,
497 if (parent_irq <= 0) { 513 if (parent_irq <= 0) {
498 irq_set_default_host(armada_370_xp_mpic_domain); 514 irq_set_default_host(armada_370_xp_mpic_domain);
499 set_handle_irq(armada_370_xp_handle_irq); 515 set_handle_irq(armada_370_xp_handle_irq);
516#ifdef CONFIG_SMP
517 set_smp_cross_call(armada_mpic_send_doorbell);
518 register_cpu_notifier(&armada_370_xp_mpic_cpu_notifier);
519#endif
500 } else { 520 } else {
501 irq_set_chained_handler(parent_irq, 521 irq_set_chained_handler(parent_irq,
502 armada_370_xp_mpic_handle_cascade_irq); 522 armada_370_xp_mpic_handle_cascade_irq);
diff --git a/drivers/irqchip/irq-orion.c b/drivers/irqchip/irq-orion.c
index e25f246cd2fb..34d18b48bb78 100644
--- a/drivers/irqchip/irq-orion.c
+++ b/drivers/irqchip/irq-orion.c
@@ -42,7 +42,7 @@ __exception_irq_entry orion_handle_irq(struct pt_regs *regs)
42 u32 stat = readl_relaxed(gc->reg_base + ORION_IRQ_CAUSE) & 42 u32 stat = readl_relaxed(gc->reg_base + ORION_IRQ_CAUSE) &
43 gc->mask_cache; 43 gc->mask_cache;
44 while (stat) { 44 while (stat) {
45 u32 hwirq = ffs(stat) - 1; 45 u32 hwirq = __fls(stat);
46 u32 irq = irq_find_mapping(orion_irq_domain, 46 u32 irq = irq_find_mapping(orion_irq_domain,
47 gc->irq_base + hwirq); 47 gc->irq_base + hwirq);
48 handle_IRQ(irq, regs); 48 handle_IRQ(irq, regs);
@@ -117,7 +117,7 @@ static void orion_bridge_irq_handler(unsigned int irq, struct irq_desc *desc)
117 gc->mask_cache; 117 gc->mask_cache;
118 118
119 while (stat) { 119 while (stat) {
120 u32 hwirq = ffs(stat) - 1; 120 u32 hwirq = __fls(stat);
121 121
122 generic_handle_irq(irq_find_mapping(d, gc->irq_base + hwirq)); 122 generic_handle_irq(irq_find_mapping(d, gc->irq_base + hwirq));
123 stat &= ~(1 << hwirq); 123 stat &= ~(1 << hwirq);
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index e87140bef667..db11b4f40611 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -98,7 +98,11 @@
98#define TWL4030_BASEADD_BACKUP 0x0014 98#define TWL4030_BASEADD_BACKUP 0x0014
99#define TWL4030_BASEADD_INT 0x002E 99#define TWL4030_BASEADD_INT 0x002E
100#define TWL4030_BASEADD_PM_MASTER 0x0036 100#define TWL4030_BASEADD_PM_MASTER 0x0036
101
101#define TWL4030_BASEADD_PM_RECEIVER 0x005B 102#define TWL4030_BASEADD_PM_RECEIVER 0x005B
103#define TWL4030_DCDC_GLOBAL_CFG 0x06
104#define SMARTREFLEX_ENABLE BIT(3)
105
102#define TWL4030_BASEADD_RTC 0x001C 106#define TWL4030_BASEADD_RTC 0x001C
103#define TWL4030_BASEADD_SECURED_REG 0x0000 107#define TWL4030_BASEADD_SECURED_REG 0x0000
104 108
@@ -1204,6 +1208,11 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1204 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface. 1208 * Disable TWL4030/TWL5030 I2C Pull-up on I2C1 and I2C4(SR) interface.
1205 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0, 1209 * Program I2C_SCL_CTRL_PU(bit 0)=0, I2C_SDA_CTRL_PU (bit 2)=0,
1206 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0. 1210 * SR_I2C_SCL_CTRL_PU(bit 4)=0 and SR_I2C_SDA_CTRL_PU(bit 6)=0.
1211 *
1212 * Also, always enable SmartReflex bit as that's needed for omaps to
1213 * to do anything over I2C4 for voltage scaling even if SmartReflex
1214 * is disabled. Without the SmartReflex bit omap sys_clkreq idle
1215 * signal will never trigger for retention idle.
1207 */ 1216 */
1208 if (twl_class_is_4030()) { 1217 if (twl_class_is_4030()) {
1209 u8 temp; 1218 u8 temp;
@@ -1212,6 +1221,12 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
1212 temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \ 1221 temp &= ~(SR_I2C_SDA_CTRL_PU | SR_I2C_SCL_CTRL_PU | \
1213 I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU); 1222 I2C_SDA_CTRL_PU | I2C_SCL_CTRL_PU);
1214 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1); 1223 twl_i2c_write_u8(TWL4030_MODULE_INTBR, temp, REG_GPPUPDCTR1);
1224
1225 twl_i2c_read_u8(TWL_MODULE_PM_RECEIVER, &temp,
1226 TWL4030_DCDC_GLOBAL_CFG);
1227 temp |= SMARTREFLEX_ENABLE;
1228 twl_i2c_write_u8(TWL_MODULE_PM_RECEIVER, temp,
1229 TWL4030_DCDC_GLOBAL_CFG);
1215 } 1230 }
1216 1231
1217 if (node) { 1232 if (node) {
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index fa0e4e057b99..49b46e6ca959 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -12,6 +12,14 @@ config POWER_RESET_AS3722
12 help 12 help
13 This driver supports turning off board via a ams AS3722 power-off. 13 This driver supports turning off board via a ams AS3722 power-off.
14 14
15config POWER_RESET_AXXIA
16 bool "LSI Axxia reset driver"
17 depends on POWER_RESET && ARCH_AXXIA
18 help
19 This driver supports restart for Axxia SoC.
20
21 Say Y if you have an Axxia family SoC.
22
15config POWER_RESET_GPIO 23config POWER_RESET_GPIO
16 bool "GPIO power-off driver" 24 bool "GPIO power-off driver"
17 depends on OF_GPIO && POWER_RESET 25 depends on OF_GPIO && POWER_RESET
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index a5b4a77d1a41..16c0516e5a19 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -1,4 +1,5 @@
1obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o 1obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
2obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
2obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o 3obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
3obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o 4obj-$(CONFIG_POWER_RESET_MSM) += msm-poweroff.o
4obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o 5obj-$(CONFIG_POWER_RESET_QNAP) += qnap-poweroff.o
diff --git a/drivers/power/reset/axxia-reset.c b/drivers/power/reset/axxia-reset.c
new file mode 100644
index 000000000000..3b1f8d601784
--- /dev/null
+++ b/drivers/power/reset/axxia-reset.c
@@ -0,0 +1,88 @@
1/*
2 * Reset driver for Axxia devices
3 *
4 * Copyright (C) 2014 LSI
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 and
8 * only version 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16#include <linux/init.h>
17#include <linux/err.h>
18#include <linux/io.h>
19#include <linux/kernel.h>
20#include <linux/mfd/syscon.h>
21#include <linux/module.h>
22#include <linux/of.h>
23#include <linux/platform_device.h>
24#include <linux/reboot.h>
25#include <linux/regmap.h>
26
27#include <asm/system_misc.h>
28
29
30#define SC_CRIT_WRITE_KEY 0x1000
31#define SC_LATCH_ON_RESET 0x1004
32#define SC_RESET_CONTROL 0x1008
33#define RSTCTL_RST_ZERO (1<<3)
34#define RSTCTL_RST_FAB (1<<2)
35#define RSTCTL_RST_CHIP (1<<1)
36#define RSTCTL_RST_SYS (1<<0)
37#define SC_EFUSE_INT_STATUS 0x180c
38#define EFUSE_READ_DONE (1<<31)
39
40static struct regmap *syscon;
41
42static void do_axxia_restart(enum reboot_mode reboot_mode, const char *cmd)
43{
44 /* Access Key (0xab) */
45 regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);
46 /* Select internal boot from 0xffff0000 */
47 regmap_write(syscon, SC_LATCH_ON_RESET, 0x00000040);
48 /* Assert ResetReadDone (to avoid hanging in boot ROM) */
49 regmap_write(syscon, SC_EFUSE_INT_STATUS, EFUSE_READ_DONE);
50 /* Assert chip reset */
51 regmap_update_bits(syscon, SC_RESET_CONTROL,
52 RSTCTL_RST_CHIP, RSTCTL_RST_CHIP);
53}
54
55static int axxia_reset_probe(struct platform_device *pdev)
56{
57 struct device *dev = &pdev->dev;
58
59 syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
60 if (IS_ERR(syscon)) {
61 pr_err("%s: syscon lookup failed\n", dev->of_node->name);
62 return PTR_ERR(syscon);
63 }
64
65 arm_pm_restart = do_axxia_restart;
66
67 return 0;
68}
69
70static const struct of_device_id of_axxia_reset_match[] = {
71 { .compatible = "lsi,axm55xx-reset", },
72 {},
73};
74MODULE_DEVICE_TABLE(of, of_axxia_reset_match);
75
76static struct platform_driver axxia_reset_driver = {
77 .probe = axxia_reset_probe,
78 .driver = {
79 .name = "axxia-reset",
80 .of_match_table = of_match_ptr(of_axxia_reset_match),
81 },
82};
83
84static int __init axxia_reset_init(void)
85{
86 return platform_driver_register(&axxia_reset_driver);
87}
88device_initcall(axxia_reset_init);