clock-exynos4.c 42.4 KB
Newer Older
1
/*
2
 * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
K
Kukjin Kim 已提交
3
 *		http://www.samsung.com
4
 *
K
Kukjin Kim 已提交
5
 * EXYNOS4 - Clock support
6 7 8 9 10 11 12 13 14
 *
 * 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>
15
#include <linux/syscore_ops.h>
16 17 18 19 20 21 22

#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>
23
#include <plat/pm.h>
24 25 26

#include <mach/map.h>
#include <mach/regs-clock.h>
27
#include <mach/sysmmu.h>
28

29
#include "common.h"
30
#include "clock-exynos4.h"
31

32
#ifdef CONFIG_PM_SLEEP
33
static struct sleep_save exynos4_clock_save[] = {
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
	SAVE_ITEM(EXYNOS4_CLKDIV_LEFTBUS),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_LEFTBUS),
	SAVE_ITEM(EXYNOS4_CLKDIV_RIGHTBUS),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_RIGHTBUS),
	SAVE_ITEM(EXYNOS4_CLKSRC_TOP0),
	SAVE_ITEM(EXYNOS4_CLKSRC_TOP1),
	SAVE_ITEM(EXYNOS4_CLKSRC_CAM),
	SAVE_ITEM(EXYNOS4_CLKSRC_TV),
	SAVE_ITEM(EXYNOS4_CLKSRC_MFC),
	SAVE_ITEM(EXYNOS4_CLKSRC_G3D),
	SAVE_ITEM(EXYNOS4_CLKSRC_LCD0),
	SAVE_ITEM(EXYNOS4_CLKSRC_MAUDIO),
	SAVE_ITEM(EXYNOS4_CLKSRC_FSYS),
	SAVE_ITEM(EXYNOS4_CLKSRC_PERIL0),
	SAVE_ITEM(EXYNOS4_CLKSRC_PERIL1),
	SAVE_ITEM(EXYNOS4_CLKDIV_CAM),
	SAVE_ITEM(EXYNOS4_CLKDIV_TV),
	SAVE_ITEM(EXYNOS4_CLKDIV_MFC),
	SAVE_ITEM(EXYNOS4_CLKDIV_G3D),
	SAVE_ITEM(EXYNOS4_CLKDIV_LCD0),
	SAVE_ITEM(EXYNOS4_CLKDIV_MAUDIO),
	SAVE_ITEM(EXYNOS4_CLKDIV_FSYS0),
	SAVE_ITEM(EXYNOS4_CLKDIV_FSYS1),
	SAVE_ITEM(EXYNOS4_CLKDIV_FSYS2),
	SAVE_ITEM(EXYNOS4_CLKDIV_FSYS3),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL0),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL1),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL2),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL3),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL4),
	SAVE_ITEM(EXYNOS4_CLKDIV_PERIL5),
	SAVE_ITEM(EXYNOS4_CLKDIV_TOP),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_TOP),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_CAM),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_TV),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_LCD0),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_MAUDIO),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_FSYS),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_PERIL0),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_PERIL1),
	SAVE_ITEM(EXYNOS4_CLKDIV2_RATIO),
	SAVE_ITEM(EXYNOS4_CLKGATE_SCLKCAM),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_CAM),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_TV),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_MFC),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_G3D),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_LCD0),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_FSYS),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_GPS),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_PERIL),
	SAVE_ITEM(EXYNOS4_CLKGATE_BLOCK),
	SAVE_ITEM(EXYNOS4_CLKSRC_MASK_DMC),
	SAVE_ITEM(EXYNOS4_CLKSRC_DMC),
	SAVE_ITEM(EXYNOS4_CLKDIV_DMC0),
	SAVE_ITEM(EXYNOS4_CLKDIV_DMC1),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_DMC),
	SAVE_ITEM(EXYNOS4_CLKSRC_CPU),
	SAVE_ITEM(EXYNOS4_CLKDIV_CPU),
	SAVE_ITEM(EXYNOS4_CLKDIV_CPU + 0x4),
	SAVE_ITEM(EXYNOS4_CLKGATE_SCLKCPU),
	SAVE_ITEM(EXYNOS4_CLKGATE_IP_CPU),
95
};
96
#endif
97

98
static struct clk exynos4_clk_sclk_hdmi27m = {
99 100 101 102
	.name		= "sclk_hdmi27m",
	.rate		= 27000000,
};

103
static struct clk exynos4_clk_sclk_hdmiphy = {
104 105 106
	.name		= "sclk_hdmiphy",
};

107
static struct clk exynos4_clk_sclk_usbphy0 = {
108 109 110 111
	.name		= "sclk_usbphy0",
	.rate		= 27000000,
};

112
static struct clk exynos4_clk_sclk_usbphy1 = {
113 114 115
	.name		= "sclk_usbphy1",
};

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

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

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

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

136
int exynos4_clksrc_mask_fsys_ctrl(struct clk *clk, int enable)
137
{
138
	return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_FSYS, clk, enable);
139 140
}

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

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

151 152
static int exynos4_clk_ip_mfc_ctrl(struct clk *clk, int enable)
{
153
	return s5p_gatectrl(EXYNOS4_CLKGATE_IP_MFC, clk, enable);
154 155
}

156 157
static int exynos4_clksrc_mask_tv_ctrl(struct clk *clk, int enable)
{
158
	return s5p_gatectrl(EXYNOS4_CLKSRC_MASK_TV, clk, enable);
159 160
}

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

166 167
static int exynos4_clk_ip_tv_ctrl(struct clk *clk, int enable)
{
168
	return s5p_gatectrl(EXYNOS4_CLKGATE_IP_TV, clk, enable);
169 170
}

171
int exynos4_clk_ip_image_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
172
{
173
	return s5p_gatectrl(EXYNOS4_CLKGATE_IP_IMAGE, clk, enable);
J
Jongpill Lee 已提交
174 175
}

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

181
int exynos4_clk_ip_lcd1_ctrl(struct clk *clk, int enable)
J
Jongpill Lee 已提交
182
{
183
	return s5p_gatectrl(EXYNOS4210_CLKGATE_IP_LCD1, clk, enable);
J
Jongpill Lee 已提交
184 185
}

186
int exynos4_clk_ip_fsys_ctrl(struct clk *clk, int enable)
187
{
188
	return s5p_gatectrl(EXYNOS4_CLKGATE_IP_FSYS, clk, enable);
189 190
}

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

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

201 202 203 204 205
int exynos4_clk_ip_dmc_ctrl(struct clk *clk, int enable)
{
	return s5p_gatectrl(EXYNOS4_CLKGATE_IP_DMC, clk, enable);
}

206 207 208 209 210 211 212 213 214 215
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);
}

216 217
/* Core list of CMU_CPU side */

