cm4xxx.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. */
  42. int omap4_cm_wait_module_ready(void __iomem *clkctrl_reg)
  43. {
  44. int i = 0;
  45. if (!clkctrl_reg)
  46. return 0;
  47. omap_test_timeout((
  48. ((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) == 0) ||
  49. (((__raw_readl(clkctrl_reg) & OMAP4430_IDLEST_MASK) >>
  50. OMAP4430_IDLEST_SHIFT) == 0x2)),
  51. MAX_MODULE_READY_TIME, i);
  52. return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
  53. }