cm4xxx.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * OMAP4 CM module functions
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Paul Walmsley
  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/module.h>
  13. #include <linux/types.h>
  14. #include <linux/delay.h>
  15. #include <linux/spinlock.h>
  16. #include <linux/list.h>
  17. #include <linux/errno.h>
  18. #include <linux/err.h>
  19. #include <linux/io.h>
  20. #include <asm/atomic.h>
  21. #include <plat/common.h>
  22. #include "cm.h"
  23. #include "cm-regbits-44xx.h"
  24. /**
  25. * omap4_cm_wait_module_ready - wait for a module to be in 'func' state
  26. * @clkctrl_reg: CLKCTRL module address
  27. *
  28. * Wait for the module IDLEST to be functional. If the idle state is in any
  29. * the non functional state (trans, idle or disabled), module and thus the
  30. * sysconfig cannot be accessed and will probably lead to an "imprecise
  31. * external abort"
  32. *
  33. * Module idle state:
  34. * 0x0 func: Module is fully functional, including OCP
  35. * 0x1 trans: Module is performing transition: wakeup, or sleep, or sleep
  36. * abortion
  37. * 0x2 idle: Module is in Idle mode (only OCP part). It is functional if
  38. * using separate functional clock
  39. * 0x3 disabled: Module is disabled and cannot be accessed
  40. *
  41. * TODO: Need to handle module accessible in idle state
  42. */
  43. int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
  44. {
  45. int i = 0;
  46. if (!clkctrl_reg)
  47. return 0;
  48. omap_test_timeout(((__raw_readl(clkctrl_reg) &
  49. OMAP4430_IDLEST_MASK) == 0),
  50. MAX_MODULE_READY_TIME, i);
  51. return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
  52. }