Linux 4.16.11
[linux/fpc-iii.git] / drivers / clk / mxs / clk.c
blob5301bce8957b92e9cb5a40f692d26180e767737e
1 /*
2 * Copyright 2012 Freescale Semiconductor, Inc.
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:
8 * http://www.opensource.org/licenses/gpl-license.html
9 * http://www.gnu.org/copyleft/gpl.html
12 #include <linux/err.h>
13 #include <linux/io.h>
14 #include <linux/jiffies.h>
15 #include <linux/spinlock.h>
16 #include "clk.h"
18 DEFINE_SPINLOCK(mxs_lock);
20 int mxs_clk_wait(void __iomem *reg, u8 shift)
22 unsigned long timeout = jiffies + msecs_to_jiffies(10);
24 while (readl_relaxed(reg) & (1 << shift))
25 if (time_after(jiffies, timeout))
26 return -ETIMEDOUT;
28 return 0;