clock.c 36.4 KB
Newer Older
K
Kukjin Kim 已提交
1
/* linux/arch/arm/mach-exynos4/clock.c
2
 *
K
Kukjin Kim 已提交
3 4
 * Copyright (c) 2010-2011 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
5
 *
K
Kukjin Kim 已提交
6
 * EXYNOS4 - Clock support
7 8 9 10 11 12 13 14 15
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/io.h>
16
#include <linux/syscore_ops.h>
17 18 19 20 21 22 23

#include <plat/cpu-freq.h>
#include <plat/clock.h>
#include <plat/cpu.h>
#include <plat/pll.h>
#include <plat/s5p-clock.h>
#include <plat/clock-clksrc.h>
24
#include <plat/exynos4.h>
25
#include <plat/pm.h>
26 27 28

#include <mach/map.h>
#include <mach/regs-clock.h>
29
#include <mach/sysmmu.h>
30
#include <mach/exynos4-clock.h>
31

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
static struct sleep_save exynos4_clock_save[] = {
	SAVE_ITEM(S5P_CLKDIV_LEFTBUS),
	SAVE_ITEM(S5P_CLKGATE_IP_LEFTBUS),
	SAVE_ITEM(S5P_CLKDIV_RIGHTBUS),
	SAVE_ITEM(S5P_CLKGATE_IP_RIGHTBUS),
	SAVE_ITEM(S5P_CLKSRC_TOP0),
	SAVE_ITEM(S5P_CLKSRC_TOP1),
	SAVE_ITEM(S5P_CLKSRC_CAM),
	SAVE_ITEM(S5P_CLKSRC_TV),
	SAVE_ITEM(S5P_CLKSRC_MFC),
	SAVE_ITEM(S5P_CLKSRC_G3D),
	SAVE_ITEM(S5P_CLKSRC_LCD0),
	SAVE_ITEM(S5P_CLKSRC_MAUDIO),
	SAVE_ITEM(S5P_CLKSRC_FSYS),
	SAVE_ITEM(S5P_CLKSRC_PERIL0),
	SAVE_ITEM(S5P_CLKSRC_PERIL1),
	SAVE_ITEM(S5P_CLKDIV_CAM),
	SAVE_ITEM(S5P_CLKDIV_TV),
	SAVE_ITEM(S5P_CLKDIV_MFC),
	SAVE_ITEM(S5P_CLKDIV_G3D),
	SAVE_ITEM(S5P_CLKDIV_LCD0),
	SAVE_ITEM(S5P_CLKDIV_MAUDIO),
	SAVE_ITEM(S5P_CLKDIV_FSYS0),
	SAVE_ITEM(S5P_CLKDIV_FSYS1),
	SAVE_ITEM(S5P_CLKDIV_FSYS2),
	SAVE_ITEM(S5P_CLKDIV_FSYS3),
	SAVE_ITEM(S5P_CLKDIV_PERIL0),
	SAVE_ITEM(S5P_CLKDIV_PERIL1),
	SAVE_ITEM(S5P_CLKDIV_PERIL2),
	SAVE_ITEM(S5P_CLKDIV_PERIL3),
	SAVE_ITEM(S5P_CLKDIV_PERIL4),
	SAVE_ITEM(S5P_CLKDIV_PERIL5),
	SAVE_ITEM(S5P_CLKDIV_TOP),
	SAVE_ITEM(S5P_CLKSRC_MASK_TOP),
	SAVE_ITEM(S5P_CLKSRC_MASK_CAM),
	SAVE_ITEM(S5P_CLKSRC_MASK_TV),
	SAVE_ITEM(S5P_CLKSRC_MASK_LCD0),
	SAVE_ITEM(S5P_CLKSRC_MASK_MAUDIO),
	SAVE_ITEM(S5P_CLKSRC_MASK_FSYS),
	SAVE_ITEM(S5P_CLKSRC_MASK_PERIL0),
	SAVE_ITEM(S5P_CLKSRC_MASK_PERIL1),
	SAVE_ITEM(S5P_CLKDIV2_RATIO),
	SAVE_ITEM(S5P_CLKGATE_SCLKCAM),
	SAVE_ITEM(S5P_CLKGATE_IP_CAM),
	SAVE_ITEM(S5P_CLKGATE_IP_TV),
	SAVE_ITEM(S5P_CLKGATE_IP_MFC),
	SAVE_ITEM(S5P_CLKGATE_IP_G3D),
	SAVE_ITEM(S5P_CLKGATE_IP_LCD0),
	SAVE_ITEM(S5P_CLKGATE_IP_FSYS),
	SAVE_ITEM(S5P_CLKGATE_IP_GPS),
	SAVE_ITEM(S5P_CLKGATE_IP_PERIL),
	SAVE_ITEM(S5P_CLKGATE_BLOCK),
	SAVE_ITEM(S5P_CLKSRC_MASK_DMC),
	SAVE_ITEM(S5P_CLKSRC_DMC),
	SAVE_ITEM(S5P_CLKDIV_DMC0),
	SAVE_ITEM(S5P_CLKDIV_DMC1),
	SAVE_ITEM(S5P_CLKGATE_IP_DMC),
	SAVE_ITEM(S5P_CLKSRC_CPU),
	SAVE_ITEM(S5P_CLKDIV_CPU),
	SAVE_ITEM(S5P_CLKDIV_CPU + 0x4),
	SAVE_ITEM(S5P_CLKGATE_SCLKCPU),
	SAVE_ITEM(S5P_CLKGATE_IP_CPU),
};

96
struct clk clk_sclk_hdmi27m = {
97 98 99 100
	.name		= "sclk_hdmi27m",
	.rate		= 27000000,
};

101
struct clk clk_sclk_hdmiphy = {
102 103 104
	.name		= "sclk_hdmiphy",
};

105
struct clk clk_sclk_usbphy0 = {
106 107 108 109
	.name		= "sclk_usbphy0",
	.rate		= 27000000,
};

110
struct clk clk_sclk_usbphy1 = {
111 112 113
	.name		= "sclk_usbphy1",
};

114 115 116 117 118
static struct clk dummy_apb_pclk = {
	.name		= "apb_pclk",
	.id		= -1,
};

K
Kukjin Kim 已提交
119
static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
120 121 122 123
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
}

K
Kukjin Kim 已提交
124
static int exynos4_clksrc_mask_cam_ctrl(struct clk *clk, int enable)
125 126 127 128
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_CAM, clk, enable);
}

K
Kukjin Kim 已提交
129
static int exynos4_clksrc_mask_lcd0_ctrl(struct clk *clk, int enable)
130 131 132 133
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_LCD0, clk, enable);
}

134
int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
135 136 137 138
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_FSYS, clk, enable);
}

K
Kukjin Kim 已提交
139
static int exynos4_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
140 141 142 143
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable);
}

K
Kukjin Kim 已提交
144
static int exynos4_clksrc_mask_peril1_ctrl(struct clk *clk, int enable)
145 146 147 148
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL1, clk, enable);
}

149 150 151 152 153
static int exynos4_clk_ip_mfc_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_CLKGATE_IP_MFC, clk, enable);
}

154 155 156 157 158
static int exynos4_clksrc_mask_tv_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_TV, clk, enable);
}

K
Kukjin Kim 已提交
159
static int exynos4_clk_ip_cam_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
160 161 162 163
{
	return s5p_gatectrl(S5P_CLKGATE_IP_CAM, clk, enable);
}

164 165 166 167 168
static int exynos4_clk_ip_tv_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_CLKGATE_IP_TV, clk, enable);
}

K
Kukjin Kim 已提交
169
static int exynos4_clk_ip_image_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
170 171 172 173
{
	return s5p_gatectrl(S5P_CLKGATE_IP_IMAGE, clk, enable);
}

K
Kukjin Kim 已提交
174
static int exynos4_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
175 176 177 178
{
	return s5p_gatectrl(S5P_CLKGATE_IP_LCD0, clk, enable);
}

179
int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
180 181 182 183
{
	return s5p_gatectrl(S5P_CLKGATE_IP_LCD1, clk, enable);
}

184
int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable)
185 186 187 188
{
	return s5p_gatectrl(S5P_CLKGATE_IP_FSYS, clk, enable);
}

K
Kukjin Kim 已提交
189
static int exynos4_clk_ip_peril_ctrl(struct clk *clk, int enable)
190 191 192 193
{
	return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable);
}

K
Kukjin Kim 已提交
194
static int exynos4_clk_ip_perir_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
195 196 197 198
{
	return s5p_gatectrl(S5P_CLKGATE_IP_PERIR, clk, enable);
}

199 200 201 202 203 204 205 206 207 208
static int exynos4_clk_hdmiphy_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_HDMI_PHY_CONTROL, clk, enable);
}

static int exynos4_clk_dac_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_DAC_PHY_CONTROL, clk, enable);
}

209 210 211 212 213 214 215 216
/* Core list of CMU_CPU side */

