prcm.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: GPL-2.0+
  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>
  14. */
  15. #include <common.h>
  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. /* APB0 clock gate and reset bit offsets are the same. */
  22. void prcm_apb0_enable(u32 flags)
  23. {
  24. struct sunxi_prcm_reg *prcm =
  25. (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
  26. /* open the clock for module */
  27. setbits_le32(&prcm->apb0_gate, flags);
  28. /* deassert reset for module */
  29. setbits_le32(&prcm->apb0_reset, flags);
  30. }
  31. void prcm_apb0_disable(u32 flags)
  32. {
  33. struct sunxi_prcm_reg *prcm =
  34. (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
  35. /* assert reset for module */
  36. clrbits_le32(&prcm->apb0_reset, flags);
  37. /* close the clock for module */
  38. clrbits_le32(&prcm->apb0_gate, flags);
  39. }