pm-at32ap700x.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Low-level Power Management code.
  3. *
  4. * Copyright (C) 2008 Atmel Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <asm/asm.h>
  11. #include <asm/asm-offsets.h>
  12. #include <asm/thread_info.h>
  13. #include <asm/arch/pm.h>
  14. .section .bss, "wa", @nobits
  15. .global disable_idle_sleep
  16. .type disable_idle_sleep, @object
  17. disable_idle_sleep:
  18. .int 4
  19. .size disable_idle_sleep, . - disable_idle_sleep
  20. /* Keep this close to the irq handlers */
  21. .section .irq.text, "ax", @progbits
  22. /*
  23. * void cpu_enter_idle(void)
  24. *
  25. * Put the CPU into "idle" mode, in which it will consume
  26. * significantly less power.
  27. *
  28. * If an interrupt comes along in the window between
  29. * unmask_interrupts and the sleep instruction below, the
  30. * interrupt code will adjust the return address so that we
  31. * never execute the sleep instruction. This is required
  32. * because the AP7000 doesn't unmask interrupts when entering
  33. * sleep modes; later CPUs may not need this workaround.
  34. */
  35. .global cpu_enter_idle
  36. .type cpu_enter_idle, @function
  37. cpu_enter_idle:
  38. mask_interrupts
  39. get_thread_info r8
  40. ld.w r9, r8[TI_flags]
  41. bld r9, TIF_NEED_RESCHED
  42. brcs .Lret_from_sleep
  43. sbr r9, TIF_CPU_GOING_TO_SLEEP
  44. st.w r8[TI_flags], r9
  45. unmask_interrupts
  46. sleep CPU_SLEEP_IDLE
  47. .size cpu_idle_sleep, . - cpu_idle_sleep
  48. /*
  49. * Common return path for PM functions that don't run from
  50. * SRAM.
  51. */
  52. .global cpu_idle_skip_sleep
  53. .type cpu_idle_skip_sleep, @function
  54. cpu_idle_skip_sleep:
  55. mask_interrupts
  56. ld.w r9, r8[TI_flags]
  57. cbr r9, TIF_CPU_GOING_TO_SLEEP
  58. st.w r8[TI_flags], r9
  59. .Lret_from_sleep:
  60. unmask_interrupts
  61. retal r12
  62. .size cpu_idle_skip_sleep, . - cpu_idle_skip_sleep