static struct clksrc_clk clk_mout_apll = {
	.clk	= {
		.name		= "mout_apll",
	},
	.sources	= &clk_src_apll,
	.reg_src	= { .reg = S5P_CLKSRC_CPU, .shift = 0, .size = 1 },
217 218
};

219
struct clksrc_clk clk_sclk_apll = {
220 221 222 223
	.clk	= {
		.name		= "sclk_apll",
		.parent		= &clk_mout_apll.clk,
	},
224 225 226
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 24, .size = 3 },
};

227
struct clksrc_clk clk_mout_epll = {
228 229 230 231 232 233 234
	.clk	= {
		.name		= "mout_epll",
	},
	.sources	= &clk_src_epll,
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 4, .size = 1 },
};

235
struct clksrc_clk clk_mout_mpll = {
236 237 238 239
	.clk = {
		.name		= "mout_mpll",
	},
	.sources	= &clk_src_mpll,
240 241

	/* reg_src will be added in each SoCs' clock */
242 243 244
};

static struct clk *clkset_moutcore_list[] = {
245
	[0] = &clk_mout_apll.clk,
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
	[1] = &clk_mout_mpll.clk,
};

static struct clksrc_sources clkset_moutcore = {
	.sources	= clkset_moutcore_list,
	.nr_sources	= ARRAY_SIZE(clkset_moutcore_list),
};

static struct clksrc_clk clk_moutcore = {
	.clk	= {
		.name		= "moutcore",
	},
	.sources	= &clkset_moutcore,
	.reg_src	= { .reg = S5P_CLKSRC_CPU, .shift = 16, .size = 1 },
};

static struct clksrc_clk clk_coreclk = {
	.clk	= {
		.name		= "core_clk",
		.parent		= &clk_moutcore.clk,
	},
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 0, .size = 3 },
};

static struct clksrc_clk clk_armclk = {
	.clk	= {
		.name		= "armclk",
		.parent		= &clk_coreclk.clk,
	},
};

static struct clksrc_clk clk_aclk_corem0 = {
	.clk	= {
		.name		= "aclk_corem0",
		.parent		= &clk_coreclk.clk,
	},
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
};

static struct clksrc_clk clk_aclk_cores = {
	.clk	= {
		.name		= "aclk_cores",
		.parent		= &clk_coreclk.clk,
	},
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 4, .size = 3 },
};

static struct clksrc_clk clk_aclk_corem1 = {
	.clk	= {
		.name		= "aclk_corem1",
		.parent		= &clk_coreclk.clk,
	},
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 8, .size = 3 },
};

static struct clksrc_clk clk_periphclk = {
	.clk	= {
		.name		= "periphclk",
		.parent		= &clk_coreclk.clk,
	},
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 12, .size = 3 },
};

/* Core list of CMU_CORE side */

311
struct clk *clkset_corebus_list[] = {
312
	[0] = &clk_mout_mpll.clk,
313
	[1] = &clk_sclk_apll.clk,
314 315
};

316
struct clksrc_sources clkset_mout_corebus = {
317 318 319 320 321 322 323 324 325
	.sources	= clkset_corebus_list,
	.nr_sources	= ARRAY_SIZE(clkset_corebus_list),
};

static struct clksrc_clk clk_mout_corebus = {
	.clk	= {
		.name		= "mout_corebus",
	},
	.sources	= &clkset_mout_corebus,
326
	.reg_src	= { .reg = S5P_CLKSRC_DMC, .shift = 4, .size = 1 },
327 328 329 330 331 332 333
};

static struct clksrc_clk clk_sclk_dmc = {
	.clk	= {
		.name		= "sclk_dmc",
		.parent		= &clk_mout_corebus.clk,
	},
334
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 12, .size = 3 },
335 336 337 338 339 340 341
};

static struct clksrc_clk clk_aclk_cored = {
	.clk	= {
		.name		= "aclk_cored",
		.parent		= &clk_sclk_dmc.clk,
	},
342
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 16, .size = 3 },
343 344 345 346 347 348 349
};

static struct clksrc_clk clk_aclk_corep = {
	.clk	= {
		.name		= "aclk_corep",
		.parent		= &clk_aclk_cored.clk,
	},
350
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 20, .size = 3 },
351 352 353 354 355 356 357
};

static struct clksrc_clk clk_aclk_acp = {
	.clk	= {
		.name		= "aclk_acp",
		.parent		= &clk_mout_corebus.clk,
	},
358
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 0, .size = 3 },
359 360 361 362 363 364 365
};

