clock36xx.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * OMAP36xx-specific clkops
  3. *
  4. * Copyright (C) 2010 Texas Instruments, Inc.
  5. * Copyright (C) 2010 Nokia Corporation
  6. *
  7. * Mike Turquette
  8. * Vijaykumar GN
  9. * Paul Walmsley
  10. *
  11. * Parts of this code are based on code written by
  12. * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu,
  13. * Russell King
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License version 2 as
  17. * published by the Free Software Foundation.
  18. */
  19. #undef DEBUG
  20. #include <linux/kernel.h>
  21. #include <linux/clk.h>
  22. #include <linux/io.h>
  23. #include "clock.h"
  24. #include "clock36xx.h"
  25. /**
  26. * omap36xx_pwrdn_clk_enable_with_hsdiv_restore - enable clocks suffering
  27. * from HSDivider PWRDN problem Implements Errata ID: i556.
  28. * @clk: DPLL output struct clk
  29. *
  30. * 3630 only: dpll3_m3_ck, dpll4_m2_ck, dpll4_m3_ck, dpll4_m4_ck,
  31. * dpll4_m5_ck & dpll4_m6_ck dividers gets loaded with reset
  32. * valueafter their respective PWRDN bits are set. Any dummy write
  33. * (Any other value different from the Read value) to the
  34. * corresponding CM_CLKSEL register will refresh the dividers.
  35. */
  36. #ifdef CONFIG_COMMON_CLK
  37. int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk)
  38. {
  39. struct clk_hw_omap *parent;
  40. struct clk_hw *parent_hw;
  41. #else
  42. static int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk *clk)
  43. {
  44. struct clk *parent;
  45. #endif
  46. u32 dummy_v, orig_v, clksel_shift;
  47. int ret;
  48. /* Clear PWRDN bit of HSDIVIDER */
  49. ret = omap2_dflt_clk_enable(clk);
  50. #ifdef CONFIG_COMMON_CLK
  51. parent_hw = __clk_get_hw(__clk_get_parent(clk->clk));
  52. parent = to_clk_hw_omap(parent_hw);
  53. #else
  54. parent = clk->parent;
  55. #endif
  56. /* Restore the dividers */
  57. if (!ret) {
  58. clksel_shift = __ffs(parent->clksel_mask);
  59. orig_v = __raw_readl(parent->clksel_reg);
  60. dummy_v = orig_v;
  61. /* Write any other value different from the Read value */
  62. dummy_v ^= (1 << clksel_shift);
  63. __raw_writel(dummy_v, parent->clksel_reg);
  64. /* Write the original divider */
  65. __raw_writel(orig_v, parent->clksel_reg);
  66. }
  67. return ret;
  68. }
  69. #ifndef CONFIG_COMMON_CLK
  70. const struct clkops clkops_omap36xx_pwrdn_with_hsdiv_wait_restore = {
  71. .enable = omap36xx_pwrdn_clk_enable_with_hsdiv_restore,
  72. .disable = omap2_dflt_clk_disable,
  73. .find_companion = omap2_clk_dflt_find_companion,
  74. .find_idlest = omap2_clk_dflt_find_idlest,
  75. };
  76. #endif