clock.c 31.5 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",
};

K
Kukjin Kim 已提交
114
static int exynos4_clksrc_mask_top_ctrl(struct clk *clk, int enable)
115 116 117 118
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_TOP, clk, enable);
}

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

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

129
int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
130 131 132 133
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_FSYS, clk, enable);
}

K
Kukjin Kim 已提交
134
static int exynos4_clksrc_mask_peril0_ctrl(struct clk *clk, int enable)
135 136 137 138
{
	return s5p_gatectrl(S5P_CLKSRC_MASK_PERIL0, clk, enable);
}

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

144 145 146 147 148
static int exynos4_clk_ip_mfc_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(S5P_CLKGATE_IP_MFC, clk, enable);
}

K
Kukjin Kim 已提交
149
static int exynos4_clk_ip_cam_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
150 151 152 153
{
	return s5p_gatectrl(S5P_CLKGATE_IP_CAM, clk, enable);
}

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

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

K
Kukjin Kim 已提交
164
static int exynos4_clk_ip_lcd0_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
165 166 167 168
{
	return s5p_gatectrl(S5P_CLKGATE_IP_LCD0, clk, enable);
}

169
int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
170 171 172 173
{
	return s5p_gatectrl(S5P_CLKGATE_IP_LCD1, clk, enable);
}

174
int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable)
175 176 177 178
{
	return s5p_gatectrl(S5P_CLKGATE_IP_FSYS, clk, enable);
}

K
Kukjin Kim 已提交
179
static int exynos4_clk_ip_peril_ctrl(struct clk *clk, int enable)
180 181 182 183
{
	return s5p_gatectrl(S5P_CLKGATE_IP_PERIL, clk, enable);
}

K
Kukjin Kim 已提交
184
static int exynos4_clk_ip_perir_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
185 186 187 188
{
	return s5p_gatectrl(S5P_CLKGATE_IP_PERIR, clk, enable);
}

189 190 191 192 193 194 195 196
/* 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 },
197 198
};

199
struct clksrc_clk clk_sclk_apll = {
200 201 202 203
	.clk	= {
		.name		= "sclk_apll",
		.parent		= &clk_mout_apll.clk,
	},
204 205 206
	.reg_div	= { .reg = S5P_CLKDIV_CPU, .shift = 24, .size = 3 },
};

207
struct clksrc_clk clk_mout_epll = {
208 209 210 211 212 213 214
	.clk	= {
		.name		= "mout_epll",
	},
	.sources	= &clk_src_epll,
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 4, .size = 1 },
};

215
struct clksrc_clk clk_mout_mpll = {
216 217 218 219
	.clk = {
		.name		= "mout_mpll",
	},
	.sources	= &clk_src_mpll,
220 221

	/* reg_src will be added in each SoCs' clock */
222 223 224
};

static struct clk *clkset_moutcore_list[] = {
225
	[0] = &clk_mout_apll.clk,
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 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
	[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 */

291
struct clk *clkset_corebus_list[] = {
292
	[0] = &clk_mout_mpll.clk,
293
	[1] = &clk_sclk_apll.clk,
294 295
};

296
struct clksrc_sources clkset_mout_corebus = {
297 298 299 300 301 302 303 304 305
	.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,
306
	.reg_src	= { .reg = S5P_CLKSRC_DMC, .shift = 4, .size = 1 },
307 308 309 310 311 312 313
};

static struct clksrc_clk clk_sclk_dmc = {
	.clk	= {
		.name		= "sclk_dmc",
		.parent		= &clk_mout_corebus.clk,
	},
314
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 12, .size = 3 },
315 316 317 318 319 320 321
};

static struct clksrc_clk clk_aclk_cored = {
	.clk	= {
		.name		= "aclk_cored",
		.parent		= &clk_sclk_dmc.clk,
	},
322
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 16, .size = 3 },
323 324 325 326 327 328 329
};

static struct clksrc_clk clk_aclk_corep = {
	.clk	= {
		.name		= "aclk_corep",
		.parent		= &clk_aclk_cored.clk,
	},
330
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 20, .size = 3 },
331 332 333 334 335 336 337
};

static struct clksrc_clk clk_aclk_acp = {
	.clk	= {
		.name		= "aclk_acp",
		.parent		= &clk_mout_corebus.clk,
	},
338
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 0, .size = 3 },
339 340 341 342 343 344 345
};