static struct clksrc_clk clk_pclk_acp = {
	.clk	= {
		.name		= "pclk_acp",
		.parent		= &clk_aclk_acp.clk,
	},
366
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 4, .size = 3 },
367 368 369 370
};

/* Core list of CMU_TOP side */

371
struct clk *clkset_aclk_top_list[] = {
372
	[0] = &clk_mout_mpll.clk,
373
	[1] = &clk_sclk_apll.clk,
374 375
};

376
struct clksrc_sources clkset_aclk = {
377 378 379 380 381 382 383 384
	.sources	= clkset_aclk_top_list,
	.nr_sources	= ARRAY_SIZE(clkset_aclk_top_list),
};

static struct clksrc_clk clk_aclk_200 = {
	.clk	= {
		.name		= "aclk_200",
	},
385
	.sources	= &clkset_aclk,
386 387 388 389 390 391 392 393
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 12, .size = 1 },
	.reg_div	= { .reg = S5P_CLKDIV_TOP, .shift = 0, .size = 3 },
};

static struct clksrc_clk clk_aclk_100 = {
	.clk	= {
		.name		= "aclk_100",
	},
394
	.sources	= &clkset_aclk,
395 396 397 398 399 400 401 402
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 16, .size = 1 },
	.reg_div	= { .reg = S5P_CLKDIV_TOP, .shift = 4, .size = 4 },
};

static struct clksrc_clk clk_aclk_160 = {
	.clk	= {
		.name		= "aclk_160",
	},
403
	.sources	= &clkset_aclk,
404 405 406 407
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 },
	.reg_div	= { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 },
};

408
struct clksrc_clk clk_aclk_133 = {
409 410 411
	.clk	= {
		.name		= "aclk_133",
	},
412
	.sources	= &clkset_aclk,
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 24, .size = 1 },
	.reg_div	= { .reg = S5P_CLKDIV_TOP, .shift = 12, .size = 3 },
};

static struct clk *clkset_vpllsrc_list[] = {
	[0] = &clk_fin_vpll,
	[1] = &clk_sclk_hdmi27m,
};

static struct clksrc_sources clkset_vpllsrc = {
	.sources	= clkset_vpllsrc_list,
	.nr_sources	= ARRAY_SIZE(clkset_vpllsrc_list),
};

static struct clksrc_clk clk_vpllsrc = {
	.clk	= {
		.name		= "vpll_src",
K
Kukjin Kim 已提交
430
		.enable		= exynos4_clksrc_mask_top_ctrl,
431
		.ctrlbit	= (1 << 0),
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446
	},
	.sources	= &clkset_vpllsrc,
	.reg_src	= { .reg = S5P_CLKSRC_TOP1, .shift = 0, .size = 1 },
};

static struct clk *clkset_sclk_vpll_list[] = {
	[0] = &clk_vpllsrc.clk,
	[1] = &clk_fout_vpll,
};

static struct clksrc_sources clkset_sclk_vpll = {
	.sources	= clkset_sclk_vpll_list,
	.nr_sources	= ARRAY_SIZE(clkset_sclk_vpll_list),
};

447
struct clksrc_clk clk_sclk_vpll = {
448 449 450 451 452 453 454
	.clk	= {
		.name		= "sclk_vpll",
	},
	.sources	= &clkset_sclk_vpll,
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 8, .size = 1 },
};

