clock.h 24.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 *  linux/arch/arm/mach-omap1/clock.h
 *
 *  Copyright (C) 2004 - 2005 Nokia corporation
 *  Written by Tuukka Tikkanen <tuukka.tikkanen@elektrobit.com>
 *  Based on clocks.h by Tony Lindgren, Gordon McNutt and RidgeRun, Inc
 *
 * 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.
 */

#ifndef __ARCH_ARM_MACH_OMAP1_CLOCK_H
#define __ARCH_ARM_MACH_OMAP1_CLOCK_H

16 17
static int omap1_clk_enable_generic(struct clk * clk);
static void omap1_clk_disable_generic(struct clk * clk);
18 19
static void omap1_ckctl_recalc(struct clk * clk);
static void omap1_watchdog_recalc(struct clk * clk);
I
Imre Deak 已提交
20 21
static int omap1_set_sossi_rate(struct clk *clk, unsigned long rate);
static void omap1_sossi_recalc(struct clk *clk);
22 23 24 25 26 27 28 29 30 31 32 33 34
static void omap1_ckctl_recalc_dsp_domain(struct clk * clk);
static int omap1_clk_enable_dsp_domain(struct clk * clk);
static int omap1_clk_set_rate_dsp_domain(struct clk * clk, unsigned long rate);
static void omap1_clk_disable_dsp_domain(struct clk * clk);
static int omap1_set_uart_rate(struct clk * clk, unsigned long rate);
static void omap1_uart_recalc(struct clk * clk);
static int omap1_clk_enable_uart_functional(struct clk * clk);
static void omap1_clk_disable_uart_functional(struct clk * clk);
static int omap1_set_ext_clk_rate(struct clk * clk, unsigned long rate);
static long omap1_round_ext_clk_rate(struct clk * clk, unsigned long rate);
static void omap1_init_ext_clk(struct clk * clk);
static int omap1_select_table_rate(struct clk * clk, unsigned long rate);
static long omap1_round_to_table_rate(struct clk * clk, unsigned long rate);
35 36
static int omap1_clk_enable(struct clk *clk);
static void omap1_clk_disable(struct clk *clk);
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

struct mpu_rate {
	unsigned long		rate;
	unsigned long		xtal;
	unsigned long		pll_rate;
	__u16			ckctl_val;
	__u16			dpllctl_val;
};

struct uart_clk {
	struct clk	clk;
	unsigned long	sysc_addr;
};

/* Provide a method for preventing idling some ARM IDLECT clocks */
struct arm_idlect1_clk {
	struct clk	clk;
	unsigned long	no_idle_count;
	__u8		idlect_shift;
};

/* ARM_CKCTL bit shifts */
#define CKCTL_PERDIV_OFFSET	0
#define CKCTL_LCDDIV_OFFSET	2
#define CKCTL_ARMDIV_OFFSET	4
#define CKCTL_DSPDIV_OFFSET	6
#define CKCTL_TCDIV_OFFSET	8
#define CKCTL_DSPMMUDIV_OFFSET	10
/*#define ARM_TIMXO		12*/
#define EN_DSPCK		13
/*#define ARM_INTHCK_SEL	14*/ /* Divide-by-2 for mpu inth_ck */
/* DSP_CKCTL bit shifts */
#define CKCTL_DSPPERDIV_OFFSET	0

/* ARM_IDLECT2 bit shifts */
#define EN_WDTCK	0
#define EN_XORPCK	1
#define EN_PERCK	2
#define EN_LCDCK	3
#define EN_LBCK		4 /* Not on 1610/1710 */
/*#define EN_HSABCK	5*/
#define EN_APICK	6
#define EN_TIMCK	7
#define DMACK_REQ	8
#define EN_GPIOCK	9 /* Not on 1610/1710 */
/*#define EN_LBFREECK	10*/
#define EN_CKOUT_ARM	11

/* ARM_IDLECT3 bit shifts */
#define EN_OCPI_CK	0
#define EN_TC1_CK	2
#define EN_TC2_CK	4