218
static struct clksrc_clk exynos4_clk_mout_apll = {
219 220 221
	.clk	= {
		.name		= "mout_apll",
	},
222
	.sources = &clk_src_apll,
223
	.reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 0, .size = 1 },
224 225
};

226
static struct clksrc_clk exynos4_clk_sclk_apll = {
227 228
	.clk	= {
		.name		= "sclk_apll",
229
		.parent		= &exynos4_clk_mout_apll.clk,
230
	},
231
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 24, .size = 3 },
232 233
};

234
static struct clksrc_clk exynos4_clk_mout_epll = {
235 236 237
	.clk	= {
		.name		= "mout_epll",
	},
238
	.sources = &clk_src_epll,
239
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 4, .size = 1 },
240 241
};

242
struct clksrc_clk exynos4_clk_mout_mpll = {
243
	.clk	= {
244 245
		.name		= "mout_mpll",
	},
246
	.sources = &clk_src_mpll,
247 248

	/* reg_src will be added in each SoCs' clock */
249 250
};

251 252 253
static struct clk *exynos4_clkset_moutcore_list[] = {
	[0] = &exynos4_clk_mout_apll.clk,
	[1] = &exynos4_clk_mout_mpll.clk,
254 255
};

256 257 258
static struct clksrc_sources exynos4_clkset_moutcore = {
	.sources	= exynos4_clkset_moutcore_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_moutcore_list),
259 260
};

261
static struct clksrc_clk exynos4_clk_moutcore = {
262 263 264
	.clk	= {
		.name		= "moutcore",
	},
265 266
	.sources = &exynos4_clkset_moutcore,
	.reg_src = { .reg = EXYNOS4_CLKSRC_CPU, .shift = 16, .size = 1 },
267 268
};

269
static struct clksrc_clk exynos4_clk_coreclk = {
270 271
	.clk	= {
		.name		= "core_clk",
272
		.parent		= &exynos4_clk_moutcore.clk,
273
	},
274
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 0, .size = 3 },
275 276
};

277
static struct clksrc_clk exynos4_clk_armclk = {
278 279
	.clk	= {
		.name		= "armclk",
280
		.parent		= &exynos4_clk_coreclk.clk,
281 282 283
	},
};

284
static struct clksrc_clk exynos4_clk_aclk_corem0 = {
285 286
	.clk	= {
		.name		= "aclk_corem0",
287
		.parent		= &exynos4_clk_coreclk.clk,
288
	},
289
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 4, .size = 3 },
290 291
};

292
static struct clksrc_clk exynos4_clk_aclk_cores = {
293 294
	.clk	= {
		.name		= "aclk_cores",
295
		.parent		= &exynos4_clk_coreclk.clk,
296
	},
297
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 4, .size = 3 },
298 299
};

300
static struct clksrc_clk exynos4_clk_aclk_corem1 = {
301 302
	.clk	= {
		.name		= "aclk_corem1",
303
		.parent		= &exynos4_clk_coreclk.clk,
304
	},
305
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 8, .size = 3 },
306 307
};

308
static struct clksrc_clk exynos4_clk_periphclk = {
309 310
	.clk	= {
		.name		= "periphclk",
311
		.parent		= &exynos4_clk_coreclk.clk,
312
	},
313
	.reg_div = { .reg = EXYNOS4_CLKDIV_CPU, .shift = 12, .size = 3 },
314 315 316 317
};

/* Core list of CMU_CORE side */

318 319 320
static struct clk *exynos4_clkset_corebus_list[] = {
	[0] = &exynos4_clk_mout_mpll.clk,
	[1] = &exynos4_clk_sclk_apll.clk,
321 322
};

323 324 325
struct clksrc_sources exynos4_clkset_mout_corebus = {
	.sources	= exynos4_clkset_corebus_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_corebus_list),
326 327
};

328
static struct clksrc_clk exynos4_clk_mout_corebus = {
329 330 331
	.clk	= {
		.name		= "mout_corebus",
	},
332 333
	.sources = &exynos4_clkset_mout_corebus,
	.reg_src = { .reg = EXYNOS4_CLKSRC_DMC, .shift = 4, .size = 1 },
334 335
};

336
static struct clksrc_clk exynos4_clk_sclk_dmc = {
337 338
	.clk	= {
		.name		= "sclk_dmc",
339
		.parent		= &exynos4_clk_mout_corebus.clk,
340
	},
341
	.reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 12, .size = 3 },
342 343
};

344
static struct clksrc_clk exynos4_clk_aclk_cored = {
345 346
	.clk	= {
		.name		= "aclk_cored",
347
		.parent		= &exynos4_clk_sclk_dmc.clk,
348
	},
349
	.reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 16, .size = 3 },
350 351
};

352
static struct clksrc_clk exynos4_clk_aclk_corep = {
353 354
	.clk	= {
		.name		= "aclk_corep",
355
		.parent		= &exynos4_clk_aclk_cored.clk,
356
	},
357
	.reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 20, .size = 3 },
358 359
};

360
static struct clksrc_clk exynos4_clk_aclk_acp = {
361 362
	.clk	= {
		.name		= "aclk_acp",
363
		.parent		= &exynos4_clk_mout_corebus.clk,
364
	},
365
	.reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 0, .size = 3 },
366 367
};

368
static struct clksrc_clk exynos4_clk_pclk_acp = {
369 370
	.clk	= {
		.name		= "pclk_acp",
371
		.parent		= &exynos4_clk_aclk_acp.clk,
372
	},
373
	.reg_div = { .reg = EXYNOS4_CLKDIV_DMC0, .shift = 4, .size = 3 },
374 375 376 377
};

/* Core list of CMU_TOP side */

378 379 380
struct clk *exynos4_clkset_aclk_top_list[] = {
	[0] = &exynos4_clk_mout_mpll.clk,
	[1] = &exynos4_clk_sclk_apll.clk,
381 382
};

383 384 385
static struct clksrc_sources exynos4_clkset_aclk = {
	.sources	= exynos4_clkset_aclk_top_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_aclk_top_list),
386 387
};

388
static struct clksrc_clk exynos4_clk_aclk_200 = {
389 390 391
	.clk	= {
		.name		= "aclk_200",
	},
392 393 394
	.sources = &exynos4_clkset_aclk,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 12, .size = 1 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 0, .size = 3 },
