blob: ef7c46eab3b0ce5d70164a4231bd8dcfbda8861c [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Oliver Schinagl0096aa22014-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 Schinagl0096aa22014-10-03 20:16:24 +080014 */
15
Oliver Schinagl0096aa22014-10-03 20:16:24 +080016#include <errno.h>
17#include <asm/io.h>
18#include <asm/arch/cpu.h>
19#include <asm/arch/prcm.h>
20#include <asm/arch/sys_proto.h>
21
Chen-Yu Tsai0b171c42014-10-22 16:47:46 +080022/* APB0 clock gate and reset bit offsets are the same. */
23void prcm_apb0_enable(u32 flags)
Oliver Schinagl0096aa22014-10-03 20:16:24 +080024{
25 struct sunxi_prcm_reg *prcm =
26 (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
27
Chen-Yu Tsai0b171c42014-10-22 16:47:46 +080028 /* open the clock for module */
29 setbits_le32(&prcm->apb0_gate, flags);
30
31 /* deassert reset for module */
32 setbits_le32(&prcm->apb0_reset, flags);
Oliver Schinagl0096aa22014-10-03 20:16:24 +080033}
Jelle van der Waa8d3d7c12016-01-14 14:06:26 +010034
35void prcm_apb0_disable(u32 flags)
36{
37 struct sunxi_prcm_reg *prcm =
38 (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
39
40 /* assert reset for module */
41 clrbits_le32(&prcm->apb0_reset, flags);
42
43 /* close the clock for module */
44 clrbits_le32(&prcm->apb0_gate, flags);
45}