/* DSP_IDLECT2 bit shifts (0,1,2 are same as for ARM_IDLECT2) */
#define EN_DSPTIMCK	5

/* Various register defines for clock controls scattered around OMAP chip */
94
#define SDW_MCLK_INV_BIT	2	/* In ULPD_CLKC_CTRL */
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
#define USB_MCLK_EN_BIT		4	/* In ULPD_CLKC_CTRL */
#define USB_HOST_HHC_UHOST_EN	9	/* In MOD_CONF_CTRL_0 */
#define SWD_ULPD_PLL_CLK_REQ	1	/* In SWD_CLK_DIV_CTRL_SEL */
#define COM_ULPD_PLL_CLK_REQ	1	/* In COM_CLK_DIV_CTRL_SEL */
#define SWD_CLK_DIV_CTRL_SEL	0xfffe0874
#define COM_CLK_DIV_CTRL_SEL	0xfffe0878
#define SOFT_REQ_REG		0xfffe0834
#define SOFT_REQ_REG2		0xfffe0880

/*-------------------------------------------------------------------------
 * Omap1 MPU rate table
 *-------------------------------------------------------------------------*/
static struct mpu_rate rate_table[] = {
	/* MPU MHz, xtal MHz, dpll1 MHz, CKCTL, DPLL_CTL
	 * NOTE: Comment order here is different from bits in CKCTL value:
	 * armdiv, dspdiv, dspmmu, tcdiv, perdiv, lcddiv
	 */
#if defined(CONFIG_OMAP_ARM_216MHZ)
	{ 216000000, 12000000, 216000000, 0x050d, 0x2910 }, /* 1/1/2/2/2/8 */
#endif
#if defined(CONFIG_OMAP_ARM_195MHZ)
	{ 195000000, 13000000, 195000000, 0x050e, 0x2790 }, /* 1/1/2/2/4/8 */
#endif
#if defined(CONFIG_OMAP_ARM_192MHZ)
	{ 192000000, 19200000, 192000000, 0x050f, 0x2510 }, /* 1/1/2/2/8/8 */
	{ 192000000, 12000000, 192000000, 0x050f, 0x2810 }, /* 1/1/2/2/8/8 */
	{  96000000, 12000000, 192000000, 0x055f, 0x2810 }, /* 2/2/2/2/8/8 */
	{  48000000, 12000000, 192000000, 0x0baf, 0x2810 }, /* 4/4/4/8/8/8 */
	{  24000000, 12000000, 192000000, 0x0fff, 0x2810 }, /* 8/8/8/8/8/8 */
#endif
#if defined(CONFIG_OMAP_ARM_182MHZ)
	{ 182000000, 13000000, 182000000, 0x050e, 0x2710 }, /* 1/1/2/2/4/8 */
#endif
#if defined(CONFIG_OMAP_ARM_168MHZ)
	{ 168000000, 12000000, 168000000, 0x010f, 0x2710 }, /* 1/1/1/2/8/8 */
#endif
#if defined(CONFIG_OMAP_ARM_150MHZ)
	{ 150000000, 12000000, 150000000, 0x010a, 0x2cb0 }, /* 1/1/1/2/4/4 */
#endif
#if defined(CONFIG_OMAP_ARM_120MHZ)
	{ 120000000, 12000000, 120000000, 0x010a, 0x2510 }, /* 1/1/1/2/4/4 */
#endif
#if defined(CONFIG_OMAP_ARM_96MHZ)
	{  96000000, 12000000,  96000000, 0x0005, 0x2410 }, /* 1/1/1/1/2/2 */
#endif
#if defined(CONFIG_OMAP_ARM_60MHZ)
	{  60000000, 12000000,  60000000, 0x0005, 0x2290 }, /* 1/1/1/1/2/2 */
#endif
#if defined(CONFIG_OMAP_ARM_30MHZ)
	{  30000000, 12000000,  60000000, 0x0555, 0x2290 }, /* 2/2/2/2/2/2 */
#endif
	{ 0, 0, 0, 0, 0 },
};

