Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'arm-multiplatform-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc

Pull yet more ARM multiplatform updates from Arnd Bergmann:
"This is the third and final bit of the multiplatform conversion for
ARMv5, finishing off OMAP1. One patch enables the common-clk
interface, and the other ones does the Kconfig change.

These were waiting on a few dependencies to trickle in for common-clk,
and the last one of those was in the USB tree"

* tag 'arm-multiplatform-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc:
ARM: omap1: enable multiplatform
ARM: OMAP1: clock: Convert to CCF

+584 -897
-13
arch/arm/Kconfig
··· 396 396 help 397 397 Support for StrongARM 11x0 based boards. 398 398 399 - config ARCH_OMAP1 400 - bool "TI OMAP1" 401 - depends on CPU_LITTLE_ENDIAN 402 - select CLKSRC_MMIO 403 - select FORCE_PCI if PCCARD 404 - select GENERIC_IRQ_CHIP 405 - select GPIOLIB 406 - select HAVE_LEGACY_CLK 407 - select IRQ_DOMAIN 408 - select SPARSE_IRQ 409 - help 410 - Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx) 411 - 412 399 endchoice 413 400 414 401 menu "Multiple platform selection"
+3
arch/arm/configs/omap1_defconfig
··· 17 17 CONFIG_MODULE_UNLOAD=y 18 18 CONFIG_MODULE_FORCE_UNLOAD=y 19 19 # CONFIG_BLK_DEV_BSG is not set 20 + CONFIG_ARCH_MULTI_V4T=y 21 + CONFIG_ARCH_MULTI_V5=y 22 + # CONFIG_ARCH_MULTI_V7 is not set 20 23 CONFIG_ARCH_OMAP=y 21 24 CONFIG_ARCH_OMAP1=y 22 25 CONFIG_OMAP_RESET_CLOCKS=y
+16
arch/arm/mach-omap1/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 + menuconfig ARCH_OMAP1 3 + bool "TI OMAP1" 4 + depends on ARCH_MULTI_V4T || ARCH_MULTI_V5 5 + depends on CPU_LITTLE_ENDIAN 6 + select ARCH_HAS_HOLES_MEMORYMODEL 7 + select ARCH_OMAP 8 + select CLKSRC_MMIO 9 + select FORCE_PCI if PCCARD 10 + select GPIOLIB 11 + help 12 + Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx) 13 + 2 14 if ARCH_OMAP1 3 15 4 16 menu "TI OMAP1 specific features" ··· 18 6 comment "OMAP Core Type" 19 7 20 8 config ARCH_OMAP730 9 + depends on ARCH_MULTI_V5 21 10 bool "OMAP730 Based System" 22 11 select ARCH_OMAP_OTG 23 12 select CPU_ARM926T 24 13 select OMAP_MPU_TIMER 25 14 26 15 config ARCH_OMAP850 16 + depends on ARCH_MULTI_V5 27 17 bool "OMAP850 Based System" 28 18 select ARCH_OMAP_OTG 29 19 select CPU_ARM926T 30 20 31 21 config ARCH_OMAP15XX 22 + depends on ARCH_MULTI_V4T 32 23 default y 33 24 bool "OMAP15xx Based System" 34 25 select CPU_ARM925T 35 26 select OMAP_MPU_TIMER 36 27 37 28 config ARCH_OMAP16XX 29 + depends on ARCH_MULTI_V5 38 30 bool "OMAP16xx Based System" 39 31 select ARCH_OMAP_OTG 40 32 select CPU_ARM926T
+300 -393
arch/arm/mach-omap1/clock.c
··· 16 16 #include <linux/io.h> 17 17 #include <linux/clk.h> 18 18 #include <linux/clkdev.h> 19 + #include <linux/clk-provider.h> 19 20 #include <linux/soc/ti/omap1-io.h> 21 + #include <linux/spinlock.h> 20 22 21 23 #include <asm/mach-types.h> 22 24 ··· 30 28 #include "sram.h" 31 29 32 30 __u32 arm_idlect1_mask; 33 - struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p; 31 + /* provide direct internal access (not via clk API) to some clocks */ 32 + struct omap1_clk *api_ck_p, *ck_dpll1_p, *ck_ref_p; 34 33 35 - static LIST_HEAD(clocks); 36 - static DEFINE_MUTEX(clocks_mutex); 37 - static DEFINE_SPINLOCK(clockfw_lock); 34 + /* protect registeres shared among clk_enable/disable() and clk_set_rate() operations */ 35 + static DEFINE_SPINLOCK(arm_ckctl_lock); 36 + static DEFINE_SPINLOCK(arm_idlect2_lock); 37 + static DEFINE_SPINLOCK(mod_conf_ctrl_0_lock); 38 + static DEFINE_SPINLOCK(mod_conf_ctrl_1_lock); 39 + static DEFINE_SPINLOCK(swd_clk_div_ctrl_sel_lock); 38 40 39 41 /* 40 42 * Omap1 specific clock functions 41 43 */ 42 44 43 - unsigned long omap1_uart_recalc(struct clk *clk) 45 + unsigned long omap1_uart_recalc(struct omap1_clk *clk, unsigned long p_rate) 44 46 { 45 47 unsigned int val = __raw_readl(clk->enable_reg); 46 48 return val & 1 << clk->enable_bit ? 48000000 : 12000000; 47 49 } 48 50 49 - unsigned long omap1_sossi_recalc(struct clk *clk) 51 + unsigned long omap1_sossi_recalc(struct omap1_clk *clk, unsigned long p_rate) 50 52 { 51 53 u32 div = omap_readl(MOD_CONF_CTRL_1); 52 54 53 55 div = (div >> 17) & 0x7; 54 56 div++; 55 57 56 - return clk->parent->rate / div; 58 + return p_rate / div; 57 59 } 58 60 59 - static void omap1_clk_allow_idle(struct clk *clk) 61 + static void omap1_clk_allow_idle(struct omap1_clk *clk) 60 62 { 61 63 struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk; 62 64 ··· 71 65 arm_idlect1_mask |= 1 << iclk->idlect_shift; 72 66 } 73 67 74 - static void omap1_clk_deny_idle(struct clk *clk) 68 + static void omap1_clk_deny_idle(struct omap1_clk *clk) 75 69 { 76 70 struct arm_idlect1_clk * iclk = (struct arm_idlect1_clk *)clk; 77 71 ··· 135 129 return newval; 136 130 } 137 131 138 - static int calc_dsor_exp(struct clk *clk, unsigned long rate) 132 + static int calc_dsor_exp(unsigned long rate, unsigned long realrate) 139 133 { 140 134 /* Note: If target frequency is too low, this function will return 4, 141 135 * which is invalid value. Caller must check for this value and act ··· 148 142 * DSP_CK >= TC_CK 149 143 * DSPMMU_CK >= TC_CK 150 144 */ 151 - unsigned long realrate; 152 - struct clk * parent; 153 145 unsigned dsor_exp; 154 146 155 - parent = clk->parent; 156 - if (unlikely(parent == NULL)) 147 + if (unlikely(realrate == 0)) 157 148 return -EIO; 158 149 159 - realrate = parent->rate; 160 150 for (dsor_exp=0; dsor_exp<4; dsor_exp++) { 161 151 if (realrate <= rate) 162 152 break; ··· 163 161 return dsor_exp; 164 162 } 165 163 166 - unsigned long omap1_ckctl_recalc(struct clk *clk) 164 + unsigned long omap1_ckctl_recalc(struct omap1_clk *clk, unsigned long p_rate) 167 165 { 168 166 /* Calculate divisor encoded as 2-bit exponent */ 169 167 int dsor = 1 << (3 & (omap_readw(ARM_CKCTL) >> clk->rate_offset)); 170 168 171 - return clk->parent->rate / dsor; 169 + /* update locally maintained rate, required by arm_ck for omap1_show_rates() */ 170 + clk->rate = p_rate / dsor; 171 + return clk->rate; 172 172 } 173 173 174 - unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk) 174 + static int omap1_clk_is_enabled(struct clk_hw *hw) 175 175 { 176 + struct omap1_clk *clk = to_omap1_clk(hw); 177 + bool api_ck_was_enabled = true; 178 + __u32 regval32; 179 + int ret; 180 + 181 + if (!clk->ops) /* no gate -- always enabled */ 182 + return 1; 183 + 184 + if (clk->ops == &clkops_dspck) { 185 + api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw); 186 + if (!api_ck_was_enabled) 187 + if (api_ck_p->ops->enable(api_ck_p) < 0) 188 + return 0; 189 + } 190 + 191 + if (clk->flags & ENABLE_REG_32BIT) 192 + regval32 = __raw_readl(clk->enable_reg); 193 + else 194 + regval32 = __raw_readw(clk->enable_reg); 195 + 196 + ret = regval32 & (1 << clk->enable_bit); 197 + 198 + if (!api_ck_was_enabled) 199 + api_ck_p->ops->disable(api_ck_p); 200 + 201 + return ret; 202 + } 203 + 204 + 205 + unsigned long omap1_ckctl_recalc_dsp_domain(struct omap1_clk *clk, unsigned long p_rate) 206 + { 207 + bool api_ck_was_enabled; 176 208 int dsor; 177 209 178 210 /* Calculate divisor encoded as 2-bit exponent ··· 216 180 * Note that DSP_CKCTL virt addr = phys addr, so 217 181 * we must use __raw_readw() instead of omap_readw(). 218 182 */ 219 - omap1_clk_enable(api_ck_p); 183 + api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw); 184 + if (!api_ck_was_enabled) 185 + api_ck_p->ops->enable(api_ck_p); 220 186 dsor = 1 << (3 & (__raw_readw(DSP_CKCTL) >> clk->rate_offset)); 221 - omap1_clk_disable(api_ck_p); 187 + if (!api_ck_was_enabled) 188 + api_ck_p->ops->disable(api_ck_p); 222 189 223 - return clk->parent->rate / dsor; 190 + return p_rate / dsor; 224 191 } 225 192 226 193 /* MPU virtual clock functions */ 227 - int omap1_select_table_rate(struct clk *clk, unsigned long rate) 194 + int omap1_select_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 228 195 { 229 196 /* Find the highest supported frequency <= rate and switch to it */ 230 197 struct mpu_rate * ptr; ··· 262 223 return 0; 263 224 } 264 225 265 - int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate) 226 + int omap1_clk_set_rate_dsp_domain(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 266 227 { 267 228 int dsor_exp; 268 229 u16 regval; 269 230 270 - dsor_exp = calc_dsor_exp(clk, rate); 231 + dsor_exp = calc_dsor_exp(rate, p_rate); 271 232 if (dsor_exp > 3) 272 233 dsor_exp = -EINVAL; 273 234 if (dsor_exp < 0) ··· 277 238 regval &= ~(3 << clk->rate_offset); 278 239 regval |= dsor_exp << clk->rate_offset; 279 240 __raw_writew(regval, DSP_CKCTL); 280 - clk->rate = clk->parent->rate / (1 << dsor_exp); 241 + clk->rate = p_rate / (1 << dsor_exp); 281 242 282 243 return 0; 283 244 } 284 245 285 - long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate) 246 + long omap1_clk_round_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, 247 + unsigned long *p_rate) 286 248 { 287 - int dsor_exp = calc_dsor_exp(clk, rate); 249 + int dsor_exp = calc_dsor_exp(rate, *p_rate); 250 + 288 251 if (dsor_exp < 0) 289 252 return dsor_exp; 290 253 if (dsor_exp > 3) 291 254 dsor_exp = 3; 292 - return clk->parent->rate / (1 << dsor_exp); 255 + return *p_rate / (1 << dsor_exp); 293 256 } 294 257 295 - int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate) 258 + int omap1_clk_set_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 296 259 { 260 + unsigned long flags; 297 261 int dsor_exp; 298 262 u16 regval; 299 263 300 - dsor_exp = calc_dsor_exp(clk, rate); 264 + dsor_exp = calc_dsor_exp(rate, p_rate); 301 265 if (dsor_exp > 3) 302 266 dsor_exp = -EINVAL; 303 267 if (dsor_exp < 0) 304 268 return dsor_exp; 269 + 270 + /* protect ARM_CKCTL register from concurrent access via clk_enable/disable() */ 271 + spin_lock_irqsave(&arm_ckctl_lock, flags); 305 272 306 273 regval = omap_readw(ARM_CKCTL); 307 274 regval &= ~(3 << clk->rate_offset); 308 275 regval |= dsor_exp << clk->rate_offset; 309 276 regval = verify_ckctl_value(regval); 310 277 omap_writew(regval, ARM_CKCTL); 311 - clk->rate = clk->parent->rate / (1 << dsor_exp); 278 + clk->rate = p_rate / (1 << dsor_exp); 279 + 280 + spin_unlock_irqrestore(&arm_ckctl_lock, flags); 281 + 312 282 return 0; 313 283 } 314 284 315 - long omap1_round_to_table_rate(struct clk *clk, unsigned long rate) 285 + long omap1_round_to_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate) 316 286 { 317 287 /* Find the highest supported frequency <= rate */ 318 288 struct mpu_rate * ptr; ··· 372 324 } 373 325 374 326 /* XXX Only needed on 1510 */ 375 - int omap1_set_uart_rate(struct clk *clk, unsigned long rate) 327 + long omap1_round_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate) 376 328 { 329 + return rate > 24000000 ? 48000000 : 12000000; 330 + } 331 + 332 + int omap1_set_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 333 + { 334 + unsigned long flags; 377 335 unsigned int val; 378 336 379 - val = __raw_readl(clk->enable_reg); 380 337 if (rate == 12000000) 381 - val &= ~(1 << clk->enable_bit); 338 + val = 0; 382 339 else if (rate == 48000000) 383 - val |= (1 << clk->enable_bit); 340 + val = 1 << clk->enable_bit; 384 341 else 385 342 return -EINVAL; 343 + 344 + /* protect MOD_CONF_CTRL_0 register from concurrent access via clk_enable/disable() */ 345 + spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags); 346 + 347 + val |= __raw_readl(clk->enable_reg) & ~(1 << clk->enable_bit); 386 348 __raw_writel(val, clk->enable_reg); 349 + 350 + spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags); 351 + 387 352 clk->rate = rate; 388 353 389 354 return 0; 390 355 } 391 356 392 357 /* External clock (MCLK & BCLK) functions */ 393 - int omap1_set_ext_clk_rate(struct clk *clk, unsigned long rate) 358 + int omap1_set_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 394 359 { 360 + unsigned long flags; 395 361 unsigned dsor; 396 362 __u16 ratio_bits; 397 363 ··· 416 354 else 417 355 ratio_bits = (dsor - 2) << 2; 418 356 357 + /* protect SWD_CLK_DIV_CTRL_SEL register from concurrent access via clk_enable/disable() */ 358 + spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags); 359 + 419 360 ratio_bits |= __raw_readw(clk->enable_reg) & ~0xfd; 420 361 __raw_writew(ratio_bits, clk->enable_reg); 362 + 363 + spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags); 421 364 422 365 return 0; 423 366 } 424 367 425 - int omap1_set_sossi_rate(struct clk *clk, unsigned long rate) 368 + static int calc_div_sossi(unsigned long rate, unsigned long p_rate) 426 369 { 427 - u32 l; 428 370 int div; 429 - unsigned long p_rate; 430 371 431 - p_rate = clk->parent->rate; 432 372 /* Round towards slower frequency */ 433 373 div = (p_rate + rate - 1) / rate; 434 - div--; 374 + 375 + return --div; 376 + } 377 + 378 + long omap1_round_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate) 379 + { 380 + int div; 381 + 382 + div = calc_div_sossi(rate, *p_rate); 383 + if (div < 0) 384 + div = 0; 385 + else if (div > 7) 386 + div = 7; 387 + 388 + return *p_rate / (div + 1); 389 + } 390 + 391 + int omap1_set_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate) 392 + { 393 + unsigned long flags; 394 + u32 l; 395 + int div; 396 + 397 + div = calc_div_sossi(rate, p_rate); 435 398 if (div < 0 || div > 7) 436 399 return -EINVAL; 400 + 401 + /* protect MOD_CONF_CTRL_1 register from concurrent access via clk_enable/disable() */ 402 + spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags); 437 403 438 404 l = omap_readl(MOD_CONF_CTRL_1); 439 405 l &= ~(7 << 17); ··· 470 380 471 381 clk->rate = p_rate / (div + 1); 472 382 383 + spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags); 384 + 473 385 return 0; 474 386 } 475 387 476 - long omap1_round_ext_clk_rate(struct clk *clk, unsigned long rate) 388 + long omap1_round_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate) 477 389 { 478 390 return 96000000 / calc_ext_dsor(rate); 479 391 } 480 392 481 - void omap1_init_ext_clk(struct clk *clk) 393 + int omap1_init_ext_clk(struct omap1_clk *clk) 482 394 { 483 395 unsigned dsor; 484 396 __u16 ratio_bits; ··· 496 404 dsor = ratio_bits + 2; 497 405 498 406 clk-> rate = 96000000 / dsor; 407 + 408 + return 0; 499 409 } 500 410 501 - int omap1_clk_enable(struct clk *clk) 411 + static int omap1_clk_enable(struct clk_hw *hw) 502 412 { 413 + struct omap1_clk *clk = to_omap1_clk(hw), *parent = to_omap1_clk(clk_hw_get_parent(hw)); 503 414 int ret = 0; 504 415 505 - if (clk->usecount++ == 0) { 506 - if (clk->parent) { 507 - ret = omap1_clk_enable(clk->parent); 508 - if (ret) 509 - goto err; 416 + if (parent && clk->flags & CLOCK_NO_IDLE_PARENT) 417 + omap1_clk_deny_idle(parent); 510 418 511 - if (clk->flags & CLOCK_NO_IDLE_PARENT) 512 - omap1_clk_deny_idle(clk->parent); 513 - } 514 - 419 + if (clk->ops && !(WARN_ON(!clk->ops->enable))) 515 420 ret = clk->ops->enable(clk); 516 - if (ret) { 517 - if (clk->parent) 518 - omap1_clk_disable(clk->parent); 519 - goto err; 520 - } 521 - } 522 - return ret; 523 421 524 - err: 525 - clk->usecount--; 526 422 return ret; 527 423 } 528 424 529 - void omap1_clk_disable(struct clk *clk) 425 + static void omap1_clk_disable(struct clk_hw *hw) 530 426 { 531 - if (clk->usecount > 0 && !(--clk->usecount)) { 427 + struct omap1_clk *clk = to_omap1_clk(hw), *parent = to_omap1_clk(clk_hw_get_parent(hw)); 428 + 429 + if (clk->ops && !(WARN_ON(!clk->ops->disable))) 532 430 clk->ops->disable(clk); 533 - if (likely(clk->parent)) { 534 - omap1_clk_disable(clk->parent); 535 - if (clk->flags & CLOCK_NO_IDLE_PARENT) 536 - omap1_clk_allow_idle(clk->parent); 537 - } 538 - } 431 + 432 + if (likely(parent) && clk->flags & CLOCK_NO_IDLE_PARENT) 433 + omap1_clk_allow_idle(parent); 539 434 } 540 435 541 - static int omap1_clk_enable_generic(struct clk *clk) 436 + static int omap1_clk_enable_generic(struct omap1_clk *clk) 542 437 { 438 + unsigned long flags; 543 439 __u16 regval16; 544 440 __u32 regval32; 545 441 546 442 if (unlikely(clk->enable_reg == NULL)) { 547 443 printk(KERN_ERR "clock.c: Enable for %s without enable code\n", 548 - clk->name); 444 + clk_hw_get_name(&clk->hw)); 549 445 return -EINVAL; 550 446 } 447 + 448 + /* protect clk->enable_reg from concurrent access via clk_set_rate() */ 449 + if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL)) 450 + spin_lock_irqsave(&arm_ckctl_lock, flags); 451 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2)) 452 + spin_lock_irqsave(&arm_idlect2_lock, flags); 453 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0)) 454 + spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags); 455 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1)) 456 + spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags); 457 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL)) 458 + spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags); 551 459 552 460 if (clk->flags & ENABLE_REG_32BIT) { 553 461 regval32 = __raw_readl(clk->enable_reg); ··· 559 467 __raw_writew(regval16, clk->enable_reg); 560 468 } 561 469 470 + if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL)) 471 + spin_unlock_irqrestore(&arm_ckctl_lock, flags); 472 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2)) 473 + spin_unlock_irqrestore(&arm_idlect2_lock, flags); 474 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0)) 475 + spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags); 476 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1)) 477 + spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags); 478 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL)) 479 + spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags); 480 + 562 481 return 0; 563 482 } 564 483 565 - static void omap1_clk_disable_generic(struct clk *clk) 484 + static void omap1_clk_disable_generic(struct omap1_clk *clk) 566 485 { 486 + unsigned long flags; 567 487 __u16 regval16; 568 488 __u32 regval32; 569 489 570 490 if (clk->enable_reg == NULL) 571 491 return; 492 + 493 + /* protect clk->enable_reg from concurrent access via clk_set_rate() */ 494 + if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL)) 495 + spin_lock_irqsave(&arm_ckctl_lock, flags); 496 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2)) 497 + spin_lock_irqsave(&arm_idlect2_lock, flags); 498 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0)) 499 + spin_lock_irqsave(&mod_conf_ctrl_0_lock, flags); 500 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1)) 501 + spin_lock_irqsave(&mod_conf_ctrl_1_lock, flags); 502 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL)) 503 + spin_lock_irqsave(&swd_clk_div_ctrl_sel_lock, flags); 572 504 573 505 if (clk->flags & ENABLE_REG_32BIT) { 574 506 regval32 = __raw_readl(clk->enable_reg); ··· 603 487 regval16 &= ~(1 << clk->enable_bit); 604 488 __raw_writew(regval16, clk->enable_reg); 605 489 } 490 + 491 + if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_CKCTL)) 492 + spin_unlock_irqrestore(&arm_ckctl_lock, flags); 493 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(ARM_IDLECT2)) 494 + spin_unlock_irqrestore(&arm_idlect2_lock, flags); 495 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0)) 496 + spin_unlock_irqrestore(&mod_conf_ctrl_0_lock, flags); 497 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1)) 498 + spin_unlock_irqrestore(&mod_conf_ctrl_1_lock, flags); 499 + else if (clk->enable_reg == OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL)) 500 + spin_unlock_irqrestore(&swd_clk_div_ctrl_sel_lock, flags); 606 501 } 607 502 608 503 const struct clkops clkops_generic = { ··· 621 494 .disable = omap1_clk_disable_generic, 622 495 }; 623 496 624 - static int omap1_clk_enable_dsp_domain(struct clk *clk) 497 + static int omap1_clk_enable_dsp_domain(struct omap1_clk *clk) 625 498 { 626 - int retval; 499 + bool api_ck_was_enabled; 500 + int retval = 0; 627 501 628 - retval = omap1_clk_enable(api_ck_p); 502 + api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw); 503 + if (!api_ck_was_enabled) 504 + retval = api_ck_p->ops->enable(api_ck_p); 505 + 629 506 if (!retval) { 630 507 retval = omap1_clk_enable_generic(clk); 631 - omap1_clk_disable(api_ck_p); 508 + 509 + if (!api_ck_was_enabled) 510 + api_ck_p->ops->disable(api_ck_p); 632 511 } 633 512 634 513 return retval; 635 514 } 636 515 637 - static void omap1_clk_disable_dsp_domain(struct clk *clk) 516 + static void omap1_clk_disable_dsp_domain(struct omap1_clk *clk) 638 517 { 639 - if (omap1_clk_enable(api_ck_p) == 0) { 640 - omap1_clk_disable_generic(clk); 641 - omap1_clk_disable(api_ck_p); 642 - } 518 + bool api_ck_was_enabled; 519 + 520 + api_ck_was_enabled = omap1_clk_is_enabled(&api_ck_p->hw); 521 + if (!api_ck_was_enabled) 522 + if (api_ck_p->ops->enable(api_ck_p) < 0) 523 + return; 524 + 525 + omap1_clk_disable_generic(clk); 526 + 527 + if (!api_ck_was_enabled) 528 + api_ck_p->ops->disable(api_ck_p); 643 529 } 644 530 645 531 const struct clkops clkops_dspck = { ··· 661 521 }; 662 522 663 523 /* XXX SYSC register handling does not belong in the clock framework */ 664 - static int omap1_clk_enable_uart_functional_16xx(struct clk *clk) 524 + static int omap1_clk_enable_uart_functional_16xx(struct omap1_clk *clk) 665 525 { 666 526 int ret; 667 527 struct uart_clk *uclk; ··· 678 538 } 679 539 680 540 /* XXX SYSC register handling does not belong in the clock framework */ 681 - static void omap1_clk_disable_uart_functional_16xx(struct clk *clk) 541 + static void omap1_clk_disable_uart_functional_16xx(struct omap1_clk *clk) 682 542 { 683 543 struct uart_clk *uclk; 684 544 ··· 695 555 .disable = omap1_clk_disable_uart_functional_16xx, 696 556 }; 697 557 698 - long omap1_clk_round_rate(struct clk *clk, unsigned long rate) 558 + static unsigned long omap1_clk_recalc_rate(struct clk_hw *hw, unsigned long p_rate) 699 559 { 700 - if (clk->round_rate != NULL) 701 - return clk->round_rate(clk, rate); 560 + struct omap1_clk *clk = to_omap1_clk(hw); 561 + 562 + if (clk->recalc) 563 + return clk->recalc(clk, p_rate); 702 564 703 565 return clk->rate; 704 566 } 705 567 706 - int omap1_clk_set_rate(struct clk *clk, unsigned long rate) 568 + static long omap1_clk_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *p_rate) 707 569 { 570 + struct omap1_clk *clk = to_omap1_clk(hw); 571 + 572 + if (clk->round_rate != NULL) 573 + return clk->round_rate(clk, rate, p_rate); 574 + 575 + return omap1_clk_recalc_rate(hw, *p_rate); 576 + } 577 + 578 + static int omap1_clk_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long p_rate) 579 + { 580 + struct omap1_clk *clk = to_omap1_clk(hw); 708 581 int ret = -EINVAL; 709 582 710 583 if (clk->set_rate) 711 - ret = clk->set_rate(clk, rate); 584 + ret = clk->set_rate(clk, rate, p_rate); 712 585 return ret; 713 586 } 714 587 ··· 729 576 * Omap1 clock reset and init functions 730 577 */ 731 578 579 + static int omap1_clk_init_op(struct clk_hw *hw) 580 + { 581 + struct omap1_clk *clk = to_omap1_clk(hw); 582 + 583 + if (clk->init) 584 + return clk->init(clk); 585 + 586 + return 0; 587 + } 588 + 732 589 #ifdef CONFIG_OMAP_RESET_CLOCKS 733 590 734 - void omap1_clk_disable_unused(struct clk *clk) 591 + static void omap1_clk_disable_unused(struct clk_hw *hw) 735 592 { 736 - __u32 regval32; 593 + struct omap1_clk *clk = to_omap1_clk(hw); 594 + const char *name = clk_hw_get_name(hw); 737 595 738 596 /* Clocks in the DSP domain need api_ck. Just assume bootloader 739 597 * has not enabled any DSP clocks */ 740 598 if (clk->enable_reg == DSP_IDLECT2) { 741 - pr_info("Skipping reset check for DSP domain clock \"%s\"\n", 742 - clk->name); 599 + pr_info("Skipping reset check for DSP domain clock \"%s\"\n", name); 743 600 return; 744 601 } 745 602 746 - /* Is the clock already disabled? */ 747 - if (clk->flags & ENABLE_REG_32BIT) 748 - regval32 = __raw_readl(clk->enable_reg); 749 - else 750 - regval32 = __raw_readw(clk->enable_reg); 751 - 752 - if ((regval32 & (1 << clk->enable_bit)) == 0) 753 - return; 754 - 755 - printk(KERN_INFO "Disabling unused clock \"%s\"... ", clk->name); 756 - clk->ops->disable(clk); 603 + pr_info("Disabling unused clock \"%s\"... ", name); 604 + omap1_clk_disable(hw); 757 605 printk(" done\n"); 758 606 } 759 607 760 608 #endif 761 609 610 + const struct clk_ops omap1_clk_gate_ops = { 611 + .enable = omap1_clk_enable, 612 + .disable = omap1_clk_disable, 613 + .is_enabled = omap1_clk_is_enabled, 614 + #ifdef CONFIG_OMAP_RESET_CLOCKS 615 + .disable_unused = omap1_clk_disable_unused, 616 + #endif 617 + }; 762 618 763 - int clk_enable(struct clk *clk) 764 - { 765 - unsigned long flags; 766 - int ret; 619 + const struct clk_ops omap1_clk_rate_ops = { 620 + .recalc_rate = omap1_clk_recalc_rate, 621 + .round_rate = omap1_clk_round_rate, 622 + .set_rate = omap1_clk_set_rate, 623 + .init = omap1_clk_init_op, 624 + }; 767 625 768 - if (IS_ERR_OR_NULL(clk)) 769 - return -EINVAL; 770 - 771 - spin_lock_irqsave(&clockfw_lock, flags); 772 - ret = omap1_clk_enable(clk); 773 - spin_unlock_irqrestore(&clockfw_lock, flags); 774 - 775 - return ret; 776 - } 777 - EXPORT_SYMBOL(clk_enable); 778 - 779 - void clk_disable(struct clk *clk) 780 - { 781 - unsigned long flags; 782 - 783 - if (IS_ERR_OR_NULL(clk)) 784 - return; 785 - 786 - spin_lock_irqsave(&clockfw_lock, flags); 787 - if (clk->usecount == 0) { 788 - pr_err("Trying disable clock %s with 0 usecount\n", 789 - clk->name); 790 - WARN_ON(1); 791 - goto out; 792 - } 793 - 794 - omap1_clk_disable(clk); 795 - 796 - out: 797 - spin_unlock_irqrestore(&clockfw_lock, flags); 798 - } 799 - EXPORT_SYMBOL(clk_disable); 800 - 801 - unsigned long clk_get_rate(struct clk *clk) 802 - { 803 - unsigned long flags; 804 - unsigned long ret; 805 - 806 - if (IS_ERR_OR_NULL(clk)) 807 - return 0; 808 - 809 - spin_lock_irqsave(&clockfw_lock, flags); 810 - ret = clk->rate; 811 - spin_unlock_irqrestore(&clockfw_lock, flags); 812 - 813 - return ret; 814 - } 815 - EXPORT_SYMBOL(clk_get_rate); 816 - 817 - /* 818 - * Optional clock functions defined in include/linux/clk.h 819 - */ 820 - 821 - long clk_round_rate(struct clk *clk, unsigned long rate) 822 - { 823 - unsigned long flags; 824 - long ret; 825 - 826 - if (IS_ERR_OR_NULL(clk)) 827 - return 0; 828 - 829 - spin_lock_irqsave(&clockfw_lock, flags); 830 - ret = omap1_clk_round_rate(clk, rate); 831 - spin_unlock_irqrestore(&clockfw_lock, flags); 832 - 833 - return ret; 834 - } 835 - EXPORT_SYMBOL(clk_round_rate); 836 - 837 - int clk_set_rate(struct clk *clk, unsigned long rate) 838 - { 839 - unsigned long flags; 840 - int ret = -EINVAL; 841 - 842 - if (IS_ERR_OR_NULL(clk)) 843 - return ret; 844 - 845 - spin_lock_irqsave(&clockfw_lock, flags); 846 - ret = omap1_clk_set_rate(clk, rate); 847 - if (ret == 0) 848 - propagate_rate(clk); 849 - spin_unlock_irqrestore(&clockfw_lock, flags); 850 - 851 - return ret; 852 - } 853 - EXPORT_SYMBOL(clk_set_rate); 854 - 855 - int clk_set_parent(struct clk *clk, struct clk *parent) 856 - { 857 - WARN_ONCE(1, "clk_set_parent() not implemented for OMAP1\n"); 858 - 859 - return -EINVAL; 860 - } 861 - EXPORT_SYMBOL(clk_set_parent); 862 - 863 - struct clk *clk_get_parent(struct clk *clk) 864 - { 865 - return clk->parent; 866 - } 867 - EXPORT_SYMBOL(clk_get_parent); 626 + const struct clk_ops omap1_clk_full_ops = { 627 + .enable = omap1_clk_enable, 628 + .disable = omap1_clk_disable, 629 + .is_enabled = omap1_clk_is_enabled, 630 + #ifdef CONFIG_OMAP_RESET_CLOCKS 631 + .disable_unused = omap1_clk_disable_unused, 632 + #endif 633 + .recalc_rate = omap1_clk_recalc_rate, 634 + .round_rate = omap1_clk_round_rate, 635 + .set_rate = omap1_clk_set_rate, 636 + .init = omap1_clk_init_op, 637 + }; 868 638 869 639 /* 870 640 * OMAP specific clock functions shared between omap1 and omap2 871 641 */ 872 642 873 643 /* Used for clocks that always have same value as the parent clock */ 874 - unsigned long followparent_recalc(struct clk *clk) 644 + unsigned long followparent_recalc(struct omap1_clk *clk, unsigned long p_rate) 875 645 { 876 - return clk->parent->rate; 646 + return p_rate; 877 647 } 878 648 879 649 /* 880 650 * Used for clocks that have the same value as the parent clock, 881 651 * divided by some factor 882 652 */ 883 - unsigned long omap_fixed_divisor_recalc(struct clk *clk) 653 + unsigned long omap_fixed_divisor_recalc(struct omap1_clk *clk, unsigned long p_rate) 884 654 { 885 655 WARN_ON(!clk->fixed_div); 886 656 887 - return clk->parent->rate / clk->fixed_div; 657 + return p_rate / clk->fixed_div; 888 658 } 889 659 890 660 /* Propagate rate to children */ 891 - void propagate_rate(struct clk *tclk) 661 + void propagate_rate(struct omap1_clk *tclk) 892 662 { 893 663 struct clk *clkp; 894 664 895 - list_for_each_entry(clkp, &tclk->children, sibling) { 896 - if (clkp->recalc) 897 - clkp->rate = clkp->recalc(clkp); 898 - propagate_rate(clkp); 899 - } 900 - } 901 - 902 - static LIST_HEAD(root_clks); 903 - 904 - /** 905 - * clk_preinit - initialize any fields in the struct clk before clk init 906 - * @clk: struct clk * to initialize 907 - * 908 - * Initialize any struct clk fields needed before normal clk initialization 909 - * can run. No return value. 910 - */ 911 - void clk_preinit(struct clk *clk) 912 - { 913 - INIT_LIST_HEAD(&clk->children); 914 - } 915 - 916 - int clk_register(struct clk *clk) 917 - { 918 - if (IS_ERR_OR_NULL(clk)) 919 - return -EINVAL; 920 - 921 - /* 922 - * trap out already registered clocks 923 - */ 924 - if (clk->node.next || clk->node.prev) 925 - return 0; 926 - 927 - mutex_lock(&clocks_mutex); 928 - if (clk->parent) 929 - list_add(&clk->sibling, &clk->parent->children); 930 - else 931 - list_add(&clk->sibling, &root_clks); 932 - 933 - list_add(&clk->node, &clocks); 934 - if (clk->init) 935 - clk->init(clk); 936 - mutex_unlock(&clocks_mutex); 937 - 938 - return 0; 939 - } 940 - EXPORT_SYMBOL(clk_register); 941 - 942 - void clk_unregister(struct clk *clk) 943 - { 944 - if (IS_ERR_OR_NULL(clk)) 665 + /* depend on CCF ability to recalculate new rates across whole clock subtree */ 666 + if (WARN_ON(!(clk_hw_get_flags(&tclk->hw) & CLK_GET_RATE_NOCACHE))) 945 667 return; 946 668 947 - mutex_lock(&clocks_mutex); 948 - list_del(&clk->sibling); 949 - list_del(&clk->node); 950 - mutex_unlock(&clocks_mutex); 951 - } 952 - EXPORT_SYMBOL(clk_unregister); 669 + clkp = clk_get_sys(NULL, clk_hw_get_name(&tclk->hw)); 670 + if (WARN_ON(!clkp)) 671 + return; 953 672 954 - /* 955 - * Low level helpers 956 - */ 957 - static int clkll_enable_null(struct clk *clk) 958 - { 959 - return 0; 673 + clk_get_rate(clkp); 674 + clk_put(clkp); 960 675 } 961 676 962 - static void clkll_disable_null(struct clk *clk) 963 - { 964 - } 965 - 966 - const struct clkops clkops_null = { 967 - .enable = clkll_enable_null, 968 - .disable = clkll_disable_null, 677 + const struct clk_ops omap1_clk_null_ops = { 969 678 }; 970 679 971 680 /* ··· 835 820 * 836 821 * Used for clock aliases that are needed on some OMAPs, but not others 837 822 */ 838 - struct clk dummy_ck = { 839 - .name = "dummy", 840 - .ops = &clkops_null, 823 + struct omap1_clk dummy_ck __refdata = { 824 + .hw.init = CLK_HW_INIT_NO_PARENT("dummy", &omap1_clk_null_ops, 0), 841 825 }; 842 - 843 - /* 844 - * 845 - */ 846 - 847 - #ifdef CONFIG_OMAP_RESET_CLOCKS 848 - /* 849 - * Disable any unused clocks left on by the bootloader 850 - */ 851 - static int __init clk_disable_unused(void) 852 - { 853 - struct clk *ck; 854 - unsigned long flags; 855 - 856 - pr_info("clock: disabling unused clocks to save power\n"); 857 - 858 - spin_lock_irqsave(&clockfw_lock, flags); 859 - list_for_each_entry(ck, &clocks, node) { 860 - if (ck->ops == &clkops_null) 861 - continue; 862 - 863 - if (ck->usecount > 0 || !ck->enable_reg) 864 - continue; 865 - 866 - omap1_clk_disable_unused(ck); 867 - } 868 - spin_unlock_irqrestore(&clockfw_lock, flags); 869 - 870 - return 0; 871 - } 872 - late_initcall(clk_disable_unused); 873 - #endif 874 - 875 - #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 876 - /* 877 - * debugfs support to trace clock tree hierarchy and attributes 878 - */ 879 - 880 - #include <linux/debugfs.h> 881 - #include <linux/seq_file.h> 882 - 883 - static struct dentry *clk_debugfs_root; 884 - 885 - static int debug_clock_show(struct seq_file *s, void *unused) 886 - { 887 - struct clk *c; 888 - struct clk *pa; 889 - 890 - mutex_lock(&clocks_mutex); 891 - seq_printf(s, "%-30s %-30s %-10s %s\n", 892 - "clock-name", "parent-name", "rate", "use-count"); 893 - 894 - list_for_each_entry(c, &clocks, node) { 895 - pa = c->parent; 896 - seq_printf(s, "%-30s %-30s %-10lu %d\n", 897 - c->name, pa ? pa->name : "none", c->rate, 898 - c->usecount); 899 - } 900 - mutex_unlock(&clocks_mutex); 901 - 902 - return 0; 903 - } 904 - 905 - DEFINE_SHOW_ATTRIBUTE(debug_clock); 906 - 907 - static void clk_debugfs_register_one(struct clk *c) 908 - { 909 - struct dentry *d; 910 - struct clk *pa = c->parent; 911 - 912 - d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root); 913 - c->dent = d; 914 - 915 - debugfs_create_u8("usecount", S_IRUGO, c->dent, &c->usecount); 916 - debugfs_create_ulong("rate", S_IRUGO, c->dent, &c->rate); 917 - debugfs_create_x8("flags", S_IRUGO, c->dent, &c->flags); 918 - } 919 - 920 - static void clk_debugfs_register(struct clk *c) 921 - { 922 - struct clk *pa = c->parent; 923 - 924 - if (pa && !pa->dent) 925 - clk_debugfs_register(pa); 926 - 927 - if (!c->dent) 928 - clk_debugfs_register_one(c); 929 - } 930 - 931 - static int __init clk_debugfs_init(void) 932 - { 933 - struct clk *c; 934 - struct dentry *d; 935 - 936 - d = debugfs_create_dir("clock", NULL); 937 - clk_debugfs_root = d; 938 - 939 - list_for_each_entry(c, &clocks, node) 940 - clk_debugfs_register(c); 941 - 942 - debugfs_create_file("summary", S_IRUGO, d, NULL, &debug_clock_fops); 943 - 944 - return 0; 945 - } 946 - late_initcall(clk_debugfs_init); 947 - 948 - #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
+49 -90
arch/arm/mach-omap1/clock.h
··· 11 11 #define __ARCH_ARM_MACH_OMAP1_CLOCK_H 12 12 13 13 #include <linux/clk.h> 14 - #include <linux/list.h> 15 - 16 14 #include <linux/clkdev.h> 15 + #include <linux/clk-provider.h> 17 16 18 17 struct module; 19 - struct clk; 18 + struct omap1_clk; 20 19 21 20 struct omap_clk { 22 21 u16 cpu; ··· 28 29 .lk = { \ 29 30 .dev_id = dev, \ 30 31 .con_id = con, \ 31 - .clk = ck, \ 32 + .clk_hw = ck, \ 32 33 }, \ 33 34 } 34 35 ··· 39 40 #define CK_16XX (1 << 3) /* 16xx, 17xx, 5912 */ 40 41 #define CK_1710 (1 << 4) /* 1710 extra for rate selection */ 41 42 42 - 43 - /* Temporary, needed during the common clock framework conversion */ 44 - #define __clk_get_name(clk) (clk->name) 45 - 46 43 /** 47 44 * struct clkops - some clock function pointers 48 45 * @enable: fn ptr that enables the current clock in hardware ··· 46 51 * @allow_idle: fn ptr that enables autoidle for the current clock in hardware 47 52 */ 48 53 struct clkops { 49 - int (*enable)(struct clk *); 50 - void (*disable)(struct clk *); 54 + int (*enable)(struct omap1_clk *clk); 55 + void (*disable)(struct omap1_clk *clk); 51 56 }; 52 57 53 58 /* ··· 60 65 #define CLOCK_NO_IDLE_PARENT (1 << 2) 61 66 62 67 /** 63 - * struct clk - OMAP struct clk 64 - * @node: list_head connecting this clock into the full clock list 68 + * struct omap1_clk - OMAP1 struct clk 69 + * @hw: struct clk_hw for common clock framework integration 65 70 * @ops: struct clkops * for this clock 66 - * @name: the name of the clock in the hardware (used in hwmod data and debug) 67 - * @parent: pointer to this clock's parent struct clk 68 - * @children: list_head connecting to the child clks' @sibling list_heads 69 - * @sibling: list_head connecting this clk to its parent clk's @children 70 71 * @rate: current clock rate 71 72 * @enable_reg: register to write to enable the clock (see @enable_bit) 72 73 * @recalc: fn ptr that returns the clock's current rate ··· 70 79 * @round_rate: fn ptr that can round the clock's current rate 71 80 * @init: fn ptr to do clock-specific initialization 72 81 * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg) 73 - * @usecount: number of users that have requested this clock to be enabled 74 82 * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div 75 83 * @flags: see "struct clk.flags possibilities" above 76 84 * @rate_offset: bitshift for rate selection bitfield (OMAP1 only) 77 - * 78 - * XXX @rate_offset should probably be removed and OMAP1 79 - * clock code converted to use clksel. 80 - * 81 - * XXX @usecount is poorly named. It should be "enable_count" or 82 - * something similar. "users" in the description refers to kernel 83 - * code (core code or drivers) that have called clk_enable() and not 84 - * yet called clk_disable(); the usecount of parent clocks is also 85 - * incremented by the clock code when clk_enable() is called on child 86 - * clocks and decremented by the clock code when clk_disable() is 87 - * called on child clocks. 88 - * 89 - * XXX @usecount, @children, @sibling should be marked for 90 - * internal use only. 91 - * 92 - * @children and @sibling are used to optimize parent-to-child clock 93 - * tree traversals. (child-to-parent traversals use @parent.) 94 - * 95 - * XXX The notion of the clock's current rate probably needs to be 96 - * separated from the clock's target rate. 97 85 */ 98 - struct clk { 99 - struct list_head node; 86 + struct omap1_clk { 87 + struct clk_hw hw; 100 88 const struct clkops *ops; 101 - const char *name; 102 - struct clk *parent; 103 - struct list_head children; 104 - struct list_head sibling; /* node for children */ 105 89 unsigned long rate; 106 90 void __iomem *enable_reg; 107 - unsigned long (*recalc)(struct clk *); 108 - int (*set_rate)(struct clk *, unsigned long); 109 - long (*round_rate)(struct clk *, unsigned long); 110 - void (*init)(struct clk *); 91 + unsigned long (*recalc)(struct omap1_clk *clk, unsigned long rate); 92 + int (*set_rate)(struct omap1_clk *clk, unsigned long rate, 93 + unsigned long p_rate); 94 + long (*round_rate)(struct omap1_clk *clk, unsigned long rate, 95 + unsigned long *p_rate); 96 + int (*init)(struct omap1_clk *clk); 111 97 u8 enable_bit; 112 - s8 usecount; 113 98 u8 fixed_div; 114 99 u8 flags; 115 100 u8 rate_offset; 116 - #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) 117 - struct dentry *dent; /* For visible tree hierarchy */ 118 - #endif 119 101 }; 102 + #define to_omap1_clk(_hw) container_of(_hw, struct omap1_clk, hw) 120 103 121 - extern void clk_preinit(struct clk *clk); 122 - extern int clk_register(struct clk *clk); 123 - extern void clk_unregister(struct clk *clk); 124 - extern void propagate_rate(struct clk *clk); 125 - extern unsigned long followparent_recalc(struct clk *clk); 126 - unsigned long omap_fixed_divisor_recalc(struct clk *clk); 104 + void propagate_rate(struct omap1_clk *clk); 105 + unsigned long followparent_recalc(struct omap1_clk *clk, unsigned long p_rate); 106 + unsigned long omap_fixed_divisor_recalc(struct omap1_clk *clk, unsigned long p_rate); 127 107 128 - extern const struct clkops clkops_null; 129 - 130 - extern struct clk dummy_ck; 108 + extern struct omap1_clk dummy_ck; 131 109 132 110 int omap1_clk_init(void); 133 111 void omap1_clk_late_init(void); 134 - extern int omap1_clk_enable(struct clk *clk); 135 - extern void omap1_clk_disable(struct clk *clk); 136 - extern long omap1_clk_round_rate(struct clk *clk, unsigned long rate); 137 - extern int omap1_clk_set_rate(struct clk *clk, unsigned long rate); 138 - extern unsigned long omap1_ckctl_recalc(struct clk *clk); 139 - extern int omap1_set_sossi_rate(struct clk *clk, unsigned long rate); 140 - extern unsigned long omap1_sossi_recalc(struct clk *clk); 141 - extern unsigned long omap1_ckctl_recalc_dsp_domain(struct clk *clk); 142 - extern int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate); 143 - extern int omap1_set_uart_rate(struct clk *clk, unsigned long rate); 144 - extern unsigned long omap1_uart_recalc(struct clk *clk); 145 - extern int omap1_set_ext_clk_rate(struct clk *clk, unsigned long rate); 146 - extern long omap1_round_ext_clk_rate(struct clk *clk, unsigned long rate); 147 - extern void omap1_init_ext_clk(struct clk *clk); 148 - extern int omap1_select_table_rate(struct clk *clk, unsigned long rate); 149 - extern long omap1_round_to_table_rate(struct clk *clk, unsigned long rate); 150 - extern int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate); 151 - extern long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate); 152 - 153 - #ifdef CONFIG_OMAP_RESET_CLOCKS 154 - extern void omap1_clk_disable_unused(struct clk *clk); 155 - #else 156 - #define omap1_clk_disable_unused NULL 157 - #endif 112 + unsigned long omap1_ckctl_recalc(struct omap1_clk *clk, unsigned long p_rate); 113 + long omap1_round_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate); 114 + int omap1_set_sossi_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate); 115 + unsigned long omap1_sossi_recalc(struct omap1_clk *clk, unsigned long p_rate); 116 + unsigned long omap1_ckctl_recalc_dsp_domain(struct omap1_clk *clk, unsigned long p_rate); 117 + int omap1_clk_set_rate_dsp_domain(struct omap1_clk *clk, unsigned long rate, 118 + unsigned long p_rate); 119 + long omap1_round_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate); 120 + int omap1_set_uart_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate); 121 + unsigned long omap1_uart_recalc(struct omap1_clk *clk, unsigned long p_rate); 122 + int omap1_set_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate); 123 + long omap1_round_ext_clk_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate); 124 + int omap1_init_ext_clk(struct omap1_clk *clk); 125 + int omap1_select_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate); 126 + long omap1_round_to_table_rate(struct omap1_clk *clk, unsigned long rate, unsigned long *p_rate); 127 + int omap1_clk_set_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, unsigned long p_rate); 128 + long omap1_clk_round_rate_ckctl_arm(struct omap1_clk *clk, unsigned long rate, 129 + unsigned long *p_rate); 158 130 159 131 struct uart_clk { 160 - struct clk clk; 161 - unsigned long sysc_addr; 132 + struct omap1_clk clk; 133 + unsigned long sysc_addr; 162 134 }; 163 135 164 136 /* Provide a method for preventing idling some ARM IDLECT clocks */ 165 137 struct arm_idlect1_clk { 166 - struct clk clk; 167 - unsigned long no_idle_count; 168 - __u8 idlect_shift; 138 + struct omap1_clk clk; 139 + unsigned long no_idle_count; 140 + __u8 idlect_shift; 169 141 }; 170 142 171 143 /* ARM_CKCTL bit shifts */ ··· 178 224 #define SOFT_REQ_REG2 0xfffe0880 179 225 180 226 extern __u32 arm_idlect1_mask; 181 - extern struct clk *api_ck_p, *ck_dpll1_p, *ck_ref_p; 227 + extern struct omap1_clk *api_ck_p, *ck_dpll1_p, *ck_ref_p; 182 228 183 229 extern const struct clkops clkops_dspck; 184 230 extern const struct clkops clkops_uart_16xx; ··· 186 232 187 233 /* used for passing SoC type to omap1_{select,round_to}_table_rate() */ 188 234 extern u32 cpu_mask; 235 + 236 + extern const struct clk_ops omap1_clk_null_ops; 237 + extern const struct clk_ops omap1_clk_gate_ops; 238 + extern const struct clk_ops omap1_clk_rate_ops; 239 + extern const struct clk_ops omap1_clk_full_ops; 189 240 190 241 #endif
+209 -274
arch/arm/mach-omap1/clock_data.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/io.h> 16 16 #include <linux/clk.h> 17 + #include <linux/clkdev.h> 18 + #include <linux/clk-provider.h> 17 19 #include <linux/cpufreq.h> 18 20 #include <linux/delay.h> 19 21 #include <linux/soc/ti/omap1-io.h> ··· 73 71 * Omap1 clocks 74 72 */ 75 73 76 - static struct clk ck_ref = { 77 - .name = "ck_ref", 78 - .ops = &clkops_null, 74 + static struct omap1_clk ck_ref = { 75 + .hw.init = CLK_HW_INIT_NO_PARENT("ck_ref", &omap1_clk_rate_ops, 0), 79 76 .rate = 12000000, 80 77 }; 81 78 82 - static struct clk ck_dpll1 = { 83 - .name = "ck_dpll1", 84 - .ops = &clkops_null, 85 - .parent = &ck_ref, 79 + static struct omap1_clk ck_dpll1 = { 80 + .hw.init = CLK_HW_INIT("ck_dpll1", "ck_ref", &omap1_clk_rate_ops, 81 + /* 82 + * force recursive refresh of rates of the clock 83 + * and its children when clk_get_rate() is called 84 + */ 85 + CLK_GET_RATE_NOCACHE), 86 86 }; 87 87 88 88 /* ··· 93 89 */ 94 90 static struct arm_idlect1_clk ck_dpll1out = { 95 91 .clk = { 96 - .name = "ck_dpll1out", 92 + .hw.init = CLK_HW_INIT("ck_dpll1out", "ck_dpll1", &omap1_clk_gate_ops, 0), 97 93 .ops = &clkops_generic, 98 - .parent = &ck_dpll1, 99 94 .flags = CLOCK_IDLE_CONTROL | ENABLE_REG_32BIT, 100 95 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 101 96 .enable_bit = EN_CKOUT_ARM, 102 - .recalc = &followparent_recalc, 103 97 }, 104 98 .idlect_shift = IDL_CLKOUT_ARM_SHIFT, 105 99 }; 106 100 107 - static struct clk sossi_ck = { 108 - .name = "ck_sossi", 101 + static struct omap1_clk sossi_ck = { 102 + .hw.init = CLK_HW_INIT("ck_sossi", "ck_dpll1out", &omap1_clk_full_ops, 0), 109 103 .ops = &clkops_generic, 110 - .parent = &ck_dpll1out.clk, 111 104 .flags = CLOCK_NO_IDLE_PARENT | ENABLE_REG_32BIT, 112 105 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_1), 113 106 .enable_bit = CONF_MOD_SOSSI_CLK_EN_R, 114 107 .recalc = &omap1_sossi_recalc, 108 + .round_rate = &omap1_round_sossi_rate, 115 109 .set_rate = &omap1_set_sossi_rate, 116 110 }; 117 111 118 - static struct clk arm_ck = { 119 - .name = "arm_ck", 120 - .ops = &clkops_null, 121 - .parent = &ck_dpll1, 112 + static struct omap1_clk arm_ck = { 113 + .hw.init = CLK_HW_INIT("arm_ck", "ck_dpll1", &omap1_clk_rate_ops, 0), 122 114 .rate_offset = CKCTL_ARMDIV_OFFSET, 123 115 .recalc = &omap1_ckctl_recalc, 124 116 .round_rate = omap1_clk_round_rate_ckctl_arm, ··· 123 123 124 124 static struct arm_idlect1_clk armper_ck = { 125 125 .clk = { 126 - .name = "armper_ck", 126 + .hw.init = CLK_HW_INIT("armper_ck", "ck_dpll1", &omap1_clk_full_ops, 127 + CLK_IS_CRITICAL), 127 128 .ops = &clkops_generic, 128 - .parent = &ck_dpll1, 129 129 .flags = CLOCK_IDLE_CONTROL, 130 130 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 131 131 .enable_bit = EN_PERCK, ··· 141 141 * FIXME: This clock seems to be necessary but no-one has asked for its 142 142 * activation. [ GPIO code for 1510 ] 143 143 */ 144 - static struct clk arm_gpio_ck = { 145 - .name = "ick", 144 + static struct omap1_clk arm_gpio_ck = { 145 + .hw.init = CLK_HW_INIT("ick", "ck_dpll1", &omap1_clk_gate_ops, CLK_IS_CRITICAL), 146 146 .ops = &clkops_generic, 147 - .parent = &ck_dpll1, 148 147 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 149 148 .enable_bit = EN_GPIOCK, 150 - .recalc = &followparent_recalc, 151 149 }; 152 150 153 151 static struct arm_idlect1_clk armxor_ck = { 154 152 .clk = { 155 - .name = "armxor_ck", 153 + .hw.init = CLK_HW_INIT("armxor_ck", "ck_ref", &omap1_clk_gate_ops, 154 + CLK_IS_CRITICAL), 156 155 .ops = &clkops_generic, 157 - .parent = &ck_ref, 158 156 .flags = CLOCK_IDLE_CONTROL, 159 157 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 160 158 .enable_bit = EN_XORPCK, 161 - .recalc = &followparent_recalc, 162 159 }, 163 160 .idlect_shift = IDLXORP_ARM_SHIFT, 164 161 }; 165 162 166 163 static struct arm_idlect1_clk armtim_ck = { 167 164 .clk = { 168 - .name = "armtim_ck", 165 + .hw.init = CLK_HW_INIT("armtim_ck", "ck_ref", &omap1_clk_gate_ops, 166 + CLK_IS_CRITICAL), 169 167 .ops = &clkops_generic, 170 - .parent = &ck_ref, 171 168 .flags = CLOCK_IDLE_CONTROL, 172 169 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 173 170 .enable_bit = EN_TIMCK, 174 - .recalc = &followparent_recalc, 175 171 }, 176 172 .idlect_shift = IDLTIM_ARM_SHIFT, 177 173 }; 178 174 179 175 static struct arm_idlect1_clk armwdt_ck = { 180 176 .clk = { 181 - .name = "armwdt_ck", 177 + .hw.init = CLK_HW_INIT("armwdt_ck", "ck_ref", &omap1_clk_full_ops, 0), 182 178 .ops = &clkops_generic, 183 - .parent = &ck_ref, 184 179 .flags = CLOCK_IDLE_CONTROL, 185 180 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 186 181 .enable_bit = EN_WDTCK, ··· 185 190 .idlect_shift = IDLWDT_ARM_SHIFT, 186 191 }; 187 192 188 - static struct clk arminth_ck16xx = { 189 - .name = "arminth_ck", 190 - .ops = &clkops_null, 191 - .parent = &arm_ck, 192 - .recalc = &followparent_recalc, 193 + static struct omap1_clk arminth_ck16xx = { 194 + .hw.init = CLK_HW_INIT("arminth_ck", "arm_ck", &omap1_clk_null_ops, 0), 193 195 /* Note: On 16xx the frequency can be divided by 2 by programming 194 196 * ARM_CKCTL:ARM_INTHCK_SEL(14) to 1 195 197 * ··· 194 202 */ 195 203 }; 196 204 197 - static struct clk dsp_ck = { 198 - .name = "dsp_ck", 205 + static struct omap1_clk dsp_ck = { 206 + .hw.init = CLK_HW_INIT("dsp_ck", "ck_dpll1", &omap1_clk_full_ops, 0), 199 207 .ops = &clkops_generic, 200 - .parent = &ck_dpll1, 201 208 .enable_reg = OMAP1_IO_ADDRESS(ARM_CKCTL), 202 209 .enable_bit = EN_DSPCK, 203 210 .rate_offset = CKCTL_DSPDIV_OFFSET, ··· 205 214 .set_rate = omap1_clk_set_rate_ckctl_arm, 206 215 }; 207 216 208 - static struct clk dspmmu_ck = { 209 - .name = "dspmmu_ck", 210 - .ops = &clkops_null, 211 - .parent = &ck_dpll1, 217 + static struct omap1_clk dspmmu_ck = { 218 + .hw.init = CLK_HW_INIT("dspmmu_ck", "ck_dpll1", &omap1_clk_rate_ops, 0), 212 219 .rate_offset = CKCTL_DSPMMUDIV_OFFSET, 213 220 .recalc = &omap1_ckctl_recalc, 214 221 .round_rate = omap1_clk_round_rate_ckctl_arm, 215 222 .set_rate = omap1_clk_set_rate_ckctl_arm, 216 223 }; 217 224 218 - static struct clk dspper_ck = { 219 - .name = "dspper_ck", 225 + static struct omap1_clk dspper_ck = { 226 + .hw.init = CLK_HW_INIT("dspper_ck", "ck_dpll1", &omap1_clk_full_ops, 0), 220 227 .ops = &clkops_dspck, 221 - .parent = &ck_dpll1, 222 228 .enable_reg = DSP_IDLECT2, 223 229 .enable_bit = EN_PERCK, 224 230 .rate_offset = CKCTL_PERDIV_OFFSET, ··· 224 236 .set_rate = &omap1_clk_set_rate_dsp_domain, 225 237 }; 226 238 227 - static struct clk dspxor_ck = { 228 - .name = "dspxor_ck", 239 + static struct omap1_clk dspxor_ck = { 240 + .hw.init = CLK_HW_INIT("dspxor_ck", "ck_ref", &omap1_clk_gate_ops, 0), 229 241 .ops = &clkops_dspck, 230 - .parent = &ck_ref, 231 242 .enable_reg = DSP_IDLECT2, 232 243 .enable_bit = EN_XORPCK, 233 - .recalc = &followparent_recalc, 234 244 }; 235 245 236 - static struct clk dsptim_ck = { 237 - .name = "dsptim_ck", 246 + static struct omap1_clk dsptim_ck = { 247 + .hw.init = CLK_HW_INIT("dsptim_ck", "ck_ref", &omap1_clk_gate_ops, 0), 238 248 .ops = &clkops_dspck, 239 - .parent = &ck_ref, 240 249 .enable_reg = DSP_IDLECT2, 241 250 .enable_bit = EN_DSPTIMCK, 242 - .recalc = &followparent_recalc, 243 251 }; 244 252 245 253 static struct arm_idlect1_clk tc_ck = { 246 254 .clk = { 247 - .name = "tc_ck", 248 - .ops = &clkops_null, 249 - .parent = &ck_dpll1, 255 + .hw.init = CLK_HW_INIT("tc_ck", "ck_dpll1", &omap1_clk_rate_ops, 0), 250 256 .flags = CLOCK_IDLE_CONTROL, 251 257 .rate_offset = CKCTL_TCDIV_OFFSET, 252 258 .recalc = &omap1_ckctl_recalc, ··· 250 268 .idlect_shift = IDLIF_ARM_SHIFT, 251 269 }; 252 270 253 - static struct clk arminth_ck1510 = { 254 - .name = "arminth_ck", 255 - .ops = &clkops_null, 256 - .parent = &tc_ck.clk, 257 - .recalc = &followparent_recalc, 271 + static struct omap1_clk arminth_ck1510 = { 272 + .hw.init = CLK_HW_INIT("arminth_ck", "tc_ck", &omap1_clk_null_ops, 0), 258 273 /* Note: On 1510 the frequency follows TC_CK 259 274 * 260 275 * 16xx version is in MPU clocks. 261 276 */ 262 277 }; 263 278 264 - static struct clk tipb_ck = { 279 + static struct omap1_clk tipb_ck = { 265 280 /* No-idle controlled by "tc_ck" */ 266 - .name = "tipb_ck", 267 - .ops = &clkops_null, 268 - .parent = &tc_ck.clk, 269 - .recalc = &followparent_recalc, 281 + .hw.init = CLK_HW_INIT("tipb_ck", "tc_ck", &omap1_clk_null_ops, 0), 270 282 }; 271 283 272 - static struct clk l3_ocpi_ck = { 284 + static struct omap1_clk l3_ocpi_ck = { 273 285 /* No-idle controlled by "tc_ck" */ 274 - .name = "l3_ocpi_ck", 286 + .hw.init = CLK_HW_INIT("l3_ocpi_ck", "tc_ck", &omap1_clk_gate_ops, 0), 275 287 .ops = &clkops_generic, 276 - .parent = &tc_ck.clk, 277 288 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3), 278 289 .enable_bit = EN_OCPI_CK, 279 - .recalc = &followparent_recalc, 280 290 }; 281 291 282 - static struct clk tc1_ck = { 283 - .name = "tc1_ck", 292 + static struct omap1_clk tc1_ck = { 293 + .hw.init = CLK_HW_INIT("tc1_ck", "tc_ck", &omap1_clk_gate_ops, 0), 284 294 .ops = &clkops_generic, 285 - .parent = &tc_ck.clk, 286 295 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3), 287 296 .enable_bit = EN_TC1_CK, 288 - .recalc = &followparent_recalc, 289 297 }; 290 298 291 299 /* 292 300 * FIXME: This clock seems to be necessary but no-one has asked for its 293 301 * activation. [ pm.c (SRAM), CCP, Camera ] 294 302 */ 295 - static struct clk tc2_ck = { 296 - .name = "tc2_ck", 303 + 304 + static struct omap1_clk tc2_ck = { 305 + .hw.init = CLK_HW_INIT("tc2_ck", "tc_ck", &omap1_clk_gate_ops, CLK_IS_CRITICAL), 297 306 .ops = &clkops_generic, 298 - .parent = &tc_ck.clk, 299 307 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT3), 300 308 .enable_bit = EN_TC2_CK, 301 - .recalc = &followparent_recalc, 302 309 }; 303 310 304 - static struct clk dma_ck = { 311 + static struct omap1_clk dma_ck = { 305 312 /* No-idle controlled by "tc_ck" */ 306 - .name = "dma_ck", 307 - .ops = &clkops_null, 308 - .parent = &tc_ck.clk, 309 - .recalc = &followparent_recalc, 313 + .hw.init = CLK_HW_INIT("dma_ck", "tc_ck", &omap1_clk_null_ops, 0), 310 314 }; 311 315 312 - static struct clk dma_lcdfree_ck = { 313 - .name = "dma_lcdfree_ck", 314 - .ops = &clkops_null, 315 - .parent = &tc_ck.clk, 316 - .recalc = &followparent_recalc, 316 + static struct omap1_clk dma_lcdfree_ck = { 317 + .hw.init = CLK_HW_INIT("dma_lcdfree_ck", "tc_ck", &omap1_clk_null_ops, 0), 317 318 }; 318 319 319 320 static struct arm_idlect1_clk api_ck = { 320 321 .clk = { 321 - .name = "api_ck", 322 + .hw.init = CLK_HW_INIT("api_ck", "tc_ck", &omap1_clk_gate_ops, 0), 322 323 .ops = &clkops_generic, 323 - .parent = &tc_ck.clk, 324 324 .flags = CLOCK_IDLE_CONTROL, 325 325 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 326 326 .enable_bit = EN_APICK, 327 - .recalc = &followparent_recalc, 328 327 }, 329 328 .idlect_shift = IDLAPI_ARM_SHIFT, 330 329 }; 331 330 332 331 static struct arm_idlect1_clk lb_ck = { 333 332 .clk = { 334 - .name = "lb_ck", 333 + .hw.init = CLK_HW_INIT("lb_ck", "tc_ck", &omap1_clk_gate_ops, 0), 335 334 .ops = &clkops_generic, 336 - .parent = &tc_ck.clk, 337 335 .flags = CLOCK_IDLE_CONTROL, 338 336 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 339 337 .enable_bit = EN_LBCK, 340 - .recalc = &followparent_recalc, 341 338 }, 342 339 .idlect_shift = IDLLB_ARM_SHIFT, 343 340 }; 344 341 345 - static struct clk rhea1_ck = { 346 - .name = "rhea1_ck", 347 - .ops = &clkops_null, 348 - .parent = &tc_ck.clk, 349 - .recalc = &followparent_recalc, 342 + static struct omap1_clk rhea1_ck = { 343 + .hw.init = CLK_HW_INIT("rhea1_ck", "tc_ck", &omap1_clk_null_ops, 0), 350 344 }; 351 345 352 - static struct clk rhea2_ck = { 353 - .name = "rhea2_ck", 354 - .ops = &clkops_null, 355 - .parent = &tc_ck.clk, 356 - .recalc = &followparent_recalc, 346 + static struct omap1_clk rhea2_ck = { 347 + .hw.init = CLK_HW_INIT("rhea2_ck", "tc_ck", &omap1_clk_null_ops, 0), 357 348 }; 358 349 359 - static struct clk lcd_ck_16xx = { 360 - .name = "lcd_ck", 350 + static struct omap1_clk lcd_ck_16xx = { 351 + .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0), 361 352 .ops = &clkops_generic, 362 - .parent = &ck_dpll1, 363 353 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 364 354 .enable_bit = EN_LCDCK, 365 355 .rate_offset = CKCTL_LCDDIV_OFFSET, ··· 342 388 343 389 static struct arm_idlect1_clk lcd_ck_1510 = { 344 390 .clk = { 345 - .name = "lcd_ck", 391 + .hw.init = CLK_HW_INIT("lcd_ck", "ck_dpll1", &omap1_clk_full_ops, 0), 346 392 .ops = &clkops_generic, 347 - .parent = &ck_dpll1, 348 393 .flags = CLOCK_IDLE_CONTROL, 349 394 .enable_reg = OMAP1_IO_ADDRESS(ARM_IDLECT2), 350 395 .enable_bit = EN_LCDCK, ··· 355 402 .idlect_shift = OMAP1510_IDLLCD_ARM_SHIFT, 356 403 }; 357 404 405 + 358 406 /* 359 407 * XXX The enable_bit here is misused - it simply switches between 12MHz 360 - * and 48MHz. Reimplement with clksel. 408 + * and 48MHz. Reimplement with clk_mux. 361 409 * 362 410 * XXX does this need SYSC register handling? 363 411 */ 364 - static struct clk uart1_1510 = { 365 - .name = "uart1_ck", 366 - .ops = &clkops_null, 412 + static struct omap1_clk uart1_1510 = { 367 413 /* Direct from ULPD, no real parent */ 368 - .parent = &armper_ck.clk, 369 - .rate = 12000000, 414 + .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0), 370 415 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 371 416 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), 372 417 .enable_bit = CONF_MOD_UART1_CLK_MODE_R, 418 + .round_rate = &omap1_round_uart_rate, 373 419 .set_rate = &omap1_set_uart_rate, 374 420 .recalc = &omap1_uart_recalc, 375 421 }; 376 422 377 423 /* 378 424 * XXX The enable_bit here is misused - it simply switches between 12MHz 379 - * and 48MHz. Reimplement with clksel. 425 + * and 48MHz. Reimplement with clk_mux. 380 426 * 381 427 * XXX SYSC register handling does not belong in the clock framework 382 428 */ 383 429 static struct uart_clk uart1_16xx = { 384 430 .clk = { 385 - .name = "uart1_ck", 386 431 .ops = &clkops_uart_16xx, 387 432 /* Direct from ULPD, no real parent */ 388 - .parent = &armper_ck.clk, 433 + .hw.init = CLK_HW_INIT("uart1_ck", "armper_ck", &omap1_clk_full_ops, 0), 389 434 .rate = 48000000, 390 435 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 391 436 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), ··· 394 443 395 444 /* 396 445 * XXX The enable_bit here is misused - it simply switches between 12MHz 397 - * and 48MHz. Reimplement with clksel. 446 + * and 48MHz. Reimplement with clk_mux. 398 447 * 399 448 * XXX does this need SYSC register handling? 400 449 */ 401 - static struct clk uart2_ck = { 402 - .name = "uart2_ck", 403 - .ops = &clkops_null, 450 + static struct omap1_clk uart2_ck = { 404 451 /* Direct from ULPD, no real parent */ 405 - .parent = &armper_ck.clk, 406 - .rate = 12000000, 452 + .hw.init = CLK_HW_INIT("uart2_ck", "armper_ck", &omap1_clk_full_ops, 0), 407 453 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 408 454 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), 409 455 .enable_bit = CONF_MOD_UART2_CLK_MODE_R, 456 + .round_rate = &omap1_round_uart_rate, 410 457 .set_rate = &omap1_set_uart_rate, 411 458 .recalc = &omap1_uart_recalc, 412 459 }; 413 460 414 461 /* 415 462 * XXX The enable_bit here is misused - it simply switches between 12MHz 416 - * and 48MHz. Reimplement with clksel. 463 + * and 48MHz. Reimplement with clk_mux. 417 464 * 418 465 * XXX does this need SYSC register handling? 419 466 */ 420 - static struct clk uart3_1510 = { 421 - .name = "uart3_ck", 422 - .ops = &clkops_null, 467 + static struct omap1_clk uart3_1510 = { 423 468 /* Direct from ULPD, no real parent */ 424 - .parent = &armper_ck.clk, 425 - .rate = 12000000, 469 + .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0), 426 470 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 427 471 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), 428 472 .enable_bit = CONF_MOD_UART3_CLK_MODE_R, 473 + .round_rate = &omap1_round_uart_rate, 429 474 .set_rate = &omap1_set_uart_rate, 430 475 .recalc = &omap1_uart_recalc, 431 476 }; 432 477 433 478 /* 434 479 * XXX The enable_bit here is misused - it simply switches between 12MHz 435 - * and 48MHz. Reimplement with clksel. 480 + * and 48MHz. Reimplement with clk_mux. 436 481 * 437 482 * XXX SYSC register handling does not belong in the clock framework 438 483 */ 439 484 static struct uart_clk uart3_16xx = { 440 485 .clk = { 441 - .name = "uart3_ck", 442 486 .ops = &clkops_uart_16xx, 443 487 /* Direct from ULPD, no real parent */ 444 - .parent = &armper_ck.clk, 488 + .hw.init = CLK_HW_INIT("uart3_ck", "armper_ck", &omap1_clk_full_ops, 0), 445 489 .rate = 48000000, 446 490 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 447 491 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), ··· 445 499 .sysc_addr = 0xfffb9854, 446 500 }; 447 501 448 - static struct clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */ 449 - .name = "usb_clko", 502 + static struct omap1_clk usb_clko = { /* 6 MHz output on W4_USB_CLKO */ 450 503 .ops = &clkops_generic, 451 504 /* Direct from ULPD, no parent */ 505 + .hw.init = CLK_HW_INIT_NO_PARENT("usb_clko", &omap1_clk_full_ops, 0), 452 506 .rate = 6000000, 453 507 .flags = ENABLE_REG_32BIT, 454 508 .enable_reg = OMAP1_IO_ADDRESS(ULPD_CLOCK_CTRL), 455 509 .enable_bit = USB_MCLK_EN_BIT, 456 510 }; 457 511 458 - static struct clk usb_hhc_ck1510 = { 459 - .name = "usb_hhc_ck", 512 + static struct omap1_clk usb_hhc_ck1510 = { 460 513 .ops = &clkops_generic, 461 514 /* Direct from ULPD, no parent */ 515 + .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0), 462 516 .rate = 48000000, /* Actually 2 clocks, 12MHz and 48MHz */ 463 517 .flags = ENABLE_REG_32BIT, 464 518 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), 465 519 .enable_bit = USB_HOST_HHC_UHOST_EN, 466 520 }; 467 521 468 - static struct clk usb_hhc_ck16xx = { 469 - .name = "usb_hhc_ck", 522 + static struct omap1_clk usb_hhc_ck16xx = { 470 523 .ops = &clkops_generic, 471 524 /* Direct from ULPD, no parent */ 525 + .hw.init = CLK_HW_INIT_NO_PARENT("usb_hhc_ck", &omap1_clk_full_ops, 0), 472 526 .rate = 48000000, 473 527 /* OTG_SYSCON_2.OTG_PADEN == 0 (not 1510-compatible) */ 474 528 .flags = ENABLE_REG_32BIT, ··· 476 530 .enable_bit = OTG_SYSCON_2_UHOST_EN_SHIFT 477 531 }; 478 532 479 - static struct clk usb_dc_ck = { 480 - .name = "usb_dc_ck", 533 + static struct omap1_clk usb_dc_ck = { 481 534 .ops = &clkops_generic, 482 535 /* Direct from ULPD, no parent */ 536 + .hw.init = CLK_HW_INIT_NO_PARENT("usb_dc_ck", &omap1_clk_full_ops, 0), 483 537 .rate = 48000000, 484 538 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG), 485 539 .enable_bit = SOFT_USB_OTG_DPLL_REQ_SHIFT, 486 540 }; 487 541 488 - static struct clk uart1_7xx = { 489 - .name = "uart1_ck", 542 + static struct omap1_clk uart1_7xx = { 490 543 .ops = &clkops_generic, 491 544 /* Direct from ULPD, no parent */ 545 + .hw.init = CLK_HW_INIT_NO_PARENT("uart1_ck", &omap1_clk_full_ops, 0), 492 546 .rate = 12000000, 493 547 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG), 494 548 .enable_bit = 9, 495 549 }; 496 550 497 - static struct clk uart2_7xx = { 498 - .name = "uart2_ck", 551 + static struct omap1_clk uart2_7xx = { 499 552 .ops = &clkops_generic, 500 553 /* Direct from ULPD, no parent */ 554 + .hw.init = CLK_HW_INIT_NO_PARENT("uart2_ck", &omap1_clk_full_ops, 0), 501 555 .rate = 12000000, 502 556 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG), 503 557 .enable_bit = 11, 504 558 }; 505 559 506 - static struct clk mclk_1510 = { 507 - .name = "mclk", 560 + static struct omap1_clk mclk_1510 = { 508 561 .ops = &clkops_generic, 509 562 /* Direct from ULPD, no parent. May be enabled by ext hardware. */ 563 + .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0), 510 564 .rate = 12000000, 511 565 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG), 512 566 .enable_bit = SOFT_COM_MCKO_REQ_SHIFT, 513 567 }; 514 568 515 - static struct clk mclk_16xx = { 516 - .name = "mclk", 569 + static struct omap1_clk mclk_16xx = { 517 570 .ops = &clkops_generic, 518 571 /* Direct from ULPD, no parent. May be enabled by ext hardware. */ 572 + .hw.init = CLK_HW_INIT_NO_PARENT("mclk", &omap1_clk_full_ops, 0), 519 573 .enable_reg = OMAP1_IO_ADDRESS(COM_CLK_DIV_CTRL_SEL), 520 574 .enable_bit = COM_ULPD_PLL_CLK_REQ, 521 575 .set_rate = &omap1_set_ext_clk_rate, ··· 523 577 .init = &omap1_init_ext_clk, 524 578 }; 525 579 526 - static struct clk bclk_1510 = { 527 - .name = "bclk", 528 - .ops = &clkops_generic, 580 + static struct omap1_clk bclk_1510 = { 529 581 /* Direct from ULPD, no parent. May be enabled by ext hardware. */ 582 + .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_rate_ops, 0), 530 583 .rate = 12000000, 531 584 }; 532 585 533 - static struct clk bclk_16xx = { 534 - .name = "bclk", 586 + static struct omap1_clk bclk_16xx = { 535 587 .ops = &clkops_generic, 536 588 /* Direct from ULPD, no parent. May be enabled by ext hardware. */ 589 + .hw.init = CLK_HW_INIT_NO_PARENT("bclk", &omap1_clk_full_ops, 0), 537 590 .enable_reg = OMAP1_IO_ADDRESS(SWD_CLK_DIV_CTRL_SEL), 538 591 .enable_bit = SWD_ULPD_PLL_CLK_REQ, 539 592 .set_rate = &omap1_set_ext_clk_rate, ··· 540 595 .init = &omap1_init_ext_clk, 541 596 }; 542 597 543 - static struct clk mmc1_ck = { 544 - .name = "mmc1_ck", 598 + static struct omap1_clk mmc1_ck = { 545 599 .ops = &clkops_generic, 546 600 /* Functional clock is direct from ULPD, interface clock is ARMPER */ 547 - .parent = &armper_ck.clk, 601 + .hw.init = CLK_HW_INIT("mmc1_ck", "armper_ck", &omap1_clk_full_ops, 0), 548 602 .rate = 48000000, 549 603 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 550 604 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), ··· 554 610 * XXX MOD_CONF_CTRL_0 bit 20 is defined in the 1510 TRM as 555 611 * CONF_MOD_MCBSP3_AUXON ?? 556 612 */ 557 - static struct clk mmc2_ck = { 558 - .name = "mmc2_ck", 613 + static struct omap1_clk mmc2_ck = { 559 614 .ops = &clkops_generic, 560 615 /* Functional clock is direct from ULPD, interface clock is ARMPER */ 561 - .parent = &armper_ck.clk, 616 + .hw.init = CLK_HW_INIT("mmc2_ck", "armper_ck", &omap1_clk_full_ops, 0), 562 617 .rate = 48000000, 563 618 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 564 619 .enable_reg = OMAP1_IO_ADDRESS(MOD_CONF_CTRL_0), 565 620 .enable_bit = 20, 566 621 }; 567 622 568 - static struct clk mmc3_ck = { 569 - .name = "mmc3_ck", 623 + static struct omap1_clk mmc3_ck = { 570 624 .ops = &clkops_generic, 571 625 /* Functional clock is direct from ULPD, interface clock is ARMPER */ 572 - .parent = &armper_ck.clk, 626 + .hw.init = CLK_HW_INIT("mmc3_ck", "armper_ck", &omap1_clk_full_ops, 0), 573 627 .rate = 48000000, 574 628 .flags = ENABLE_REG_32BIT | CLOCK_NO_IDLE_PARENT, 575 629 .enable_reg = OMAP1_IO_ADDRESS(SOFT_REQ_REG), 576 630 .enable_bit = SOFT_MMC_DPLL_REQ_SHIFT, 577 631 }; 578 632 579 - static struct clk virtual_ck_mpu = { 580 - .name = "mpu", 581 - .ops = &clkops_null, 582 - .parent = &arm_ck, /* Is smarter alias for */ 633 + static struct omap1_clk virtual_ck_mpu = { 634 + /* Is smarter alias for arm_ck */ 635 + .hw.init = CLK_HW_INIT("mpu", "arm_ck", &omap1_clk_rate_ops, 0), 583 636 .recalc = &followparent_recalc, 584 637 .set_rate = &omap1_select_table_rate, 585 638 .round_rate = &omap1_round_to_table_rate, ··· 584 643 585 644 /* virtual functional clock domain for I2C. Just for making sure that ARMXOR_CK 586 645 remains active during MPU idle whenever this is enabled */ 587 - static struct clk i2c_fck = { 588 - .name = "i2c_fck", 589 - .ops = &clkops_null, 646 + static struct omap1_clk i2c_fck = { 647 + .hw.init = CLK_HW_INIT("i2c_fck", "armxor_ck", &omap1_clk_gate_ops, 0), 590 648 .flags = CLOCK_NO_IDLE_PARENT, 591 - .parent = &armxor_ck.clk, 592 - .recalc = &followparent_recalc, 593 649 }; 594 650 595 - static struct clk i2c_ick = { 596 - .name = "i2c_ick", 597 - .ops = &clkops_null, 651 + static struct omap1_clk i2c_ick = { 652 + .hw.init = CLK_HW_INIT("i2c_ick", "armper_ck", &omap1_clk_gate_ops, 0), 598 653 .flags = CLOCK_NO_IDLE_PARENT, 599 - .parent = &armper_ck.clk, 600 - .recalc = &followparent_recalc, 601 654 }; 602 655 603 656 /* ··· 600 665 601 666 static struct omap_clk omap_clks[] = { 602 667 /* non-ULPD clocks */ 603 - CLK(NULL, "ck_ref", &ck_ref, CK_16XX | CK_1510 | CK_310 | CK_7XX), 604 - CLK(NULL, "ck_dpll1", &ck_dpll1, CK_16XX | CK_1510 | CK_310 | CK_7XX), 668 + CLK(NULL, "ck_ref", &ck_ref.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 669 + CLK(NULL, "ck_dpll1", &ck_dpll1.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 605 670 /* CK_GEN1 clocks */ 606 - CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk, CK_16XX), 607 - CLK(NULL, "ck_sossi", &sossi_ck, CK_16XX), 608 - CLK(NULL, "arm_ck", &arm_ck, CK_16XX | CK_1510 | CK_310), 609 - CLK(NULL, "armper_ck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310), 610 - CLK("omap_gpio.0", "ick", &arm_gpio_ck, CK_1510 | CK_310), 611 - CLK(NULL, "armxor_ck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX), 612 - CLK(NULL, "armtim_ck", &armtim_ck.clk, CK_16XX | CK_1510 | CK_310), 613 - CLK("omap_wdt", "fck", &armwdt_ck.clk, CK_16XX | CK_1510 | CK_310), 614 - CLK("omap_wdt", "ick", &armper_ck.clk, CK_16XX), 615 - CLK("omap_wdt", "ick", &dummy_ck, CK_1510 | CK_310), 616 - CLK(NULL, "arminth_ck", &arminth_ck1510, CK_1510 | CK_310), 617 - CLK(NULL, "arminth_ck", &arminth_ck16xx, CK_16XX), 671 + CLK(NULL, "ck_dpll1out", &ck_dpll1out.clk.hw, CK_16XX), 672 + CLK(NULL, "ck_sossi", &sossi_ck.hw, CK_16XX), 673 + CLK(NULL, "arm_ck", &arm_ck.hw, CK_16XX | CK_1510 | CK_310), 674 + CLK(NULL, "armper_ck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310), 675 + CLK("omap_gpio.0", "ick", &arm_gpio_ck.hw, CK_1510 | CK_310), 676 + CLK(NULL, "armxor_ck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 677 + CLK(NULL, "armtim_ck", &armtim_ck.clk.hw, CK_16XX | CK_1510 | CK_310), 678 + CLK("omap_wdt", "fck", &armwdt_ck.clk.hw, CK_16XX | CK_1510 | CK_310), 679 + CLK("omap_wdt", "ick", &armper_ck.clk.hw, CK_16XX), 680 + CLK("omap_wdt", "ick", &dummy_ck.hw, CK_1510 | CK_310), 681 + CLK(NULL, "arminth_ck", &arminth_ck1510.hw, CK_1510 | CK_310), 682 + CLK(NULL, "arminth_ck", &arminth_ck16xx.hw, CK_16XX), 618 683 /* CK_GEN2 clocks */ 619 - CLK(NULL, "dsp_ck", &dsp_ck, CK_16XX | CK_1510 | CK_310), 620 - CLK(NULL, "dspmmu_ck", &dspmmu_ck, CK_16XX | CK_1510 | CK_310), 621 - CLK(NULL, "dspper_ck", &dspper_ck, CK_16XX | CK_1510 | CK_310), 622 - CLK(NULL, "dspxor_ck", &dspxor_ck, CK_16XX | CK_1510 | CK_310), 623 - CLK(NULL, "dsptim_ck", &dsptim_ck, CK_16XX | CK_1510 | CK_310), 684 + CLK(NULL, "dsp_ck", &dsp_ck.hw, CK_16XX | CK_1510 | CK_310), 685 + CLK(NULL, "dspmmu_ck", &dspmmu_ck.hw, CK_16XX | CK_1510 | CK_310), 686 + CLK(NULL, "dspper_ck", &dspper_ck.hw, CK_16XX | CK_1510 | CK_310), 687 + CLK(NULL, "dspxor_ck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310), 688 + CLK(NULL, "dsptim_ck", &dsptim_ck.hw, CK_16XX | CK_1510 | CK_310), 624 689 /* CK_GEN3 clocks */ 625 - CLK(NULL, "tc_ck", &tc_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX), 626 - CLK(NULL, "tipb_ck", &tipb_ck, CK_1510 | CK_310), 627 - CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck, CK_16XX | CK_7XX), 628 - CLK(NULL, "tc1_ck", &tc1_ck, CK_16XX), 629 - CLK(NULL, "tc2_ck", &tc2_ck, CK_16XX), 630 - CLK(NULL, "dma_ck", &dma_ck, CK_16XX | CK_1510 | CK_310), 631 - CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck, CK_16XX), 632 - CLK(NULL, "api_ck", &api_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX), 633 - CLK(NULL, "lb_ck", &lb_ck.clk, CK_1510 | CK_310), 634 - CLK(NULL, "rhea1_ck", &rhea1_ck, CK_16XX), 635 - CLK(NULL, "rhea2_ck", &rhea2_ck, CK_16XX), 636 - CLK(NULL, "lcd_ck", &lcd_ck_16xx, CK_16XX | CK_7XX), 637 - CLK(NULL, "lcd_ck", &lcd_ck_1510.clk, CK_1510 | CK_310), 690 + CLK(NULL, "tc_ck", &tc_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 691 + CLK(NULL, "tipb_ck", &tipb_ck.hw, CK_1510 | CK_310), 692 + CLK(NULL, "l3_ocpi_ck", &l3_ocpi_ck.hw, CK_16XX | CK_7XX), 693 + CLK(NULL, "tc1_ck", &tc1_ck.hw, CK_16XX), 694 + CLK(NULL, "tc2_ck", &tc2_ck.hw, CK_16XX), 695 + CLK(NULL, "dma_ck", &dma_ck.hw, CK_16XX | CK_1510 | CK_310), 696 + CLK(NULL, "dma_lcdfree_ck", &dma_lcdfree_ck.hw, CK_16XX), 697 + CLK(NULL, "api_ck", &api_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 698 + CLK(NULL, "lb_ck", &lb_ck.clk.hw, CK_1510 | CK_310), 699 + CLK(NULL, "rhea1_ck", &rhea1_ck.hw, CK_16XX), 700 + CLK(NULL, "rhea2_ck", &rhea2_ck.hw, CK_16XX), 701 + CLK(NULL, "lcd_ck", &lcd_ck_16xx.hw, CK_16XX | CK_7XX), 702 + CLK(NULL, "lcd_ck", &lcd_ck_1510.clk.hw, CK_1510 | CK_310), 638 703 /* ULPD clocks */ 639 - CLK(NULL, "uart1_ck", &uart1_1510, CK_1510 | CK_310), 640 - CLK(NULL, "uart1_ck", &uart1_16xx.clk, CK_16XX), 641 - CLK(NULL, "uart1_ck", &uart1_7xx, CK_7XX), 642 - CLK(NULL, "uart2_ck", &uart2_ck, CK_16XX | CK_1510 | CK_310), 643 - CLK(NULL, "uart2_ck", &uart2_7xx, CK_7XX), 644 - CLK(NULL, "uart3_ck", &uart3_1510, CK_1510 | CK_310), 645 - CLK(NULL, "uart3_ck", &uart3_16xx.clk, CK_16XX), 646 - CLK(NULL, "usb_clko", &usb_clko, CK_16XX | CK_1510 | CK_310), 647 - CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510, CK_1510 | CK_310), 648 - CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx, CK_16XX), 649 - CLK(NULL, "usb_dc_ck", &usb_dc_ck, CK_16XX | CK_7XX), 650 - CLK(NULL, "mclk", &mclk_1510, CK_1510 | CK_310), 651 - CLK(NULL, "mclk", &mclk_16xx, CK_16XX), 652 - CLK(NULL, "bclk", &bclk_1510, CK_1510 | CK_310), 653 - CLK(NULL, "bclk", &bclk_16xx, CK_16XX), 654 - CLK("mmci-omap.0", "fck", &mmc1_ck, CK_16XX | CK_1510 | CK_310), 655 - CLK("mmci-omap.0", "fck", &mmc3_ck, CK_7XX), 656 - CLK("mmci-omap.0", "ick", &armper_ck.clk, CK_16XX | CK_1510 | CK_310 | CK_7XX), 657 - CLK("mmci-omap.1", "fck", &mmc2_ck, CK_16XX), 658 - CLK("mmci-omap.1", "ick", &armper_ck.clk, CK_16XX), 704 + CLK(NULL, "uart1_ck", &uart1_1510.hw, CK_1510 | CK_310), 705 + CLK(NULL, "uart1_ck", &uart1_16xx.clk.hw, CK_16XX), 706 + CLK(NULL, "uart1_ck", &uart1_7xx.hw, CK_7XX), 707 + CLK(NULL, "uart2_ck", &uart2_ck.hw, CK_16XX | CK_1510 | CK_310), 708 + CLK(NULL, "uart2_ck", &uart2_7xx.hw, CK_7XX), 709 + CLK(NULL, "uart3_ck", &uart3_1510.hw, CK_1510 | CK_310), 710 + CLK(NULL, "uart3_ck", &uart3_16xx.clk.hw, CK_16XX), 711 + CLK(NULL, "usb_clko", &usb_clko.hw, CK_16XX | CK_1510 | CK_310), 712 + CLK(NULL, "usb_hhc_ck", &usb_hhc_ck1510.hw, CK_1510 | CK_310), 713 + CLK(NULL, "usb_hhc_ck", &usb_hhc_ck16xx.hw, CK_16XX), 714 + CLK(NULL, "usb_dc_ck", &usb_dc_ck.hw, CK_16XX | CK_7XX), 715 + CLK(NULL, "mclk", &mclk_1510.hw, CK_1510 | CK_310), 716 + CLK(NULL, "mclk", &mclk_16xx.hw, CK_16XX), 717 + CLK(NULL, "bclk", &bclk_1510.hw, CK_1510 | CK_310), 718 + CLK(NULL, "bclk", &bclk_16xx.hw, CK_16XX), 719 + CLK("mmci-omap.0", "fck", &mmc1_ck.hw, CK_16XX | CK_1510 | CK_310), 720 + CLK("mmci-omap.0", "fck", &mmc3_ck.hw, CK_7XX), 721 + CLK("mmci-omap.0", "ick", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 722 + CLK("mmci-omap.1", "fck", &mmc2_ck.hw, CK_16XX), 723 + CLK("mmci-omap.1", "ick", &armper_ck.clk.hw, CK_16XX), 659 724 /* Virtual clocks */ 660 - CLK(NULL, "mpu", &virtual_ck_mpu, CK_16XX | CK_1510 | CK_310), 661 - CLK("omap_i2c.1", "fck", &i2c_fck, CK_16XX | CK_1510 | CK_310 | CK_7XX), 662 - CLK("omap_i2c.1", "ick", &i2c_ick, CK_16XX), 663 - CLK("omap_i2c.1", "ick", &dummy_ck, CK_1510 | CK_310 | CK_7XX), 664 - CLK("omap1_spi100k.1", "fck", &dummy_ck, CK_7XX), 665 - CLK("omap1_spi100k.1", "ick", &dummy_ck, CK_7XX), 666 - CLK("omap1_spi100k.2", "fck", &dummy_ck, CK_7XX), 667 - CLK("omap1_spi100k.2", "ick", &dummy_ck, CK_7XX), 668 - CLK("omap_uwire", "fck", &armxor_ck.clk, CK_16XX | CK_1510 | CK_310), 669 - CLK("omap-mcbsp.1", "ick", &dspper_ck, CK_16XX), 670 - CLK("omap-mcbsp.1", "ick", &dummy_ck, CK_1510 | CK_310), 671 - CLK("omap-mcbsp.2", "ick", &armper_ck.clk, CK_16XX), 672 - CLK("omap-mcbsp.2", "ick", &dummy_ck, CK_1510 | CK_310), 673 - CLK("omap-mcbsp.3", "ick", &dspper_ck, CK_16XX), 674 - CLK("omap-mcbsp.3", "ick", &dummy_ck, CK_1510 | CK_310), 675 - CLK("omap-mcbsp.1", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310), 676 - CLK("omap-mcbsp.2", "fck", &armper_ck.clk, CK_16XX | CK_1510 | CK_310), 677 - CLK("omap-mcbsp.3", "fck", &dspxor_ck, CK_16XX | CK_1510 | CK_310), 725 + CLK(NULL, "mpu", &virtual_ck_mpu.hw, CK_16XX | CK_1510 | CK_310), 726 + CLK("omap_i2c.1", "fck", &i2c_fck.hw, CK_16XX | CK_1510 | CK_310 | CK_7XX), 727 + CLK("omap_i2c.1", "ick", &i2c_ick.hw, CK_16XX), 728 + CLK("omap_i2c.1", "ick", &dummy_ck.hw, CK_1510 | CK_310 | CK_7XX), 729 + CLK("omap1_spi100k.1", "fck", &dummy_ck.hw, CK_7XX), 730 + CLK("omap1_spi100k.1", "ick", &dummy_ck.hw, CK_7XX), 731 + CLK("omap1_spi100k.2", "fck", &dummy_ck.hw, CK_7XX), 732 + CLK("omap1_spi100k.2", "ick", &dummy_ck.hw, CK_7XX), 733 + CLK("omap_uwire", "fck", &armxor_ck.clk.hw, CK_16XX | CK_1510 | CK_310), 734 + CLK("omap-mcbsp.1", "ick", &dspper_ck.hw, CK_16XX), 735 + CLK("omap-mcbsp.1", "ick", &dummy_ck.hw, CK_1510 | CK_310), 736 + CLK("omap-mcbsp.2", "ick", &armper_ck.clk.hw, CK_16XX), 737 + CLK("omap-mcbsp.2", "ick", &dummy_ck.hw, CK_1510 | CK_310), 738 + CLK("omap-mcbsp.3", "ick", &dspper_ck.hw, CK_16XX), 739 + CLK("omap-mcbsp.3", "ick", &dummy_ck.hw, CK_1510 | CK_310), 740 + CLK("omap-mcbsp.1", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310), 741 + CLK("omap-mcbsp.2", "fck", &armper_ck.clk.hw, CK_16XX | CK_1510 | CK_310), 742 + CLK("omap-mcbsp.3", "fck", &dspxor_ck.hw, CK_16XX | CK_1510 | CK_310), 678 743 }; 679 744 680 745 /* ··· 713 778 /* By default all idlect1 clocks are allowed to idle */ 714 779 arm_idlect1_mask = ~0; 715 780 716 - for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) 717 - clk_preinit(c->lk.clk); 718 - 719 781 cpu_mask = 0; 720 782 if (cpu_is_omap1710()) 721 783 cpu_mask |= CK_1710; ··· 725 793 if (cpu_is_omap310()) 726 794 cpu_mask |= CK_310; 727 795 728 - for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) 729 - if (c->cpu & cpu_mask) { 730 - clkdev_add(&c->lk); 731 - clk_register(c->lk.clk); 732 - } 733 - 734 796 /* Pointers to these clocks are needed by code in clock.c */ 735 - api_ck_p = clk_get(NULL, "api_ck"); 736 - ck_dpll1_p = clk_get(NULL, "ck_dpll1"); 737 - ck_ref_p = clk_get(NULL, "ck_ref"); 797 + api_ck_p = &api_ck.clk; 798 + ck_dpll1_p = &ck_dpll1; 799 + ck_ref_p = &ck_ref; 738 800 739 801 if (cpu_is_omap7xx()) 740 802 ck_ref.rate = 13000000; ··· 770 844 } 771 845 } 772 846 } 773 - propagate_rate(&ck_dpll1); 774 - /* Cache rates for clocks connected to ck_ref (not dpll1) */ 775 - propagate_rate(&ck_ref); 776 - omap1_show_rates(); 847 + 777 848 if (machine_is_omap_perseus2() || machine_is_omap_fsample()) { 778 849 /* Select slicer output as OMAP input clock */ 779 850 omap_writew(omap_readw(OMAP7XX_PCC_UPLD_CTRL) & ~0x1, ··· 802 879 */ 803 880 omap_writew(0x0000, ARM_IDLECT2); /* Turn LCD clock off also */ 804 881 805 - /* 806 - * Only enable those clocks we will need, let the drivers 807 - * enable other clocks as necessary 808 - */ 809 - clk_enable(&armper_ck.clk); 810 - clk_enable(&armxor_ck.clk); 811 - clk_enable(&armtim_ck.clk); /* This should be done by timer code */ 882 + for (c = omap_clks; c < omap_clks + ARRAY_SIZE(omap_clks); c++) { 883 + if (!(c->cpu & cpu_mask)) 884 + continue; 812 885 813 - if (cpu_is_omap15xx()) 814 - clk_enable(&arm_gpio_ck); 886 + if (c->lk.clk_hw->init) { /* NULL if provider already registered */ 887 + const struct clk_init_data *init = c->lk.clk_hw->init; 888 + const char *name = c->lk.clk_hw->init->name; 889 + int err; 890 + 891 + err = clk_hw_register(NULL, c->lk.clk_hw); 892 + if (err < 0) { 893 + pr_err("failed to register clock \"%s\"! (%d)\n", name, err); 894 + /* may be tried again, restore init data */ 895 + c->lk.clk_hw->init = init; 896 + continue; 897 + } 898 + } 899 + 900 + clk_hw_register_clkdev(c->lk.clk_hw, c->lk.con_id, c->lk.dev_id); 901 + } 902 + 903 + omap1_show_rates(); 815 904 816 905 return 0; 817 906 } ··· 835 900 unsigned long rate = ck_dpll1.rate; 836 901 837 902 /* Find the highest supported frequency and enable it */ 838 - if (omap1_select_table_rate(&virtual_ck_mpu, ~0)) { 903 + if (omap1_select_table_rate(&virtual_ck_mpu, ~0, arm_ck.rate)) { 839 904 pr_err("System frequencies not set, using default. Check your config.\n"); 840 905 /* 841 906 * Reprogramming the DPLL is tricky, it must be done from SRAM.
+1 -1
arch/arm/mach-omap1/hardware.h
··· 64 64 #define OMAP1_IO_OFFSET 0x00f00000 /* Virtual IO = 0xff0b0000 */ 65 65 #define OMAP1_IO_ADDRESS(pa) IOMEM((pa) - OMAP1_IO_OFFSET) 66 66 67 - #include <mach/serial.h> 67 + #include "serial.h" 68 68 69 69 /* 70 70 * ---------------------------------------------------------------------------
arch/arm/mach-omap1/include/mach/serial.h arch/arm/mach-omap1/serial.h
-117
arch/arm/mach-omap1/include/mach/uncompress.h
··· 1 - /* 2 - * arch/arm/plat-omap/include/mach/uncompress.h 3 - * 4 - * Serial port stubs for kernel decompress status messages 5 - * 6 - * Initially based on: 7 - * linux-2.4.15-rmk1-dsplinux1.6/arch/arm/plat-omap/include/mach1510/uncompress.h 8 - * Copyright (C) 2000 RidgeRun, Inc. 9 - * Author: Greg Lonnon <glonnon@ridgerun.com> 10 - * 11 - * Rewritten by: 12 - * Author: <source@mvista.com> 13 - * 2004 (c) MontaVista Software, Inc. 14 - * 15 - * This file is licensed under the terms of the GNU General Public License 16 - * version 2. This program is licensed "as is" without any warranty of any 17 - * kind, whether express or implied. 18 - */ 19 - 20 - #include <linux/types.h> 21 - #include <linux/serial_reg.h> 22 - 23 - #include <asm/memory.h> 24 - #include <asm/mach-types.h> 25 - 26 - #include "serial.h" 27 - 28 - #define MDR1_MODE_MASK 0x07 29 - 30 - volatile u8 *uart_base; 31 - int uart_shift; 32 - 33 - /* 34 - * Store the DEBUG_LL uart number into memory. 35 - * See also debug-macro.S, and serial.c for related code. 36 - */ 37 - static void set_omap_uart_info(unsigned char port) 38 - { 39 - /* 40 - * Get address of some.bss variable and round it down 41 - * a la CONFIG_AUTO_ZRELADDR. 42 - */ 43 - u32 ram_start = (u32)&uart_shift & 0xf8000000; 44 - u32 *uart_info = (u32 *)(ram_start + OMAP_UART_INFO_OFS); 45 - *uart_info = port; 46 - } 47 - 48 - static inline void putc(int c) 49 - { 50 - if (!uart_base) 51 - return; 52 - 53 - /* Check for UART 16x mode */ 54 - if ((uart_base[UART_OMAP_MDR1 << uart_shift] & MDR1_MODE_MASK) != 0) 55 - return; 56 - 57 - while (!(uart_base[UART_LSR << uart_shift] & UART_LSR_THRE)) 58 - barrier(); 59 - uart_base[UART_TX << uart_shift] = c; 60 - } 61 - 62 - static inline void flush(void) 63 - { 64 - } 65 - 66 - /* 67 - * Macros to configure UART1 and debug UART 68 - */ 69 - #define _DEBUG_LL_ENTRY(mach, dbg_uart, dbg_shft, dbg_id) \ 70 - if (machine_is_##mach()) { \ 71 - uart_base = (volatile u8 *)(dbg_uart); \ 72 - uart_shift = (dbg_shft); \ 73 - port = (dbg_id); \ 74 - set_omap_uart_info(port); \ 75 - break; \ 76 - } 77 - 78 - #define DEBUG_LL_OMAP7XX(p, mach) \ 79 - _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP7XX_PORT_SHIFT, \ 80 - OMAP1UART##p) 81 - 82 - #define DEBUG_LL_OMAP1(p, mach) \ 83 - _DEBUG_LL_ENTRY(mach, OMAP1_UART##p##_BASE, OMAP_PORT_SHIFT, \ 84 - OMAP1UART##p) 85 - 86 - static inline void arch_decomp_setup(void) 87 - { 88 - int port = 0; 89 - 90 - /* 91 - * Initialize the port based on the machine ID from the bootloader. 92 - * Note that we're using macros here instead of switch statement 93 - * as machine_is functions are optimized out for the boards that 94 - * are not selected. 95 - */ 96 - do { 97 - /* omap7xx/8xx based boards using UART1 with shift 0 */ 98 - DEBUG_LL_OMAP7XX(1, herald); 99 - DEBUG_LL_OMAP7XX(1, omap_perseus2); 100 - 101 - /* omap15xx/16xx based boards using UART1 */ 102 - DEBUG_LL_OMAP1(1, ams_delta); 103 - DEBUG_LL_OMAP1(1, nokia770); 104 - DEBUG_LL_OMAP1(1, omap_h2); 105 - DEBUG_LL_OMAP1(1, omap_h3); 106 - DEBUG_LL_OMAP1(1, omap_innovator); 107 - DEBUG_LL_OMAP1(1, omap_osk); 108 - DEBUG_LL_OMAP1(1, omap_palmte); 109 - DEBUG_LL_OMAP1(1, omap_palmz71); 110 - 111 - /* omap15xx/16xx based boards using UART2 */ 112 - DEBUG_LL_OMAP1(2, omap_palmtt); 113 - 114 - /* omap15xx/16xx based boards using UART3 */ 115 - DEBUG_LL_OMAP1(3, sx1); 116 - } while (0); 117 - }
-7
arch/arm/mach-omap1/io.c
··· 15 15 #include <asm/mach/map.h> 16 16 17 17 #include "tc.h" 18 - #include "mux.h" 19 18 #include "iomap.h" 20 19 #include "common.h" 21 - #include "clock.h" 22 20 23 21 /* 24 22 * The machine specific code may provide the extra mapping besides the ··· 123 125 */ 124 126 omap_writew(0x0, MPU_PUBLIC_TIPB_CNTL); 125 127 omap_writew(0x0, MPU_PRIVATE_TIPB_CNTL); 126 - 127 - /* Must init clocks early to assure that timer interrupt works 128 - */ 129 - omap1_clk_init(); 130 - omap1_mux_init(); 131 128 } 132 129 133 130 void __init omap1_init_late(void)
+1 -2
arch/arm/mach-omap1/serial.c
··· 19 19 20 20 #include <asm/mach-types.h> 21 21 22 - #include <mach/serial.h> 23 - 22 + #include "serial.h" 24 23 #include "mux.h" 25 24 #include "pm.h" 26 25 #include "soc.h"
+5
arch/arm/mach-omap1/time.c
··· 51 51 #include <asm/mach/time.h> 52 52 53 53 #include "hardware.h" 54 + #include "mux.h" 54 55 #include "iomap.h" 55 56 #include "common.h" 57 + #include "clock.h" 56 58 57 59 #ifdef CONFIG_OMAP_MPU_TIMER 58 60 ··· 226 224 */ 227 225 void __init omap1_timer_init(void) 228 226 { 227 + omap1_clk_init(); 228 + omap1_mux_init(); 229 + 229 230 if (omap_32k_timer_init() != 0) 230 231 omap_mpu_timer_init(); 231 232 }