Loading...
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright 2012 Freescale Semiconductor, Inc.
4 */
5
6#include <linux/err.h>
7#include <linux/io.h>
8#include <linux/jiffies.h>
9#include <linux/spinlock.h>
10#include "clk.h"
11
12DEFINE_SPINLOCK(mxs_lock);
13
14int mxs_clk_wait(void __iomem *reg, u8 shift)
15{
16 unsigned long timeout = jiffies + msecs_to_jiffies(10);
17
18 while (readl_relaxed(reg) & (1 << shift))
19 if (time_after(jiffies, timeout))
20 return -ETIMEDOUT;
21
22 return 0;
23}
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
12#include <linux/err.h>
13#include <linux/io.h>
14#include <linux/jiffies.h>
15#include <linux/spinlock.h>
16
17DEFINE_SPINLOCK(mxs_lock);
18
19int mxs_clk_wait(void __iomem *reg, u8 shift)
20{
21 unsigned long timeout = jiffies + msecs_to_jiffies(10);
22
23 while (readl_relaxed(reg) & (1 << shift))
24 if (time_after(jiffies, timeout))
25 return -ETIMEDOUT;
26
27 return 0;
28}