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