sysregs.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright 2011 Calxeda, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef _MACH_HIGHBANK__SYSREGS_H_
  17. #define _MACH_HIGHBANK__SYSREGS_H_
  18. #include <linux/io.h>
  19. #include <linux/smp.h>
  20. #include <asm/smp_plat.h>
  21. #include <asm/smp_scu.h>
  22. #include "core.h"
  23. extern void __iomem *sregs_base;
  24. #define HB_SREG_A9_PWR_REQ 0xf00
  25. #define HB_SREG_A9_BOOT_STAT 0xf04
  26. #define HB_SREG_A9_BOOT_DATA 0xf08
  27. #define HB_PWR_SUSPEND 0
  28. #define HB_PWR_SOFT_RESET 1
  29. #define HB_PWR_HARD_RESET 2
  30. #define HB_PWR_SHUTDOWN 3
  31. #define SREG_CPU_PWR_CTRL(c) (0x200 + ((c) * 4))
  32. static inline void highbank_set_core_pwr(void)
  33. {
  34. int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
  35. if (scu_base_addr)
  36. scu_power_mode(scu_base_addr, SCU_PM_POWEROFF);
  37. else
  38. writel_relaxed(1, sregs_base + SREG_CPU_PWR_CTRL(cpu));
  39. }
  40. static inline void highbank_clear_core_pwr(void)
  41. {
  42. int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
  43. if (scu_base_addr)
  44. scu_power_mode(scu_base_addr, SCU_PM_NORMAL);
  45. else
  46. writel_relaxed(0, sregs_base + SREG_CPU_PWR_CTRL(cpu));
  47. }
  48. static inline void highbank_set_pwr_suspend(void)
  49. {
  50. writel(HB_PWR_SUSPEND, sregs_base + HB_SREG_A9_PWR_REQ);
  51. highbank_set_core_pwr();
  52. }
  53. static inline void highbank_set_pwr_shutdown(void)
  54. {
  55. writel(HB_PWR_SHUTDOWN, sregs_base + HB_SREG_A9_PWR_REQ);
  56. highbank_set_core_pwr();
  57. }
  58. static inline void highbank_set_pwr_soft_reset(void)
  59. {
  60. writel(HB_PWR_SOFT_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
  61. highbank_set_core_pwr();
  62. }
  63. static inline void highbank_set_pwr_hard_reset(void)
  64. {
  65. writel(HB_PWR_HARD_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
  66. highbank_set_core_pwr();
  67. }
  68. static inline void highbank_clear_pwr_request(void)
  69. {
  70. writel(~0UL, sregs_base + HB_SREG_A9_PWR_REQ);
  71. highbank_clear_core_pwr();
  72. }
  73. #endif