clock3xxx.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * OMAP3-specific clock framework functions
  3. *
  4. * Copyright (C) 2007-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2007-2010 Nokia Corporation
  6. *
  7. * Paul Walmsley
  8. * Jouni Högander
  9. *
  10. * Parts of this code are based on code written by
  11. * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. */
  17. #undef DEBUG
  18. #include <linux/kernel.h>
  19. #include <linux/errno.h>
  20. #include <linux/clk.h>
  21. #include <linux/io.h>
  22. #include <plat/hardware.h>
  23. #include <plat/clock.h>
  24. #include "clock.h"
  25. #include "clock3xxx.h"
  26. #include "prm2xxx_3xxx.h"
  27. #include "prm-regbits-34xx.h"
  28. #include "cm2xxx_3xxx.h"
  29. #include "cm-regbits-34xx.h"
  30. /*
  31. * DPLL5_FREQ_FOR_USBHOST: USBHOST and USBTLL are the only clocks
  32. * that are sourced by DPLL5, and both of these require this clock
  33. * to be at 120 MHz for proper operation.
  34. */
  35. #define DPLL5_FREQ_FOR_USBHOST 120000000
  36. /* needed by omap3_core_dpll_m2_set_rate() */
  37. struct clk *sdrc_ick_p, *arm_fck_p;
  38. int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate)
  39. {
  40. /*
  41. * According to the 12-5 CDP code from TI, "Limitation 2.5"
  42. * on 3430ES1 prevents us from changing DPLL multipliers or dividers
  43. * on DPLL4.
  44. */
  45. if (omap_rev() == OMAP3430_REV_ES1_0) {
  46. pr_err("clock: DPLL4 cannot change rate due to "
  47. "silicon 'Limitation 2.5' on 3430ES1.\n");
  48. return -EINVAL;
  49. }
  50. return omap3_noncore_dpll_set_rate(clk, rate);
  51. }
  52. void __init omap3_clk_lock_dpll5(void)
  53. {
  54. struct clk *dpll5_clk;
  55. struct clk *dpll5_m2_clk;
  56. dpll5_clk = clk_get(NULL, "dpll5_ck");
  57. clk_set_rate(dpll5_clk, DPLL5_FREQ_FOR_USBHOST);
  58. clk_enable(dpll5_clk);
  59. /* Program dpll5_m2_clk divider for no division */
  60. dpll5_m2_clk = clk_get(NULL, "dpll5_m2_ck");
  61. clk_enable(dpll5_m2_clk);
  62. clk_set_rate(dpll5_m2_clk, DPLL5_FREQ_FOR_USBHOST);
  63. clk_disable(dpll5_m2_clk);
  64. clk_disable(dpll5_clk);
  65. return;
  66. }
  67. /* Common clock code */
  68. /*
  69. * Switch the MPU rate if specified on cmdline. We cannot do this
  70. * early until cmdline is parsed. XXX This should be removed from the
  71. * clock code and handled by the OPP layer code in the near future.
  72. */
  73. static int __init omap3xxx_clk_arch_init(void)
  74. {
  75. int ret;
  76. if (!cpu_is_omap34xx())
  77. return 0;
  78. ret = omap2_clk_switch_mpurate_at_boot("dpll1_ck");
  79. if (!ret)
  80. omap2_clk_print_new_rates("osc_sys_ck", "core_ck", "arm_fck");
  81. return ret;
  82. }
  83. arch_initcall(omap3xxx_clk_arch_init);