2 * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
3 * http://www.samsung.com
5 * EXYNOS4210 - Clock support
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/err.h>
14 #include <linux/clk.h>
16 #include <linux/syscore_ops.h>
18 #include <plat/cpu-freq.h>
19 #include <plat/clock.h>
22 #include <plat/s5p-clock.h>
23 #include <plat/clock-clksrc.h>
26 #include <mach/hardware.h>
28 #include <mach/regs-clock.h>
29 #include <mach/sysmmu.h>
32 #include "clock-exynos4.h"
34 #ifdef CONFIG_PM_SLEEP
35 static struct sleep_save exynos4210_clock_save
[] = {
36 SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE
),
37 SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE
),
38 SAVE_ITEM(EXYNOS4210_CLKSRC_LCD1
),
39 SAVE_ITEM(EXYNOS4210_CLKDIV_LCD1
),
40 SAVE_ITEM(EXYNOS4210_CLKSRC_MASK_LCD1
),
41 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_IMAGE
),
42 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_LCD1
),
43 SAVE_ITEM(EXYNOS4210_CLKGATE_IP_PERIR
),
47 static struct clksrc_clk
*sysclks
[] = {
48 /* nothing here yet */
51 static struct clksrc_clk exynos4210_clk_mout_g2d0
= {
55 .sources
= &exynos4_clkset_mout_g2d0
,
56 .reg_src
= { .reg
= EXYNOS4_CLKSRC_IMAGE
, .shift
= 0, .size
= 1 },
59 static struct clksrc_clk exynos4210_clk_mout_g2d1
= {
63 .sources
= &exynos4_clkset_mout_g2d1
,
64 .reg_src
= { .reg
= EXYNOS4_CLKSRC_IMAGE
, .shift
= 4, .size
= 1 },
67 static struct clk
*exynos4210_clkset_mout_g2d_list
[] = {
68 [0] = &exynos4210_clk_mout_g2d0
.clk
,
69 [1] = &exynos4210_clk_mout_g2d1
.clk
,
72 static struct clksrc_sources exynos4210_clkset_mout_g2d
= {
73 .sources
= exynos4210_clkset_mout_g2d_list
,
74 .nr_sources
= ARRAY_SIZE(exynos4210_clkset_mout_g2d_list
),
77 static int exynos4_clksrc_mask_lcd1_ctrl(struct clk
*clk
, int enable
)
79 return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1
, clk
, enable
);
82 static struct clksrc_clk clksrcs
[] = {
87 .enable
= exynos4_clksrc_mask_fsys_ctrl
,
90 .sources
= &exynos4_clkset_mout_corebus
,
91 .reg_src
= { .reg
= EXYNOS4_CLKSRC_FSYS
, .shift
= 24, .size
= 1 },
92 .reg_div
= { .reg
= EXYNOS4_CLKDIV_FSYS0
, .shift
= 20, .size
= 4 },
96 .devname
= "exynos4-fb.1",
97 .enable
= exynos4_clksrc_mask_lcd1_ctrl
,
100 .sources
= &exynos4_clkset_group
,
101 .reg_src
= { .reg
= EXYNOS4210_CLKSRC_LCD1
, .shift
= 0, .size
= 4 },
102 .reg_div
= { .reg
= EXYNOS4210_CLKDIV_LCD1
, .shift
= 0, .size
= 4 },
105 .name
= "sclk_fimg2d",
107 .sources
= &exynos4210_clkset_mout_g2d
,
108 .reg_src
= { .reg
= EXYNOS4_CLKSRC_IMAGE
, .shift
= 8, .size
= 1 },
109 .reg_div
= { .reg
= EXYNOS4_CLKDIV_IMAGE
, .shift
= 0, .size
= 4 },
113 static struct clk init_clocks_off
[] = {
117 .parent
= &exynos4_clk_aclk_133
.clk
,
118 .enable
= exynos4_clk_ip_fsys_ctrl
,
123 .parent
= &exynos4_clk_aclk_133
.clk
,
124 .enable
= exynos4_clk_ip_fsys_ctrl
,
125 .ctrlbit
= (1 << 10),
128 .devname
= "exynos4-fb.1",
129 .enable
= exynos4_clk_ip_lcd1_ctrl
,
132 .name
= SYSMMU_CLOCK_NAME
,
133 .devname
= SYSMMU_CLOCK_DEVNAME(2d
, 14),
134 .enable
= exynos4_clk_ip_image_ctrl
,
137 .name
= SYSMMU_CLOCK_NAME
,
138 .devname
= SYSMMU_CLOCK_DEVNAME(fimd1
, 11),
139 .enable
= exynos4_clk_ip_lcd1_ctrl
,
143 .enable
= exynos4_clk_ip_image_ctrl
,
148 #ifdef CONFIG_PM_SLEEP
149 static int exynos4210_clock_suspend(void)
151 s3c_pm_do_save(exynos4210_clock_save
, ARRAY_SIZE(exynos4210_clock_save
));
156 static void exynos4210_clock_resume(void)
158 s3c_pm_do_restore_core(exynos4210_clock_save
, ARRAY_SIZE(exynos4210_clock_save
));
162 #define exynos4210_clock_suspend NULL
163 #define exynos4210_clock_resume NULL
166 static struct syscore_ops exynos4210_clock_syscore_ops
= {
167 .suspend
= exynos4210_clock_suspend
,
168 .resume
= exynos4210_clock_resume
,
171 void __init
exynos4210_register_clocks(void)
175 exynos4_clk_mout_mpll
.reg_src
.reg
= EXYNOS4_CLKSRC_CPU
;
176 exynos4_clk_mout_mpll
.reg_src
.shift
= 8;
177 exynos4_clk_mout_mpll
.reg_src
.size
= 1;
179 for (ptr
= 0; ptr
< ARRAY_SIZE(sysclks
); ptr
++)
180 s3c_register_clksrc(sysclks
[ptr
], 1);
182 s3c_register_clksrc(clksrcs
, ARRAY_SIZE(clksrcs
));
184 s3c_register_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
185 s3c_disable_clocks(init_clocks_off
, ARRAY_SIZE(init_clocks_off
));
187 register_syscore_ops(&exynos4210_clock_syscore_ops
);