static struct clksrc_clk clk_pclk_acp = {
	.clk	= {
		.name		= "pclk_acp",
		.parent		= &clk_aclk_acp.clk,
	},
346
	.reg_div	= { .reg = S5P_CLKDIV_DMC0, .shift = 4, .size = 3 },
347 348 349 350
};

/* Core list of CMU_TOP side */

351
struct clk *clkset_aclk_top_list[] = {
352
	[0] = &clk_mout_mpll.clk,
353
	[1] = &clk_sclk_apll.clk,
354 355
};

356
struct clksrc_sources clkset_aclk = {
357 358 359 360 361 362 363 364
	.sources	= clkset_aclk_top_list,
	.nr_sources	= ARRAY_SIZE(clkset_aclk_top_list),
};

static struct clksrc_clk clk_aclk_200 = {
	.clk	= {
		.name		= "aclk_200",
	},
365
	.sources	= &clkset_aclk,
366 367 368 369 370 371 372 373
	.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",
	},
374
	.sources	= &clkset_aclk,
375 376 377 378 379 380 381 382
	.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",
	},
383
	.sources	= &clkset_aclk,
384 385 386 387
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 20, .size = 1 },
	.reg_div	= { .reg = S5P_CLKDIV_TOP, .shift = 8, .size = 3 },
};

388
struct clksrc_clk clk_aclk_133 = {
389 390 391
	.clk	= {
		.name		= "aclk_133",
	},
392
	.sources	= &clkset_aclk,
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
	.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 已提交
410
		.enable		= exynos4_clksrc_mask_top_ctrl,
411
		.ctrlbit	= (1 << 0),
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426
	},
	.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),
};

427
struct clksrc_clk clk_sclk_vpll = {
428 429 430 431 432 433 434
	.clk	= {
		.name		= "sclk_vpll",
	},
	.sources	= &clkset_sclk_vpll,
	.reg_src	= { .reg = S5P_CLKSRC_TOP0, .shift = 8, .size = 1 },
};

