dpll44xx.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * OMAP4-specific DPLL control functions
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc.
  5. * Rajendra Nayak
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/errno.h>
  13. #include <linux/clk.h>
  14. #include <linux/io.h>
  15. #include <linux/bitops.h>
  16. #include <plat/cpu.h>
  17. #include <plat/clock.h>
  18. #include "clock.h"
  19. #include "cm-regbits-44xx.h"
  20. /* Supported only on OMAP4 */
  21. int omap4_dpllmx_gatectrl_read(struct clk *clk)
  22. {
  23. u32 v;
  24. u32 mask;
  25. if (!clk || !clk->clksel_reg || !cpu_is_omap44xx())
  26. return -EINVAL;
  27. mask = clk->flags & CLOCK_CLKOUTX2 ?
  28. OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK :
  29. OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK;
  30. v = __raw_readl(clk->clksel_reg);
  31. v &= mask;
  32. v >>= __ffs(mask);
  33. return v;
  34. }
  35. void omap4_dpllmx_allow_gatectrl(struct clk *clk)
  36. {
  37. u32 v;
  38. u32 mask;
  39. if (!clk || !clk->clksel_reg || !cpu_is_omap44xx())
  40. return;
  41. mask = clk->flags & CLOCK_CLKOUTX2 ?
  42. OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK :
  43. OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK;
  44. v = __raw_readl(clk->clksel_reg);
  45. /* Clear the bit to allow gatectrl */
  46. v &= ~mask;
  47. __raw_writel(v, clk->clksel_reg);
  48. }
  49. void omap4_dpllmx_deny_gatectrl(struct clk *clk)
  50. {
  51. u32 v;
  52. u32 mask;
  53. if (!clk || !clk->clksel_reg || !cpu_is_omap44xx())
  54. return;
  55. mask = clk->flags & CLOCK_CLKOUTX2 ?
  56. OMAP4430_DPLL_CLKOUTX2_GATE_CTRL_MASK :
  57. OMAP4430_DPLL_CLKOUT_GATE_CTRL_MASK;
  58. v = __raw_readl(clk->clksel_reg);
  59. /* Set the bit to deny gatectrl */
  60. v |= mask;
  61. __raw_writel(v, clk->clksel_reg);
  62. }
  63. const struct clkops clkops_omap4_dpllmx_ops = {
  64. .allow_idle = omap4_dpllmx_allow_gatectrl,
  65. .deny_idle = omap4_dpllmx_deny_gatectrl,
  66. };