455
static struct clk init_clocks_off[] = {
456 457 458
	{
		.name		= "timers",
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
459
		.enable		= exynos4_clk_ip_peril_ctrl,
460
		.ctrlbit	= (1<<24),
J
Jongpill Lee 已提交
461 462
	}, {
		.name		= "csis",
463
		.devname	= "s5p-mipi-csis.0",
K
Kukjin Kim 已提交
464
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
465 466 467
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "csis",
468
		.devname	= "s5p-mipi-csis.1",
K
Kukjin Kim 已提交
469
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
470 471 472
		.ctrlbit	= (1 << 5),
	}, {
		.name		= "fimc",
473
		.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
474
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
475 476 477
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "fimc",
478
		.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
479
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
480 481 482
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "fimc",
483
		.devname	= "exynos4-fimc.2",
K
Kukjin Kim 已提交
484
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
485 486 487
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "fimc",
488
		.devname	= "exynos4-fimc.3",
K
Kukjin Kim 已提交
489
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
490 491 492
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "fimd",
493
		.devname	= "exynos4-fb.0",
K
Kukjin Kim 已提交
494
		.enable		= exynos4_clk_ip_lcd0_ctrl,
J
Jongpill Lee 已提交
495
		.ctrlbit	= (1 << 0),
496 497
	}, {
		.name		= "hsmmc",
498
		.devname	= "s3c-sdhci.0",
499
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
500
		.enable		= exynos4_clk_ip_fsys_ctrl,
501 502 503
		.ctrlbit	= (1 << 5),
	}, {
		.name		= "hsmmc",
504
		.devname	= "s3c-sdhci.1",
505
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
506
		.enable		= exynos4_clk_ip_fsys_ctrl,
507 508 509
		.ctrlbit	= (1 << 6),
	}, {
		.name		= "hsmmc",
510
		.devname	= "s3c-sdhci.2",
511
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
512
		.enable		= exynos4_clk_ip_fsys_ctrl,
513 514 515
		.ctrlbit	= (1 << 7),
	}, {
		.name		= "hsmmc",
516
		.devname	= "s3c-sdhci.3",
517
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
518
		.enable		= exynos4_clk_ip_fsys_ctrl,
519 520
		.ctrlbit	= (1 << 8),
	}, {
521
		.name		= "dwmmc",
522
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
523
		.enable		= exynos4_clk_ip_fsys_ctrl,
524
		.ctrlbit	= (1 << 9),
J
Jassi Brar 已提交
525
	}, {
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
		.name		= "dac",
		.devname	= "s5p-sdo",
		.enable		= exynos4_clk_ip_tv_ctrl,
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "mixer",
		.devname	= "s5p-mixer",
		.enable		= exynos4_clk_ip_tv_ctrl,
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "vp",
		.devname	= "s5p-mixer",
		.enable		= exynos4_clk_ip_tv_ctrl,
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "hdmi",
		.devname	= "exynos4-hdmi",
		.enable		= exynos4_clk_ip_tv_ctrl,
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "hdmiphy",
		.devname	= "exynos4-hdmi",
		.enable		= exynos4_clk_hdmiphy_ctrl,
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "dacphy",
		.devname	= "s5p-sdo",
		.enable		= exynos4_clk_dac_ctrl,
		.ctrlbit	= (1 << 0),
J
Jassi Brar 已提交
555
	}, {
556
		.name		= "dma",
557
		.devname	= "dma-pl330.0",
K
Kukjin Kim 已提交
558
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jassi Brar 已提交
559 560
		.ctrlbit	= (1 << 0),
	}, {
561
		.name		= "dma",
562
		.devname	= "dma-pl330.1",
K
Kukjin Kim 已提交
563
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jassi Brar 已提交
564
		.ctrlbit	= (1 << 1),
J
Jongpill Lee 已提交
565 566
	}, {
		.name		= "adc",
K
Kukjin Kim 已提交
567
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
568
		.ctrlbit	= (1 << 15),
569 570 571 572
	}, {
		.name		= "keypad",
		.enable		= exynos4_clk_ip_perir_ctrl,
		.ctrlbit	= (1 << 16),
C
Changhwan Youn 已提交
573 574
	}, {
		.name		= "rtc",
K
Kukjin Kim 已提交
575
		.enable		= exynos4_clk_ip_perir_ctrl,
C
Changhwan Youn 已提交
576
		.ctrlbit	= (1 << 15),
J
Jongpill Lee 已提交
577 578
	}, {
		.name		= "watchdog",
579
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
580
		.enable		= exynos4_clk_ip_perir_ctrl,
J
Jongpill Lee 已提交
581 582 583
		.ctrlbit	= (1 << 14),
	}, {
		.name		= "usbhost",
K
Kukjin Kim 已提交
584
		.enable		= exynos4_clk_ip_fsys_ctrl ,
J
Jongpill Lee 已提交
585 586 587
		.ctrlbit	= (1 << 12),
	}, {
		.name		= "otg",
K
Kukjin Kim 已提交
588
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jongpill Lee 已提交
589 590 591
		.ctrlbit	= (1 << 13),
	}, {
		.name		= "spi",
592
		.devname	= "s3c64xx-spi.0",
K
Kukjin Kim 已提交
593
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
594 595 596
		.ctrlbit	= (1 << 16),
	}, {
		.name		= "spi",
597
		.devname	= "s3c64xx-spi.1",
K
Kukjin Kim 已提交
598
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
599 600 601
		.ctrlbit	= (1 << 17),
	}, {
		.name		= "spi",
602
		.devname	= "s3c64xx-spi.2",
K
Kukjin Kim 已提交
603
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
604
		.ctrlbit	= (1 << 18),
J
Jassi Brar 已提交
605 606
	}, {
		.name		= "iis",
607
		.devname	= "samsung-i2s.0",
K
Kukjin Kim 已提交
608
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
609 610 611
		.ctrlbit	= (1 << 19),
	}, {
		.name		= "iis",
612
		.devname	= "samsung-i2s.1",
K
Kukjin Kim 已提交
613
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
614 615 616
		.ctrlbit	= (1 << 20),
	}, {
		.name		= "iis",
617
		.devname	= "samsung-i2s.2",
K
Kukjin Kim 已提交
618
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
619
		.ctrlbit	= (1 << 21),
J
Jassi Brar 已提交
620 621
	}, {
		.name		= "ac97",
622
		.devname	= "samsung-ac97",
K
Kukjin Kim 已提交
623
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
624
		.ctrlbit	= (1 << 27),
J
Jongpill Lee 已提交
625 626
	}, {
		.name		= "fimg2d",
K
Kukjin Kim 已提交
627
		.enable		= exynos4_clk_ip_image_ctrl,
J
Jongpill Lee 已提交
628
		.ctrlbit	= (1 << 0),
629 630 631 632 633
	}, {
		.name		= "mfc",
		.devname	= "s5p-mfc",
		.enable		= exynos4_clk_ip_mfc_ctrl,
		.ctrlbit	= (1 << 0),
J
Jongpill Lee 已提交
634 635
	}, {
		.name		= "i2c",
636
		.devname	= "s3c2440-i2c.0",
J
Jongpill Lee 已提交
637
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
638
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
639 640 641
		.ctrlbit	= (1 << 6),
	}, {
		.name		= "i2c",
642
		.devname	= "s3c2440-i2c.1",
J
Jongpill Lee 已提交
643
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
644
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
645 646 647
		.ctrlbit	= (1 << 7),
	}, {
		.name		= "i2c",
648
		.devname	= "s3c2440-i2c.2",
J
Jongpill Lee 已提交
649
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
650
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
651 652 653
		.ctrlbit	= (1 << 8),
	}, {
		.name		= "i2c",
654
		.devname	= "s3c2440-i2c.3",
J
Jongpill Lee 已提交
655
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
656
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
657 658 659
		.ctrlbit	= (1 << 9),
	}, {
		.name		= "i2c",
660
		.devname	= "s3c2440-i2c.4",
J
Jongpill Lee 已提交
661
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
662
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
663 664 665
		.ctrlbit	= (1 << 10),
	}, {
		.name		= "i2c",
666
		.devname	= "s3c2440-i2c.5",
J
Jongpill Lee 已提交
667
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
668
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
669 670 671
		.ctrlbit	= (1 << 11),
	}, {
		.name		= "i2c",
672
		.devname	= "s3c2440-i2c.6",
J
Jongpill Lee 已提交
673
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
674
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
675 676 677
		.ctrlbit	= (1 << 12),
	}, {
		.name		= "i2c",
678
		.devname	= "s3c2440-i2c.7",
J
Jongpill Lee 已提交
679
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
680
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
681
		.ctrlbit	= (1 << 13),
682 683 684 685 686 687
	}, {
		.name		= "i2c",
		.devname	= "s3c2440-hdmiphy-i2c",
		.parent		= &clk_aclk_100.clk,
		.enable		= exynos4_clk_ip_peril_ctrl,
		.ctrlbit	= (1 << 14),
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744
	}, {
		.name		= "SYSMMU_MDMA",
		.enable		= exynos4_clk_ip_image_ctrl,
		.ctrlbit	= (1 << 5),
	}, {
		.name		= "SYSMMU_FIMC0",
		.enable		= exynos4_clk_ip_cam_ctrl,
		.ctrlbit	= (1 << 7),
	}, {
		.name		= "SYSMMU_FIMC1",
		.enable		= exynos4_clk_ip_cam_ctrl,
		.ctrlbit	= (1 << 8),
	}, {
		.name		= "SYSMMU_FIMC2",
		.enable		= exynos4_clk_ip_cam_ctrl,
		.ctrlbit	= (1 << 9),
	}, {
		.name		= "SYSMMU_FIMC3",
		.enable		= exynos4_clk_ip_cam_ctrl,
		.ctrlbit	= (1 << 10),
	}, {
		.name		= "SYSMMU_JPEG",
		.enable		= exynos4_clk_ip_cam_ctrl,
		.ctrlbit	= (1 << 11),
	}, {
		.name		= "SYSMMU_FIMD0",
		.enable		= exynos4_clk_ip_lcd0_ctrl,
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "SYSMMU_FIMD1",
		.enable		= exynos4_clk_ip_lcd1_ctrl,
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "SYSMMU_PCIe",
		.enable		= exynos4_clk_ip_fsys_ctrl,
		.ctrlbit	= (1 << 18),
	}, {
		.name		= "SYSMMU_G2D",
		.enable		= exynos4_clk_ip_image_ctrl,
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "SYSMMU_ROTATOR",
		.enable		= exynos4_clk_ip_image_ctrl,
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "SYSMMU_TV",
		.enable		= exynos4_clk_ip_tv_ctrl,
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "SYSMMU_MFC_L",
		.enable		= exynos4_clk_ip_mfc_ctrl,
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "SYSMMU_MFC_R",
		.enable		= exynos4_clk_ip_mfc_ctrl,
		.ctrlbit	= (1 << 2),
	}
745 746 747
};

