2 * Copyright 2013 Stefan Roese <sr@denx.de>
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #include <asm/errno.h>
21 #include <asm/imx-common/regs-common.h>
23 /* 1 second delay should be plenty of time for block reset. */
24 #define RESET_MAX_TIMEOUT 1000000
26 #define MXS_BLOCK_SFTRST (1 << 31)
27 #define MXS_BLOCK_CLKGATE (1 << 30)
29 int mxs_wait_mask_set(struct mxs_register_32 *reg, uint32_t mask, unsigned
33 if ((readl(®->reg) & mask) == mask)
41 int mxs_wait_mask_clr(struct mxs_register_32 *reg, uint32_t mask, unsigned
45 if ((readl(®->reg) & mask) == 0)
53 int mxs_reset_block(struct mxs_register_32 *reg)
56 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
58 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
62 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
65 writel(MXS_BLOCK_SFTRST, ®->reg_set);
67 /* Wait for CLKGATE being set */
68 if (mxs_wait_mask_set(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))
72 writel(MXS_BLOCK_SFTRST, ®->reg_clr);
74 if (mxs_wait_mask_clr(reg, MXS_BLOCK_SFTRST, RESET_MAX_TIMEOUT))
78 writel(MXS_BLOCK_CLKGATE, ®->reg_clr);
80 if (mxs_wait_mask_clr(reg, MXS_BLOCK_CLKGATE, RESET_MAX_TIMEOUT))