/*-------------------------------------------------------------------------
 * Omap1 clocks
 *-------------------------------------------------------------------------*/

static struct clk ck_ref = {
	.name		= "ck_ref",
	.rate		= 12000000,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
157
			  CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
158 159
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
160 161 162 163 164 165
};

static struct clk ck_dpll1 = {
	.name		= "ck_dpll1",
	.parent		= &ck_ref,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
166
			  CLOCK_IN_OMAP310 | RATE_PROPAGATES | ALWAYS_ENABLED,
167 168
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
169 170 171 172
};

static struct arm_idlect1_clk ck_dpll1out = {
	.clk = {
I
Imre Deak 已提交
173
		.name		= "ck_dpll1out",
174
		.parent		= &ck_dpll1,
I
Imre Deak 已提交
175 176
		.flags		= CLOCK_IN_OMAP16XX | CLOCK_IDLE_CONTROL |
				  ENABLE_REG_32BIT | RATE_PROPAGATES,
177 178 179
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_CKOUT_ARM,
		.recalc		= &followparent_recalc,
180 181
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
182 183 184 185
	},
	.idlect_shift	= 12,
};

I
Imre Deak 已提交
186 187 188 189 190 191 192 193 194 195 196 197 198
static struct clk sossi_ck = {
	.name		= "ck_sossi",
	.parent		= &ck_dpll1out.clk,
	.flags		= CLOCK_IN_OMAP16XX | CLOCK_NO_IDLE_PARENT |
			  ENABLE_REG_32BIT,
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_1,
	.enable_bit	= 16,
	.recalc		= &omap1_sossi_recalc,
	.set_rate	= &omap1_set_sossi_rate,
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
};

199 200 201 202
static struct clk arm_ck = {
	.name		= "arm_ck",
	.parent		= &ck_dpll1,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
203 204
			  CLOCK_IN_OMAP310 | RATE_CKCTL | RATE_PROPAGATES |
			  ALWAYS_ENABLED,
205 206
	.rate_offset	= CKCTL_ARMDIV_OFFSET,
	.recalc		= &omap1_ckctl_recalc,
207 208
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
209 210 211 212 213 214 215
};

static struct arm_idlect1_clk armper_ck = {
	.clk = {
		.name		= "armper_ck",
		.parent		= &ck_dpll1,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
216 217
				  CLOCK_IN_OMAP310 | RATE_CKCTL |
				  CLOCK_IDLE_CONTROL,
218 219 220 221
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_PERCK,
		.rate_offset	= CKCTL_PERDIV_OFFSET,
		.recalc		= &omap1_ckctl_recalc,
222 223
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
224 225 226 227 228 229 230
	},
	.idlect_shift	= 2,
};

static struct clk arm_gpio_ck = {
	.name		= "arm_gpio_ck",
	.parent		= &ck_dpll1,
231
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310,
232 233 234
	.enable_reg	= (void __iomem *)ARM_IDLECT2,
	.enable_bit	= EN_GPIOCK,
	.recalc		= &followparent_recalc,
235 236
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
237 238 239 240 241 242 243
};

static struct arm_idlect1_clk armxor_ck = {
	.clk = {
		.name		= "armxor_ck",
		.parent		= &ck_ref,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
244
				  CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
245 246 247
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_XORPCK,
		.recalc		= &followparent_recalc,
248 249
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
250 251 252 253 254 255 256 257 258
	},
	.idlect_shift	= 1,
};

static struct arm_idlect1_clk armtim_ck = {
	.clk = {
		.name		= "armtim_ck",
		.parent		= &ck_ref,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
259
				  CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
260 261 262
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_TIMCK,
		.recalc		= &followparent_recalc,
263 264
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
265 266 267 268 269 270 271 272 273
	},
	.idlect_shift	= 9,
};