435
static struct clk init_clocks_off[] = {
436 437 438
	{
		.name		= "timers",
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
439
		.enable		= exynos4_clk_ip_peril_ctrl,
440
		.ctrlbit	= (1<<24),
J
Jongpill Lee 已提交
441 442
	}, {
		.name		= "csis",
443
		.devname	= "s5p-mipi-csis.0",
K
Kukjin Kim 已提交
444
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
445 446 447
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "csis",
448
		.devname	= "s5p-mipi-csis.1",
K
Kukjin Kim 已提交
449
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
450 451 452
		.ctrlbit	= (1 << 5),
	}, {
		.name		= "fimc",
453
		.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
454
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
455 456 457
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "fimc",
458
		.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
459
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
460 461 462
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "fimc",
463
		.devname	= "exynos4-fimc.2",
K
Kukjin Kim 已提交
464
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
465 466 467
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "fimc",
468
		.devname	= "exynos4-fimc.3",
K
Kukjin Kim 已提交
469
		.enable		= exynos4_clk_ip_cam_ctrl,
J
Jongpill Lee 已提交
470 471 472
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "fimd",
473
		.devname	= "exynos4-fb.0",
K
Kukjin Kim 已提交
474
		.enable		= exynos4_clk_ip_lcd0_ctrl,
J
Jongpill Lee 已提交
475
		.ctrlbit	= (1 << 0),
476 477
	}, {
		.name		= "hsmmc",
478
		.devname	= "s3c-sdhci.0",
479
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
480
		.enable		= exynos4_clk_ip_fsys_ctrl,
481 482 483
		.ctrlbit	= (1 << 5),
	}, {
		.name		= "hsmmc",
484
		.devname	= "s3c-sdhci.1",
485
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
486
		.enable		= exynos4_clk_ip_fsys_ctrl,
487 488 489
		.ctrlbit	= (1 << 6),
	}, {
		.name		= "hsmmc",
490
		.devname	= "s3c-sdhci.2",
491
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
492
		.enable		= exynos4_clk_ip_fsys_ctrl,
493 494 495
		.ctrlbit	= (1 << 7),
	}, {
		.name		= "hsmmc",
496
		.devname	= "s3c-sdhci.3",
497
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
498
		.enable		= exynos4_clk_ip_fsys_ctrl,
499 500
		.ctrlbit	= (1 << 8),
	}, {
501
		.name		= "dwmmc",
502
		.parent		= &clk_aclk_133.clk,
K
Kukjin Kim 已提交
503
		.enable		= exynos4_clk_ip_fsys_ctrl,
504
		.ctrlbit	= (1 << 9),
J
Jassi Brar 已提交
505 506
	}, {
		.name		= "pdma",
507
		.devname	= "s3c-pl330.0",
K
Kukjin Kim 已提交
508
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jassi Brar 已提交
509 510 511
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "pdma",
512
		.devname	= "s3c-pl330.1",
K
Kukjin Kim 已提交
513
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jassi Brar 已提交
514
		.ctrlbit	= (1 << 1),
J
Jongpill Lee 已提交
515 516
	}, {
		.name		= "adc",
K
Kukjin Kim 已提交
517
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
518
		.ctrlbit	= (1 << 15),
519 520 521 522
	}, {
		.name		= "keypad",
		.enable		= exynos4_clk_ip_perir_ctrl,
		.ctrlbit	= (1 << 16),
C
Changhwan Youn 已提交
523 524
	}, {
		.name		= "rtc",
K
Kukjin Kim 已提交
525
		.enable		= exynos4_clk_ip_perir_ctrl,
C
Changhwan Youn 已提交
526
		.ctrlbit	= (1 << 15),
J
Jongpill Lee 已提交
527 528
	}, {
		.name		= "watchdog",
529
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
530
		.enable		= exynos4_clk_ip_perir_ctrl,
J
Jongpill Lee 已提交
531 532 533
		.ctrlbit	= (1 << 14),
	}, {
		.name		= "usbhost",
K
Kukjin Kim 已提交
534
		.enable		= exynos4_clk_ip_fsys_ctrl ,
J
Jongpill Lee 已提交
535 536 537
		.ctrlbit	= (1 << 12),
	}, {
		.name		= "otg",
K
Kukjin Kim 已提交
538
		.enable		= exynos4_clk_ip_fsys_ctrl,
J
Jongpill Lee 已提交
539 540 541
		.ctrlbit	= (1 << 13),
	}, {
		.name		= "spi",
542
		.devname	= "s3c64xx-spi.0",
K
Kukjin Kim 已提交
543
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
544 545 546
		.ctrlbit	= (1 << 16),
	}, {
		.name		= "spi",
547
		.devname	= "s3c64xx-spi.1",
K
Kukjin Kim 已提交
548
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
549 550 551
		.ctrlbit	= (1 << 17),
	}, {
		.name		= "spi",
552
		.devname	= "s3c64xx-spi.2",
K
Kukjin Kim 已提交
553
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
554
		.ctrlbit	= (1 << 18),
J
Jassi Brar 已提交
555 556
	}, {
		.name		= "iis",
557
		.devname	= "samsung-i2s.0",
K
Kukjin Kim 已提交
558
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
559 560 561
		.ctrlbit	= (1 << 19),
	}, {
		.name		= "iis",
562
		.devname	= "samsung-i2s.1",
K
Kukjin Kim 已提交
563
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
564 565 566
		.ctrlbit	= (1 << 20),
	}, {
		.name		= "iis",
567
		.devname	= "samsung-i2s.2",
K
Kukjin Kim 已提交
568
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
569
		.ctrlbit	= (1 << 21),
J
Jassi Brar 已提交
570 571
	}, {
		.name		= "ac97",
572
		.devname	= "samsung-ac97",
K
Kukjin Kim 已提交
573
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jassi Brar 已提交
574
		.ctrlbit	= (1 << 27),
J
Jongpill Lee 已提交
575 576
	}, {
		.name		= "fimg2d",
K
Kukjin Kim 已提交
577
		.enable		= exynos4_clk_ip_image_ctrl,
J
Jongpill Lee 已提交
578
		.ctrlbit	= (1 << 0),
579 580 581 582 583
	}, {
		.name		= "mfc",
		.devname	= "s5p-mfc",
		.enable		= exynos4_clk_ip_mfc_ctrl,
		.ctrlbit	= (1 << 0),
J
Jongpill Lee 已提交
584 585
	}, {
		.name		= "i2c",
586
		.devname	= "s3c2440-i2c.0",
J
Jongpill Lee 已提交
587
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
588
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
589 590 591
		.ctrlbit	= (1 << 6),
	}, {
		.name		= "i2c",
592
		.devname	= "s3c2440-i2c.1",
J
Jongpill Lee 已提交
593
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
594
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
595 596 597
		.ctrlbit	= (1 << 7),
	}, {
		.name		= "i2c",
598
		.devname	= "s3c2440-i2c.2",
J
Jongpill Lee 已提交
599
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
600
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
601 602 603
		.ctrlbit	= (1 << 8),
	}, {
		.name		= "i2c",
604
		.devname	= "s3c2440-i2c.3",
J
Jongpill Lee 已提交
605
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
606
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
607 608 609
		.ctrlbit	= (1 << 9),
	}, {
		.name		= "i2c",
610
		.devname	= "s3c2440-i2c.4",
J
Jongpill Lee 已提交
611
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
612
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
613 614 615
		.ctrlbit	= (1 << 10),
	}, {
		.name		= "i2c",
616
		.devname	= "s3c2440-i2c.5",
J
Jongpill Lee 已提交
617
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
618
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
619 620 621
		.ctrlbit	= (1 << 11),
	}, {
		.name		= "i2c",
622
		.devname	= "s3c2440-i2c.6",
J
Jongpill Lee 已提交
623
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
624
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
625 626 627
		.ctrlbit	= (1 << 12),
	}, {
		.name		= "i2c",
628
		.devname	= "s3c2440-i2c.7",
J
Jongpill Lee 已提交
629
		.parent		= &clk_aclk_100.clk,
K
Kukjin Kim 已提交
630
		.enable		= exynos4_clk_ip_peril_ctrl,
J
Jongpill Lee 已提交
631
		.ctrlbit	= (1 << 13),
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
	}, {
		.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),
	}
