clockdomain33xx.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * AM33XX clockdomain control
  3. *
  4. * Copyright (C) 2011-2012 Texas Instruments Incorporated - http://www.ti.com/
  5. * Vaibhav Hiremath <hvaibhav@ti.com>
  6. *
  7. * Derived from mach-omap2/clockdomain44xx.c written by Rajendra Nayak
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/kernel.h>
  19. #include "clockdomain.h"
  20. #include "cm33xx.h"
  21. static int am33xx_clkdm_sleep(struct clockdomain *clkdm)
  22. {
  23. am33xx_cm_clkdm_force_sleep(clkdm->cm_inst, clkdm->clkdm_offs);
  24. return 0;
  25. }
  26. static int am33xx_clkdm_wakeup(struct clockdomain *clkdm)
  27. {
  28. am33xx_cm_clkdm_force_wakeup(clkdm->cm_inst, clkdm->clkdm_offs);
  29. return 0;
  30. }
  31. static void am33xx_clkdm_allow_idle(struct clockdomain *clkdm)
  32. {
  33. am33xx_cm_clkdm_enable_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
  34. }
  35. static void am33xx_clkdm_deny_idle(struct clockdomain *clkdm)
  36. {
  37. am33xx_cm_clkdm_disable_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
  38. }
  39. static int am33xx_clkdm_clk_enable(struct clockdomain *clkdm)
  40. {
  41. if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
  42. return am33xx_clkdm_wakeup(clkdm);
  43. return 0;
  44. }
  45. static int am33xx_clkdm_clk_disable(struct clockdomain *clkdm)
  46. {
  47. bool hwsup = false;
  48. hwsup = am33xx_cm_is_clkdm_in_hwsup(clkdm->cm_inst, clkdm->clkdm_offs);
  49. if (!hwsup && (clkdm->flags & CLKDM_CAN_FORCE_SLEEP))
  50. am33xx_clkdm_sleep(clkdm);
  51. return 0;
  52. }
  53. struct clkdm_ops am33xx_clkdm_operations = {
  54. .clkdm_sleep = am33xx_clkdm_sleep,
  55. .clkdm_wakeup = am33xx_clkdm_wakeup,
  56. .clkdm_allow_idle = am33xx_clkdm_allow_idle,
  57. .clkdm_deny_idle = am33xx_clkdm_deny_idle,
  58. .clkdm_clk_enable = am33xx_clkdm_clk_enable,
  59. .clkdm_clk_disable = am33xx_clkdm_clk_disable,
  60. };