static struct arm_idlect1_clk armwdt_ck = {
	.clk = {
		.name		= "armwdt_ck",
		.parent		= &ck_ref,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
274
				  CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
275 276 277
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_WDTCK,
		.recalc		= &omap1_watchdog_recalc,
278 279
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
280 281 282 283 284 285 286 287 288 289 290 291 292 293
	},
	.idlect_shift	= 0,
};

static struct clk arminth_ck16xx = {
	.name		= "arminth_ck",
	.parent		= &arm_ck,
	.flags		= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
	.recalc		= &followparent_recalc,
	/* Note: On 16xx the frequency can be divided by 2 by programming
	 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1
	 *
	 * 1510 version is in TC clocks.
	 */
294 295
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
296 297 298 299 300
};

static struct clk dsp_ck = {
	.name		= "dsp_ck",
	.parent		= &ck_dpll1,
301
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
302 303 304 305 306
			  RATE_CKCTL,
	.enable_reg	= (void __iomem *)ARM_CKCTL,
	.enable_bit	= EN_DSPCK,
	.rate_offset	= CKCTL_DSPDIV_OFFSET,
	.recalc		= &omap1_ckctl_recalc,
307 308
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
309 310 311 312 313
};

static struct clk dspmmu_ck = {
	.name		= "dspmmu_ck",
	.parent		= &ck_dpll1,
314
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
315 316 317
			  RATE_CKCTL | ALWAYS_ENABLED,
	.rate_offset	= CKCTL_DSPMMUDIV_OFFSET,
	.recalc		= &omap1_ckctl_recalc,
318 319
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
320 321 322 323 324
};

static struct clk dspper_ck = {
	.name		= "dspper_ck",
	.parent		= &ck_dpll1,
325
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
326
			  RATE_CKCTL | VIRTUAL_IO_ADDRESS,
327
	.enable_reg	= DSP_IDLECT2,
328 329 330 331 332 333 334 335 336 337 338
	.enable_bit	= EN_PERCK,
	.rate_offset	= CKCTL_PERDIV_OFFSET,
	.recalc		= &omap1_ckctl_recalc_dsp_domain,
	.set_rate	= &omap1_clk_set_rate_dsp_domain,
	.enable		= &omap1_clk_enable_dsp_domain,
	.disable	= &omap1_clk_disable_dsp_domain,
};

static struct clk dspxor_ck = {
	.name		= "dspxor_ck",
	.parent		= &ck_ref,
339
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
340
			  VIRTUAL_IO_ADDRESS,
341
	.enable_reg	= DSP_IDLECT2,
342 343 344 345 346 347 348 349 350
	.enable_bit	= EN_XORPCK,
	.recalc		= &followparent_recalc,
	.enable		= &omap1_clk_enable_dsp_domain,
	.disable	= &omap1_clk_disable_dsp_domain,
};

static struct clk dsptim_ck = {
	.name		= "dsptim_ck",
	.parent		= &ck_ref,
351
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
352
			  VIRTUAL_IO_ADDRESS,
353
	.enable_reg	= DSP_IDLECT2,
354 355 356 357 358 359 360 361 362 363 364 365
	.enable_bit	= EN_DSPTIMCK,
	.recalc		= &followparent_recalc,
	.enable		= &omap1_clk_enable_dsp_domain,
	.disable	= &omap1_clk_disable_dsp_domain,
};

/* Tie ARM_IDLECT1:IDLIF_ARM to this logical clock structure */
static struct arm_idlect1_clk tc_ck = {
	.clk = {
		.name		= "tc_ck",
		.parent		= &ck_dpll1,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
366 367 368
				  CLOCK_IN_OMAP730 | CLOCK_IN_OMAP310 |
				  RATE_CKCTL | RATE_PROPAGATES |
				  ALWAYS_ENABLED | CLOCK_IDLE_CONTROL,
369 370
		.rate_offset	= CKCTL_TCDIV_OFFSET,
		.recalc		= &omap1_ckctl_recalc,
371 372
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
373 374 375 376 377 378 379
	},
	.idlect_shift	= 6,
};