395 396
};

397
static struct clksrc_clk exynos4_clk_aclk_100 = {
398 399 400
	.clk	= {
		.name		= "aclk_100",
	},
401 402 403
	.sources = &exynos4_clkset_aclk,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 16, .size = 1 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 4, .size = 4 },
404 405
};

406
static struct clksrc_clk exynos4_clk_aclk_160 = {
407 408 409
	.clk	= {
		.name		= "aclk_160",
	},
410 411 412
	.sources = &exynos4_clkset_aclk,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 20, .size = 1 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 8, .size = 3 },
413 414
};

415
struct clksrc_clk exynos4_clk_aclk_133 = {
416 417 418
	.clk	= {
		.name		= "aclk_133",
	},
419 420 421
	.sources = &exynos4_clkset_aclk,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 24, .size = 1 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_TOP, .shift = 12, .size = 3 },
422 423
};

424
static struct clk *exynos4_clkset_vpllsrc_list[] = {
425
	[0] = &clk_fin_vpll,
426
	[1] = &exynos4_clk_sclk_hdmi27m,
427 428
};

429 430 431
static struct clksrc_sources exynos4_clkset_vpllsrc = {
	.sources	= exynos4_clkset_vpllsrc_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_vpllsrc_list),
432 433
};

434
static struct clksrc_clk exynos4_clk_vpllsrc = {
435 436
	.clk	= {
		.name		= "vpll_src",
K
Kukjin Kim 已提交
437
		.enable		= exynos4_clksrc_mask_top_ctrl,
438
		.ctrlbit	= (1 << 0),
439
	},
440 441
	.sources = &exynos4_clkset_vpllsrc,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP1, .shift = 0, .size = 1 },
442 443
};

444 445
static struct clk *exynos4_clkset_sclk_vpll_list[] = {
	[0] = &exynos4_clk_vpllsrc.clk,
446 447 448
	[1] = &clk_fout_vpll,
};

449 450 451
static struct clksrc_sources exynos4_clkset_sclk_vpll = {
	.sources	= exynos4_clkset_sclk_vpll_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_sclk_vpll_list),
452 453
};

454
static struct clksrc_clk exynos4_clk_sclk_vpll = {
455 456 457
	.clk	= {
		.name		= "sclk_vpll",
	},
458 459
	.sources = &exynos4_clkset_sclk_vpll,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TOP0, .shift = 8, .size = 1 },
460 461
};

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

738
static struct clk exynos4_init_clocks_on[] = {
739 740
	{
		.name		= "uart",
741
		.devname	= "s5pv210-uart.0",
K
Kukjin Kim 已提交
742
		.enable		= exynos4_clk_ip_peril_ctrl,
743 744 745
		.ctrlbit	= (1 << 0),
	}, {
		.name		= "uart",
746
		.devname	= "s5pv210-uart.1",
K
Kukjin Kim 已提交
747
		.enable		= exynos4_clk_ip_peril_ctrl,
748 749 750
		.ctrlbit	= (1 << 1),
	}, {
		.name		= "uart",
751
		.devname	= "s5pv210-uart.2",
K
Kukjin Kim 已提交
752
		.enable		= exynos4_clk_ip_peril_ctrl,
753 754 755
		.ctrlbit	= (1 << 2),
	}, {
		.name		= "uart",
756
		.devname	= "s5pv210-uart.3",
K
Kukjin Kim 已提交
757
		.enable		= exynos4_clk_ip_peril_ctrl,
758 759 760
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "uart",
761
		.devname	= "s5pv210-uart.4",
K
Kukjin Kim 已提交
762
		.enable		= exynos4_clk_ip_peril_ctrl,
763 764 765
		.ctrlbit	= (1 << 4),
	}, {
		.name		= "uart",
766
		.devname	= "s5pv210-uart.5",
K
Kukjin Kim 已提交
767
		.enable		= exynos4_clk_ip_peril_ctrl,
768 769
		.ctrlbit	= (1 << 5),
	}
770 771
};

772
static struct clk exynos4_clk_pdma0 = {
773 774 775 776 777 778
	.name		= "dma",
	.devname	= "dma-pl330.0",
	.enable		= exynos4_clk_ip_fsys_ctrl,
	.ctrlbit	= (1 << 0),
};

779
static struct clk exynos4_clk_pdma1 = {
780 781 782 783 784 785
	.name		= "dma",
	.devname	= "dma-pl330.1",
	.enable		= exynos4_clk_ip_fsys_ctrl,
	.ctrlbit	= (1 << 1),
};

B
Boojin Kim 已提交
786 787 788 789 790 791 792
static struct clk exynos4_clk_mdma1 = {
	.name		= "dma",
	.devname	= "dma-pl330.2",
	.enable		= exynos4_clk_ip_image_ctrl,
	.ctrlbit	= ((1 << 8) | (1 << 5) | (1 << 2)),
};

793 794 795 796 797 798 799
static struct clk exynos4_clk_fimd0 = {
	.name		= "fimd",
	.devname	= "exynos4-fb.0",
	.enable		= exynos4_clk_ip_lcd0_ctrl,
	.ctrlbit	= (1 << 0),
};

800
struct clk *exynos4_clkset_group_list[] = {
801 802
	[0] = &clk_ext_xtal_mux,
	[1] = &clk_xusbxti,
803 804 805 806 807 808 809
	[2] = &exynos4_clk_sclk_hdmi27m,
	[3] = &exynos4_clk_sclk_usbphy0,
	[4] = &exynos4_clk_sclk_usbphy1,
	[5] = &exynos4_clk_sclk_hdmiphy,
	[6] = &exynos4_clk_mout_mpll.clk,
	[7] = &exynos4_clk_mout_epll.clk,
	[8] = &exynos4_clk_sclk_vpll.clk,
810 811
};

812 813 814
struct clksrc_sources exynos4_clkset_group = {
	.sources	= exynos4_clkset_group_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_group_list),
815 816
};

817 818 819
static struct clk *exynos4_clkset_mout_g2d0_list[] = {
	[0] = &exynos4_clk_mout_mpll.clk,
	[1] = &exynos4_clk_sclk_apll.clk,
J
Jongpill Lee 已提交
820 821
};

822 823 824
static struct clksrc_sources exynos4_clkset_mout_g2d0 = {
	.sources	= exynos4_clkset_mout_g2d0_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_g2d0_list),
J
Jongpill Lee 已提交
825 826
};

