clk.c 712 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. * Copyright 2012 Freescale Semiconductor, Inc.
  3. *
  4. * The code contained herein is licensed under the GNU General Public
  5. * License. You may obtain a copy of the GNU General Public License
  6. * Version 2 or later at the following locations:
  7. *
  8. * http://www.opensource.org/licenses/gpl-license.html
  9. * http://www.gnu.org/copyleft/gpl.html
  10. */
  11. #include <linux/err.h>
  12. #include <linux/io.h>
  13. #include <linux/jiffies.h>
  14. #include <linux/spinlock.h>
  15. #include "clk.h"
  16. DEFINE_SPINLOCK(mxs_lock);
  17. int mxs_clk_wait(void __iomem *reg, u8 shift)
  18. {
  19. unsigned long timeout = jiffies + msecs_to_jiffies(10);
  20. while (readl_relaxed(reg) & (1 << shift))
  21. if (time_after(jiffies, timeout))
  22. return -ETIMEDOUT;
  23. return 0;
  24. }