static struct clk arminth_ck1510 = {
	.name		= "arminth_ck",
	.parent		= &tc_ck.clk,
380 381
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
			  ALWAYS_ENABLED,
382 383 384 385 386
	.recalc		= &followparent_recalc,
	/* Note: On 1510 the frequency follows TC_CK
	 *
	 * 16xx version is in MPU clocks.
	 */
387 388
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
389 390 391 392
};

static struct clk tipb_ck = {
	/* No-idle controlled by "tc_ck" */
393
	.name		= "tipb_ck",
394
	.parent		= &tc_ck.clk,
395 396
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
			  ALWAYS_ENABLED,
397
	.recalc		= &followparent_recalc,
398 399
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
400 401 402 403 404 405 406 407 408 409
};

static struct clk l3_ocpi_ck = {
	/* No-idle controlled by "tc_ck" */
	.name		= "l3_ocpi_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX,
	.enable_reg	= (void __iomem *)ARM_IDLECT3,
	.enable_bit	= EN_OCPI_CK,
	.recalc		= &followparent_recalc,
410 411
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
412 413 414 415 416 417 418 419 420
};

static struct clk tc1_ck = {
	.name		= "tc1_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX,
	.enable_reg	= (void __iomem *)ARM_IDLECT3,
	.enable_bit	= EN_TC1_CK,
	.recalc		= &followparent_recalc,
421 422
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
423 424 425 426 427 428 429 430 431
};

static struct clk tc2_ck = {
	.name		= "tc2_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX,
	.enable_reg	= (void __iomem *)ARM_IDLECT3,
	.enable_bit	= EN_TC2_CK,
	.recalc		= &followparent_recalc,
432 433
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
434 435 436 437 438 439 440
};

static struct clk dma_ck = {
	/* No-idle controlled by "tc_ck" */
	.name		= "dma_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
441
			  CLOCK_IN_OMAP310 | ALWAYS_ENABLED,
442
	.recalc		= &followparent_recalc,
443 444
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
445 446 447 448 449 450 451
};

static struct clk dma_lcdfree_ck = {
	.name		= "dma_lcdfree_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
	.recalc		= &followparent_recalc,
452 453
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
454 455 456 457 458 459 460
};

static struct arm_idlect1_clk api_ck = {
	.clk = {
		.name		= "api_ck",
		.parent		= &tc_ck.clk,
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
461
				  CLOCK_IN_OMAP310 | CLOCK_IDLE_CONTROL,
462 463 464
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_APICK,
		.recalc		= &followparent_recalc,
465 466
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
467 468 469 470 471 472 473 474
	},
	.idlect_shift	= 8,
};

static struct arm_idlect1_clk lb_ck = {
	.clk = {
		.name		= "lb_ck",
		.parent		= &tc_ck.clk,
475 476
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
				  CLOCK_IDLE_CONTROL,
477 478 479
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_LBCK,
		.recalc		= &followparent_recalc,
480 481
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
482 483 484 485 486 487 488 489 490
	},
	.idlect_shift	= 4,
};

static struct clk rhea1_ck = {
	.name		= "rhea1_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
	.recalc		= &followparent_recalc,
491 492
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
493 494 495 496 497 498 499
};

static struct clk rhea2_ck = {
	.name		= "rhea2_ck",
	.parent		= &tc_ck.clk,
	.flags		= CLOCK_IN_OMAP16XX | ALWAYS_ENABLED,
	.recalc		= &followparent_recalc,
500 501
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
502 503 504 505 506 507 508 509 510 511
};

static struct clk lcd_ck_16xx = {
	.name		= "lcd_ck",
	.parent		= &ck_dpll1,
	.flags		= CLOCK_IN_OMAP16XX | CLOCK_IN_OMAP730 | RATE_CKCTL,
	.enable_reg	= (void __iomem *)ARM_IDLECT2,
	.enable_bit	= EN_LCDCK,
	.rate_offset	= CKCTL_LCDDIV_OFFSET,
	.recalc		= &omap1_ckctl_recalc,
512 513
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
514 515 516 517 518 519
};