827
static struct clksrc_clk exynos4_clk_mout_g2d0 = {
J
Jongpill Lee 已提交
828 829 830
	.clk	= {
		.name		= "mout_g2d0",
	},
831 832
	.sources = &exynos4_clkset_mout_g2d0,
	.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
J
Jongpill Lee 已提交
833 834
};

835 836 837
static struct clk *exynos4_clkset_mout_g2d1_list[] = {
	[0] = &exynos4_clk_mout_epll.clk,
	[1] = &exynos4_clk_sclk_vpll.clk,
J
Jongpill Lee 已提交
838 839
};

840 841 842
static struct clksrc_sources exynos4_clkset_mout_g2d1 = {
	.sources	= exynos4_clkset_mout_g2d1_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_g2d1_list),
J
Jongpill Lee 已提交
843 844
};

845
static struct clksrc_clk exynos4_clk_mout_g2d1 = {
J
Jongpill Lee 已提交
846 847 848
	.clk	= {
		.name		= "mout_g2d1",
	},
849 850
	.sources = &exynos4_clkset_mout_g2d1,
	.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
J
Jongpill Lee 已提交
851 852
};

853 854 855
static struct clk *exynos4_clkset_mout_g2d_list[] = {
	[0] = &exynos4_clk_mout_g2d0.clk,
	[1] = &exynos4_clk_mout_g2d1.clk,
J
Jongpill Lee 已提交
856 857
};

858 859 860
static struct clksrc_sources exynos4_clkset_mout_g2d = {
	.sources	= exynos4_clkset_mout_g2d_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_g2d_list),
J
Jongpill Lee 已提交
861 862
};

863 864 865
static struct clk *exynos4_clkset_mout_mfc0_list[] = {
	[0] = &exynos4_clk_mout_mpll.clk,
	[1] = &exynos4_clk_sclk_apll.clk,
866 867
};

868 869 870
static struct clksrc_sources exynos4_clkset_mout_mfc0 = {
	.sources	= exynos4_clkset_mout_mfc0_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_mfc0_list),
871 872
};

873
static struct clksrc_clk exynos4_clk_mout_mfc0 = {
874 875 876
	.clk	= {
		.name		= "mout_mfc0",
	},
877 878
	.sources = &exynos4_clkset_mout_mfc0,
	.reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 0, .size = 1 },
879 880
};

881 882 883
static struct clk *exynos4_clkset_mout_mfc1_list[] = {
	[0] = &exynos4_clk_mout_epll.clk,
	[1] = &exynos4_clk_sclk_vpll.clk,
884 885
};

886 887 888
static struct clksrc_sources exynos4_clkset_mout_mfc1 = {
	.sources	= exynos4_clkset_mout_mfc1_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_mfc1_list),
889 890
};

891
static struct clksrc_clk exynos4_clk_mout_mfc1 = {
892 893 894
	.clk	= {
		.name		= "mout_mfc1",
	},
895 896
	.sources = &exynos4_clkset_mout_mfc1,
	.reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 4, .size = 1 },
897 898
};

899 900 901
static struct clk *exynos4_clkset_mout_mfc_list[] = {
	[0] = &exynos4_clk_mout_mfc0.clk,
	[1] = &exynos4_clk_mout_mfc1.clk,
902 903
};

904 905 906
static struct clksrc_sources exynos4_clkset_mout_mfc = {
	.sources	= exynos4_clkset_mout_mfc_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_mout_mfc_list),
907 908
};

909 910 911
static struct clk *exynos4_clkset_sclk_dac_list[] = {
	[0] = &exynos4_clk_sclk_vpll.clk,
	[1] = &exynos4_clk_sclk_hdmiphy,
912 913
};

914 915 916
static struct clksrc_sources exynos4_clkset_sclk_dac = {
	.sources	= exynos4_clkset_sclk_dac_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_sclk_dac_list),
917 918
};

919
static struct clksrc_clk exynos4_clk_sclk_dac = {
920 921 922 923 924
	.clk		= {
		.name		= "sclk_dac",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 8),
	},
925 926
	.sources = &exynos4_clkset_sclk_dac,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 8, .size = 1 },
927 928
};

929
static struct clksrc_clk exynos4_clk_sclk_pixel = {
930 931
	.clk		= {
		.name		= "sclk_pixel",
932
		.parent		= &exynos4_clk_sclk_vpll.clk,
933
	},
934
	.reg_div = { .reg = EXYNOS4_CLKDIV_TV, .shift = 0, .size = 4 },
935 936
};

937 938 939
static struct clk *exynos4_clkset_sclk_hdmi_list[] = {
	[0] = &exynos4_clk_sclk_pixel.clk,
	[1] = &exynos4_clk_sclk_hdmiphy,
940 941
};

942 943 944
static struct clksrc_sources exynos4_clkset_sclk_hdmi = {
	.sources	= exynos4_clkset_sclk_hdmi_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_sclk_hdmi_list),
945 946
};

947
static struct clksrc_clk exynos4_clk_sclk_hdmi = {
948 949 950 951 952
	.clk		= {
		.name		= "sclk_hdmi",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 0),
	},
953 954
	.sources = &exynos4_clkset_sclk_hdmi,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 0, .size = 1 },
955 956
};

957 958 959
static struct clk *exynos4_clkset_sclk_mixer_list[] = {
	[0] = &exynos4_clk_sclk_dac.clk,
	[1] = &exynos4_clk_sclk_hdmi.clk,
960 961
};

962 963 964
static struct clksrc_sources exynos4_clkset_sclk_mixer = {
	.sources	= exynos4_clkset_sclk_mixer_list,
	.nr_sources	= ARRAY_SIZE(exynos4_clkset_sclk_mixer_list),
965 966
};

967
static struct clksrc_clk exynos4_clk_sclk_mixer = {
968
	.clk	= {
969 970 971 972
		.name		= "sclk_mixer",
		.enable		= exynos4_clksrc_mask_tv_ctrl,
		.ctrlbit	= (1 << 4),
	},
973 974
	.sources = &exynos4_clkset_sclk_mixer,
	.reg_src = { .reg = EXYNOS4_CLKSRC_TV, .shift = 4, .size = 1 },
975 976
};

977 978 979 980 981
static struct clksrc_clk *exynos4_sclk_tv[] = {
	&exynos4_clk_sclk_dac,
	&exynos4_clk_sclk_pixel,
	&exynos4_clk_sclk_hdmi,
	&exynos4_clk_sclk_mixer,
982 983
};

