2 * Copyright 2013 Stefan Roese <sr@denx.de>
4 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/imx-common/regs-common.h>
12 /* 1 second delay should be plenty of time for block reset. */
13 #define RESET_MAX_TIMEOUT 1000000
15 #define MXS_BLOCK_SFTRST (1 << 31)
16 #define MXS_BLOCK_CLKGATE (1 << 30)
18 int mxs_wait_mask_set(struct mxs_register_32 *reg, uint32_t mask, unsigned
22 if ((readl(®->reg) & mask) == mask)
30 int mxs_wait_mask_clr(struct mxs_register_32 *reg, uint32_t mask, unsigned
34 if ((readl(®->reg) & mask) == 0)
42 int mxs_reset_block(struct mxs_register_32 *reg)
45 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
47 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
51 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
54 writel(MXS_BLOCK_SFTRST, ®->reg_set);
56 /* Wait for CLKGATE being set */
57 if (mxs_wait_mask_set(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))
61 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
63 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
67 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
69 if (mxs_wait_mask_clr(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))