static struct arm_idlect1_clk lcd_ck_1510 = {
	.clk = {
		.name		= "lcd_ck",
		.parent		= &ck_dpll1,
520 521
		.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
				  RATE_CKCTL | CLOCK_IDLE_CONTROL,
522 523 524 525
		.enable_reg	= (void __iomem *)ARM_IDLECT2,
		.enable_bit	= EN_LCDCK,
		.rate_offset	= CKCTL_LCDDIV_OFFSET,
		.recalc		= &omap1_ckctl_recalc,
526 527
		.enable		= &omap1_clk_enable_generic,
		.disable	= &omap1_clk_disable_generic,
528 529 530 531 532 533 534 535 536
	},
	.idlect_shift	= 3,
};

static struct clk uart1_1510 = {
	.name		= "uart1_ck",
	/* Direct from ULPD, no real parent */
	.parent		= &armper_ck.clk,
	.rate		= 12000000,
537 538 539
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
			  ENABLE_REG_32BIT | ALWAYS_ENABLED |
			  CLOCK_NO_IDLE_PARENT,
540 541 542 543
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= 29,	/* Chooses between 12MHz and 48MHz */
	.set_rate	= &omap1_set_uart_rate,
	.recalc		= &omap1_uart_recalc,
544 545
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
};

static struct uart_clk uart1_16xx = {
	.clk	= {
		.name		= "uart1_ck",
		/* Direct from ULPD, no real parent */
		.parent		= &armper_ck.clk,
		.rate		= 48000000,
		.flags		= CLOCK_IN_OMAP16XX | RATE_FIXED |
				  ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
		.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
		.enable_bit	= 29,
		.enable		= &omap1_clk_enable_uart_functional,
		.disable	= &omap1_clk_disable_uart_functional,
	},
	.sysc_addr	= 0xfffb0054,
};

static struct clk uart2_ck = {
	.name		= "uart2_ck",
	/* Direct from ULPD, no real parent */
	.parent		= &armper_ck.clk,
	.rate		= 12000000,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
570 571
			  CLOCK_IN_OMAP310 | ENABLE_REG_32BIT |
			  ALWAYS_ENABLED | CLOCK_NO_IDLE_PARENT,
572 573 574 575
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= 30,	/* Chooses between 12MHz and 48MHz */
	.set_rate	= &omap1_set_uart_rate,
	.recalc		= &omap1_uart_recalc,
576 577
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
578 579 580 581 582 583 584
};

static struct clk uart3_1510 = {
	.name		= "uart3_ck",
	/* Direct from ULPD, no real parent */
	.parent		= &armper_ck.clk,
	.rate		= 12000000,
585 586 587
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
			  ENABLE_REG_32BIT | ALWAYS_ENABLED |
			  CLOCK_NO_IDLE_PARENT,
588 589 590 591
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= 31,	/* Chooses between 12MHz and 48MHz */
	.set_rate	= &omap1_set_uart_rate,
	.recalc		= &omap1_uart_recalc,
592 593
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
};

static struct uart_clk uart3_16xx = {
	.clk	= {
		.name		= "uart3_ck",
		/* Direct from ULPD, no real parent */
		.parent		= &armper_ck.clk,
		.rate		= 48000000,
		.flags		= CLOCK_IN_OMAP16XX | RATE_FIXED |
				  ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
		.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
		.enable_bit	= 31,
		.enable		= &omap1_clk_enable_uart_functional,
		.disable	= &omap1_clk_disable_uart_functional,
	},
	.sysc_addr	= 0xfffb9854,
};

static struct clk usb_clko = {	/* 6 MHz output on W4_USB_CLKO */
	.name		= "usb_clko",
	/* Direct from ULPD, no parent */
	.rate		= 6000000,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
617
			  CLOCK_IN_OMAP310 | RATE_FIXED | ENABLE_REG_32BIT,
618 619
	.enable_reg	= (void __iomem *)ULPD_CLOCK_CTRL,
	.enable_bit	= USB_MCLK_EN_BIT,
620 621
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
622 623 624 625 626 627
};