static struct clk init_clocks[] = {
748 749
	{
		.name		= "uart",
750
		.devname	= "s5pv210-uart.0",
K
Kukjin Kim 已提交
751
		.enable		= exynos4_clk_ip_peril_ctrl,
752 753 754
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "uart",
755
		.devname	= "s5pv210-uart.1",
K
Kukjin Kim 已提交
756
		.enable		= exynos4_clk_ip_peril_ctrl,
757 758 759
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "uart",
760
		.devname	= "s5pv210-uart.2",
K
Kukjin Kim 已提交
761
		.enable		= exynos4_clk_ip_peril_ctrl,
762 763 764
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "uart",
765
		.devname	= "s5pv210-uart.3",
K
Kukjin Kim 已提交
766
		.enable		= exynos4_clk_ip_peril_ctrl,
767 768 769
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "uart",
770
		.devname	= "s5pv210-uart.4",
K
Kukjin Kim 已提交
771
		.enable		= exynos4_clk_ip_peril_ctrl,
772 773 774
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "uart",
775
		.devname	= "s5pv210-uart.5",
K
Kukjin Kim 已提交
776
		.enable		= exynos4_clk_ip_peril_ctrl,
777 778
		.ctrlbit	= (1 << 5),
	}
779 780
};

781
struct clk *clkset_group_list[] = {
782 783 784
	[0] = &clk_ext_xtal_mux,
	[1] = &clk_xusbxti,
	[2] = &clk_sclk_hdmi27m,
785 786 787
	[3] = &clk_sclk_usbphy0,
	[4] = &clk_sclk_usbphy1,
	[5] = &clk_sclk_hdmiphy,
788 789 790 791 792
	[6] = &clk_mout_mpll.clk,
	[7] = &clk_mout_epll.clk,
	[8] = &clk_sclk_vpll.clk,
};

793
struct clksrc_sources clkset_group = {
794 795 796 797
	.sources	= clkset_group_list,
	.nr_sources	= ARRAY_SIZE(clkset_group_list),
};

J
Jongpill Lee 已提交
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843
static struct clk *clkset_mout_g2d0_list[] = {
	[0] = &clk_mout_mpll.clk,
	[1] = &clk_sclk_apll.clk,
};

static struct clksrc_sources clkset_mout_g2d0 = {
	.sources	= clkset_mout_g2d0_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_g2d0_list),
};

static struct clksrc_clk clk_mout_g2d0 = {
	.clk	= {
		.name		= "mout_g2d0",
	},
	.sources	= &clkset_mout_g2d0,
	.reg_src	= { .reg = S5P_CLKSRC_IMAGE, .shift = 0, .size = 1 },
};

static struct clk *clkset_mout_g2d1_list[] = {
	[0] = &clk_mout_epll.clk,
	[1] = &clk_sclk_vpll.clk,
};

static struct clksrc_sources clkset_mout_g2d1 = {
	.sources	= clkset_mout_g2d1_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_g2d1_list),
};

static struct clksrc_clk clk_mout_g2d1 = {
	.clk	= {
		.name		= "mout_g2d1",
	},
	.sources	= &clkset_mout_g2d1,
	.reg_src	= { .reg = S5P_CLKSRC_IMAGE, .shift = 4, .size = 1 },
};

static struct clk *clkset_mout_g2d_list[] = {
	[0] = &clk_mout_g2d0.clk,
	[1] = &clk_mout_g2d1.clk,
};

static struct clksrc_sources clkset_mout_g2d = {
	.sources	= clkset_mout_g2d_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_g2d_list),
};

844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889
static struct clk *clkset_mout_mfc0_list[] = {
	[0] = &clk_mout_mpll.clk,
	[1] = &clk_sclk_apll.clk,
};

static struct clksrc_sources clkset_mout_mfc0 = {
	.sources	= clkset_mout_mfc0_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_mfc0_list),
};

static struct clksrc_clk clk_mout_mfc0 = {
	.clk	= {
		.name		= "mout_mfc0",
	},
	.sources	= &clkset_mout_mfc0,
	.reg_src	= { .reg = S5P_CLKSRC_MFC, .shift = 0, .size = 1 },
};

static struct clk *clkset_mout_mfc1_list[] = {
	[0] = &clk_mout_epll.clk,
	[1] = &clk_sclk_vpll.clk,
};

static struct clksrc_sources clkset_mout_mfc1 = {
	.sources	= clkset_mout_mfc1_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_mfc1_list),
};

static struct clksrc_clk clk_mout_mfc1 = {
	.clk	= {
		.name		= "mout_mfc1",
	},
	.sources	= &clkset_mout_mfc1,
	.reg_src	= { .reg = S5P_CLKSRC_MFC, .shift = 4, .size = 1 },
};

static struct clk *clkset_mout_mfc_list[] = {
	[0] = &clk_mout_mfc0.clk,
	[1] = &clk_mout_mfc1.clk,
};

static struct clksrc_sources clkset_mout_mfc = {
	.sources	= clkset_mout_mfc_list,
	.nr_sources	= ARRAY_SIZE(clkset_mout_mfc_list),
};

890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964
static struct clk *clkset_sclk_dac_list[] = {
	[0] = &clk_sclk_vpll.clk,
	[1] = &clk_sclk_hdmiphy,
};

static struct clksrc_sources clkset_sclk_dac = {
	.sources	= clkset_sclk_dac_list,
	.nr_sources	= ARRAY_SIZE(clkset_sclk_dac_list),
};

static struct clksrc_clk clk_sclk_dac = {
	.clk		= {
		.name		= "sclk_dac",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 8),
	},
	.sources = &clkset_sclk_dac,
	.reg_src = { .reg = S5P_CLKSRC_TV, .shift = 8, .size = 1 },
};

