Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Oliver Schinagl | 174deb7 | 2014-10-03 20:16:24 +0800 | [diff] [blame] | 2 | /* |
| 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 Schinagl | 174deb7 | 2014-10-03 20:16:24 +0800 | [diff] [blame] | 14 | */ |
| 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 Tsai | 472ed06 | 2014-10-22 16:47:46 +0800 | [diff] [blame] | 23 | /* APB0 clock gate and reset bit offsets are the same. */ |
| 24 | void prcm_apb0_enable(u32 flags) |
Oliver Schinagl | 174deb7 | 2014-10-03 20:16:24 +0800 | [diff] [blame] | 25 | { |
| 26 | struct sunxi_prcm_reg *prcm = |
| 27 | (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE; |
| 28 | |
Chen-Yu Tsai | 472ed06 | 2014-10-22 16:47:46 +0800 | [diff] [blame] | 29 | /* 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 Schinagl | 174deb7 | 2014-10-03 20:16:24 +0800 | [diff] [blame] | 34 | } |
Jelle van der Waa | 9d08268 | 2016-01-14 14:06:26 +0100 | [diff] [blame] | 35 | |
| 36 | void 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 | } |