2 * Copyright 2013 Stefan Roese <sr@denx.de>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm/arch/sys_proto.h>
11 #include <asm/imx-common/regs-common.h>
13 /* 1 second delay should be plenty of time for block reset. */
14 #define RESET_MAX_TIMEOUT 1000000
16 #define MXS_BLOCK_SFTRST (1 << 31)
17 #define MXS_BLOCK_CLKGATE (1 << 30)
19 int mxs_wait_mask_set(struct mxs_register_32 *reg, uint32_t mask, unsigned
23 if ((readl(®->reg) & mask) == mask)
31 int mxs_wait_mask_clr(struct mxs_register_32 *reg, uint32_t mask, unsigned
35 if ((readl(®->reg) & mask) == 0)
43 int mxs_reset_block(struct mxs_register_32 *reg)
46 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
48 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
52 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
55 writel(MXS_BLOCK_SFTRST, ®->reg_set);
57 /* Wait for CLKGATE being set */
58 if (mxs_wait_mask_set(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))
62 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
64 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
68 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
70 if (mxs_wait_mask_clr(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))