static struct clksrc_clk clk_sclk_pixel = {
	.clk		= {
		.name		= "sclk_pixel",
		.parent = &clk_sclk_vpll.clk,
	},
	.reg_div = { .reg = S5P_CLKDIV_TV, .shift = 0, .size = 4 },
};

static struct clk *clkset_sclk_hdmi_list[] = {
	[0] = &clk_sclk_pixel.clk,
	[1] = &clk_sclk_hdmiphy,
};

static struct clksrc_sources clkset_sclk_hdmi = {
	.sources	= clkset_sclk_hdmi_list,
	.nr_sources	= ARRAY_SIZE(clkset_sclk_hdmi_list),
};

static struct clksrc_clk clk_sclk_hdmi = {
	.clk		= {
		.name		= "sclk_hdmi",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 0),
	},
	.sources = &clkset_sclk_hdmi,
	.reg_src = { .reg = S5P_CLKSRC_TV, .shift = 0, .size = 1 },
};

static struct clk *clkset_sclk_mixer_list[] = {
	[0] = &clk_sclk_dac.clk,
	[1] = &clk_sclk_hdmi.clk,
};

static struct clksrc_sources clkset_sclk_mixer = {
	.sources	= clkset_sclk_mixer_list,
	.nr_sources	= ARRAY_SIZE(clkset_sclk_mixer_list),
};

static struct clksrc_clk clk_sclk_mixer = {
	.clk		= {
		.name		= "sclk_mixer",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 4),
	},
	.sources = &clkset_sclk_mixer,
	.reg_src = { .reg = S5P_CLKSRC_TV, .shift = 4, .size = 1 },
};

static struct clksrc_clk *sclk_tv[] = {
	&clk_sclk_dac,
	&clk_sclk_pixel,
	&clk_sclk_hdmi,
	&clk_sclk_mixer,
};

965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009
static struct clksrc_clk clk_dout_mmc0 = {
	.clk		= {
		.name		= "dout_mmc0",
	},
	.sources = &clkset_group,
	.reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 0, .size = 4 },
	.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 0, .size = 4 },
};

static struct clksrc_clk clk_dout_mmc1 = {
	.clk		= {
		.name		= "dout_mmc1",
	},
	.sources = &clkset_group,
	.reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 4, .size = 4 },
	.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 16, .size = 4 },
};

static struct clksrc_clk clk_dout_mmc2 = {
	.clk		= {
		.name		= "dout_mmc2",
	},
	.sources = &clkset_group,
	.reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 8, .size = 4 },
	.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 0, .size = 4 },
};

static struct clksrc_clk clk_dout_mmc3 = {
	.clk		= {
		.name		= "dout_mmc3",
	},
	.sources = &clkset_group,
	.reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 12, .size = 4 },
	.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 16, .size = 4 },
};

static struct clksrc_clk clk_dout_mmc4 = {
	.clk		= {
		.name		= "dout_mmc4",
	},
	.sources = &clkset_group,
	.reg_src = { .reg = S5P_CLKSRC_FSYS, .shift = 16, .size = 4 },
	.reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 0, .size = 4 },
};