984
static struct clksrc_clk exynos4_clk_dout_mmc0 = {
985
	.clk	= {
986 987
		.name		= "dout_mmc0",
	},
988 989 990
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 0, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 0, .size = 4 },
991 992
};

993
static struct clksrc_clk exynos4_clk_dout_mmc1 = {
994
	.clk	= {
995 996
		.name		= "dout_mmc1",
	},
997 998 999
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 4, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 16, .size = 4 },
1000 1001
};

1002
static struct clksrc_clk exynos4_clk_dout_mmc2 = {
1003
	.clk	= {
1004 1005
		.name		= "dout_mmc2",
	},
1006 1007 1008
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 8, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 0, .size = 4 },
1009 1010
};

1011
static struct clksrc_clk exynos4_clk_dout_mmc3 = {
1012
	.clk	= {
1013 1014
		.name		= "dout_mmc3",
	},
1015 1016 1017
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 12, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 16, .size = 4 },
1018 1019
};

1020
static struct clksrc_clk exynos4_clk_dout_mmc4 = {
1021 1022 1023
	.clk		= {
		.name		= "dout_mmc4",
	},
1024 1025 1026
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 16, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS3, .shift = 0, .size = 4 },
1027 1028
};

1029
static struct clksrc_clk exynos4_clksrcs[] = {
1030
	{
1031
		.clk	= {
1032
			.name		= "sclk_pwm",
K
Kukjin Kim 已提交
1033
			.enable		= exynos4_clksrc_mask_peril0_ctrl,
1034 1035
			.ctrlbit	= (1 << 24),
		},
1036 1037 1038
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 24, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL3, .shift = 0, .size = 4 },
1039
	}, {
1040
		.clk	= {
1041
			.name		= "sclk_csis",
1042
			.devname	= "s5p-mipi-csis.0",
K
Kukjin Kim 已提交
1043
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1044 1045
			.ctrlbit	= (1 << 24),
		},
1046 1047 1048
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 24, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 24, .size = 4 },
1049
	}, {
1050
		.clk	= {
1051
			.name		= "sclk_csis",
1052
			.devname	= "s5p-mipi-csis.1",
K
Kukjin Kim 已提交
1053
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1054 1055
			.ctrlbit	= (1 << 28),
		},
1056 1057 1058
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 28, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 28, .size = 4 },
1059
	}, {
1060
		.clk	= {
1061
			.name		= "sclk_cam0",
K
Kukjin Kim 已提交
1062
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1063 1064
			.ctrlbit	= (1 << 16),
		},
1065 1066 1067
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 16, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 16, .size = 4 },
1068
	}, {
1069
		.clk	= {
1070
			.name		= "sclk_cam1",
K
Kukjin Kim 已提交
1071
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1072 1073
			.ctrlbit	= (1 << 20),
		},
1074 1075 1076
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 20, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 20, .size = 4 },
1077
	}, {
1078
		.clk	= {
1079
			.name		= "sclk_fimc",
1080
			.devname	= "exynos4-fimc.0",
K
Kukjin Kim 已提交
1081
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1082 1083
			.ctrlbit	= (1 << 0),
		},
1084 1085 1086
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 0, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 0, .size = 4 },
1087
	}, {
1088
		.clk	= {
1089
			.name		= "sclk_fimc",
1090
			.devname	= "exynos4-fimc.1",
K
Kukjin Kim 已提交
1091
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1092 1093
			.ctrlbit	= (1 << 4),
		},
1094 1095 1096
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 4, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 4, .size = 4 },
1097
	}, {
1098
		.clk	= {
1099
			.name		= "sclk_fimc",
1100
			.devname	= "exynos4-fimc.2",
K
Kukjin Kim 已提交
1101
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1102 1103
			.ctrlbit	= (1 << 8),
		},
1104 1105 1106
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 8, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 8, .size = 4 },
1107
	}, {
1108
		.clk	= {
1109
			.name		= "sclk_fimc",
1110
			.devname	= "exynos4-fimc.3",
K
Kukjin Kim 已提交
1111
			.enable		= exynos4_clksrc_mask_cam_ctrl,
1112 1113
			.ctrlbit	= (1 << 12),
		},
1114 1115 1116
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_CAM, .shift = 12, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_CAM, .shift = 12, .size = 4 },
1117
	}, {
1118
		.clk	= {
1119
			.name		= "sclk_fimd",
1120
			.devname	= "exynos4-fb.0",
K
Kukjin Kim 已提交
1121
			.enable		= exynos4_clksrc_mask_lcd0_ctrl,
1122 1123
			.ctrlbit	= (1 << 0),
		},
1124 1125 1126
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4_CLKSRC_LCD0, .shift = 0, .size = 4 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_LCD0, .shift = 0, .size = 4 },
1127
	}, {
1128
		.clk	= {
1129 1130
			.name		= "sclk_fimg2d",
		},
1131 1132 1133
		.sources = &exynos4_clkset_mout_g2d,
		.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
1134
	}, {
1135
		.clk	= {
1136 1137 1138
			.name		= "sclk_mfc",
			.devname	= "s5p-mfc",
		},
1139 1140 1141
		.sources = &exynos4_clkset_mout_mfc,
		.reg_src = { .reg = EXYNOS4_CLKSRC_MFC, .shift = 8, .size = 1 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_MFC, .shift = 0, .size = 4 },
1142
	}, {
1143
		.clk	= {
1144
			.name		= "sclk_dwmmc",
1145
			.parent		= &exynos4_clk_dout_mmc4.clk,
K
Kukjin Kim 已提交
1146
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
1147 1148
			.ctrlbit	= (1 << 16),
		},
1149
		.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS3, .shift = 8, .size = 8 },
1150
	}
1151 1152
};

1153
static struct clksrc_clk exynos4_clk_sclk_uart0 = {
1154 1155 1156 1157 1158 1159
	.clk	= {
		.name		= "uclk1",
		.devname	= "exynos4210-uart.0",
		.enable		= exynos4_clksrc_mask_peril0_ctrl,
		.ctrlbit	= (1 << 0),
	},
1160 1161 1162
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 0, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 0, .size = 4 },
1163 1164
};

1165
static struct clksrc_clk exynos4_clk_sclk_uart1 = {
1166
	.clk	= {
1167 1168 1169 1170 1171
		.name		= "uclk1",
		.devname	= "exynos4210-uart.1",
		.enable		= exynos4_clksrc_mask_peril0_ctrl,
		.ctrlbit	= (1 << 4),
	},
1172 1173 1174
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 4, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 4, .size = 4 },
1175 1176
};