static struct clk usb_hhc_ck1510 = {
	.name		= "usb_hhc_ck",
	/* Direct from ULPD, no parent */
	.rate		= 48000000, /* Actually 2 clocks, 12MHz and 48MHz */
628
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 |
629 630 631
			  RATE_FIXED | ENABLE_REG_32BIT,
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= USB_HOST_HHC_UHOST_EN,
632 633
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
634 635 636 637 638 639 640 641 642 643 644
};

static struct clk usb_hhc_ck16xx = {
	.name		= "usb_hhc_ck",
	/* Direct from ULPD, no parent */
	.rate		= 48000000,
	/* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */
	.flags		= CLOCK_IN_OMAP16XX |
			  RATE_FIXED | ENABLE_REG_32BIT,
	.enable_reg	= (void __iomem *)OTG_BASE + 0x08 /* OTG_SYSCON_2 */,
	.enable_bit	= 8 /* UHOST_EN */,
645 646
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
647 648 649 650 651 652 653 654 655
};

static struct clk usb_dc_ck = {
	.name		= "usb_dc_ck",
	/* Direct from ULPD, no parent */
	.rate		= 48000000,
	.flags		= CLOCK_IN_OMAP16XX | RATE_FIXED,
	.enable_reg	= (void __iomem *)SOFT_REQ_REG,
	.enable_bit	= 4,
656 657
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
658 659 660 661 662 663
};

static struct clk mclk_1510 = {
	.name		= "mclk",
	/* Direct from ULPD, no parent. May be enabled by ext hardware. */
	.rate		= 12000000,
664 665 666
 	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | RATE_FIXED,
 	.enable_reg	= (void __iomem *)SOFT_REQ_REG,
 	.enable_bit	= 6,
667 668
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
669 670 671 672 673 674 675 676 677 678 679
};

static struct clk mclk_16xx = {
	.name		= "mclk",
	/* Direct from ULPD, no parent. May be enabled by ext hardware. */
	.flags		= CLOCK_IN_OMAP16XX,
	.enable_reg	= (void __iomem *)COM_CLK_DIV_CTRL_SEL,
	.enable_bit	= COM_ULPD_PLL_CLK_REQ,
	.set_rate	= &omap1_set_ext_clk_rate,
	.round_rate	= &omap1_round_ext_clk_rate,
	.init		= &omap1_init_ext_clk,
680 681
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
682 683 684 685 686 687
};

static struct clk bclk_1510 = {
	.name		= "bclk",
	/* Direct from ULPD, no parent. May be enabled by ext hardware. */
	.rate		= 12000000,
688
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP310 | RATE_FIXED,
689 690
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
691 692 693 694 695 696 697 698 699 700 701
};

static struct clk bclk_16xx = {
	.name		= "bclk",
	/* Direct from ULPD, no parent. May be enabled by ext hardware. */
	.flags		= CLOCK_IN_OMAP16XX,
	.enable_reg	= (void __iomem *)SWD_CLK_DIV_CTRL_SEL,
	.enable_bit	= SWD_ULPD_PLL_CLK_REQ,
	.set_rate	= &omap1_set_ext_clk_rate,
	.round_rate	= &omap1_round_ext_clk_rate,
	.init		= &omap1_init_ext_clk,
702 703
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
704 705 706
};

static struct clk mmc1_ck = {
707 708
	.name		= "mmc_ck",
	.id		= 1,
709 710 711 712
	/* Functional clock is direct from ULPD, interface clock is ARMPER */
	.parent		= &armper_ck.clk,
	.rate		= 48000000,
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
713 714
			  CLOCK_IN_OMAP310 | RATE_FIXED | ENABLE_REG_32BIT |
			  CLOCK_NO_IDLE_PARENT,
715 716
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= 23,
717 718
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
719 720 721
};