689 690 691
};

static struct clk init_clocks[] = {
692 693
	{
		.name		= "uart",
694
		.devname	= "s5pv210-uart.0",
K
Kukjin Kim 已提交
695
		.enable		= exynos4_clk_ip_peril_ctrl,
696 697 698
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "uart",
699
		.devname	= "s5pv210-uart.1",
K
Kukjin Kim 已提交
700
		.enable		= exynos4_clk_ip_peril_ctrl,
701 702 703
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "uart",
704
		.devname	= "s5pv210-uart.2",
K
Kukjin Kim 已提交
705
		.enable		= exynos4_clk_ip_peril_ctrl,
706 707 708
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "uart",
709
		.devname	= "s5pv210-uart.3",
K
Kukjin Kim 已提交
710
		.enable		= exynos4_clk_ip_peril_ctrl,
711 712 713
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "uart",
714
		.devname	= "s5pv210-uart.4",
K
Kukjin Kim 已提交
715
		.enable		= exynos4_clk_ip_peril_ctrl,
716 717 718
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "uart",
719
		.devname	= "s5pv210-uart.5",
K
Kukjin Kim 已提交
720
		.enable		= exynos4_clk_ip_peril_ctrl,
721 722
		.ctrlbit	= (1 << 5),
	}
723 724
};

725
struct clk *clkset_group_list[] = {
726 727 728
	[0] = &clk_ext_xtal_mux,
	[1] = &clk_xusbxti,
	[2] = &clk_sclk_hdmi27m,
729 730 731
	[3] = &clk_sclk_usbphy0,
	[4] = &clk_sclk_usbphy1,
	[5] = &clk_sclk_hdmiphy,
732 733 734 735 736
	[6] = &clk_mout_mpll.clk,
	[7] = &clk_mout_epll.clk,
	[8] = &clk_sclk_vpll.clk,
};

737
struct clksrc_sources clkset_group = {
738 739 740 741
	.sources	= clkset_group_list,
	.nr_sources	= ARRAY_SIZE(clkset_group_list),
};

J
Jongpill Lee 已提交
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
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),
};

788 789 790 791 792 793 794 795 796 797 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
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),
};

834 835 836 837 838 839 840 841 842 843 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
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 },
};

