prcm.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Sunxi A31 Power Management Unit
  3. *
  4. * (C) Copyright 2013 Oliver Schinagl <oliver@schinagl.nl>
  5. * http://linux-sunxi.org
  6. *
  7. * Based on sun6i sources and earlier U-Boot Allwinner A10 SPL work
  8. *
  9. * (C) Copyright 2006-2013
  10. * Allwinner Technology Co., Ltd. <www.allwinnertech.com>
  11. * Berg Xing <bergxing@allwinnertech.com>
  12. * Tom Cubie <tangliang@allwinnertech.com>
  13. *
  14. * SPDX-License-Identifier: GPL-2.0+
  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. /* APB0 clock gate and reset bit offsets are the same. */
  23. void prcm_apb0_enable(u32 flags)
  24. {
  25. struct sunxi_prcm_reg *prcm =
  26. (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
  27. /* open the clock for module */
  28. setbits_le32(&prcm->apb0_gate, flags);
  29. /* deassert reset for module */
  30. setbits_le32(&prcm->apb0_reset, flags);
  31. }
  32. void prcm_apb0_disable(u32 flags)
  33. {
  34. struct sunxi_prcm_reg *prcm =
  35. (struct sunxi_prcm_reg *)SUNXI_PRCM_BASE;
  36. /* assert reset for module */
  37. clrbits_le32(&prcm->apb0_reset, flags);
  38. /* close the clock for module */
  39. clrbits_le32(&prcm->apb0_gate, flags);
  40. }