generictimer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (C) 2013 - ARM Ltd
  3. * Author: Marc Zyngier <marc.zyngier@arm.com>
  4. *
  5. * Based on code by Carl van Schaik <carl@ok-labs.com>.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _GENERICTIMER_H_
  20. #define _GENERICTIMER_H_
  21. #ifdef __ASSEMBLY__
  22. /*
  23. * This macro provide a physical timer that can be used for delay in the code.
  24. * The macro is moved from sunxi/psci_sun7i.S
  25. *
  26. * reg: is used in this macro.
  27. * ticks: The freq is based on generic timer.
  28. */
  29. .macro timer_wait reg, ticks
  30. movw \reg, #(\ticks & 0xffff)
  31. movt \reg, #(\ticks >> 16)
  32. mcr p15, 0, \reg, c14, c2, 0
  33. isb
  34. mov \reg, #3
  35. mcr p15, 0, \reg, c14, c2, 1
  36. 1 : isb
  37. mrc p15, 0, \reg, c14, c2, 1
  38. ands \reg, \reg, #4
  39. bne 1b
  40. mov \reg, #0
  41. mcr p15, 0, \reg, c14, c2, 1
  42. isb
  43. .endm
  44. #endif /* __ASSEMBLY__ */
  45. #endif /* _GENERICTIMER_H_ */