879 880 881 882
static struct clksrc_clk clksrcs[] = {
	{
		.clk	= {
			.name		= "uclk1",
883
			.devname	= "s5pv210-uart.0",
K
Kukjin Kim 已提交
884
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
885
			.ctrlbit	= (1 << 0),
886 887 888 889 890 891 892
		},
		.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",
893
			.devname	= "s5pv210-uart.1",
K
Kukjin Kim 已提交
894
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
895
			.ctrlbit	= (1 << 4),
896 897 898 899 900 901 902
		},
		.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",
903
			.devname	= "s5pv210-uart.2",
K
Kukjin Kim 已提交
904
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
905
			.ctrlbit	= (1 << 8),
906 907 908 909 910 911 912
		},
		.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",
913
			.devname	= "s5pv210-uart.3",
K
Kukjin Kim 已提交
914
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
915
			.ctrlbit	= (1 << 12),
916 917 918 919 920 921 922
		},
		.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 已提交
923
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
924 925 926 927 928
			.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 },
929 930 931
	}, {
		.clk		= {
			.name		= "sclk_csis",
932
			.devname	= "s5p-mipi-csis.0",
K
Kukjin Kim 已提交
933
			.enable		= exynos4_clksrc_mask_cam_ctrl,
934 935 936 937 938 939 940 941
			.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",
942
			.devname	= "s5p-mipi-csis.1",
K
Kukjin Kim 已提交
943
			.enable		= exynos4_clksrc_mask_cam_ctrl,
944 945 946 947 948 949 950 951
			.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		= {
			.name		= "sclk_cam",
952
			.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
953
			.enable		= exynos4_clksrc_mask_cam_ctrl,
954 955 956 957 958 959 960 961
			.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		= {
			.name		= "sclk_cam",
962
			.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
963
			.enable		= exynos4_clksrc_mask_cam_ctrl,
964 965 966 967 968 969 970 971
			.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",
972
			.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
973
			.enable		= exynos4_clksrc_mask_cam_ctrl,
974 975 976 977 978 979 980 981
			.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",
982
			.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
983
			.enable		= exynos4_clksrc_mask_cam_ctrl,
984 985 986 987 988 989 990 991
			.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",
992
			.devname	= "exynos4-fimc.2",
K
Kukjin Kim 已提交
993
			.enable		= exynos4_clksrc_mask_cam_ctrl,
994 995 996 997 998 999 1000 1001
			.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",
1002
			.devname	= "exynos4-fimc.3",
K
Kukjin Kim 已提交
1003
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1004 1005 1006 1007 1008 1009 1010 1011
			.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",
1012
			.devname	= "exynos4-fb.0",
K
Kukjin Kim 已提交
1013
			.enable		= exynos4_clksrc_mask_lcd0_ctrl,
1014 1015 1016 1017 1018 1019 1020 1021
			.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",
1022
			.devname	= "s3c64xx-spi.0",
K
Kukjin Kim 已提交
1023
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1024 1025 1026 1027 1028 1029 1030 1031
			.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",
1032
			.devname	= "s3c64xx-spi.1",
K
Kukjin Kim 已提交
1033
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1034 1035 1036 1037 1038 1039 1040 1041
			.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",
1042
			.devname	= "s3c64xx-spi.2",
K
Kukjin Kim 已提交
1043
			.enable		= exynos4_clksrc_mask_peril1_ctrl,
1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055
			.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 },
1056 1057 1058 1059 1060 1061 1062 1063
	}, {
		.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 },
1064 1065 1066
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1067
			.devname	= "s3c-sdhci.0",
1068
			.parent		= &clk_dout_mmc0.clk,
K
Kukjin Kim 已提交
1069
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1070 1071 1072 1073 1074 1075
			.ctrlbit	= (1 << 0),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 8, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1076
			.devname	= "s3c-sdhci.1",
1077
			.parent         = &clk_dout_mmc1.clk,
K
Kukjin Kim 已提交
1078
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1079 1080 1081 1082 1083 1084
			.ctrlbit	= (1 << 4),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS1, .shift = 24, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1085
			.devname	= "s3c-sdhci.2",
1086
			.parent         = &clk_dout_mmc2.clk,
K
Kukjin Kim 已提交
1087
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1088 1089 1090 1091 1092 1093
			.ctrlbit	= (1 << 8),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 8, .size = 8 },
	}, {
		.clk		= {
			.name		= "sclk_mmc",
1094
			.devname	= "s3c-sdhci.3",
1095
			.parent         = &clk_dout_mmc3.clk,
K
Kukjin Kim 已提交
1096
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1097 1098 1099 1100 1101
			.ctrlbit	= (1 << 12),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS2, .shift = 24, .size = 8 },
	}, {
		.clk		= {
1102
			.name		= "sclk_dwmmc",
1103
			.parent         = &clk_dout_mmc4.clk,
K
Kukjin Kim 已提交
1104
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1105 1106 1107 1108
			.ctrlbit	= (1 << 16),
		},
		.reg_div = { .reg = S5P_CLKDIV_FSYS3, .shift = 8, .size = 8 },
	}