static struct clk mmc2_ck = {
722 723
	.name		= "mmc_ck",
	.id		= 2,
724 725 726 727 728 729 730
	/* Functional clock is direct from ULPD, interface clock is ARMPER */
	.parent		= &armper_ck.clk,
	.rate		= 48000000,
	.flags		= CLOCK_IN_OMAP16XX |
			  RATE_FIXED | ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT,
	.enable_reg	= (void __iomem *)MOD_CONF_CTRL_0,
	.enable_bit	= 20,
731 732
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
733 734 735 736 737
};

static struct clk virtual_ck_mpu = {
	.name		= "mpu",
	.flags		= CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
738
			  CLOCK_IN_OMAP310 | VIRTUAL_CLOCK | ALWAYS_ENABLED,
739 740 741 742
	.parent		= &arm_ck, /* Is smarter alias for */
	.recalc		= &followparent_recalc,
	.set_rate	= &omap1_select_table_rate,
	.round_rate	= &omap1_round_to_table_rate,
743 744
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
745 746
};

747 748 749 750 751
/* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK
remains active during MPU idle whenever this is enabled */
static struct clk i2c_fck = {
	.name		= "i2c_fck",
	.id		= 1,
752
	.flags		= CLOCK_IN_OMAP310 | CLOCK_IN_OMAP1510 | CLOCK_IN_OMAP16XX |
753 754 755 756 757 758 759 760
			  VIRTUAL_CLOCK | CLOCK_NO_IDLE_PARENT |
			  ALWAYS_ENABLED,
	.parent		= &armxor_ck.clk,
	.recalc		= &followparent_recalc,
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
};

761 762 763 764 765 766 767 768 769 770 771 772
static struct clk i2c_ick = {
	.name		= "i2c_ick",
	.id		= 1,
	.flags		= CLOCK_IN_OMAP16XX |
			  VIRTUAL_CLOCK | CLOCK_NO_IDLE_PARENT |
			  ALWAYS_ENABLED,
	.parent		= &armper_ck.clk,
	.recalc		= &followparent_recalc,
	.enable		= &omap1_clk_enable_generic,
	.disable	= &omap1_clk_disable_generic,
};

773 774 775 776 777 778
static struct clk * onchip_clks[] = {
	/* non-ULPD clocks */
	&ck_ref,
	&ck_dpll1,
	/* CK_GEN1 clocks */
	&ck_dpll1out.clk,
I
Imre Deak 已提交
779
	&sossi_ck,
780 781 782 783 784 785 786 787 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
	&arm_ck,
	&armper_ck.clk,
	&arm_gpio_ck,
	&armxor_ck.clk,
	&armtim_ck.clk,
	&armwdt_ck.clk,
	&arminth_ck1510,  &arminth_ck16xx,
	/* CK_GEN2 clocks */
	&dsp_ck,
	&dspmmu_ck,
	&dspper_ck,
	&dspxor_ck,
	&dsptim_ck,
	/* CK_GEN3 clocks */
	&tc_ck.clk,
	&tipb_ck,
	&l3_ocpi_ck,
	&tc1_ck,
	&tc2_ck,
	&dma_ck,
	&dma_lcdfree_ck,
	&api_ck.clk,
	&lb_ck.clk,
	&rhea1_ck,
	&rhea2_ck,
	&lcd_ck_16xx,
	&lcd_ck_1510.clk,
	/* ULPD clocks */
	&uart1_1510,
	&uart1_16xx.clk,
	&uart2_ck,
	&uart3_1510,
	&uart3_16xx.clk,
	&usb_clko,
	&usb_hhc_ck1510, &usb_hhc_ck16xx,
	&usb_dc_ck,
	&mclk_1510,  &mclk_16xx,
	&bclk_1510,  &bclk_16xx,
	&mmc1_ck,
	&mmc2_ck,
	/* Virtual clocks */
	&virtual_ck_mpu,
822
	&i2c_fck,
823
	&i2c_ick,
824 825 826
};

#endif