1177
static struct clksrc_clk exynos4_clk_sclk_uart2 = {
1178
	.clk	= {
1179 1180 1181 1182 1183
		.name		= "uclk1",
		.devname	= "exynos4210-uart.2",
		.enable		= exynos4_clksrc_mask_peril0_ctrl,
		.ctrlbit	= (1 << 8),
	},
1184 1185 1186
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 8, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 8, .size = 4 },
1187 1188
};

1189
static struct clksrc_clk exynos4_clk_sclk_uart3 = {
1190
	.clk	= {
1191 1192 1193 1194 1195
		.name		= "uclk1",
		.devname	= "exynos4210-uart.3",
		.enable		= exynos4_clksrc_mask_peril0_ctrl,
		.ctrlbit	= (1 << 12),
	},
1196 1197 1198
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL0, .shift = 12, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL0, .shift = 12, .size = 4 },
1199 1200
};

1201
static struct clksrc_clk exynos4_clk_sclk_mmc0 = {
1202
	.clk	= {
1203
		.name		= "sclk_mmc",
1204
		.devname	= "exynos4-sdhci.0",
1205
		.parent		= &exynos4_clk_dout_mmc0.clk,
1206 1207 1208
		.enable		= exynos4_clksrc_mask_fsys_ctrl,
		.ctrlbit	= (1 << 0),
	},
1209
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 8, .size = 8 },
1210 1211
};

1212
static struct clksrc_clk exynos4_clk_sclk_mmc1 = {
1213
	.clk	= {
1214
		.name		= "sclk_mmc",
1215
		.devname	= "exynos4-sdhci.1",
1216
		.parent		= &exynos4_clk_dout_mmc1.clk,
1217 1218 1219
		.enable		= exynos4_clksrc_mask_fsys_ctrl,
		.ctrlbit	= (1 << 4),
	},
1220
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS1, .shift = 24, .size = 8 },
1221 1222
};

1223
static struct clksrc_clk exynos4_clk_sclk_mmc2 = {
1224
	.clk	= {
1225
		.name		= "sclk_mmc",
1226
		.devname	= "exynos4-sdhci.2",
1227
		.parent		= &exynos4_clk_dout_mmc2.clk,
1228 1229 1230
		.enable		= exynos4_clksrc_mask_fsys_ctrl,
		.ctrlbit	= (1 << 8),
	},
1231
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 8, .size = 8 },
1232 1233
};

1234
static struct clksrc_clk exynos4_clk_sclk_mmc3 = {
1235
	.clk	= {
1236
		.name		= "sclk_mmc",
1237
		.devname	= "exynos4-sdhci.3",
1238
		.parent		= &exynos4_clk_dout_mmc3.clk,
1239 1240 1241
		.enable		= exynos4_clksrc_mask_fsys_ctrl,
		.ctrlbit	= (1 << 12),
	},
1242
	.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS2, .shift = 24, .size = 8 },
1243 1244
};

1245
static struct clksrc_clk exynos4_clk_sclk_spi0 = {
1246
	.clk	= {
1247
		.name		= "sclk_spi",
1248
		.devname	= "exynos4210-spi.0",
1249
		.enable		= exynos4_clksrc_mask_peril1_ctrl,
1250
		.ctrlbit	= (1 << 16),
1251
	},
1252 1253 1254
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 16, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 0, .size = 4 },
1255 1256
};

1257
static struct clksrc_clk exynos4_clk_sclk_spi1 = {
1258
	.clk	= {
1259
		.name		= "sclk_spi",
1260
		.devname	= "exynos4210-spi.1",
1261
		.enable		= exynos4_clksrc_mask_peril1_ctrl,
1262
		.ctrlbit	= (1 << 20),
1263
	},
1264 1265 1266
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 20, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL1, .shift = 16, .size = 4 },
1267 1268
};

1269
static struct clksrc_clk exynos4_clk_sclk_spi2 = {
1270
	.clk	= {
1271
		.name		= "sclk_spi",
1272
		.devname	= "exynos4210-spi.2",
1273
		.enable		= exynos4_clksrc_mask_peril1_ctrl,
1274
		.ctrlbit	= (1 << 24),
1275
	},
1276 1277 1278
	.sources = &exynos4_clkset_group,
	.reg_src = { .reg = EXYNOS4_CLKSRC_PERIL1, .shift = 24, .size = 4 },
	.reg_div = { .reg = EXYNOS4_CLKDIV_PERIL2, .shift = 0, .size = 4 },
1279 1280
};

1281
/* Clock initialization code */
1282 1283 1284 1285 1286 1287 1288 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
static struct clksrc_clk *exynos4_sysclks[] = {
	&exynos4_clk_mout_apll,
	&exynos4_clk_sclk_apll,
	&exynos4_clk_mout_epll,
	&exynos4_clk_mout_mpll,
	&exynos4_clk_moutcore,
	&exynos4_clk_coreclk,
	&exynos4_clk_armclk,
	&exynos4_clk_aclk_corem0,
	&exynos4_clk_aclk_cores,
	&exynos4_clk_aclk_corem1,
	&exynos4_clk_periphclk,
	&exynos4_clk_mout_corebus,
	&exynos4_clk_sclk_dmc,
	&exynos4_clk_aclk_cored,
	&exynos4_clk_aclk_corep,
	&exynos4_clk_aclk_acp,
	&exynos4_clk_pclk_acp,
	&exynos4_clk_vpllsrc,
	&exynos4_clk_sclk_vpll,
	&exynos4_clk_aclk_200,
	&exynos4_clk_aclk_100,
	&exynos4_clk_aclk_160,
	&exynos4_clk_aclk_133,
	&exynos4_clk_dout_mmc0,
	&exynos4_clk_dout_mmc1,
	&exynos4_clk_dout_mmc2,
	&exynos4_clk_dout_mmc3,
	&exynos4_clk_dout_mmc4,
	&exynos4_clk_mout_mfc0,
	&exynos4_clk_mout_mfc1,
};

static struct clk *exynos4_clk_cdev[] = {
	&exynos4_clk_pdma0,
	&exynos4_clk_pdma1,
B
Boojin Kim 已提交
1318
	&exynos4_clk_mdma1,
1319
	&exynos4_clk_fimd0,
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333
};