1010 1011 1012 1013
static struct clksrc_clk clksrcs[] = {
	{
		.clk	= {
			.name		= "uclk1",
1014
			.devname	= "s5pv210-uart.0",
K
Kukjin Kim 已提交
1015
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1016
			.ctrlbit	= (1 << 0),
1017 1018 1019 1020 1021 1022 1023
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 0, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 0, .size = 4 },
	}, {
		.clk		= {
			.name		= "uclk1",
1024
			.devname	= "s5pv210-uart.1",
K
Kukjin Kim 已提交
1025
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1026
			.ctrlbit	= (1 << 4),
1027 1028 1029 1030 1031 1032 1033
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 4, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 4, .size = 4 },
	}, {
		.clk		= {
			.name		= "uclk1",
1034
			.devname	= "s5pv210-uart.2",
K
Kukjin Kim 已提交
1035
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1036
			.ctrlbit	= (1 << 8),
1037 1038 1039 1040 1041 1042 1043
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 8, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 8, .size = 4 },
	}, {
		.clk		= {
			.name		= "uclk1",
1044
			.devname	= "s5pv210-uart.3",
K
Kukjin Kim 已提交
1045
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1046
			.ctrlbit	= (1 << 12),
1047 1048 1049 1050 1051 1052 1053
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 12, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL0, .shift = 12, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_pwm",
K
Kukjin Kim 已提交
1054
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1055 1056 1057 1058 1059
			.ctrlbit	= (1 << 24),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL0, .shift = 24, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL3, .shift = 0, .size = 4 },
1060 1061 1062
	}, {
		.clk		= {
			.name		= "sclk_csis",
1063
			.devname	= "s5p-mipi-csis.0",
K
Kukjin Kim 已提交
1064
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1065 1066 1067 1068 1069 1070 1071 1072
			.ctrlbit	= (1 << 24),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 24, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 24, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_csis",
1073
			.devname	= "s5p-mipi-csis.1",
K
Kukjin Kim 已提交
1074
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1075 1076 1077 1078 1079 1080 1081
			.ctrlbit	= (1 << 28),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 28, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 28, .size = 4 },
	}, {
		.clk		= {
1082
			.name		= "sclk_cam0",
K
Kukjin Kim 已提交
1083
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1084 1085 1086 1087 1088 1089 1090
			.ctrlbit	= (1 << 16),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 16, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 16, .size = 4 },
	}, {
		.clk		= {
1091
			.name		= "sclk_cam1",
K
Kukjin Kim 已提交
1092
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1093 1094 1095 1096 1097 1098 1099 1100
			.ctrlbit	= (1 << 20),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 20, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 20, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimc",
1101
			.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
1102
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1103 1104 1105 1106 1107 1108 1109 1110
			.ctrlbit	= (1 << 0),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 0, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 0, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimc",
1111
			.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
1112
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1113 1114 1115 1116 1117 1118 1119 1120
			.ctrlbit	= (1 << 4),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 4, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 4, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimc",
1121
			.devname	= "exynos4-fimc.2",
K
Kukjin Kim 已提交
1122
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1123 1124 1125 1126 1127 1128 1129 1130
			.ctrlbit	= (1 << 8),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 8, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 8, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimc",
1131
			.devname	= "exynos4-fimc.3",
K
Kukjin Kim 已提交
1132
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1133 1134 1135 1136 1137 1138 1139 1140
			.ctrlbit	= (1 << 12),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_CAM, .shift = 12, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_CAM, .shift = 12, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimd",
1141
			.devname	= "exynos4-fb.0",
K
Kukjin Kim 已提交
1142
			.enable		= exynos4_clksrc_mask_lcd0_ctrl,
1143 1144 1145 1146 1147 1148 1149 1150
			.ctrlbit	= (1 << 0),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_LCD0, .shift = 0, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_LCD0, .shift = 0, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_spi",
1151
			.devname	= "s3c64xx-spi.0",
K
Kukjin Kim 已提交
1152
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1153 1154 1155 1156 1157 1158 1159 1160
			.ctrlbit	= (1 << 16),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 16, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 0, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_spi",
1161
			.devname	= "s3c64xx-spi.1",
K
Kukjin Kim 已提交
1162
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1163 1164 1165 1166 1167 1168 1169 1170
			.ctrlbit	= (1 << 20),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 20, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL1, .shift = 16, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_spi",
1171
			.devname	= "s3c64xx-spi.2",
K
Kukjin Kim 已提交
1172
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184
			.ctrlbit	= (1 << 24),
		},
		.sources = &clkset_group,
		.reg_src = { .reg = S5P_CLKSRC_PERIL1, .shift = 24, .size = 4 },
		.reg_div = { .reg = S5P_CLKDIV_PERIL2, .shift = 0, .size = 4 },
	}, {
		.clk		= {
			.name		= "sclk_fimg2d",
		},
		.sources = &clkset_mout_g2d,
		.reg_src = { .reg = S5P_CLKSRC_IMAGE, .shift = 8, .size = 1 },
		.reg_div = { .reg = S5P_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1185 1186 1187 1188 1189 1190 1191 1192
	}, {
		.clk		= {
			.name		= "sclk_mfc",
			.devname	= "s5p-mfc",
		},
		.sources = &clkset_mout_mfc,
		.reg_src = { .reg = S5P_CLKSRC_MFC, .shift = 8, .size = 1 },
		.reg_div = { .reg = S5P_CLKDIV_MFC, .shift = 0, .size = 4 },
1193 1194 1195
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1196
			.devname	= "s3c-sdhci.0",
1197
			.parent		= &clk_dout_mmc0.clk,
K
Kukjin Kim 已提交
1198
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1199 1200 1201 1202 1203 1204
			.ctrlbit	= (1 << 0),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 8, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1205
			.devname	= "s3c-sdhci.1",
1206
			.parent         = &clk_dout_mmc1.clk,
K
Kukjin Kim 已提交
1207
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1208 1209 1210 1211 1212 1213
			.ctrlbit	= (1 << 4),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 24, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1214
			.devname	= "s3c-sdhci.2",
1215
			.parent         = &clk_dout_mmc2.clk,
K
Kukjin Kim 已提交
1216
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1217 1218 1219 1220 1221 1222
			.ctrlbit	= (1 << 8),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 8, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1223
			.devname	= "s3c-sdhci.3",
1224
			.parent         = &clk_dout_mmc3.clk,
K
Kukjin Kim 已提交
1225
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1226 1227 1228 1229 1230
			.ctrlbit	= (1 << 12),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 24, .size = 8 },
	}, {
		.clk		= {
1231
			.name		= "sclk_dwmmc",
1232
			.parent         = &clk_dout_mmc4.clk,
K
Kukjin Kim 已提交
1233
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1234 1235 1236 1237
			.ctrlbit	= (1 << 16),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
	}
1238 1239 1240 1241 1242
};

/* Clock initialization code */
static struct clksrc_clk *sysclks[] = {
	&clk_mout_apll,
1243
	&clk_sclk_apll,
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264
	&clk_mout_epll,
	&clk_mout_mpll,
	&clk_moutcore,
	&clk_coreclk,
	&clk_armclk,
	&clk_aclk_corem0,
	&clk_aclk_cores,
	&clk_aclk_corem1,
	&clk_periphclk,
	&clk_mout_corebus,
	&clk_sclk_dmc,
	&clk_aclk_cored,
	&clk_aclk_corep,
	&clk_aclk_acp,
	&clk_pclk_acp,
	&clk_vpllsrc,
	&clk_sclk_vpll,
	&clk_aclk_200,
	&clk_aclk_100,
	&clk_aclk_160,
	&clk_aclk_133,
1265 1266 1267 1268 1269
	&clk_dout_mmc0,
	&clk_dout_mmc1,
	&clk_dout_mmc2,
	&clk_dout_mmc3,
	&clk_dout_mmc4,
1270 1271
	&clk_mout_mfc0,
	&clk_mout_mfc1,
1272 1273
};

1274 1275
static int xtal_rate;

K
Kukjin Kim 已提交
1276
static unsigned long exynos4_fout_apll_get_rate(struct clk *clk)
1277
{
1278 1279 1280
	if (soc_is_exynos4210())
		return s5p_get_pll45xx(xtal_rate, __raw_readl(S5P_APLL_CON0),
					pll_4508);
1281
	else if (soc_is_exynos4212() || soc_is_exynos4412())
1282 1283 1284
		return s5p_get_pll35xx(xtal_rate, __raw_readl(S5P_APLL_CON0));
	else
		return 0;
1285 1286
}

K
Kukjin Kim 已提交
1287 1288
static struct clk_ops exynos4_fout_apll_ops = {
	.get_rate = exynos4_fout_apll_get_rate,
1289 1290
};

1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
static u32 vpll_div[][8] = {
	{  54000000, 3, 53, 3, 1024, 0, 17, 0 },
	{ 108000000, 3, 53, 2, 1024, 0, 17, 0 },
};

static unsigned long exynos4_vpll_get_rate(struct clk *clk)
{
	return clk->rate;
}

static int exynos4_vpll_set_rate(struct clk *clk, unsigned long rate)
{
	unsigned int vpll_con0, vpll_con1 = 0;
	unsigned int i;

	/* Return if nothing changed */
	if (clk->rate == rate)
		return 0;

	vpll_con0 = __raw_readl(S5P_VPLL_CON0);
	vpll_con0 &= ~(0x1 << 27 |					\
			PLL90XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |	\
			PLL90XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |	\
			PLL90XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);

	vpll_con1 = __raw_readl(S5P_VPLL_CON1);
	vpll_con1 &= ~(PLL46XX_MRR_MASK << PLL46XX_MRR_SHIFT |	\
			PLL46XX_MFR_MASK << PLL46XX_MFR_SHIFT |	\
			PLL4650C_KDIV_MASK << PLL46XX_KDIV_SHIFT);

	for (i = 0; i < ARRAY_SIZE(vpll_div); i++) {
		if (vpll_div[i][0] == rate) {
			vpll_con0 |= vpll_div[i][1] << PLL46XX_PDIV_SHIFT;
			vpll_con0 |= vpll_div[i][2] << PLL46XX_MDIV_SHIFT;
			vpll_con0 |= vpll_div[i][3] << PLL46XX_SDIV_SHIFT;
			vpll_con1 |= vpll_div[i][4] << PLL46XX_KDIV_SHIFT;
			vpll_con1 |= vpll_div[i][5] << PLL46XX_MFR_SHIFT;
			vpll_con1 |= vpll_div[i][6] << PLL46XX_MRR_SHIFT;
			vpll_con0 |= vpll_div[i][7] << 27;
			break;
		}
	}

	if (i == ARRAY_SIZE(vpll_div)) {
		printk(KERN_ERR "%s: Invalid Clock VPLL Frequency\n",
				__func__);
		return -EINVAL;
	}

	__raw_writel(vpll_con0, S5P_VPLL_CON0);
	__raw_writel(vpll_con1, S5P_VPLL_CON1);

	/* Wait for VPLL lock */
	while (!(__raw_readl(S5P_VPLL_CON0) & (1 << PLL46XX_LOCKED_SHIFT)))
		continue;

	clk->rate = rate;
	return 0;
}

static struct clk_ops exynos4_vpll_ops = {
	.get_rate = exynos4_vpll_get_rate,
	.set_rate = exynos4_vpll_set_rate,
};

K
Kukjin Kim 已提交
1356
void __init_or_cpufreq exynos4_setup_clocks(void)
1357 1358
{
	struct clk *xtal_clk;
1359 1360 1361 1362
	unsigned long apll = 0;
	unsigned long mpll = 0;
	unsigned long epll = 0;
	unsigned long vpll = 0;
1363 1364 1365 1366
	unsigned long vpllsrc;
	unsigned long xtal;
	unsigned long armclk;
	unsigned long sclk_dmc;
1367 1368 1369 1370
	unsigned long aclk_200;
	unsigned long aclk_100;
	unsigned long aclk_160;
	unsigned long aclk_133;
1371 1372 1373 1374 1375 1376 1377 1378
	unsigned int ptr;

	printk(KERN_DEBUG "%s: registering clocks\n", __func__);

	xtal_clk = clk_get(NULL, "xtal");
	BUG_ON(IS_ERR(xtal_clk));

	xtal = clk_get_rate(xtal_clk);
1379 1380 1381

	xtal_rate = xtal;

1382 1383 1384 1385
	clk_put(xtal_clk);

	printk(KERN_DEBUG "%s: xtal is %ld\n", __func__, xtal);

1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
	if (soc_is_exynos4210()) {
		apll = s5p_get_pll45xx(xtal, __raw_readl(S5P_APLL_CON0),
					pll_4508);
		mpll = s5p_get_pll45xx(xtal, __raw_readl(S5P_MPLL_CON0),
					pll_4508);
		epll = s5p_get_pll46xx(xtal, __raw_readl(S5P_EPLL_CON0),
					__raw_readl(S5P_EPLL_CON1), pll_4600);

		vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
		vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(S5P_VPLL_CON0),
					__raw_readl(S5P_VPLL_CON1), pll_4650c);
1397
	} else if (soc_is_exynos4212() || soc_is_exynos4412()) {
1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408
		apll = s5p_get_pll35xx(xtal, __raw_readl(S5P_APLL_CON0));
		mpll = s5p_get_pll35xx(xtal, __raw_readl(S5P_MPLL_CON0));
		epll = s5p_get_pll36xx(xtal, __raw_readl(S5P_EPLL_CON0),
					__raw_readl(S5P_EPLL_CON1));

		vpllsrc = clk_get_rate(&clk_vpllsrc.clk);
		vpll = s5p_get_pll36xx(vpllsrc, __raw_readl(S5P_VPLL_CON0),
					__raw_readl(S5P_VPLL_CON1));
	} else {
		/* nothing */
	}
1409

K
Kukjin Kim 已提交
1410
	clk_fout_apll.ops = &exynos4_fout_apll_ops;
1411 1412
	clk_fout_mpll.rate = mpll;
	clk_fout_epll.rate = epll;
1413
	clk_fout_vpll.ops = &exynos4_vpll_ops;
1414 1415
	clk_fout_vpll.rate = vpll;

K
Kukjin Kim 已提交
1416
	printk(KERN_INFO "EXYNOS4: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1417 1418 1419 1420
			apll, mpll, epll, vpll);