1109 1110 1111 1112 1113
};

/* Clock initialization code */
static struct clksrc_clk *sysclks[] = {
	&clk_mout_apll,
1114
	&clk_sclk_apll,
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
	&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,
1136 1137 1138 1139 1140
	&clk_dout_mmc0,
	&clk_dout_mmc1,
	&clk_dout_mmc2,
	&clk_dout_mmc3,
	&clk_dout_mmc4,
1141 1142
	&clk_mout_mfc0,
	&clk_mout_mfc1,
1143 1144
};

1145 1146
static int xtal_rate;

K
Kukjin Kim 已提交
1147
static unsigned long exynos4_fout_apll_get_rate(struct clk *clk)
1148
{
1149 1150 1151 1152 1153 1154 1155
	if (soc_is_exynos4210())
		return s5p_get_pll45xx(xtal_rate, __raw_readl(S5P_APLL_CON0),
					pll_4508);
	else if (soc_is_exynos4212())
		return s5p_get_pll35xx(xtal_rate, __raw_readl(S5P_APLL_CON0));
	else
		return 0;
1156 1157
}

K
Kukjin Kim 已提交
1158 1159
static struct clk_ops exynos4_fout_apll_ops = {
	.get_rate = exynos4_fout_apll_get_rate,
1160 1161
};

K
Kukjin Kim 已提交
1162
void __init_or_cpufreq exynos4_setup_clocks(void)
1163 1164
{
	struct clk *xtal_clk;
1165 1166 1167 1168
	unsigned long apll = 0;
	unsigned long mpll = 0;
	unsigned long epll = 0;
	unsigned long vpll = 0;
1169 1170 1171 1172
	unsigned long vpllsrc;
	unsigned long xtal;
	unsigned long armclk;
	unsigned long sclk_dmc;
1173 1174 1175 1176
	unsigned long aclk_200;
	unsigned long aclk_100;
	unsigned long aclk_160;
	unsigned long aclk_133;
1177 1178 1179 1180 1181 1182 1183 1184
	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);
1185 1186 1187

	xtal_rate = xtal;

1188 1189 1190 1191
	clk_put(xtal_clk);

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

1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214
	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);
	} else if (soc_is_exynos4212()) {
		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 */
	}
1215

K
Kukjin Kim 已提交
1216
	clk_fout_apll.ops = &exynos4_fout_apll_ops;
1217 1218 1219 1220
	clk_fout_mpll.rate = mpll;
	clk_fout_epll.rate = epll;
	clk_fout_vpll.rate = vpll;

K
Kukjin Kim 已提交
1221
	printk(KERN_INFO "EXYNOS4: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1222 1223 1224 1225
			apll, mpll, epll, vpll);

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

1227 1228 1229 1230 1231
	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 已提交
1232
	printk(KERN_INFO "EXYNOS4: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1233 1234 1235
			 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
			armclk, sclk_dmc, aclk_200,
			aclk_100, aclk_160, aclk_133);
1236 1237 1238

	clk_f.rate = armclk;
	clk_h.rate = sclk_dmc;
1239
	clk_p.rate = aclk_100;
1240 1241 1242 1243 1244 1245 1246 1247 1248

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

static struct clk *clks[] __initdata = {
	/* Nothing here yet */
};

1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
#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 已提交
1271
void __init exynos4_register_clocks(void)
1272 1273 1274
{
	int ptr;

1275
	s3c24xx_register_clocks(clks, ARRAY_SIZE(clks));
1276 1277 1278 1279 1280 1281 1282

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

	s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));
	s3c_register_clocks(init_clocks, ARRAY_SIZE(init_clocks));

1283 1284
	s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
	s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
1285

1286
	register_syscore_ops(&exynos4_clock_syscore_ops);
1287 1288
	s3c_pwmclk_init();
}