static struct clksrc_clk *exynos4_clksrc_cdev[] = {
	&exynos4_clk_sclk_uart0,
	&exynos4_clk_sclk_uart1,
	&exynos4_clk_sclk_uart2,
	&exynos4_clk_sclk_uart3,
	&exynos4_clk_sclk_mmc0,
	&exynos4_clk_sclk_mmc1,
	&exynos4_clk_sclk_mmc2,
	&exynos4_clk_sclk_mmc3,
	&exynos4_clk_sclk_spi0,
	&exynos4_clk_sclk_spi1,
	&exynos4_clk_sclk_spi2,
1334

1335 1336 1337
};

static struct clk_lookup exynos4_clk_lookup[] = {
1338 1339 1340 1341
	CLKDEV_INIT("exynos4210-uart.0", "clk_uart_baud0", &exynos4_clk_sclk_uart0.clk),
	CLKDEV_INIT("exynos4210-uart.1", "clk_uart_baud0", &exynos4_clk_sclk_uart1.clk),
	CLKDEV_INIT("exynos4210-uart.2", "clk_uart_baud0", &exynos4_clk_sclk_uart2.clk),
	CLKDEV_INIT("exynos4210-uart.3", "clk_uart_baud0", &exynos4_clk_sclk_uart3.clk),
1342 1343 1344 1345
	CLKDEV_INIT("exynos4-sdhci.0", "mmc_busclk.2", &exynos4_clk_sclk_mmc0.clk),
	CLKDEV_INIT("exynos4-sdhci.1", "mmc_busclk.2", &exynos4_clk_sclk_mmc1.clk),
	CLKDEV_INIT("exynos4-sdhci.2", "mmc_busclk.2", &exynos4_clk_sclk_mmc2.clk),
	CLKDEV_INIT("exynos4-sdhci.3", "mmc_busclk.2", &exynos4_clk_sclk_mmc3.clk),
1346
	CLKDEV_INIT("exynos4-fb.0", "lcd", &exynos4_clk_fimd0),
1347 1348
	CLKDEV_INIT("dma-pl330.0", "apb_pclk", &exynos4_clk_pdma0),
	CLKDEV_INIT("dma-pl330.1", "apb_pclk", &exynos4_clk_pdma1),
1349
	CLKDEV_INIT("dma-pl330.2", "apb_pclk", &exynos4_clk_mdma1),
1350 1351 1352
	CLKDEV_INIT("exynos4210-spi.0", "spi_busclk0", &exynos4_clk_sclk_spi0.clk),
	CLKDEV_INIT("exynos4210-spi.1", "spi_busclk0", &exynos4_clk_sclk_spi1.clk),
	CLKDEV_INIT("exynos4210-spi.2", "spi_busclk0", &exynos4_clk_sclk_spi2.clk),
1353 1354
};

1355 1356
static int xtal_rate;

K
Kukjin Kim 已提交
1357
static unsigned long exynos4_fout_apll_get_rate(struct clk *clk)
1358
{
1359
	if (soc_is_exynos4210())
1360
		return s5p_get_pll45xx(xtal_rate, __raw_readl(EXYNOS4_APLL_CON0),
1361
					pll_4508);
1362
	else if (soc_is_exynos4212() || soc_is_exynos4412())
1363
		return s5p_get_pll35xx(xtal_rate, __raw_readl(EXYNOS4_APLL_CON0));
1364 1365
	else
		return 0;
1366 1367
}

K
Kukjin Kim 已提交
1368 1369
static struct clk_ops exynos4_fout_apll_ops = {
	.get_rate = exynos4_fout_apll_get_rate,
1370 1371
};

1372
static u32 exynos4_vpll_div[][8] = {
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390
	{  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;

1391
	vpll_con0 = __raw_readl(EXYNOS4_VPLL_CON0);
1392 1393 1394 1395 1396
	vpll_con0 &= ~(0x1 << 27 |					\
			PLL90XX_MDIV_MASK << PLL46XX_MDIV_SHIFT |	\
			PLL90XX_PDIV_MASK << PLL46XX_PDIV_SHIFT |	\
			PLL90XX_SDIV_MASK << PLL46XX_SDIV_SHIFT);

1397
	vpll_con1 = __raw_readl(EXYNOS4_VPLL_CON1);
1398 1399 1400 1401
	vpll_con1 &= ~(PLL46XX_MRR_MASK << PLL46XX_MRR_SHIFT |	\
			PLL46XX_MFR_MASK << PLL46XX_MFR_SHIFT |	\
			PLL4650C_KDIV_MASK << PLL46XX_KDIV_SHIFT);

1402 1403 1404 1405 1406 1407 1408 1409 1410
	for (i = 0; i < ARRAY_SIZE(exynos4_vpll_div); i++) {
		if (exynos4_vpll_div[i][0] == rate) {
			vpll_con0 |= exynos4_vpll_div[i][1] << PLL46XX_PDIV_SHIFT;
			vpll_con0 |= exynos4_vpll_div[i][2] << PLL46XX_MDIV_SHIFT;
			vpll_con0 |= exynos4_vpll_div[i][3] << PLL46XX_SDIV_SHIFT;
			vpll_con1 |= exynos4_vpll_div[i][4] << PLL46XX_KDIV_SHIFT;
			vpll_con1 |= exynos4_vpll_div[i][5] << PLL46XX_MFR_SHIFT;
			vpll_con1 |= exynos4_vpll_div[i][6] << PLL46XX_MRR_SHIFT;
			vpll_con0 |= exynos4_vpll_div[i][7] << 27;
1411 1412 1413 1414
			break;
		}
	}

1415
	if (i == ARRAY_SIZE(exynos4_vpll_div)) {
1416 1417 1418 1419 1420
		printk(KERN_ERR "%s: Invalid Clock VPLL Frequency\n",
				__func__);
		return -EINVAL;
	}

1421 1422
	__raw_writel(vpll_con0, EXYNOS4_VPLL_CON0);
	__raw_writel(vpll_con1, EXYNOS4_VPLL_CON1);
1423 1424

	/* Wait for VPLL lock */
1425
	while (!(__raw_readl(EXYNOS4_VPLL_CON0) & (1 << PLL46XX_LOCKED_SHIFT)))
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
		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 已提交
1437
void __init_or_cpufreq exynos4_setup_clocks(void)
1438 1439
{
	struct clk *xtal_clk;
1440 1441 1442 1443
	unsigned long apll = 0;
	unsigned long mpll = 0;
	unsigned long epll = 0;
	unsigned long vpll = 0;
1444 1445 1446 1447
	unsigned long vpllsrc;
	unsigned long xtal;
	unsigned long armclk;
	unsigned long sclk_dmc;
1448 1449 1450 1451
	unsigned long aclk_200;
	unsigned long aclk_100;
	unsigned long aclk_160;
	unsigned long aclk_133;
1452 1453 1454 1455 1456 1457 1458 1459
	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);
1460 1461 1462

	xtal_rate = xtal;

1463 1464 1465 1466
	clk_put(xtal_clk);

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

1467
	if (soc_is_exynos4210()) {
1468
		apll = s5p_get_pll45xx(xtal, __raw_readl(EXYNOS4_APLL_CON0),
1469
					pll_4508);
1470
		mpll = s5p_get_pll45xx(xtal, __raw_readl(EXYNOS4_MPLL_CON0),
1471
					pll_4508);
1472 1473
		epll = s5p_get_pll46xx(xtal, __raw_readl(EXYNOS4_EPLL_CON0),
					__raw_readl(EXYNOS4_EPLL_CON1), pll_4600);
1474

1475 1476 1477
		vpllsrc = clk_get_rate(&exynos4_clk_vpllsrc.clk);
		vpll = s5p_get_pll46xx(vpllsrc, __raw_readl(EXYNOS4_VPLL_CON0),
					__raw_readl(EXYNOS4_VPLL_CON1), pll_4650c);
1478
	} else if (soc_is_exynos4212() || soc_is_exynos4412()) {
1479 1480 1481 1482 1483 1484 1485 1486
		apll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS4_APLL_CON0));
		mpll = s5p_get_pll35xx(xtal, __raw_readl(EXYNOS4_MPLL_CON0));
		epll = s5p_get_pll36xx(xtal, __raw_readl(EXYNOS4_EPLL_CON0),
					__raw_readl(EXYNOS4_EPLL_CON1));

		vpllsrc = clk_get_rate(&exynos4_clk_vpllsrc.clk);
		vpll = s5p_get_pll36xx(vpllsrc, __raw_readl(EXYNOS4_VPLL_CON0),
					__raw_readl(EXYNOS4_VPLL_CON1));
1487 1488 1489
	} else {
		/* nothing */
	}