	armclk = clk_get_rate(&clk_armclk.clk);
	sclk_dmc = clk_get_rate(&clk_sclk_dmc.clk);
K
Kukjin Kim 已提交
1421

1422 1423 1424 1425 1426
	aclk_200 = clk_get_rate(&clk_aclk_200.clk);
	aclk_100 = clk_get_rate(&clk_aclk_100.clk);
	aclk_160 = clk_get_rate(&clk_aclk_160.clk);
	aclk_133 = clk_get_rate(&clk_aclk_133.clk);

K
Kukjin Kim 已提交
1427
	printk(KERN_INFO "EXYNOS4: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1428 1429 1430
			 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
			armclk, sclk_dmc, aclk_200,
			aclk_100, aclk_160, aclk_133);
1431 1432 1433

	clk_f.rate = armclk;
	clk_h.rate = sclk_dmc;
1434
	clk_p.rate = aclk_100;
1435 1436 1437 1438 1439 1440

	for (ptr = 0; ptr < ARRAY_SIZE(clksrcs); ptr++)
		s3c_set_clksrc(&clksrcs[ptr], true);
}

static struct clk *clks[] __initdata = {
1441 1442 1443 1444
	&clk_sclk_hdmi27m,
	&clk_sclk_hdmiphy,
	&clk_sclk_usbphy0,
	&clk_sclk_usbphy1,
1445 1446
};

1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468
#ifdef CONFIG_PM_SLEEP
static int exynos4_clock_suspend(void)
{
	s3c_pm_do_save(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
	return 0;
}

static void exynos4_clock_resume(void)
{
	s3c_pm_do_restore_core(exynos4_clock_save, ARRAY_SIZE(exynos4_clock_save));
}

#else
#define exynos4_clock_suspend NULL
#define exynos4_clock_resume NULL
#endif

struct syscore_ops exynos4_clock_syscore_ops = {
	.suspend	= exynos4_clock_suspend,
	.resume		= exynos4_clock_resume,
};

K
Kukjin Kim 已提交
1469
void __init exynos4_register_clocks(void)
1470 1471 1472
{
	int ptr;

1473
	s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
1474 1475 1476 1477

	for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
		s3c_register_clksrc(sysclks[ptr], 1);

1478 1479 1480
	for (ptr = 0; ptr < ARRAY_SIZE(sclk_tv); ptr++)
		s3c_register_clksrc(sclk_tv[ptr], 1);

1481 1482 1483
	s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
	s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));

1484 1485
	s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
	s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
1486

1487
	register_syscore_ops(&exynos4_clock_syscore_ops);
1488 1489
	s3c24xx_register_clock(&dummy_apb_pclk);

1490 1491
	s3c_pwmclk_init();
}