blob: 71a2e44918ebc5dd566d059a356ced47dce49515 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Oliver Schinagl174deb72014-10-03 20:16:24 +08002/*
3 * Sunxi A31 Power Management Unit
4 *
5 * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl>
6 * http://linux-sunxi.org
7 *
8 * Based on sun6i sources and earlier U-Boot Allwinner A10 SPL work
9 *
10 * (C) Copyright 2006-2013
11 * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
12 * Berg Xing <bergxing@allwinnertech.com>
13 * Tom Cubie <tangliang@allwinnertech.com>
Oliver Schinagl174deb72014-10-03 20:16:24 +080014 */
15
16#include <common.h>
17#include <errno.h>
18#include <asm/io.h>
19#include <asm/arch/cpu.h>
20#include <asm/arch/prcm.h>
21#include <asm/arch/sys_proto.h>
22
Chen-Yu Tsai472ed062014-10-22 16:47:46 +080023/* APB0 clock gate and reset bit offsets are the same. */
24void prcm_apb0_enable(u32 flags)
Oliver Schinagl174deb72014-10-03 20:16:24 +080025{
26 struct sunxi_prcm_reg *prcm =
27 (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
28
Chen-Yu Tsai472ed062014-10-22 16:47:46 +080029 /* open the clock for module */
30 setbits_le32(&prcm->apb0_gate, flags);
31
32 /* deassert reset for module */
33 setbits_le32(&prcm->apb0_reset, flags);
Oliver Schinagl174deb72014-10-03 20:16:24 +080034}
Jelle van der Waa9d082682016-01-14 14:06:26 +010035
36void prcm_apb0_disable(u32 flags)
37{
38 struct sunxi_prcm_reg *prcm =
39 (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
40
41 /* assert reset for module */
42 clrbits_le32(&prcm->apb0_reset, flags);
43
44 /* close the clock for module */
45 clrbits_le32(&prcm->apb0_gate, flags);
46}