1490

K
Kukjin Kim 已提交
1491
	clk_fout_apll.ops = &exynos4_fout_apll_ops;
1492 1493
	clk_fout_mpll.rate = mpll;
	clk_fout_epll.rate = epll;
1494
	clk_fout_vpll.ops = &exynos4_vpll_ops;
1495 1496
	clk_fout_vpll.rate = vpll;

K
Kukjin Kim 已提交
1497
	printk(KERN_INFO "EXYNOS4: PLL settings, A=%ld, M=%ld, E=%ld V=%ld",
1498 1499
			apll, mpll, epll, vpll);

1500 1501
	armclk = clk_get_rate(&exynos4_clk_armclk.clk);
	sclk_dmc = clk_get_rate(&exynos4_clk_sclk_dmc.clk);
K
Kukjin Kim 已提交
1502

1503 1504 1505 1506
	aclk_200 = clk_get_rate(&exynos4_clk_aclk_200.clk);
	aclk_100 = clk_get_rate(&exynos4_clk_aclk_100.clk);
	aclk_160 = clk_get_rate(&exynos4_clk_aclk_160.clk);
	aclk_133 = clk_get_rate(&exynos4_clk_aclk_133.clk);
1507

K
Kukjin Kim 已提交
1508
	printk(KERN_INFO "EXYNOS4: ARMCLK=%ld, DMC=%ld, ACLK200=%ld\n"
1509 1510 1511
			 "ACLK100=%ld, ACLK160=%ld, ACLK133=%ld\n",
			armclk, sclk_dmc, aclk_200,
			aclk_100, aclk_160, aclk_133);
1512 1513 1514

	clk_f.rate = armclk;
	clk_h.rate = sclk_dmc;
1515
	clk_p.rate = aclk_100;
1516

1517 1518
	for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clksrcs); ptr++)
		s3c_set_clksrc(&exynos4_clksrcs[ptr], true);
1519 1520
}

1521 1522 1523 1524 1525
static struct clk *exynos4_clks[] __initdata = {
	&exynos4_clk_sclk_hdmi27m,
	&exynos4_clk_sclk_hdmiphy,
	&exynos4_clk_sclk_usbphy0,
	&exynos4_clk_sclk_usbphy1,
1526 1527
};

1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
#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

1545
static struct syscore_ops exynos4_clock_syscore_ops = {
1546 1547 1548 1549
	.suspend	= exynos4_clock_suspend,
	.resume		= exynos4_clock_resume,
};

K
Kukjin Kim 已提交
1550
void __init exynos4_register_clocks(void)
1551 1552 1553
{
	int ptr;

1554
	s3c24xx_register_clocks(exynos4_clks, ARRAY_SIZE(exynos4_clks));
1555

1556 1557
	for (ptr = 0; ptr < ARRAY_SIZE(exynos4_sysclks); ptr++)
		s3c_register_clksrc(exynos4_sysclks[ptr], 1);
1558

1559 1560
	for (ptr = 0; ptr < ARRAY_SIZE(exynos4_sclk_tv); ptr++)
		s3c_register_clksrc(exynos4_sclk_tv[ptr], 1);
1561

1562 1563
	for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clksrc_cdev); ptr++)
		s3c_register_clksrc(exynos4_clksrc_cdev[ptr], 1);
1564

1565 1566
	s3c_register_clksrc(exynos4_clksrcs, ARRAY_SIZE(exynos4_clksrcs));
	s3c_register_clocks(exynos4_init_clocks_on, ARRAY_SIZE(exynos4_init_clocks_on));
1567

1568 1569 1570
	s3c24xx_register_clocks(exynos4_clk_cdev, ARRAY_SIZE(exynos4_clk_cdev));
	for (ptr = 0; ptr < ARRAY_SIZE(exynos4_clk_cdev); ptr++)
		s3c_disable_clocks(exynos4_clk_cdev[ptr], 1);
1571

1572 1573
	s3c_register_clocks(exynos4_init_clocks_off, ARRAY_SIZE(exynos4_init_clocks_off));
	s3c_disable_clocks(exynos4_init_clocks_off, ARRAY_SIZE(exynos4_init_clocks_off));
1574
	clkdev_add_table(exynos4_clk_lookup, ARRAY_SIZE(exynos4_clk_lookup));
1575

1576
	register_syscore_ops(&exynos4_clock_syscore_ops);
1577 1578
	s3c24xx_register_clock(&dummy_apb_pclk);

1579 1580
	s3c_pwmclk_init();
}